From 09bd9e940e98acad0c854f75b31fc79a93cde981 Mon Sep 17 00:00:00 2001 From: Tengfei Fan Date: Fri, 22 Oct 2021 13:51:11 +0800 Subject: [PATCH] ANDROID: cpuhp/pause: schedule cpu_hotplug_work on resume cpu Resume cpu need to run cpuset_hotplug_workfn which need take about several milliseconds, and even more if the system have more tasks. This isn't suitable to run in the main task context of resume cpu. Due to the cpu which is resuming only have active mask, but still not rebuild sched domain, make this slow work run on resuming cpu can not take extra overload to previous active cpus. Bug: 203839955 Fixes: 1d3a64fbd214 ("ANDROID: cpu/hotplug: rebuild sched domains immediately") Change-Id: Ia7bdd077f982950c02696c3598a41b2482046220 Signed-off-by: Tengfei Fan Signed-off-by: Maria Yu --- include/linux/cpuset.h | 1 + kernel/cgroup/cpuset.c | 5 +++++ kernel/cpu.c | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 2713db8395f6..4f52d03d61ea 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -55,6 +55,7 @@ extern int cpuset_init(void); extern void cpuset_init_smp(void); extern void cpuset_force_rebuild(void); extern void cpuset_update_active_cpus(void); +extern void cpuset_update_active_cpus_affine(int cpu); extern void cpuset_wait_for_hotplug(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); extern void cpuset_cpus_allowed_fallback(struct task_struct *p); diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index c7f574a68cdb..a49b1598466d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3289,6 +3289,11 @@ void cpuset_update_active_cpus(void) schedule_work(&cpuset_hotplug_work); } +void cpuset_update_active_cpus_affine(int cpu) +{ + schedule_work_on(cpu, &cpuset_hotplug_work); +} + void cpuset_wait_for_hotplug(void) { flush_work(&cpuset_hotplug_work); diff --git a/kernel/cpu.c b/kernel/cpu.c index b69e0904a1fc..41c73436e745 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1361,11 +1361,11 @@ int resume_cpus(struct cpumask *cpus) prev_prio = pause_reduce_prio(); - /* Lazy Resume. Build domains immediately instead of scheduling - * a workqueue. This is so that the cpu can pull load when - * sent a load balancing kick. + /* Lazy Resume. Build domains through schedule a workqueue on + * resuming cpu. This is so that the resuming cpu can work more + * early, and cannot add additional load to other busy cpu. */ - cpuset_hotplug_workfn(NULL); + cpuset_update_active_cpus_affine(cpumask_first(cpus)); cpus_write_lock();