From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Steven Rostedt" <rostedt@goodmis.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Eric Dumazet" <edumazet@google.com>,
LKML <linux-kernel@vger.kernel.org>,
"Ingo Molnar" <mingo@kernel.org>,
jiangshanlai@gmail.com, dipankar@in.ibm.com,
"Andrew Morton" <akpm@linux-foundation.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Josh Triplett" <josh@joshtriplett.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"David Howells" <dhowells@redhat.com>,
"Darren Hart" <dvhart@linux.intel.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"pranith kumar" <bobby.prani@gmail.com>,
"Greg Ungerer" <gerg@linux-m68k.org>
Subject: Re: [PATCH tip/core/rcu 2/2] documentation: Record reason for rcu_head two-byte alignment
Date: Tue, 23 Aug 2016 07:23:26 -0700 [thread overview]
Message-ID: <20160823142326.GF3482@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAMuHMdVARrSBfvhtuFe36nf=7x6cyhStUDC5ur3Rtj7oCh+sQg@mail.gmail.com>
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@linux.vnet.ibm.com> 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@linux.vnet.ibm.com> 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@linux.vnet.ibm.com> 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@infradead.org> 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@linux.vnet.ibm.com>
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@linux.vnet.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 3a8eec3ba1bd..673bcb3934a3 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3122,7 +3122,9 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func,
unsigned long flags;
struct rcu_data *rdp;
- WARN_ON_ONCE((unsigned long)head & 0x1); /* Misaligned rcu_head! */
+ /* Misaligned rcu_head! */
+ WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1));
+
if (debug_rcu_head_queue(head)) {
/* Probable double call_rcu(), so leak the callback. */
WRITE_ONCE(head->func, rcu_leak_callback);
next prev parent reply other threads:[~2016-08-23 18:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-22 15:14 [PATCH tip/core/rcu 0/2] Documentation updates Paul E. McKenney
2016-08-22 15:14 ` [PATCH tip/core/rcu 1/2] rcutorture: Remove outdated config option description Paul E. McKenney
2016-08-22 15:14 ` [PATCH tip/core/rcu 2/2] documentation: Record reason for rcu_head two-byte alignment Paul E. McKenney
2016-08-22 16:25 ` Peter Zijlstra
2016-08-22 17:34 ` Paul E. McKenney
2016-08-22 18:48 ` Eric Dumazet
2016-08-22 18:56 ` Peter Zijlstra
2016-08-22 19:18 ` Steven Rostedt
2016-08-22 19:54 ` Paul E. McKenney
2016-08-22 20:48 ` Geert Uytterhoeven
2016-08-22 21:16 ` Paul E. McKenney
2016-08-23 6:39 ` Geert Uytterhoeven
2016-08-23 13:43 ` Paul E. McKenney
2016-08-23 13:45 ` Geert Uytterhoeven
2016-08-23 14:23 ` Paul E. McKenney [this message]
2016-08-23 14:30 ` Geert Uytterhoeven
2016-08-23 14:41 ` Paul E. McKenney
2016-08-24 18:03 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160823142326.GF3482@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhart@linux.intel.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox