Re: [PATCH rcu 3/6] srcu,notifier: Remove #ifdefs in favor of SRCU Tiny srcu_usage

From: Paul E. McKenney
Date: Mon Jul 17 2023 - 14:17:40 EST


On Mon, Jul 17, 2023 at 11:09:56AM -0700, Linus Torvalds wrote:
> On Mon, 17 Jul 2023 at 11:03, Paul E. McKenney <paulmck@xxxxxxxxxx> wrote:
> >
> > +// Dummy structure for srcu_notifier_head.
> > +struct srcu_usage {
> > + char srcuu_dummy;
> > +};
> > +
> > +#define __SRCU_USAGE_INIT(name) { .srcuu_dummy = 0, }
>
> You really should be able to just do
>
> struct srcu_usage { };
> #define __SRCU_USAGE_INIT(name) { }
>
> which is something we've done for ages for spinlocks in
>
> include/linux/spinlock_types_up.h
>
> because while we had a gcc bug wrt empty structures, that was ages ago
> (ie "gcc-2.x").
>
> See commit a1365647022e ("[PATCH] remove gcc-2 checks") from 2006.
>
> So we've already had these kinds of empty dummy structs for literally
> over a decade in active use. Exactly so that you can avoid having to
> use #ifdef's etc, and can just always assume you have a spinlock, even
> if it doesn't generate any code or any data overhead.

Showing my age again, I guess. ;-)

Thank you for the hint! I will rework this as you suggest.

Thanx, Paul