Re: [RFC PATCH 4/5] tracing: Remove conditional locking from __DO_TRACE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/25/24 15:26, Peter Zijlstra wrote:
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 :/

At one point I had a version that did:
	if (0)
label: ;
	else
		for (....)

but it is goto-jumping back in the code
https://lore.kernel.org/netdev/20241001145718.8962-1-przemyslaw.kitszel@xxxxxxxxx/#t

I could switch to it again to reduce noise like this problem, but such
change would be to essentially allow bad formatting




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux