public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] trace,hardirq: No moar _rcuidle() tracing
Date: Tue, 17 Jan 2023 23:31:13 +0900	[thread overview]
Message-ID: <20230117233113.2fda1900e48969bebd0d1604@kernel.org> (raw)
In-Reply-To: <Y8ZmeGlNPLvuARBB@gmail.com>

On Tue, 17 Jan 2023 10:17:16 +0100
Ingo Molnar <mingo@kernel.org> wrote:

> 
> * Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > On Tue, Jan 17, 2023 at 01:24:46PM +0900, Masami Hiramatsu wrote:
> > > Hi Peter,
> > > 
> > > On Thu, 12 Jan 2023 20:43:49 +0100
> > > Peter Zijlstra <peterz@infradead.org> wrote:
> > > 
> > > > Robot reported that trace_hardirqs_{on,off}() tickle the forbidden
> > > > _rcuidle() tracepoint through local_irq_{en,dis}able().
> > > > 
> > > > For 'sane' configs, these calls will only happen with RCU enabled and
> > > > as such can use the regular tracepoint. This also means it's possible
> > > > to trace them from NMI context again.
> > > > 
> > > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > 
> > > The code looks good to me. I just have a question about comment.
> > > 
> > > > ---
> > > >  kernel/trace/trace_preemptirq.c |   21 +++++++++++++--------
> > > >  1 file changed, 13 insertions(+), 8 deletions(-)
> > > > 
> > > > --- a/kernel/trace/trace_preemptirq.c
> > > > +++ b/kernel/trace/trace_preemptirq.c
> > > > @@ -20,6 +20,15 @@
> > > >  static DEFINE_PER_CPU(int, tracing_irq_cpu);
> > > >  
> > > >  /*
> > > > + * ...
> > > 
> > > Is this intended? Wouldn't you leave any comment here?
> > 
> > I indeed forgot to write the comment before posting, my bad :/ Ingo fixed
> > it up when he applied.
> 
> For completeness, I've attached the final commit, which has this comment 
> included:
> 
> +/*
> + * Use regular trace points on architectures that implement noinstr
> + * tooling: these calls will only happen with RCU enabled, which can
> + * use a regular tracepoint.
> + *
> + * On older architectures, use the rcuidle tracing methods (which
> + * aren't NMI-safe - so exclude NMI contexts):
> + */

Thanks! This looks good to me.

Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

> 
> Thanks,
> 
> 	Ingo
> 
> ================>
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Thu, 12 Jan 2023 20:43:49 +0100
> Subject: [PATCH] tracing, hardirq: No moar _rcuidle() tracing
> 
> Robot reported that trace_hardirqs_{on,off}() tickle the forbidden
> _rcuidle() tracepoint through local_irq_{en,dis}able().
> 
> For 'sane' configs, these calls will only happen with RCU enabled and
> as such can use the regular tracepoint. This also means it's possible
> to trace them from NMI context again.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Link: https://lore.kernel.org/r/20230112195541.477416709@infradead.org
> ---
>  kernel/trace/trace_preemptirq.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c
> index 629f2854e12b..f992444a0b1f 100644
> --- a/kernel/trace/trace_preemptirq.c
> +++ b/kernel/trace/trace_preemptirq.c
> @@ -19,6 +19,20 @@
>  /* Per-cpu variable to prevent redundant calls when IRQs already off */
>  static DEFINE_PER_CPU(int, tracing_irq_cpu);
>  
> +/*
> + * Use regular trace points on architectures that implement noinstr
> + * tooling: these calls will only happen with RCU enabled, which can
> + * use a regular tracepoint.
> + *
> + * On older architectures, use the rcuidle tracing methods (which
> + * aren't NMI-safe - so exclude NMI contexts):
> + */
> +#ifdef CONFIG_ARCH_WANTS_NO_INSTR
> +#define trace(point)	trace_##point
> +#else
> +#define trace(point)	if (!in_nmi()) trace_##point##_rcuidle
> +#endif
> +
>  /*
>   * Like trace_hardirqs_on() but without the lockdep invocation. This is
>   * used in the low level entry code where the ordering vs. RCU is important
> @@ -28,8 +42,7 @@ static DEFINE_PER_CPU(int, tracing_irq_cpu);
>  void trace_hardirqs_on_prepare(void)
>  {
>  	if (this_cpu_read(tracing_irq_cpu)) {
> -		if (!in_nmi())
> -			trace_irq_enable(CALLER_ADDR0, CALLER_ADDR1);
> +		trace(irq_enable)(CALLER_ADDR0, CALLER_ADDR1);
>  		tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1);
>  		this_cpu_write(tracing_irq_cpu, 0);
>  	}
> @@ -40,8 +53,7 @@ NOKPROBE_SYMBOL(trace_hardirqs_on_prepare);
>  void trace_hardirqs_on(void)
>  {
>  	if (this_cpu_read(tracing_irq_cpu)) {
> -		if (!in_nmi())
> -			trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
> +		trace(irq_enable)(CALLER_ADDR0, CALLER_ADDR1);
>  		tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1);
>  		this_cpu_write(tracing_irq_cpu, 0);
>  	}
> @@ -63,8 +75,7 @@ void trace_hardirqs_off_finish(void)
>  	if (!this_cpu_read(tracing_irq_cpu)) {
>  		this_cpu_write(tracing_irq_cpu, 1);
>  		tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1);
> -		if (!in_nmi())
> -			trace_irq_disable(CALLER_ADDR0, CALLER_ADDR1);
> +		trace(irq_disable)(CALLER_ADDR0, CALLER_ADDR1);
>  	}
>  
>  }
> @@ -78,8 +89,7 @@ void trace_hardirqs_off(void)
>  	if (!this_cpu_read(tracing_irq_cpu)) {
>  		this_cpu_write(tracing_irq_cpu, 1);
>  		tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1);
> -		if (!in_nmi())
> -			trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
> +		trace(irq_disable)(CALLER_ADDR0, CALLER_ADDR1);
>  	}
>  }
>  EXPORT_SYMBOL(trace_hardirqs_off);


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2023-01-17 14:32 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 19:43 [PATCH v3 00/51] cpuidle,rcu: Clean up the mess Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 01/51] x86/perf/amd: Remove tracing from perf_lopwr_cb() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 02/51] x86/idle: Replace x86_idle with a static_call Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] x86/idle: Replace 'x86_idle' function pointer " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 03/51] cpuidle/poll: Ensure IRQ state is invariant Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle/poll: Ensure IRQs stay disabled after cpuidle_state::enter() calls tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 04/51] cpuidle: Move IRQ state validation Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 05/51] cpuidle,riscv: Push RCU-idle into driver Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, riscv: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 06/51] cpuidle,tegra: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, tegra: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 07/51] cpuidle,psci: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, psci: " tip-bot2 for Peter Zijlstra
2023-03-07 16:40   ` [PATCH v3 07/51] cpuidle,psci: " Geert Uytterhoeven
2023-03-20 14:56     ` Mark Rutland
2023-01-12 19:43 ` [PATCH v3 08/51] cpuidle,imx6: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, ARM/imx6: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 09/51] cpuidle,omap3: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, OMAP3: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 10/51] cpuidle,armada: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, armada: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 11/51] cpuidle,omap4: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, OMAP4: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 12/51] cpuidle,dt: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, dt: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 13/51] cpuidle: Fix ct_idle_*() usage Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 14/51] cpuidle,cpu_pm: Remove RCU fiddling from cpu_pm_{enter,exit}() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, cpu_pm: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 15/51] acpi_idle: Remove tracing Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 16/51] cpuidle: Annotate poll_idle() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-20  9:56   ` [PATCH v3 16/51] " Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 17/51] objtool/idle: Validate __cpuidle code as noinstr Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 18/51] cpuidle,intel_idle: Fix CPUIDLE_FLAG_IRQ_ENABLE *again* Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, intel_idle: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 19/51] cpuidle,intel_idle: Fix CPUIDLE_FLAG_INIT_XSTATE Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, intel_idle: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 20/51] cpuidle,intel_idle: Fix CPUIDLE_FLAG_IBRS Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, intel_idle: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 21/51] arch/idle: Change arch_cpu_idle() IRQ behaviour Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 22/51] x86/tdx: Remove TDX_HCALL_ISSUE_STI Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 23/51] arm,smp: Remove trace_.*_rcuidle() usage Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] arm, smp: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 24/51] arm64,smp: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] arm64, smp: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 25/51] printk: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 26/51] time/tick-broadcast: Remove RCU_NONIDLE usage Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] time/tick-broadcast: Remove RCU_NONIDLE() usage tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 27/51] cpuidle,sched: Remove annotations from TIF_{POLLING_NRFLAG,NEED_RESCHED} Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, sched: Remove instrumentation " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 28/51] cpuidle,mwait: Make noinstr clean Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, mwait: Make the mwait code " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 29/51] cpuidle,tdx: Make tdx " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, tdx: Make TDX code " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 30/51] cpuidle,xenpv: Make more PARAVIRT_XXL " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, xenpv: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 31/51] cpuidle,nospec: Make " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, nospec: Make mds_idle_clear_cpu_buffers() " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 32/51] cpuidle,acpi: Make " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, ACPI: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 33/51] trace: Remove trace_hardirqs_{on,off}_caller() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] tracing: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 34/51] trace: WARN on rcuidle Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] tracing: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 35/51] trace,hardirq: No moar _rcuidle() tracing Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] tracing, hardirq: " tip-bot2 for Peter Zijlstra
2023-01-17  4:24   ` [PATCH v3 35/51] trace,hardirq: " Masami Hiramatsu
2023-01-17  8:53     ` Peter Zijlstra
2023-01-17  9:17       ` [PATCH v4] " Ingo Molnar
2023-01-17 14:31         ` Masami Hiramatsu [this message]
2023-01-12 19:43 ` [PATCH v3 36/51] cpuidle,omap3: Use WFI for omap3_pm_idle() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, OMAP3: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 37/51] cpuidle,omap3: Push RCU-idle into omap_sram_idle() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, OMAP3: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 38/51] cpuidle,omap4: Push RCU-idle into omap4_enter_lowpower() Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 39/51] arm,omap2: Use WFI for omap2_pm_idle() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] arm, OMAP2: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 40/51] cpuidle,powerdomain: Remove trace_.*_rcuidle() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, ARM: OMAP2+: powerdomain: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 41/51] cpuidle,clk: " Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, clk: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 42/51] ubsan: Fix objtool UACCESS warns Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 43/51] intel_idle: Add force_irq_on module param Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 44/51] entry,kasan,x86: Disallow overriding mem*() functions Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] entry, kasan, x86: " tip-bot2 for Peter Zijlstra
2023-01-12 19:43 ` [PATCH v3 45/51] sched: Always inline __this_cpu_preempt_check() Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] sched/core: " tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 46/51] arm64,riscv,perf: Remove RCU_NONIDLE() usage Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] arm64, riscv, perf: " tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 47/51] cpuidle: Ensure ct_cpuidle_enter() is always called from noinstr/__cpuidle Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 48/51] cpuidle,arch: Mark all ct_cpuidle_enter() callers __cpuidle Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle, arch: " tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 49/51] cpuidle,arch: Mark all regular cpuidle_state::enter methods __cpuidle Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle,arch: Mark all regular cpuidle_state:: Enter " tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 50/51] cpuidle: Comments about noinstr/__cpuidle Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] cpuidle: Add comments about noinstr/__cpuidle usage tip-bot2 for Peter Zijlstra
2023-01-12 19:44 ` [PATCH v3 51/51] context_tracking: Fix noinstr vs KASAN Peter Zijlstra
2023-01-13 12:31   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2023-01-13 18:06 ` [PATCH v3 00/51] cpuidle,rcu: Clean up the mess Paul E. McKenney
2023-01-16 16:59 ` Mark Rutland
2023-01-17 10:26   ` Peter Zijlstra
2023-01-17 12:39     ` Sudeep Holla
2023-01-17 13:16     ` Mark Rutland
2023-01-17 14:21       ` Sudeep Holla
2023-01-17 15:35         ` Mark Rutland
2023-01-18 11:38     ` [tip: sched/core] cpuidle, arm64: Fix the ARM64 cpuidle logic tip-bot2 for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230117233113.2fda1900e48969bebd0d1604@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox