pass: rescon: Fix issue of init_level setting and remove unneeded pass_hotplug 07/185807/5
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 2 Aug 2018 07:40:51 +0000 (16:40 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 3 Aug 2018 01:44:26 +0000 (10:44 +0900)
RESCON (Resource Controller) module changes the value h/w resource
according to 'init_level' property getting from each h/w resource
configuration. Even if RESCON always is initialized before CPUHP init,
RESCON depends on CPUHP in order to get the limited number of online CPU.

Fix issue of init_level setting during init step by getting
limited_min_cpu value without CPUHP module. And remove unneeded pass_hotplug.

Change-Id: If7f13a7197fe93b41c23688d49370631d6d76e5e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-cpuhp-radiation.c
src/pass/pass-cpuhp.c
src/pass/pass-rescon.c
src/pass/pass.h

index 8010c398f684565734c226944b9ce6fef010bfb5..362c0b3d4df8db75cde0dfd727bdf8dc1e9aff68 100644 (file)
@@ -177,12 +177,12 @@ int pass_cpuhp_radiation_governor(struct pass_resource *res, void *result)
                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) {
index 5d550910d32ac371f120bd98e69543aef7dd3a4f..a74b321b40b26af8ca923a0c6aaa57f8a942d02e 100644 (file)
@@ -55,53 +55,6 @@ static bool is_enabled(struct pass_cpuhp *cpuhp)
        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;
@@ -260,8 +213,6 @@ static void cpuhp_governor_stop(struct pass_resource *res)
                return;
        }
 
-       cpuhp_hotplug_stop(res);
-
        /* Unregister the resource-monitor for CPUHP module */
        pass_resmon_unregister_timer(res, RESMON_SRC_CPUHP);
 
@@ -298,9 +249,6 @@ static int cpuhp_governor_exit(struct pass_resource *res)
         */
        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;
@@ -431,17 +379,6 @@ int pass_cpuhp_init(struct pass_resource *res)
                        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) {
index f5b0e56c6b5ea7da44a835ca41ddfe6e3c7a462d..2ea800b84f7e0bd9b6d806f1ea2017cb8bcb752d 100644 (file)
 #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 */
index 8a07cf89bccdeee01676b1b7272167934b64f6c4..b77ffb79f0ec18f674e3e1a7fc8e62f43e57b871 100644 (file)
@@ -84,14 +84,6 @@ enum pass_state {
        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;
@@ -274,8 +266,6 @@ struct pass_pmqos {
  * @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 {
@@ -290,8 +280,6 @@ struct pass_cpuhp {
        struct pass_cpuhp_governor *governor;
 
        unsigned int max_freq;
-
-       struct pass_hotplug *hotplug;
 };
 
 /*