Re: [PATCH tip/core/rcu 2/2] documentation: Record reason for rcu_head two-byte alignment

From: Paul E. McKenney
Date: Mon Aug 22 2016 - 17:16:05 EST


On Mon, Aug 22, 2016 at 10:48:57PM +0200, Geert Uytterhoeven wrote:
> Hi Paul,
>
> On Mon, Aug 22, 2016 at 9:54 PM, Paul E. McKenney
> <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> > On Mon, Aug 22, 2016 at 03:18:54PM -0400, Steven Rostedt wrote:
> >> On Mon, 22 Aug 2016 20:56:09 +0200
> >> Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >>
> >> > > Don't we have __alignof__(void *) to avoid #ifdef CONFIG_M68K and
> >> > > other new macros ?
> >
> > Hmmm... Does __alignof__(void *) give two-byte alignment on m68k,
> > allowing something like this? Heh!!! It is already there. ;-)
> >
> > struct callback_head {
> > struct callback_head *next;
> > void (*func)(struct callback_head *head);
> > } __attribute__((aligned(sizeof(void *))));
>
> No, it's aligning to sizeof(void *) (4 on m68k), not __alignof__(void *).

Right you are. Commit 720abae3d68ae from Kirill A. Shutemov in November
2015.

Given that you haven't complained, I am guessing that this works for you.
If so, I can make the __call_rcu() WARN_ON() more strict.

> > #define rcu_head callback_head
> >
> > If so, that does sound quite attractive! Might need the WARN_ON()
> > anyway, to flag wild pointers if nothing else.
> >
> > Adding Geert on CC for his thoughts.
>
> __alignof__(void *) is indeed 2 on m68k, and h8300.
>
> Note that it is 1 on crisv32!

Gah... ((__alignof__(void *) + 1) & ~0x1), eh?

> It's 4 or 8 on anything else I have a cross-compiler for.
>
> $ cat a.c
> unsigned x = __alignof__(void *);
> $ for i in /opt/cross/*/*/bin/*gcc; do echo +++ $i +++; $i -c -S a.c;
> cat a.s; done | less

Thank you for checking!

Again, does the current state work for you?

Thanx, Paul