[v8,01/24] tick/nohz: Move tick_nohz_full_mask declaration outside the #ifdef

Message ID 20231215174343.13872-2-james.morse@arm.com
State New
Headers
Series x86/resctrl: monitored closid+rmid together, separate arch/fs locking |

Commit Message

James Morse Dec. 15, 2023, 5:43 p.m. UTC
  tick_nohz_full_mask lists the CPUs that are nohz_full. This is only
needed when CONFIG_NO_HZ_FULL is defined. tick_nohz_full_cpu() allows
a specific CPU to be tested against the mask, and evaluates to false
when CONFIG_NO_HZ_FULL is not defined.

The resctrl code needs to pick a CPU to run some work on, a new helper
prefers housekeeping CPUs by examining the tick_nohz_full_mask. Hiding
the declaration behind #ifdef CONFIG_NO_HZ_FULL forces all the users to
be behind an ifdef too.

Move the tick_nohz_full_mask declaration, this lets callers drop the
ifdef, and guard access to tick_nohz_full_mask with IS_ENABLED() or
something like tick_nohz_full_cpu().

The definition does not need to be moved as any callers should be
removed at compile time unless CONFIG_NO_HZ_FULL is defined.

Signed-off-by: James Morse <james.morse@arm.com>
Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Acked-by: Reinette Chatre <reinette.chatre@intel.com> # for resctrl dependency
CC: Frederic Weisbecker <frederic@kernel.org>
---
 include/linux/tick.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

Thomas Gleixner Dec. 15, 2023, 8:31 p.m. UTC | #1
On Fri, Dec 15 2023 at 17:43, James Morse wrote:
> tick_nohz_full_mask lists the CPUs that are nohz_full. This is only
> needed when CONFIG_NO_HZ_FULL is defined. tick_nohz_full_cpu() allows
> a specific CPU to be tested against the mask, and evaluates to false
> when CONFIG_NO_HZ_FULL is not defined.
>
> The resctrl code needs to pick a CPU to run some work on, a new helper
> prefers housekeeping CPUs by examining the tick_nohz_full_mask. Hiding
> the declaration behind #ifdef CONFIG_NO_HZ_FULL forces all the users to
> be behind an ifdef too.
>
> Move the tick_nohz_full_mask declaration, this lets callers drop the
> ifdef, and guard access to tick_nohz_full_mask with IS_ENABLED() or
> something like tick_nohz_full_cpu().
>
> The definition does not need to be moved as any callers should be
> removed at compile time unless CONFIG_NO_HZ_FULL is defined.

I can pick that up separately, but I'm fine when it goes with the
resctrl lot. For that case:

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
  
James Morse Jan. 22, 2024, 6:05 p.m. UTC | #2
Hi Thomas,

On 15/12/2023 20:31, Thomas Gleixner wrote:
> On Fri, Dec 15 2023 at 17:43, James Morse wrote:
>> tick_nohz_full_mask lists the CPUs that are nohz_full. This is only
>> needed when CONFIG_NO_HZ_FULL is defined. tick_nohz_full_cpu() allows
>> a specific CPU to be tested against the mask, and evaluates to false
>> when CONFIG_NO_HZ_FULL is not defined.
>>
>> The resctrl code needs to pick a CPU to run some work on, a new helper
>> prefers housekeeping CPUs by examining the tick_nohz_full_mask. Hiding
>> the declaration behind #ifdef CONFIG_NO_HZ_FULL forces all the users to
>> be behind an ifdef too.
>>
>> Move the tick_nohz_full_mask declaration, this lets callers drop the
>> ifdef, and guard access to tick_nohz_full_mask with IS_ENABLED() or
>> something like tick_nohz_full_cpu().
>>
>> The definition does not need to be moved as any callers should be
>> removed at compile time unless CONFIG_NO_HZ_FULL is defined.


> I can pick that up separately, but I'm fine when it goes with the
> resctrl lot. For that case:

> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>


Thanks!

James
  

Patch

diff --git a/include/linux/tick.h b/include/linux/tick.h
index 716d17f31c45..0fb903838dfb 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -164,9 +164,16 @@  static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }
 static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; }
 #endif /* !CONFIG_NO_HZ_COMMON */
 
+/*
+ * Mask of CPUs that are nohz_full.
+ *
+ * Users should be guarded by CONFIG_NO_HZ_FULL or a tick_nohz_full_cpu()
+ * check.
+ */
+extern cpumask_var_t tick_nohz_full_mask;
+
 #ifdef CONFIG_NO_HZ_FULL
 extern bool tick_nohz_full_running;
-extern cpumask_var_t tick_nohz_full_mask;
 
 static inline bool tick_nohz_full_enabled(void)
 {