return level;
if (up_count * 100 >= num_pass_gov * up_threshold) {
- level += cpuhp->hotplug->num_cpus;
+ level += res->config_data.num_cpus;
if (level > res->rescon.max_level)
- level -= cpuhp->hotplug->num_cpus;
+ level -= res->config_data.num_cpus;
} else if (down_count * 100 >= num_pass_gov * down_threshold) {
- level -= cpuhp->hotplug->num_cpus;
+ level -= res->config_data.num_cpus;
}
if (right_count * 100 >= num_pass_gov * up_threshold) {
return true;
}
-static void cpuhp_hotplug_stop(struct pass_resource *res)
-{
- struct pass_level *levels = res->config_data.levels;
- int level = res->rescon.max_level;
-
- if (!res->cpuhp.hotplug || !levels)
- return;
-
- res->cpuhp.hotplug->online = levels[level].limit_min_cpu;
-}
-
-static int cpuhp_hotplug_dummy_governor(struct pass_resource *res)
-{
- int level = res->rescon.curr_level;
-
- return res->config_data.levels[level].limit_min_cpu;
-}
-
-static struct pass_hotplug* cpuhp_get_hotplug(struct pass_resource *res,
- enum pass_gov_type type)
-{
- struct pass_hotplug *hotplug;
-
- switch (type) {
- case PASS_GOV_DUMMY:
- case PASS_GOV_BASIC:
- /* Don't use Hotplug interface */
- return NULL;
- case PASS_GOV_HOTPLUG_ONLY:
- case PASS_GOV_STEP:
- case PASS_GOV_RADIATION:
- /* Use Hotplug interface */
- hotplug = calloc(1, sizeof(struct pass_hotplug));
- if (!hotplug) {
- _E("cannot allocate the memory of struct pass_hotplug");
- return NULL;
- }
- hotplug->governor = cpuhp_hotplug_dummy_governor;
- return hotplug;
- default:
- _E("Unknown hotplug type");
- break;
- };
-
- return NULL;
-}
-
static void cpuhp_calculate_busy_cpu(struct pass_resource *res, void *result)
{
struct pass_cpuhp *cpuhp = &res->cpuhp;
return;
}
- cpuhp_hotplug_stop(res);
-
/* Unregister the resource-monitor for CPUHP module */
pass_resmon_unregister_timer(res, RESMON_SRC_CPUHP);
*/
cpuhp_governor_update(res, PASS_OFF);
- if (cpuhp->hotplug)
- free(cpuhp->hotplug->sequence);
-
/* Set pass_cpuhp structure as default value */
cpuhp->pass_cpu_threshold = 0;
cpuhp->up_threshold = 0;
max_freq = res->config_data.levels[i].limit_max_freq;
cpuhp->max_freq = max_freq;
- /* Get the instance of CPU Hotplug's policy */
- cpuhp->hotplug = cpuhp_get_hotplug(res, res->config_data.gov_type);
- if (cpuhp->hotplug) {
- cpuhp->hotplug->sequence = calloc(res->config_data.num_cpus,
- sizeof(int));
- for (i = 0; i < res->config_data.num_cpus; i++)
- cpuhp->hotplug->sequence[i] = i + res->config_data.cpu;
-
- cpuhp->hotplug->num_cpus = res->config_data.num_cpus;
- }
-
/* Get the instance of CPUHP governor */
cpuhp->governor = cpuhp_get_governor(res, res->config_data.gov_type);
if (!cpuhp->governor) {
#include "pass.h"
#include "pass-hal.h"
-static void hotplug_set_online(struct pass_resource *res,
- unsigned int min_num)
-{
- struct pass_hotplug *hotplug = res->cpuhp.hotplug;
- int i;
-
- if (!hotplug || min_num == hotplug->online)
- return;
-
- if (min_num > hotplug->num_cpus)
- min_num = hotplug->num_cpus;
-
- pass_set_online_min_num(res, min_num);
-
- for (i = 0 ; i < hotplug->num_cpus; i++) {
- if (i < min_num)
- pass_set_online_state(res, hotplug->sequence[i], 1);
- else
- pass_set_online_state(res, hotplug->sequence[i], 0);
- }
-
- /*
- _I("- CPU %4s '%d->%d'Core\n",
- (hotplug->online > min_num ? "DOWN" : "UP"),
- hotplug->online, min_num);
- */
-
- hotplug->online = min_num;
-}
-
static int rescon_set_level(struct pass_resource *res, int new_level)
{
struct pass_level *levels = res->config_data.levels;;
- struct pass_cpuhp *cpuhp = &res->cpuhp;
int curr_level = res->rescon.curr_level;
int limit_max_freq;
int limit_min_freq;
int limit_min_cpu;
int fault_around_bytes;
- int ret;
+ int ret, i;
/* Get the detailed resource value according to PASS level */
limit_max_freq = levels[new_level].limit_max_freq;
limit_min_freq = levels[new_level].limit_min_freq;
+ limit_min_cpu = levels[new_level].limit_min_cpu;
fault_around_bytes = levels[new_level].fault_around_bytes;
res->rescon.prev_level = curr_level;
res->rescon.curr_level = new_level;
- /* Turn on/off CPUs according the maximum number of online CPU */
- if (cpuhp->hotplug) {
- if (cpuhp->hotplug->governor)
- limit_min_cpu = cpuhp->hotplug->governor(res);
- else
- limit_min_cpu = 1;
+ /* Turn on/off CPUs according required number of online CPU */
+ if (limit_min_cpu >= 0) {
+ if (limit_min_cpu > res->config_data.num_cpus)
+ limit_min_cpu = res->config_data.num_cpus;
+
+ pass_set_online_min_num(res, limit_min_cpu);
- hotplug_set_online(res, limit_min_cpu);
+ for (i = 0; i < res->config_data.num_cpus; i++)
+ pass_set_online_state(res, res->config_data.cpu + i,
+ (i < limit_min_cpu) ? 1 : 0);
}
/* Set maximum frequency */
PASS_ON = 1,
};
-struct pass_hotplug {
- char name[BUFF_MAX];
- unsigned int num_cpus;
- unsigned int online;
- unsigned int *sequence;
- int (*governor)(struct pass_resource *res);
-};
-
struct pass_level_condition {
int freq;
int nr_running;
* @governor: the instance of CPUHP Policy governor.
* @max_freq: the maximum frequency among levels
*
- * @hotplug: the instance of CPU Hotplug governor (will be deprecated).
- *
* CPUHP may be o enabled or disabled according to configuration file setting.
*/
struct pass_cpuhp {
struct pass_cpuhp_governor *governor;
unsigned int max_freq;
-
- struct pass_hotplug *hotplug;
};
/*