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

From: Kirill A. Shutemov
Date: Wed Aug 24 2016 - 14:05:14 EST


On Tue, Aug 23, 2016 at 07:23:26AM -0700, Paul E. McKenney wrote:
> On Tue, Aug 23, 2016 at 03:45:51PM +0200, Geert Uytterhoeven wrote:
> > Hi Paul,
> >
> > On Tue, Aug 23, 2016 at 3:43 PM, Paul E. McKenney
> > <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> > > On Tue, Aug 23, 2016 at 08:39:18AM +0200, Geert Uytterhoeven wrote:
> > >> On Mon, Aug 22, 2016 at 11:16 PM, Paul E. McKenney
> > >> <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> > >> > On Mon, Aug 22, 2016 at 10:48:57PM +0200, Geert Uytterhoeven wrote:
> > >> >> 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.
> > >> > Again, does the current state work for you?
> >
> > >> Yes it does. See also your commit 1146edcbef378922 ("rcu: Loosen __call_rcu()'s
> > >> rcu_head alignment constraint").
> > >
> > > Understood!
> > >
> > > But given that all architectures now provide at least four-byte alignment
> > > for the rcu_head structure, isn't it now OK for me to tighten up __call_rcu()'s
> > > check, for example, to this?
> > >
> > > WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1));
> >
> > Yes, I agree with that.
>
> Very good, I have queued the following patch.
>
> Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit 89d39c83d193733ed5fff1c480cd42c9de1da404
> Author: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
> Date: Tue Aug 23 06:51:47 2016 -0700
>
> rcu: Tighted up __call_rcu() rcu_head alignment check
>
> Commit 720abae3d68ae ("rcu: force alignment on struct
> callback_head/rcu_head") forced the rcu_head (AKA callback_head)
> structure's alignment to pointer size, that is, to 4-byte boundaries on
> 32-bit systems and to 8-byte boundaries on 64-bit systems. This
> commit therefore checks for this same alignment in __call_rcu(),
> which used to check for two-byte alignment.
>
> Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>

Looks good to me.

Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>

--
Kirill A. Shutemov