return level;
if (up_count * 100 >= num_pass_gov * up_threshold) {
- level += policy->freq.num_nr_cpus;
+ level += policy->hotplug->num_cpus;
if (level > policy->max_level)
- level -= policy->freq.num_nr_cpus;
+ level -= policy->hotplug->num_cpus;
} else if (down_count * 100 >= num_pass_gov * down_threshold) {
- level -= policy->freq.num_nr_cpus;
+ level -= policy->hotplug->num_cpus;
}
if (right_count * 100 >= num_pass_gov * up_threshold) {
if (!hotplug || min_num == hotplug->online)
return;
- if (min_num > hotplug->max_online)
- min_num = hotplug->max_online;
+ if (min_num > hotplug->num_cpus)
+ min_num = hotplug->num_cpus;
- for (i = 0 ; i < policy->freq.num_nr_cpus; i++) {
+ for (i = 0 ; i < hotplug->num_cpus; i++) {
if (i < min_num) {
pass_set_online_state(pass_res, hotplug->sequence[i],
PASS_CPU_UP);
*/
static void pass_hotplug_stop(struct pass_policy *policy)
{
+ struct pass_resource *pass_res = to_pass_resource(policy);
+ struct pass_conf_data *cdata = &pass_res->cdata;
struct pass_table *table = policy->pass_table;
int level = policy->max_level;
return;
policy->hotplug->online = table[level].limit_min_cpu;
- policy->hotplug->max_online = policy->freq.num_nr_cpus;
}
static int pass_hotplug_dummy_governor(struct pass_policy *policy)
/* Turn on/off CPUs according the maximum number of online CPU */
if (hotplug) {
- if (hotplug->max_online != limit_min_cpu)
- hotplug->max_online = limit_min_cpu;
-
if (hotplug->governor)
online = hotplug->governor(policy);
else
static void pass_calculate_busy_cpu(struct pass_policy *policy)
{
struct pass_cpu_stats *stats = policy->pass_cpu_stats;
+ struct pass_resource *res = to_pass_resource(policy);
struct pass_table *table = policy->pass_table;
+ struct pass_conf_data *cdata = &res->cdata;
unsigned int level = policy->curr_level;
unsigned int cpu_threshold = 0;
unsigned int busy_cpu;
sum_runnable_load = 0;
/* Calculate the number of busy cpu */
- for (j = 0; j < policy->freq.num_nr_cpus; j++) {
+ for (j = 0; j < cdata->num_cpus; j++) {
load = stats[i].load[j];
sum_load += stats[i].load[j];
sum_runnable_load += stats[i].runnable_load[j];
if (ret < 0)
return -EIO;
- for (j = 0; j < policy->freq.num_nr_cpus; j++) {
+ for (j = 0; j < pass_res->cdata.num_cpus; j++) {
ret = fscanf(fp_stats, "%d", &stats[i].load[j]);
if (ret < 0)
return -EIO;
max_cpu = policy->pass_table[i].limit_min_cpu;
}
policy->freq.max_freq = max_freq;
- policy->freq.num_nr_cpus = max_cpu;
/* Allocate memory according to the number of data and cpu */
policy->pass_cpu_stats = calloc(policy->num_pass_cpu_stats,
for (i = 0; i < policy->num_pass_cpu_stats; i++) {
policy->pass_cpu_stats[i].load =
- calloc(policy->freq.num_nr_cpus, sizeof(unsigned int));
+ calloc(pass_res->cdata.num_cpus, sizeof(unsigned int));
policy->pass_cpu_stats[i].nr_running =
- calloc(policy->freq.num_nr_cpus, sizeof(unsigned int));
+ calloc(pass_res->cdata.num_cpus, sizeof(unsigned int));
policy->pass_cpu_stats[i].runnable_load =
- calloc(policy->freq.num_nr_cpus, sizeof(unsigned int));
+ calloc(pass_res->cdata.num_cpus, sizeof(unsigned int));
}
/* Get the instance of PASS governor */
/* Get the instance of PASS hotplulg */
policy->hotplug = pass_get_hotplug(policy, policy->gov_type);
if (policy->hotplug) {
- policy->hotplug->sequence = calloc(policy->freq.num_nr_cpus,
+ policy->hotplug->sequence = calloc(pass_res->cdata.num_cpus,
sizeof(int));
- for (i = 0; i < policy->freq.num_nr_cpus; i++)
+ for (i = 0; i < pass_res->cdata.num_cpus; i++)
policy->hotplug->sequence[i] = i + pass_res->cdata.cpu;
+
+ policy->hotplug->num_cpus = pass_res->cdata.num_cpus;
}
ret = pass_governor_init(policy);
/*
* struct pass_hotplug - store information of cpu hotplug
- * @max_online: the possible maximum number of online cpu
+ * @num_cpus: the possible maximum number of online cpus
* @online: the current number of online cpu
* @sequence: the sequence to turn on/off cpu
*/
struct pass_hotplug {
char name[PASS_NAME_LEN];
- unsigned int max_online;
+ unsigned int num_cpus;
unsigned int online;
unsigned int *sequence;
int (*governor)(struct pass_policy *);
struct pass_freq_policy {
unsigned int max_freq;
- unsigned int num_nr_cpus;
unsigned int sampling_rate;
unsigned int up_threshold;
};