The sched_tick_offload_init() function is called at boot time whenever "nohz_full" is set. Now housekeeping cpumasks can be updated at run time without the corresponding "nohz_full" kernel parameter. So we have to be able to call sched_tick_offload_init() at run time to allow tick offloading. Remove the __init attribute from sched_tick_offload_init() and call it when the HK_FLAG_KERNEL_NOISE flag is first set.
Signed-off-by: Waiman Long longman@redhat.com --- kernel/sched/core.c | 2 +- kernel/sched/isolation.c | 10 +++++++++- kernel/sched/sched.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index be00629f0ba4..9f02c047e25b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5783,7 +5783,7 @@ static void sched_tick_stop(int cpu) } #endif /* CONFIG_HOTPLUG_CPU */
-int __init sched_tick_offload_init(void) +int sched_tick_offload_init(void) { tick_work_cpu = alloc_percpu(struct tick_work); BUG_ON(!tick_work_cpu); diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 3fb0e8ccce26..ee396ae13719 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -33,6 +33,7 @@ struct housekeeping { };
static struct housekeeping housekeeping; +static bool sched_tick_offload_inited;
bool housekeeping_enabled(enum hk_type type) { @@ -103,8 +104,10 @@ void __init housekeeping_init(void)
static_branch_enable(&housekeeping_overridden);
- if (housekeeping.flags & HK_FLAG_KERNEL_NOISE) + if (housekeeping.flags & HK_FLAG_KERNEL_NOISE) { sched_tick_offload_init(); + sched_tick_offload_inited = true; + }
for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX) { /* We need at least one CPU to handle housekeeping work */ @@ -324,5 +327,10 @@ int housekeeping_exclude_cpumask(struct cpumask *cpumask, unsigned long hk_flags static_key_disable(&housekeeping_overridden.key); else if (housekeeping.flags && !static_key_enabled(&housekeeping_overridden)) static_key_enable(&housekeeping_overridden.key); + + if ((housekeeping.flags & HK_FLAG_KERNEL_NOISE) && !sched_tick_offload_inited) { + sched_tick_offload_init(); + sched_tick_offload_inited = true; + } return 0; } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index be9745d104f7..d4676305e099 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2671,7 +2671,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