Bridge the boot-time 'isolcpus' and 'nohz_full' parameters with the
DHEI sysfs interface. Ensure that housekeeping_init() correctly
initializes the isolation state and that subsequent sysfs updates
can take over management even if no isolation was configured at boot.
Remove __init from sched_tick_offload_init() and update it to be
safe for multiple calls. This allows DHEI to initialize tick offload
infrastructure at runtime when the first tick-isolated core is
configured.
Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
Signed-off-by: Qiliang Yuan <yuanql9@chinatelecom.cn>
---
kernel/sched/core.c | 5 ++++-
kernel/sched/isolation.c | 3 +++
kernel/sched/sched.h | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 045f83ad261e..d155e1132d6b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5685,8 +5685,11 @@ static void sched_tick_stop(int cpu)
}
#endif /* CONFIG_HOTPLUG_CPU */
-int __init sched_tick_offload_init(void)
+int sched_tick_offload_init(void)
{
+ if (tick_work_cpu)
+ return 0;
+
tick_work_cpu = alloc_percpu(struct tick_work);
BUG_ON(!tick_work_cpu);
return 0;
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 30798e790b9f..76c039a01fb0 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -241,6 +241,9 @@ static ssize_t housekeeping_store(struct kobject *kobject,
housekeeping.flags |= BIT(type);
static_branch_enable(&housekeeping_overridden);
+ if (type == HK_TYPE_TICK || type == HK_TYPE_TIMER || type == HK_TYPE_RCU)
+ sched_tick_offload_init();
+
housekeeping_update_notify(type, new_mask);
err = count;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 93fce4bbff5e..0079e7210c38 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2867,7 +2867,7 @@ extern void post_init_entity_util_avg(struct task_struct *p);
#ifdef CONFIG_NO_HZ_FULL
extern bool sched_can_stop_tick(struct rq *rq);
-extern int __init sched_tick_offload_init(void);
+extern int sched_tick_offload_init(void);
/*
* Tick may be needed by tasks in the runqueue depending on their policy and
--
2.51.0