Subject: Re: [PATCH 1/4] [RFC] net: Explicitly initialize u64_stats_sync structures for lockdep

From: Ingo Molnar <[email-masked]>
Date: Fri, 27 Sep 2013 07:44:55 +0200

* Eric Dumazet <[email-masked]> wrote:

> On Thu, 2013-09-26 at 11:34 -0700, John Stultz wrote:
> > In order to enable lockdep on seqcount/seqlock structures, we
> > must explicitly initialize any locks.
> > 
> 
> > diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
> > index 8da8c4e..c450e11 100644
> > --- a/include/linux/u64_stats_sync.h
> > +++ b/include/linux/u64_stats_sync.h
> > @@ -67,6 +67,13 @@ struct u64_stats_sync {
> >  #endif
> >  };
> >  
> > +
> > +#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
> > +#define u64_stats_init(syncp)	seqcount_init(syncp.seq)
> > +#else
> > +#define u64_stats_init(syncp)
> > +#endif
> > +
> 
> I would prefer a function.

C cannot pass along symbolic names, unfortunately, so we are stuck with 
1970's tech and the C preprocessor.

There's a way to make such macros look a tiny bit more structured and thus 
be more palatable:

#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
# define u64_stats_init(syncp) seqcount_init(syncp.seq)
#else
# define u64_stats_init(syncp)
#endif

Note, the 'else' branch should probably be:

# define u64_stats_init(syncp) do { } while (0)

Thanks,

	Ingo