summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Słodczyk <m.slodczyk2@partner.samsung.com>2020-06-22 19:33:57 +0200
committerMaciej Słodczyk <m.slodczyk2@partner.samsung.com>2020-06-22 19:59:51 +0200
commit1ea110bb2b4e31a6e4ff9e1b6c2fe593591a90a6 (patch)
tree671c63827d2d9a836689954f9273a9e52fb73ee0
parent5baea5023cc8a9998360cdbda88bf63244d90ae8 (diff)
downloadresourced-sandbox/slodki/big.little-scheduling.tar.gz
resourced-sandbox/slodki/big.little-scheduling.tar.bz2
resourced-sandbox/slodki/big.little-scheduling.zip
cpu-sched: use cpu hotplug events for cores managementsandbox/slodki/big.little-scheduling
Change-Id: Ia4c15e0bd9ca5edc4e8ae7c3e961ec642203084d Signed-off-by: Maciej Słodczyk <m.slodczyk2@partner.samsung.com>
-rw-r--r--src/cpu/cpu-sched.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/cpu/cpu-sched.c b/src/cpu/cpu-sched.c
index 29458551..c986ce0f 100644
--- a/src/cpu/cpu-sched.c
+++ b/src/cpu/cpu-sched.c
@@ -17,7 +17,7 @@
#include "util.h"
#include "trace.h"
#include "dbus-handler.h"
-#include "dbus-handler.h"
+#include "cpu-hotplug.h"
#define CPU_SCHED_CONF_FILE RD_CONFIG_FILE(cpu-sched)
#define CPU_SCHED_CORES_MAX 32
@@ -714,6 +714,48 @@ int cpu_sched_get_core_type(int id)
return sched_data.get_core_type(id);
}
+static int cpu_sched_cpu_on(void *data)
+{
+ int id = *(int*)(data);
+ int type;
+
+ if (id < 0 || id >= CPU_SCHED_CORES_MAX) {
+ _E("cpu_sched: cpu on: unknown core id: %d *max is %d)", id, CPU_SCHED_CORES_MAX);
+ return RESOURCED_ERROR_FAIL;
+ }
+
+ type = cpu_sched_get_core_type(id);
+ if (INVALID == type)
+ return RESOURCED_ERROR_FAIL;
+
+ sched_data.cores[id].on = true;
+ /* refresh cpuset core list in sysfs */
+ cpu_sched_setup_cgroup_core_set(type);
+
+ return RESOURCED_ERROR_NONE;
+}
+
+static int cpu_sched_cpu_off(void *data)
+{
+ int id = *(int*)(data);
+ int type;
+
+ if (id < 0 || id >= CPU_SCHED_CORES_MAX) {
+ _E("cpu_sched: cpu on: unknown core id: %d *max is %d)", id, CPU_SCHED_CORES_MAX);
+ return RESOURCED_ERROR_FAIL;
+ }
+
+ type = cpu_sched_get_core_type(id);
+ if (INVALID == type)
+ return RESOURCED_ERROR_FAIL;
+
+ sched_data.cores[id].on = false;
+ /* refresh cpuset core list in sysfs */
+ cpu_sched_setup_cgroup_core_set(type);
+
+ return RESOURCED_ERROR_NONE;
+}
+
static void register_events()
{
register_notifier(RESOURCED_NOTIFIER_APP_RESUME, cpu_sched_app_fg);
@@ -725,6 +767,9 @@ static void register_events()
register_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_fg);
register_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_bg);
+ register_notifier(RESOURCED_NOTIFIER_CPU_ON, cpu_sched_cpu_on);
+ register_notifier(RESOURCED_NOTIFIER_CPU_OFF, cpu_sched_cpu_off);
+
}
static void unregister_events()
@@ -737,6 +782,9 @@ static void unregister_events()
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_fg);
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_bg);
+
+ unregister_notifier(RESOURCED_NOTIFIER_CPU_ON, cpu_sched_cpu_on);
+ unregister_notifier(RESOURCED_NOTIFIER_CPU_OFF, cpu_sched_cpu_off);
}
static int resourced_cpu_sched_init(void *data)
@@ -768,6 +816,10 @@ static int resourced_cpu_sched_init(void *data)
register_events();
+ if (cpu_hotplug_init() != 0) {
+ _E("cpu_sched: could not setup cpu hotplugging");
+ return RESOURCED_ERROR_FAIL;
+ }
_D("cpu-sched: module init ok\n");
@@ -775,6 +827,8 @@ static int resourced_cpu_sched_init(void *data)
init_failed:
unregister_events();
+ cpu_hotplug_finalize();
+
for (int i = 0; i < CPU_SCHED_CORES_MAX; i++) {
sched_data.cores[i].set = INVALID;
sched_data.cores[i].on = false;
@@ -788,6 +842,7 @@ init_failed:
static int resourced_cpu_sched_finalize(void *data)
{
unregister_events();
+ cpu_hotplug_finalize();
g_slist_free_full(sched_data.apps, cpu_sched_app_free);
sched_data.apps = NULL;