[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2aab04d1-c16b-44e4-a283-7bbf8cba28e7@p183>
Date: Mon, 24 Jun 2024 17:42:54 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Marco Elver <elver@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org
Subject: Re: [PATCH] compiler.h: simplify data_race() macro
On Mon, Jun 24, 2024 at 02:27:43PM +0200, Marco Elver wrote:
> On Mon, 24 Jun 2024 at 13:49, Alexey Dobriyan <adobriyan@...il.com> wrote:
> >
> > Use auto type deduction and comma expression to decrease macro expansion
> > size.
> >
> > __unqual_scalar_typeof() is quite wordy macro by itself.
> >
> > "expr" can be arbitrary complex so not expanding it twice is good.
> > Should be faster too because type is deduced only once
> > from the initializer.
> >
> > Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
>
> Thanks for cleaning up. That code certainly predates the availability
> of __auto_type. Although if I recall correctly, __unqual_scalar_typeof
> became the first user of _Generic (the first C11 keyword we used in
> the kernel?), but we used some ifdef to still support ancient
> compilers initially (that definitely also didn't have __auto_type).
>
> Reviewed-by: Marco Elver <elver@...gle.com>
>
> Which tree is this for?
>
> > ---
> >
> > include/linux/compiler.h | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > --- a/include/linux/compiler.h
> > +++ b/include/linux/compiler.h
> > @@ -200,10 +200,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> > */
> > #define data_race(expr) \
> > ({ \
> > - __unqual_scalar_typeof(({ expr; })) __v = ({ \
> > - __kcsan_disable_current(); \
> > - expr; \
> > - }); \
> > + __auto_type __v = (__kcsan_disable_current(), expr); \
> > __kcsan_enable_current(); \
> > __v; \
> > })
I just realized, comma expression should not be necesary.
-Wdeclaration-after-statement prohibited simple
({
__kcsan_disable_current
auto v = (expr);
__kcsan_enable_current
v;
})
Powered by blists - more mailing lists