*/
int pass_radiation_governor(struct pass_policy *policy)
{
- struct pass_table *table = policy->pass_table;
+ struct pass_level *levels = policy->levels;
struct pass_cpu_stats *cpu_stats = policy->pass_cpu_stats;
int up_threshold = policy->up_threshold;
int down_threshold = policy->down_threshold;
*/
/* Check level up condition */
- for (j = 0; j < table[level].num_up_cond && up_condition; j++) {
- if (table[level].up_cond[j].freq &&
- !(freq >= table[level].up_cond[j].freq))
+ for (j = 0; j < levels[level].num_up_cond && up_condition; j++) {
+ if (levels[level].up_cond[j].freq &&
+ !(freq >= levels[level].up_cond[j].freq))
up_condition = false;
}
- if (table[level].num_up_cond && up_condition) {
+ if (levels[level].num_up_cond && up_condition) {
up_count++;
/*
_I("[Level%d] [up_count : %2d] \
freq(%d), nr_running(%d), busy_cpu(%d)",
level, up_count,
- table[level].up_cond[j].freq ? freq : -1,
+ levels[level].up_cond[j].freq ? freq : -1,
*/
}
/* Check level down condition */
- for (j = 0; j < table[level].num_down_cond && down_condition; j++) {
- if (table[level].down_cond[j].freq
- && !(freq <= table[level].down_cond[j].freq))
+ for (j = 0; j < levels[level].num_down_cond && down_condition; j++) {
+ if (levels[level].down_cond[j].freq
+ && !(freq <= levels[level].down_cond[j].freq))
down_condition = false;
}
- if (table[level].num_down_cond && down_condition) {
+ if (levels[level].num_down_cond && down_condition) {
down_count++;
/*
_I("[Level%d] [dw_count : %2d] \
freq(%d), nr_running(%d), busy_cpu(%d)",
level, down_count,
- table[level].down_cond[j].freq ? freq : -1,
+ levels[level].down_cond[j].freq ? freq : -1,
*/
}
/* Check level right condition */
- for (j = 0; j < table[level].num_right_cond && right_condition; j++) {
+ for (j = 0; j < levels[level].num_right_cond && right_condition; j++) {
/*
* If one more conditions are false among following
* conditions, don't increment right_count.
*/
- if (table[level].right_cond[j].nr_running
- && !(nr_running > table[level].right_cond[j].nr_running))
+ if (levels[level].right_cond[j].nr_running
+ && !(nr_running > levels[level].right_cond[j].nr_running))
right_condition = false;
- if (table[level].right_cond[j].busy_cpu
- && !(busy_cpu >= table[level].right_cond[j].busy_cpu))
+ if (levels[level].right_cond[j].busy_cpu
+ && !(busy_cpu >= levels[level].right_cond[j].busy_cpu))
right_condition = false;
}
- if (table[level].num_right_cond && right_condition) {
+ if (levels[level].num_right_cond && right_condition) {
right_count++;
/*
_I("[Level%d] [right_count : %2d] \
nr_running(%d), busy_cpu(%d)",
level, right_count,
- table[level].right_cond[j].nr_running ? nr_running : -1,
- table[level].right_cond[j].busy_cpu ? busy_cpu : -1);
+ levels[level].right_cond[j].nr_running ? nr_running : -1,
+ levels[level].right_cond[j].busy_cpu ? busy_cpu : -1);
*/
}
/* Check level left condition */
- for (j = 0; j < table[level].num_left_cond && left_condition; j++) {
+ for (j = 0; j < levels[level].num_left_cond && left_condition; j++) {
/*
* If one more conditions are false among following
* conditions, don't increment left_count.
*/
- if (table[level].left_cond[j].nr_running
- && !(nr_running <= table[level].left_cond[j].nr_running))
+ if (levels[level].left_cond[j].nr_running
+ && !(nr_running <= levels[level].left_cond[j].nr_running))
left_condition = false;
- if (table[level].left_cond[j].busy_cpu
- && !(busy_cpu < table[level].left_cond[j].busy_cpu))
+ if (levels[level].left_cond[j].busy_cpu
+ && !(busy_cpu < levels[level].left_cond[j].busy_cpu))
left_condition = false;
}
- if (table[level].num_left_cond && left_condition) {
+ if (levels[level].num_left_cond && left_condition) {
left_count++;
/*
_I("[Level%d] [ left_count : %2d] \
nr_running(%d), busy_cpu(%d)",
level, left_count,
- table[level].left_cond[j].nr_running ? nr_running : -1,
- table[level].left_cond[j].busy_cpu ? busy_cpu : -1);
+ levels[level].left_cond[j].nr_running ? nr_running : -1,
+ levels[level].left_cond[j].busy_cpu ? busy_cpu : -1);
*/
}
}
*/
int pass_step_governor(struct pass_policy *policy)
{
- struct pass_table *table = policy->pass_table;
+ struct pass_level *levels = policy->levels;
struct pass_cpu_stats *cpu_stats = policy->pass_cpu_stats;
int up_threshold = policy->up_threshold;
int down_threshold = policy->down_threshold;
num_pass_gov++;
/* Check level up condition */
- for (j = 0; j < table[level].num_up_cond; j++) {
+ for (j = 0; j < levels[level].num_up_cond; j++) {
/*
* If one more conditions are false among following
* conditions, don't increment up_count.
*/
- if (freq >= table[level].up_cond[j].freq
- && nr_running >= table[level].up_cond[j].nr_running
- && busy_cpu >= table[level].up_cond[j].busy_cpu)
+ if (freq >= levels[level].up_cond[j].freq
+ && nr_running >= levels[level].up_cond[j].nr_running
+ && busy_cpu >= levels[level].up_cond[j].busy_cpu)
up_condition = true;
}
- if (table[level].num_up_cond && up_condition) {
+ if (levels[level].num_up_cond && up_condition) {
up_count++;
/*
_I("[Level%d] [up_count : %2d] \
freq(%d), nr_running(%d), busy_cpu(%d)",
level, up_count,
- table[level].up_cond[0].freq ? freq : -1,
- table[level].up_cond[0].nr_running ? nr_running : -1,
- table[level].up_cond[0].busy_cpu ? busy_cpu : -1);
+ levels[level].up_cond[0].freq ? freq : -1,
+ levels[level].up_cond[0].nr_running ? nr_running : -1,
+ levels[level].up_cond[0].busy_cpu ? busy_cpu : -1);
*/
}
/* Check level down condition */
- for (j = 0; j < table[level].num_down_cond; j++) {
+ for (j = 0; j < levels[level].num_down_cond; j++) {
/*
* If one more conditions are false among following
* conditions, don't increment down_count.
*/
- if (freq <= table[level].down_cond[j].freq
- && nr_running < table[level].down_cond[j].nr_running
- && busy_cpu < table[level].down_cond[j].busy_cpu)
+ if (freq <= levels[level].down_cond[j].freq
+ && nr_running < levels[level].down_cond[j].nr_running
+ && busy_cpu < levels[level].down_cond[j].busy_cpu)
down_condition = true;
}
- if (table[level].num_down_cond && down_condition) {
+ if (levels[level].num_down_cond && down_condition) {
down_count++;
/*
_I("[Level%d] [dw_count : %2d] \
freq(%d), nr_running(%d), busy_cpu(%d)",
level, down_count,
- table[level].down_cond[0].freq ? freq : -1,
- table[level].down_cond[0].nr_running ? nr_running : -1,
- table[level].down_cond[0].busy_cpu ? busy_cpu : -1);
+ levels[level].down_cond[0].freq ? freq : -1,
+ levels[level].down_cond[0].nr_running ? nr_running : -1,
+ levels[level].down_cond[0].busy_cpu ? busy_cpu : -1);
*/
}
if (level < policy->max_level &&
- freq == table[level].limit_max_freq)
+ freq == levels[level].limit_max_freq)
up_max_count++;
}
* - PASS_RESOURCE_GPU_ID
*/
if (MATCH(result->name, "limit_max_freq"))
- policy->pass_table[level].limit_max_freq = atoi(result->value);
+ policy->levels[level].limit_max_freq = atoi(result->value);
else if (MATCH(result->name, "limit_min_freq"))
- policy->pass_table[level].limit_min_freq = atoi(result->value);
+ policy->levels[level].limit_min_freq = atoi(result->value);
else if (MATCH(result->name, "limit_min_cpu"))
- policy->pass_table[level].limit_min_cpu = atoi(result->value);
+ policy->levels[level].limit_min_cpu = atoi(result->value);
/*
* Properties for the following h/w resources:
* - PASS_RESOURCE_CPU_ID
*/
else if (MATCH(result->name, "num_down_cond"))
- policy->pass_table[level].num_down_cond = atoi(result->value);
+ policy->levels[level].num_down_cond = atoi(result->value);
else if (MATCH(result->name, "num_down_cond_freq"))
- policy->pass_table[level].down_cond[0].freq = atoi(result->value);
+ policy->levels[level].down_cond[0].freq = atoi(result->value);
else if (MATCH(result->name, "num_down_cond_nr_running"))
- policy->pass_table[level].down_cond[0].nr_running = atoi(result->value);
+ policy->levels[level].down_cond[0].nr_running = atoi(result->value);
else if (MATCH(result->name, "num_down_cond_busy_cpu"))
- policy->pass_table[level].down_cond[0].busy_cpu = atoi(result->value);
+ policy->levels[level].down_cond[0].busy_cpu = atoi(result->value);
else if (MATCH(result->name, "num_up_cond"))
- policy->pass_table[level].num_up_cond = atoi(result->value);
+ policy->levels[level].num_up_cond = atoi(result->value);
else if (MATCH(result->name, "num_up_cond_freq"))
- policy->pass_table[level].up_cond[0].freq = atoi(result->value);
+ policy->levels[level].up_cond[0].freq = atoi(result->value);
else if (MATCH(result->name, "num_up_cond_nr_running"))
- policy->pass_table[level].up_cond[0].nr_running = atoi(result->value);
+ policy->levels[level].up_cond[0].nr_running = atoi(result->value);
else if (MATCH(result->name, "num_up_cond_busy_cpu"))
- policy->pass_table[level].up_cond[0].busy_cpu = atoi(result->value);
+ policy->levels[level].up_cond[0].busy_cpu = atoi(result->value);
else if (MATCH(result->name, "num_left_cond"))
- policy->pass_table[level].num_left_cond = atoi(result->value);
+ policy->levels[level].num_left_cond = atoi(result->value);
else if (MATCH(result->name, "num_left_cond_freq"))
- policy->pass_table[level].left_cond[0].freq = atoi(result->value);
+ policy->levels[level].left_cond[0].freq = atoi(result->value);
else if (MATCH(result->name, "num_left_cond_nr_running"))
- policy->pass_table[level].left_cond[0].nr_running = atoi(result->value);
+ policy->levels[level].left_cond[0].nr_running = atoi(result->value);
else if (MATCH(result->name, "num_left_cond_busy_cpu"))
- policy->pass_table[level].left_cond[0].busy_cpu = atoi(result->value);
+ policy->levels[level].left_cond[0].busy_cpu = atoi(result->value);
else if (MATCH(result->name, "num_right_cond"))
- policy->pass_table[level].num_right_cond = atoi(result->value);
+ policy->levels[level].num_right_cond = atoi(result->value);
else if (MATCH(result->name, "num_right_cond_freq"))
- policy->pass_table[level].right_cond[0].freq = atoi(result->value);
+ policy->levels[level].right_cond[0].freq = atoi(result->value);
else if (MATCH(result->name, "num_right_cond_nr_running"))
- policy->pass_table[level].right_cond[0].nr_running = atoi(result->value);
+ policy->levels[level].right_cond[0].nr_running = atoi(result->value);
else if (MATCH(result->name, "num_right_cond_busy_cpu"))
- policy->pass_table[level].right_cond[0].busy_cpu = atoi(result->value);
+ policy->levels[level].right_cond[0].busy_cpu = atoi(result->value);
else if (MATCH(result->name, "gov_timeout")) {
double gov_timeout = atof(result->value);
if (gov_timeout < PASS_MIN_GOV_TIMEOUT)
gov_timeout = PASS_MIN_GOV_TIMEOUT;
- policy->pass_table[level].gov_timeout = gov_timeout;
+ policy->levels[level].gov_timeout = gov_timeout;
}
/*
* - PASS_RESOURCE_MEMORY_ID
*/
else if (MATCH(result->name, "fault_around_bytes"))
- policy->pass_table[level].fault_around_bytes = atoi(result->value);
+ policy->levels[level].fault_around_bytes = atoi(result->value);
return 0;
}
policy->gov_timeout = PASS_MIN_GOV_TIMEOUT;
}
- if (policy->num_levels > 0 && !policy->pass_table) {
- policy->pass_table = calloc(policy->num_levels,
- sizeof(struct pass_table));
- if (!policy->pass_table) {
- _E("cannot allocate memory for pass_table\n");
+ if (policy->num_levels > 0 && !policy->levels) {
+ policy->levels = calloc(policy->num_levels,
+ sizeof(struct pass_level));
+ if (!policy->levels) {
+ _E("cannot allocate memory for levels\n");
return -EINVAL;
}
}
for (level = 0; level < policy->num_levels; level++) {
_I("================================================\n");
- if (policy->pass_table[level].limit_max_freq)
- _I("%s| policy->pass_table[%d].limit_max_freq : %d\n",
+ if (policy->levels[level].limit_max_freq)
+ _I("%s| policy->levels[%d].limit_max_freq : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].limit_max_freq);
- if (policy->pass_table[level].limit_min_freq)
- _I("%s| policy->pass_table[%d].limit_min_freq : %d\n",
+ policy->levels[level].limit_max_freq);
+ if (policy->levels[level].limit_min_freq)
+ _I("%s| policy->levels[%d].limit_min_freq : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].limit_min_freq);
- if (policy->pass_table[level].limit_min_cpu)
- _I("%s| policy->pass_table[%d].limit_min_cpu : %d\n",
+ policy->levels[level].limit_min_freq);
+ if (policy->levels[level].limit_min_cpu)
+ _I("%s| policy->levels[%d].limit_min_cpu : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].limit_min_cpu);
- if (policy->pass_table[level].gov_timeout)
- _I("%s| policy->pass_table[%d].gov_timeout : %f\n",
+ policy->levels[level].limit_min_cpu);
+ if (policy->levels[level].gov_timeout)
+ _I("%s| policy->levels[%d].gov_timeout : %f\n",
res->cdata.res_name, level,
- policy->pass_table[level].gov_timeout);
+ policy->levels[level].gov_timeout);
- if (policy->pass_table[level].num_down_cond)
- _I("%s| policy->pass_table[%d].num_down_cond : %d\n",
+ if (policy->levels[level].num_down_cond)
+ _I("%s| policy->levels[%d].num_down_cond : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].num_down_cond);
- if (policy->pass_table[level].down_cond[0].freq)
- _I("%s| policy->pass_table[%d].down_cond[0].freq : %d\n",
+ policy->levels[level].num_down_cond);
+ if (policy->levels[level].down_cond[0].freq)
+ _I("%s| policy->levels[%d].down_cond[0].freq : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].down_cond[0].freq);
- if (policy->pass_table[level].down_cond[0].nr_running)
- _I("%s| policy->pass_table[%d].down_cond[0].nr_running : %d\n",
+ policy->levels[level].down_cond[0].freq);
+ if (policy->levels[level].down_cond[0].nr_running)
+ _I("%s| policy->levels[%d].down_cond[0].nr_running : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].down_cond[0].nr_running);
- if (policy->pass_table[level].down_cond[0].busy_cpu)
- _I("%s| policy->pass_table[%d].down_cond[0].busy_cpu : %d\n",
+ policy->levels[level].down_cond[0].nr_running);
+ if (policy->levels[level].down_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].down_cond[0].busy_cpu : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].down_cond[0].busy_cpu);
+ policy->levels[level].down_cond[0].busy_cpu);
- if (policy->pass_table[level].num_up_cond)
- _I("%s| policy->pass_table[%d].num_up_cond : %d\n",
+ if (policy->levels[level].num_up_cond)
+ _I("%s| policy->levels[%d].num_up_cond : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].num_up_cond);
- if (policy->pass_table[level].up_cond[0].freq)
- _I("%s| policy->pass_table[%d].up_cond[0].freq : %d\n",
+ policy->levels[level].num_up_cond);
+ if (policy->levels[level].up_cond[0].freq)
+ _I("%s| policy->levels[%d].up_cond[0].freq : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].up_cond[0].freq);
- if (policy->pass_table[level].up_cond[0].nr_running)
- _I("%s| policy->pass_table[%d].up_cond[0].nr_running : %d\n",
+ policy->levels[level].up_cond[0].freq);
+ if (policy->levels[level].up_cond[0].nr_running)
+ _I("%s| policy->levels[%d].up_cond[0].nr_running : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].up_cond[0].nr_running);
- if (policy->pass_table[level].up_cond[0].busy_cpu)
- _I("%s| policy->pass_table[%d].up_cond[0].busy_cpu : %d\n",
+ policy->levels[level].up_cond[0].nr_running);
+ if (policy->levels[level].up_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].up_cond[0].busy_cpu : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].up_cond[0].busy_cpu);
+ policy->levels[level].up_cond[0].busy_cpu);
- if (policy->pass_table[level].num_left_cond)
- _I("%s| policy->pass_table[%d].num_left_cond : %d\n",
+ if (policy->levels[level].num_left_cond)
+ _I("%s| policy->levels[%d].num_left_cond : %d\n",
res->cdata.res_name, level,
- policy->pass_table[level].num_left_cond);
- if (policy->pass_table[level].left_cond[0].freq)
- _I("%s| policy->pass_table[%d].left_cond[0].freq : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].left_cond[0].freq);
- if (policy->pass_table[level].left_cond[0].nr_running)
- _I("%s| policy->pass_table[%d].left_cond[0].nr_running : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].left_cond[0].nr_running);
- if (policy->pass_table[level].left_cond[0].busy_cpu)
- _I("%s| policy->pass_table[%d].left_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].left_cond[0].busy_cpu);
-
- if (policy->pass_table[level].num_right_cond)
- _I("%s| policy->pass_table[%d].num_right_cond : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].num_right_cond);
- if (policy->pass_table[level].right_cond[0].freq)
- _I("%s| policy->pass_table[%d].right_cond[0].freq : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].right_cond[0].freq);
- if (policy->pass_table[level].right_cond[0].nr_running)
- _I("%s| policy->pass_table[%d].right_cond[0].nr_running : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].right_cond[0].nr_running);
- if (policy->pass_table[level].right_cond[0].busy_cpu)
- _I("%s| policy->pass_table[%d].right_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level, policy->pass_table[level].right_cond[0].busy_cpu);
+ policy->levels[level].num_left_cond);
+ if (policy->levels[level].left_cond[0].freq)
+ _I("%s| policy->levels[%d].left_cond[0].freq : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].freq);
+ if (policy->levels[level].left_cond[0].nr_running)
+ _I("%s| policy->levels[%d].left_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].nr_running);
+ if (policy->levels[level].left_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].left_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].busy_cpu);
+
+ if (policy->levels[level].num_right_cond)
+ _I("%s| policy->levels[%d].num_right_cond : %d\n",
+ res->cdata.res_name, level, policy->levels[level].num_right_cond);
+ if (policy->levels[level].right_cond[0].freq)
+ _I("%s| policy->levels[%d].right_cond[0].freq : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].freq);
+ if (policy->levels[level].right_cond[0].nr_running)
+ _I("%s| policy->levels[%d].right_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].nr_running);
+ if (policy->levels[level].right_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].right_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].busy_cpu);
}
*/
void pass_put_table(struct pass_policy *policy)
{
- if (policy->pass_table) {
- free(policy->pass_table);
- policy->pass_table = NULL;
+ if (policy->levels) {
+ free(policy->levels);
+ policy->levels = NULL;
}
if (policy->scenario.list) {