Skip to contentSkip to conversation

tick/nohz: remove function tick_nohz_full_add_cpus_to

PATCH Applied [email protected] 4 participants 8 messages Apr 10, 2025 – May 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 tick/nohz: remove function tick_nohz_full_add_cpus_to

From: Alex Shi <[email protected]>

This function isn't used by anyone. Remove it.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Anna-Maria Behnsen <[email protected]>
---
 include/linux/tick.h | 7 -------
 1 file changed, 7 deletions(-)
include/linux/tick.h +0 -7
index b8ddc8e631a3..ac76ae9fa36d 100644
@@ -195,12 +195,6 @@ static inline bool tick_nohz_full_enabled(void)
 	__ret;								\
 })
 
-static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask)
-{
-	if (tick_nohz_full_enabled())
-		cpumask_or(mask, mask, tick_nohz_full_mask);
-}
-
 extern void tick_nohz_dep_set(enum tick_dep_bits bit);
 extern void tick_nohz_dep_clear(enum tick_dep_bits bit);
 extern void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit);
@@ -281,7 +275,6 @@ extern void __init tick_nohz_full_setup(cpumask_var_t cpumask);
 #else
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
-static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { }
 
 static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { }
 static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { }
Signature · 1 line
2.47.1
#1 lore raw

PATCH 2/4 sched/isolation: clean up housekeeping_cpu

From: Alex Shi <[email protected]>

housekeeping_test_cpu will check 'housekeeping_overridden' again in itself so we don't need do it again outside. just call housekeeping_test_cpu is fine.

Cc Peter Zijlstra <[email protected]>
Cc Waiman Long <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 include/linux/sched/isolation.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
include/linux/sched/isolation.h +1 -5
index d8501f4709b5..231bc5766f76 100644
@@ -63,11 +63,7 @@ static inline void housekeeping_init(void) { }
 
 static inline bool housekeeping_cpu(int cpu, enum hk_type type)
 {
-#ifdef CONFIG_CPU_ISOLATION
-	if (static_branch_unlikely(&housekeeping_overridden))
-		return housekeeping_test_cpu(cpu, type);
-#endif
-	return true;
+	return housekeeping_test_cpu(cpu, type);
 }
 
 static inline bool cpu_is_isolated(int cpu)
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu

Quoted 5 lines · Le Thu, Apr 10, 2025 at 05:24:17PM +0800, [email protected] a écrit :

From: Alex Shi <[email protected]>

housekeeping_test_cpu will check 'housekeeping_overridden' again in itself so we don't need do it again outside. just call housekeeping_test_cpu is fine.

The point is to do it in the headers, so there is no function call in the off case.

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#3 lore raw

Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu

Quoted 10 lines · Frederic Weisbecker <[email protected]> 于2025年4月10日周四 21:20写道:
Quoted 5 lines · Le Thu, Apr 10, 2025 at 05:24:17PM +0800, [email protected] a écrit :

From: Alex Shi <[email protected]>

housekeeping_test_cpu will check 'housekeeping_overridden' again in itself so we don't need do it again outside. just call housekeeping_test_cpu is fine.

The point is to do it in the headers, so there is no function call in the off case.

Thanks for comments, Frederic,
But the function is 'inline', and further more, the CONFIG_CPU_ISOLATION is in defconfig
and most of puplar popular Linux vendor. So it still be compiled.

Thanks

#4 lore raw

Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu

Quoted 9 lines · Alex Shi
Quoted 8 lines · Frederic Weisbecker <[email protected]> 于2025年4月10日周四 21:20写道:
Quoted 5 lines · Le Thu, Apr 10, 2025 at 05:24:17PM +0800, [email protected] a écrit :

From: Alex Shi <[email protected]>

housekeeping_test_cpu will check 'housekeeping_overridden' again in itself so we don't need do it again outside. just call housekeeping_test_cpu is fine.

Quoted 7 lines
Quoted 2 lines

The point is to do it in the headers, so there is no function call in the off case.

Thanks for comments, Frederic,
But the function is 'inline', and further more, the CONFIG_CPU_ISOLATION is in defconfig
and most of puplar popular Linux vendor. So it still be compiled.

housekeeping_cpu() is inline and does the static branch test, which is most of the time off. If it's on, then we enter the slow path and call the real function housekeeping_test_cpu().

So the point is to optimize the fast path, which 99.999% of the uses since nohz_full is a rare workload.

But housekeeping_test_cpu() is still built on most distros just in case a distro user ever needs nohz_full.

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#5 lore raw

PATCH 3/4 sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu()

In reply to [email protected]

From: Alex Shi <[email protected]>

Since the function just call housekeeping_test_cpu() without doing any other things, we could just merge them together with name housekeeping_cpu();

Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
Cc Lai Jiangshan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Ben Segall <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Dietmar Eggemann <[email protected]>
Cc Vincent Guittot <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 include/linux/sched/isolation.h | 19 +++++++------------
 kernel/sched/isolation.c        |  4 ++--
 kernel/workqueue.c              |  2 +-
 3 files changed, 10 insertions(+), 15 deletions(-)
include/linux/sched/isolation.h +7 -12
index 231bc5766f76..90e46440fc85 100644
@@ -30,7 +30,7 @@ extern int housekeeping_any_cpu(enum hk_type type);
 extern const struct cpumask *housekeeping_cpumask(enum hk_type type);
 extern bool housekeeping_enabled(enum hk_type type);
 extern void housekeeping_affine(struct task_struct *t, enum hk_type type);
-extern bool housekeeping_test_cpu(int cpu, enum hk_type type);
+extern bool housekeeping_cpu(int cpu, enum hk_type type);
 extern void __init housekeeping_init(void);
 
 #else
@@ -50,26 +50,21 @@ static inline bool housekeeping_enabled(enum hk_type type)
 	return false;
 }
 
-static inline void housekeeping_affine(struct task_struct *t,
-				       enum hk_type type) { }
-
-static inline bool housekeeping_test_cpu(int cpu, enum hk_type type)
+static inline bool housekeeping_cpu(int cpu, enum hk_type type)
 {
 	return true;
 }
 
+static inline void housekeeping_affine(struct task_struct *t,
+				       enum hk_type type) { }
+
 static inline void housekeeping_init(void) { }
 #endif /* CONFIG_CPU_ISOLATION */
 
-static inline bool housekeeping_cpu(int cpu, enum hk_type type)
-{
-	return housekeeping_test_cpu(cpu, type);
-}
-
 static inline bool cpu_is_isolated(int cpu)
 {
-	return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) ||
-	       !housekeeping_test_cpu(cpu, HK_TYPE_TICK) ||
+	return !housekeeping_cpu(cpu, HK_TYPE_DOMAIN) ||
+	       !housekeeping_cpu(cpu, HK_TYPE_TICK) ||
 	       cpuset_cpu_is_isolated(cpu);
 }
 
kernel/sched/isolation.c +2 -2
index 81bc8b329ef1..e93776740725 100644
@@ -73,14 +73,14 @@ void housekeeping_affine(struct task_struct *t, enum hk_type type)
 }
 EXPORT_SYMBOL_GPL(housekeeping_affine);
 
-bool housekeeping_test_cpu(int cpu, enum hk_type type)
+bool housekeeping_cpu(int cpu, enum hk_type type)
 {
 	if (static_branch_unlikely(&housekeeping_overridden))
 		if (housekeeping.flags & BIT(type))
 			return cpumask_test_cpu(cpu, housekeeping.cpumasks[type]);
 	return true;
 }
-EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
+EXPORT_SYMBOL_GPL(housekeeping_cpu);
 
 void __init housekeeping_init(void)
 {
kernel/workqueue.c +1 -1
index bfe030b443e2..69a02c9e53fb 100644
@@ -2518,7 +2518,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
 	if (housekeeping_enabled(HK_TYPE_TIMER)) {
 		/* If the current cpu is a housekeeping cpu, use it. */
 		cpu = smp_processor_id();
-		if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER))
+		if (!housekeeping_cpu(cpu, HK_TYPE_TIMER))
 			cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
 		add_timer_on(timer, cpu);
 	} else {
Signature · 1 line
2.47.1
#6 lore raw

PATCH 4/4 sched/isolation: don't alloc twice for housekeeping.cpumasks

In reply to [email protected]

From: Alex Shi <[email protected]>

The variable housekeeping.cpumasks[type] will be alloced twice if nohz_full and isolcpus are both setup in cmdline, that shouldn't to do so. Just alloc once is enough and save a bit memory.

Cc Valentin Schneider <[email protected]>
Cc Ben Segall <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Dietmar Eggemann <[email protected]>
Cc Vincent Guittot <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/sched/isolation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/isolation.c +3 -3
index e93776740725..44ab46b31f6b 100644
@@ -103,10 +103,10 @@ void __init housekeeping_init(void)
 static void __init housekeeping_setup_type(enum hk_type type,
 					   cpumask_var_t housekeeping_staging)
 {
+	if (cpumask_empty(housekeeping.cpumasks[type]))
+		alloc_bootmem_cpumask_var(&housekeeping.cpumasks[type]);
 
-	alloc_bootmem_cpumask_var(&housekeeping.cpumasks[type]);
-	cpumask_copy(housekeeping.cpumasks[type],
-		     housekeeping_staging);
+	cpumask_copy(housekeeping.cpumasks[type], housekeeping_staging);
 }
 
 static int __init housekeeping_setup(char *str, unsigned long flags)
Signature · 1 line
2.47.1
merge bot Applied
#7 lore raw

[tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to()

In reply to [email protected]
The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     6c58d2791d6046727d87db50a5e46644f195dcf9
Gitweb:        https://git.kernel.org/tip/6c58d2791d6046727d87db50a5e46644f195dcf9
Author:        Alex Shi <[email protected]>
AuthorDate:    Thu, 10 Apr 2025 17:24:16 +08:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 13 May 2025 16:38:03 +02:00

tick/nohz: Remove unused tick_nohz_full_add_cpus_to()

This function isn't used anywhere. Remove it.

---
 include/linux/tick.h | 7 -------
 1 file changed, 7 deletions(-)
include/linux/tick.h +0 -7
index b8ddc8e..ac76ae9 100644
@@ -195,12 +195,6 @@ static inline bool tick_nohz_full_enabled(void)
 	__ret;								\
 })
 
-static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask)
-{
-	if (tick_nohz_full_enabled())
-		cpumask_or(mask, mask, tick_nohz_full_mask);
-}
-
 extern void tick_nohz_dep_set(enum tick_dep_bits bit);
 extern void tick_nohz_dep_clear(enum tick_dep_bits bit);
 extern void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit);
@@ -281,7 +275,6 @@ extern void __init tick_nohz_full_setup(cpumask_var_t cpumask);
 #else
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
-static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { }
 
 static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { }
 static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { }