2022-03-01 16:01:45

by Nicolas Saenz Julienne

[permalink] [raw]
Subject: [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()

housekeeping_any_cpu() will return a housekeeping CPU. That's it. It'll
try to optimize for NUMA locality and to use the local CPU, but it's not
a requisite.

So let's use raw_smp_processor_id() instead of its vanilla counterpart
in order to allow users to query for housekeeping CPUs without having to
disable preemption.

Signed-off-by: Nicolas Saenz Julienne <[email protected]>
---
include/linux/sched/isolation.h | 2 +-
kernel/sched/isolation.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index 8c15abd67aed..0c09ff1e4599 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -31,7 +31,7 @@ extern void __init housekeeping_init(void);

static inline int housekeeping_any_cpu(enum hk_type type)
{
- return smp_processor_id();
+ return raw_smp_processor_id();
}

static inline const struct cpumask *housekeeping_cpumask(enum hk_type type)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index b4d10815c45a..c2c1f6d8bb5f 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -43,14 +43,14 @@ int housekeeping_any_cpu(enum hk_type type)

if (static_branch_unlikely(&housekeeping_overridden)) {
if (housekeeping.flags & BIT(type)) {
- cpu = sched_numa_find_closest(housekeeping.cpumasks[type], smp_processor_id());
+ cpu = sched_numa_find_closest(housekeeping.cpumasks[type], raw_smp_processor_id());
if (cpu < nr_cpu_ids)
return cpu;

return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
}
}
- return smp_processor_id();
+ return raw_smp_processor_id();
}
EXPORT_SYMBOL_GPL(housekeeping_any_cpu);

--
2.35.1


2022-03-01 19:48:52

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()

On Tue, 1 Mar 2022 12:30:52 +0100
Nicolas Saenz Julienne <[email protected]> wrote:

> housekeeping_any_cpu() will return a housekeeping CPU. That's it. It'll
> try to optimize for NUMA locality and to use the local CPU, but it's not
> a requisite.
>
> So let's use raw_smp_processor_id() instead of its vanilla counterpart
> in order to allow users to query for housekeeping CPUs without having to
> disable preemption.

Peter, care to ACK this, and I can take it through my tree?

-- Steve

>
> Signed-off-by: Nicolas Saenz Julienne <[email protected]>
> ---
> include/linux/sched/isolation.h | 2 +-
> kernel/sched/isolation.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
> index 8c15abd67aed..0c09ff1e4599 100644
> --- a/include/linux/sched/isolation.h
> +++ b/include/linux/sched/isolation.h
> @@ -31,7 +31,7 @@ extern void __init housekeeping_init(void);
>
> static inline int housekeeping_any_cpu(enum hk_type type)
> {
> - return smp_processor_id();
> + return raw_smp_processor_id();
> }
>
> static inline const struct cpumask *housekeeping_cpumask(enum hk_type type)
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index b4d10815c45a..c2c1f6d8bb5f 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -43,14 +43,14 @@ int housekeeping_any_cpu(enum hk_type type)
>
> if (static_branch_unlikely(&housekeeping_overridden)) {
> if (housekeeping.flags & BIT(type)) {
> - cpu = sched_numa_find_closest(housekeeping.cpumasks[type], smp_processor_id());
> + cpu = sched_numa_find_closest(housekeeping.cpumasks[type], raw_smp_processor_id());
> if (cpu < nr_cpu_ids)
> return cpu;
>
> return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
> }
> }
> - return smp_processor_id();
> + return raw_smp_processor_id();
> }
> EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
>

Subject: Re: [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()

On 3/1/22 12:30, Nicolas Saenz Julienne wrote:
> housekeeping_any_cpu() will return a housekeeping CPU. That's it. It'll
> try to optimize for NUMA locality and to use the local CPU, but it's not
> a requisite.
>
> So let's use raw_smp_processor_id() instead of its vanilla counterpart
> in order to allow users to query for housekeeping CPUs without having to
> disable preemption.
>
> Signed-off-by: Nicolas Saenz Julienne <[email protected]>

Reviewed-by: Daniel Bristot de Oliveira <[email protected]>

-- Daniel