mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()
@ 2022-03-01 11:30 Nicolas Saenz Julienne
  2022-03-01 11:30 ` [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2022-03-01 11:30 UTC (permalink / raw)
  To: mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, bristot, linux-kernel, Nicolas Saenz Julienne

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 <nsaenzju@redhat.com>
---
 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


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

* [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-03-01 11:30 [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
@ 2022-03-01 11:30 ` Nicolas Saenz Julienne
  2022-03-01 18:58   ` Daniel Bristot de Oliveira
  2022-03-01 15:10 ` [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Steven Rostedt
  2022-03-01 18:57 ` Daniel Bristot de Oliveira
  2 siblings, 1 reply; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2022-03-01 11:30 UTC (permalink / raw)
  To: mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, bristot, linux-kernel, Nicolas Saenz Julienne

There isn't any need for this irq_work to be run locally, so avoid doing
so when the CPU is isolated.

Note that this is especially bad as queueing it into a local isolated
CPU might add noise to what was meant to be traced in the first place.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---

Changes since v1:
 - Rebase to cater for:
     04d4e665a609 ("sched/isolation: Use single feature type while
     referring to housekeeping cpumask")

 kernel/trace/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index bb2caf6aac01..250603b4eb3e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -12,6 +12,7 @@
  *  Copyright (C) 2004-2006 Ingo Molnar
  *  Copyright (C) 2004 Nadia Yvette Chambers
  */
+#include <linux/sched/isolation.h>
 #include <linux/ring_buffer.h>
 #include <generated/utsrelease.h>
 #include <linux/stacktrace.h>
@@ -1726,7 +1727,7 @@ void latency_fsnotify(struct trace_array *tr)
 	 * possible that we are called from __schedule() or do_idle(), which
 	 * could cause a deadlock.
 	 */
-	irq_work_queue(&tr->fsnotify_irqwork);
+	irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_TYPE_MISC));
 }
 
 #elif defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)	\
-- 
2.35.1


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

* Re: [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()
  2022-03-01 11:30 [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
  2022-03-01 11:30 ` [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
@ 2022-03-01 15:10 ` Steven Rostedt
  2022-03-01 18:57 ` Daniel Bristot de Oliveira
  2 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-03-01 15:10 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: mingo, peterz, frederic, tglx, mtosatti, bristot, linux-kernel

On Tue,  1 Mar 2022 12:30:52 +0100
Nicolas Saenz Julienne <nsaenzju@redhat.com> 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 <nsaenzju@redhat.com>
> ---
>  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);
>  


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

* Re: [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu()
  2022-03-01 11:30 [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
  2022-03-01 11:30 ` [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
  2022-03-01 15:10 ` [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Steven Rostedt
@ 2022-03-01 18:57 ` Daniel Bristot de Oliveira
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-03-01 18:57 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, linux-kernel

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 <nsaenzju@redhat.com>

Reviewed-by: Daniel Bristot de Oliveira <bristot@kernel.org>

-- Daniel


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

* Re: [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-03-01 11:30 ` [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
@ 2022-03-01 18:58   ` Daniel Bristot de Oliveira
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-03-01 18:58 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, linux-kernel

On 3/1/22 12:30, Nicolas Saenz Julienne wrote:
> There isn't any need for this irq_work to be run locally, so avoid doing
> so when the CPU is isolated.
> 
> Note that this is especially bad as queueing it into a local isolated
> CPU might add noise to what was meant to be traced in the first place.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>

Reviewed-by: Daniel Bristot de Oliveira <bristot@kernel.org>

-- Daniel


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

end of thread, other threads:[~2022-03-01 18:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 11:30 [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
2022-03-01 11:30 ` [PATCH v2 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
2022-03-01 18:58   ` Daniel Bristot de Oliveira
2022-03-01 15:10 ` [PATCH v2 1/2] sched/isolation: use raw_smp_processor_id() in housekeeping_any_cpu() Steven Rostedt
2022-03-01 18:57 ` Daniel Bristot de Oliveira

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

all inboxes | Powered by JetHome®