Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1403214

Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs

From Mark Rutland <mark.rutland@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs
Date 2016-05-18 20:40 +0200
Message-ID <rAexY-5ID-13@gated-at.bofh.it> (permalink)
References <rztSq-10v-15@gated-at.bofh.it> <rAbqp-3On-1@gated-at.bofh.it> <rAe4W-5wO-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] rcu: tree: correctly handle sparse possible CPUs Mark Rutland <mark.rutland@arm.com> - 2016-05-16 18:50 +0200
  Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-16 21:30 +0200
    [PATCHv2] rcu: tree: correctly handle sparse possible CPUs Mark Rutland <mark.rutland@arm.com> - 2016-05-17 12:30 +0200
      Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-17 21:10 +0200
        Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs Mark Rutland <mark.rutland@arm.com> - 2016-05-18 08:10 +0200
        Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs Arnd Bergmann <arnd@arndb.de> - 2016-05-18 14:10 +0200
          Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs Mark Rutland <mark.rutland@arm.com> - 2016-05-18 20:20 +0200
            Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-18 20:50 +0200
  Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs Andrey Ryabinin <ryabinin.a.a@gmail.com> - 2016-05-18 17:20 +0200
    Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-18 20:10 +0200
      Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs Mark Rutland <mark.rutland@arm.com> - 2016-05-18 20:40 +0200
        Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-05-18 20:50 +0200

csiph-web