The boot-time parameters 'isolcpus' and 'nohz_full' currently initialize
housekeeping masks that cannot be easily updated at runtime. To support
DHEI, the scheduler's tick offload infrastructure must be ready for
dynamic enablement even if no isolation was requested at boot.

Enable unconditional boot-time initialization for tick offload.

This ensures that the infrastructure for remote ticks is always present,
allowing DHEI to safely toggle full dynticks mode at runtime.

Signed-off-by: Qiliang Yuan <[email protected]>
---
 kernel/sched/core.c      | 5 +++++
 kernel/sched/isolation.c | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ddf9951f1438c..d987ce03e7cc6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5688,6 +5688,9 @@ static void sched_tick_stop(int cpu)
 
 int __init 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;
@@ -8509,6 +8512,8 @@ void __init sched_init_smp(void)
        current->flags &= ~PF_NO_SETAFFINITY;
        sched_init_granularity();
 
+       sched_tick_offload_init();
+
        init_sched_rt_class();
        init_sched_dl_class();
 
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 4a5967837e8de..685cc0df1bd9f 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -299,9 +299,6 @@ void __init housekeeping_init(void)
 
        static_branch_enable(&housekeeping_overridden);
 
-       if (housekeeping.flags & HK_FLAG_KERNEL_NOISE)
-               sched_tick_offload_init();
-
        for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX) {
                /* We need at least one CPU to handle housekeeping work */
                WARN_ON_ONCE(cpumask_empty(housekeeping.cpumasks[type]));

-- 
2.43.0


Reply via email to