public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to
@ 2025-04-10  9:24 alexs
  2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: alexs @ 2025-04-10  9:24 UTC (permalink / raw)
  Cc: linux-kernel, Alex Shi, Thomas Gleixner, Ingo Molnar,
	Frederic Weisbecker, Anna-Maria Behnsen

From: Alex Shi <alexs@kernel.org>

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

Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 include/linux/tick.h | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/include/linux/tick.h b/include/linux/tick.h
index b8ddc8e631a3..ac76ae9fa36d 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -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) { }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] sched/isolation: clean up housekeeping_cpu
  2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
@ 2025-04-10  9:24 ` alexs
  2025-04-10 13:20   ` Frederic Weisbecker
  2025-04-10  9:24 ` [PATCH 3/4] sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu() alexs
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: alexs @ 2025-04-10  9:24 UTC (permalink / raw)
  Cc: linux-kernel, Alex Shi, Peter Zijlstra, Waiman Long,
	Frederic Weisbecker

From: Alex Shi <alexs@kernel.org>

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.

Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: Peter Zijlstra  <peterz@infradead.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
---
 include/linux/sched/isolation.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index d8501f4709b5..231bc5766f76 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -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)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu()
  2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
  2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
@ 2025-04-10  9:24 ` alexs
  2025-04-10  9:24 ` [PATCH 4/4] sched/isolation: don't alloc twice for housekeeping.cpumasks alexs
  2025-05-13 14:49 ` [tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to() tip-bot2 for Alex Shi
  3 siblings, 0 replies; 8+ messages in thread
From: alexs @ 2025-04-10  9:24 UTC (permalink / raw)
  Cc: linux-kernel, Alex Shi, Frederic Weisbecker, Waiman Long,
	Lai Jiangshan, Tejun Heo, Valentin Schneider, Ben Segall,
	Steven Rostedt, Dietmar Eggemann, Vincent Guittot, Juri Lelli,
	Peter Zijlstra, Ingo Molnar

From: Alex Shi <alexs@kernel.org>

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

Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Ben Segall <bsegall@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
---
 include/linux/sched/isolation.h | 19 +++++++------------
 kernel/sched/isolation.c        |  4 ++--
 kernel/workqueue.c              |  2 +-
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index 231bc5766f76..90e46440fc85 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -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);
 }
 
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 81bc8b329ef1..e93776740725 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -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)
 {
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bfe030b443e2..69a02c9e53fb 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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 {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] sched/isolation: don't alloc twice for housekeeping.cpumasks
  2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
  2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
  2025-04-10  9:24 ` [PATCH 3/4] sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu() alexs
@ 2025-04-10  9:24 ` alexs
  2025-05-13 14:49 ` [tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to() tip-bot2 for Alex Shi
  3 siblings, 0 replies; 8+ messages in thread
From: alexs @ 2025-04-10  9:24 UTC (permalink / raw)
  Cc: linux-kernel, Alex Shi, Valentin Schneider, Ben Segall,
	Steven Rostedt, Dietmar Eggemann, Vincent Guittot, Juri Lelli,
	Peter Zijlstra, Ingo Molnar

From: Alex Shi <alexs@kernel.org>

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.

Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Ben Segall <bsegall@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
---
 kernel/sched/isolation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index e93776740725..44ab46b31f6b 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -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)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu
  2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
@ 2025-04-10 13:20   ` Frederic Weisbecker
  2025-04-11  0:58     ` Alex Shi
  0 siblings, 1 reply; 8+ messages in thread
From: Frederic Weisbecker @ 2025-04-10 13:20 UTC (permalink / raw)
  To: alexs; +Cc: linux-kernel, Peter Zijlstra, Waiman Long

Le Thu, Apr 10, 2025 at 05:24:17PM +0800, alexs@kernel.org a écrit :
> From: Alex Shi <alexs@kernel.org>
> 
> 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.

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu
  2025-04-10 13:20   ` Frederic Weisbecker
@ 2025-04-11  0:58     ` Alex Shi
  2025-04-11 11:08       ` Frederic Weisbecker
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Shi @ 2025-04-11  0:58 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: alexs, linux-kernel, Peter Zijlstra, Waiman Long

Frederic Weisbecker <frederic@kernel.org> 于2025年4月10日周四 21:20写道:
>
> Le Thu, Apr 10, 2025 at 05:24:17PM +0800, alexs@kernel.org a écrit :
> > From: Alex Shi <alexs@kernel.org>
> >
> > 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sched/isolation: clean up housekeeping_cpu
  2025-04-11  0:58     ` Alex Shi
@ 2025-04-11 11:08       ` Frederic Weisbecker
  0 siblings, 0 replies; 8+ messages in thread
From: Frederic Weisbecker @ 2025-04-11 11:08 UTC (permalink / raw)
  To: Alex Shi; +Cc: alexs, linux-kernel, Peter Zijlstra, Waiman Long

Le Fri, Apr 11, 2025 at 08:58:45AM +0800, Alex Shi a écrit :
> Frederic Weisbecker <frederic@kernel.org> 于2025年4月10日周四 21:20写道:
> >
> > Le Thu, Apr 10, 2025 at 05:24:17PM +0800, alexs@kernel.org a écrit :
> > > From: Alex Shi <alexs@kernel.org>
> > >
> > > 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.

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.

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to()
  2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
                   ` (2 preceding siblings ...)
  2025-04-10  9:24 ` [PATCH 4/4] sched/isolation: don't alloc twice for housekeeping.cpumasks alexs
@ 2025-05-13 14:49 ` tip-bot2 for Alex Shi
  3 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Alex Shi @ 2025-05-13 14:49 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Alex Shi, Thomas Gleixner, x86, linux-kernel

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 <alexs@kernel.org>
AuthorDate:    Thu, 10 Apr 2025 17:24:16 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Alex Shi <alexs@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250410092423.9831-1-alexs@kernel.org

---
 include/linux/tick.h | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/include/linux/tick.h b/include/linux/tick.h
index b8ddc8e..ac76ae9 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -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) { }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-05-13 14:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
2025-04-10 13:20   ` Frederic Weisbecker
2025-04-11  0:58     ` Alex Shi
2025-04-11 11:08       ` Frederic Weisbecker
2025-04-10  9:24 ` [PATCH 3/4] sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu() alexs
2025-04-10  9:24 ` [PATCH 4/4] sched/isolation: don't alloc twice for housekeeping.cpumasks alexs
2025-05-13 14:49 ` [tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to() tip-bot2 for Alex Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox