linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Michael Jeanson <mjeanson@efficios.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>, Yonghong Song <yhs@fb.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	bpf@vger.kernel.org, Joel Fernandes <joel@joelfernandes.org>,
	Jordan Rife <jrife@google.com>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 4/5] tracing: Remove conditional locking from __DO_TRACE()
Date: Mon, 25 Nov 2024 15:26:06 +0100	[thread overview]
Message-ID: <20241125142606.GG38837@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <d36281ef-bb8f-4b87-9867-8ac1752ebc1c@efficios.com>

On Mon, Nov 25, 2024 at 09:18:18AM -0500, Mathieu Desnoyers wrote:
> On 2024-11-23 12:38, Linus Torvalds wrote:

> I tried the following alteration to the code, which triggers an
> unexpected compiler warning on master, but not on v6.12. I suspect
> this is something worth discussing:
> 
>         static inline void trace_##name(proto)                          \
>         {                                                               \
>                 if (static_branch_unlikely(&__tracepoint_##name.key)) { \
>                         if (cond)                                       \
>                                 scoped_guard(preempt_notrace)           \
>                                         __DO_TRACE_CALL(name, TP_ARGS(args)); \

So coding style would like braces here for it being multi-line. As
opposed to C that only mandates it for multi-statement. And then the
problem doesn't occur.

>                 }                                                       \
>                 if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) {             \
>                         WARN_ONCE(!rcu_is_watching(),                   \
>                                   "RCU not watching for tracepoint");   \
>                 }                                                       \
>         }
> 

> I suspect this is caused by the "else" at the end of the __scoped_guard() macro:
> 
> #define __scoped_guard(_name, _label, args...)                          \
>         for (CLASS(_name, scope)(args);                                 \
>              __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name);       \
>              ({ goto _label; }))                                        \
>                 if (0) {                                                \
> _label:                                                                 \
>                         break;                                          \
>                 } else
> 
> #define scoped_guard(_name, args...)    \
>         __scoped_guard(_name, __UNIQUE_ID(label), args)
> 
> AFAIU this is a new warning introduced by
> 
> commit fcc22ac5baf ("cleanup: Adjust scoped_guard() macros to avoid potential warning")

Yeah,.. So strictly speaking the code is fine, but the various compilers
don't like it when that else dangles :/

  reply	other threads:[~2024-11-25 14:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-23 15:30 [RFC PATCH 0/5] tracing: Remove conditional locking from tracepoints Mathieu Desnoyers
2024-11-23 15:30 ` [RFC PATCH 1/5] tracing: Move it_func[0] comment to the relevant context Mathieu Desnoyers
2024-11-23 15:30 ` [RFC PATCH 2/5] tracing: Remove __idx variable from __DO_TRACE Mathieu Desnoyers
2024-11-23 15:30 ` [RFC PATCH 3/5] rcupdate_trace: Define rcu_tasks_trace lock guard Mathieu Desnoyers
2024-11-23 15:30 ` [RFC PATCH 4/5] tracing: Remove conditional locking from __DO_TRACE() Mathieu Desnoyers
2024-11-23 17:38   ` Linus Torvalds
2024-11-25  1:50     ` Mathieu Desnoyers
2024-11-25  3:22       ` Steven Rostedt
2024-11-25 14:18     ` Mathieu Desnoyers
2024-11-25 14:26       ` Peter Zijlstra [this message]
2024-11-25 15:35         ` Przemek Kitszel
2024-11-25 17:51           ` Linus Torvalds
2024-11-26  8:45             ` Peter Zijlstra
2024-11-26 18:13               ` Linus Torvalds
2024-11-26 20:47                 ` Dmitry Torokhov
2024-11-26 22:32                   ` Przemek Kitszel
2024-11-26 22:40                     ` Linus Torvalds
2024-11-23 15:30 ` [RFC PATCH 5/5] tracing: Remove cond argument from __DECLARE_TRACE_SYSCALL Mathieu Desnoyers

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=20241125142606.GG38837@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=jrife@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjeanson@efficios.com \
    --cc=namhyung@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yhs@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).