From: Mark Rutland <mark.rutland@arm.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
dennis.chen@arm.com, jiangshanlai@gmail.com,
josh@joshtriplett.org, LKML <linux-kernel@vger.kernel.org>,
mathieu.desnoyers@efficios.com,
Steven Rostedt <rostedt@goodmis.org>,
steve.capper@arm.com, Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs
Date: Wed, 18 May 2016 19:30:41 +0100 [thread overview]
Message-ID: <20160518183041.GB8664@svinekod> (raw)
In-Reply-To: <20160518180153.GA3528@linux.vnet.ibm.com>
On Wed, May 18, 2016 at 11:01:53AM -0700, Paul E. McKenney wrote:
> On Wed, May 18, 2016 at 06:15:23PM +0300, Andrey Ryabinin wrote:
> > 2016-05-16 19:48 GMT+03:00 Mark Rutland <mark.rutland@arm.com>:
> >
> > > /*
> > > + * Iterate over all possible CPUs in a leaf RCU node.
> > > + */
> > > +#define for_each_leaf_node_possible_cpu(rnp, cpu) \
> > > + for ((cpu) = rnp->grplo; \
> > > + cpu <= rnp->grphi; \
> > > + cpu = cpumask_next((cpu), cpu_possible_mask))
> > > +
> > > +/*
> > > + * Iterate over all possible CPUs in a leaf RCU node, at each step providing a
> > > + * bit for comparison against rcu_node bitmasks.
> > > + */
> > > +#define for_each_leaf_node_possible_cpu_bit(rnp, cpu, bit) \
> > > + for ((cpu) = rnp->grplo, (bit) = 1; \
> > > + cpu <= rnp->grphi; \
> > > + cpu = cpumask_next((cpu), cpu_possible_mask), \
> > > + (bit) = 1UL << (cpu - rnp->grplo))
> > > +
> >
> > [ 0.163652] UBSAN: Undefined behaviour in ../kernel/rcu/tree.c:2912:3
> > [ 0.164000] shift exponent 64 is too large for 64-bit type 'long
> > unsigned int'
>
> Ah, dead value, but can happen nevertheless. One fix is to prevent the
> assignment to bit when cpu > rnp->grphi.
>
> Any ideas for a better fix? And isn't there some combination of
> signedness that makes shifting all the bits out of the value defined
> to zero? Or is that only for right shifts?
We could add a (leaf/rcu)_node_cpu_mask(rnp, cpu) macro, and only use that in
the body of the loop. That would avoid the stale value and would be useful in a
couple of additional places.
If that makes sense to you, I can respin the patch with that.
Thanks,
Mark.
next prev parent reply other threads:[~2016-05-18 18:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 16:48 [PATCH] rcu: tree: correctly handle sparse possible CPUs Mark Rutland
2016-05-16 19:19 ` Paul E. McKenney
2016-05-17 10:22 ` [PATCHv2] " Mark Rutland
2016-05-17 19:01 ` Paul E. McKenney
2016-05-13 1:27 ` Mark Rutland
2016-05-18 0:12 ` Paul E. McKenney
2016-05-18 12:02 ` Arnd Bergmann
2016-05-18 18:15 ` Mark Rutland
2016-05-18 18:41 ` Paul E. McKenney
2016-05-20 10:30 ` kbuild test robot
2016-05-18 15:15 ` [PATCH] " Andrey Ryabinin
2016-05-18 18:01 ` Paul E. McKenney
2016-05-18 18:30 ` Mark Rutland [this message]
2016-05-18 18:44 ` Paul E. McKenney
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=20160518183041.GB8664@svinekod \
--to=mark.rutland@arm.com \
--cc=catalin.marinas@arm.com \
--cc=dennis.chen@arm.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=ryabinin.a.a@gmail.com \
--cc=steve.capper@arm.com \
--cc=will.deacon@arm.com \
/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;
as well as URLs for NNTP newsgroup(s).