Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error
From: Mark Rutland
Date: Wed Dec 14 2016 - 05:56:08 EST
On Wed, Dec 14, 2016 at 09:40:02AM +0800, Boqun Feng wrote:
> On Wed, Dec 14, 2016 at 08:47:55AM +0800, Boqun Feng wrote:
> > On Tue, Dec 13, 2016 at 10:36:47AM -0800, Paul E. McKenney wrote:
> > > On Wed, Dec 14, 2016 at 02:09:27AM +0800, Boqun Feng wrote:
> > > > #define for_each_leaf_node_cpu(rnp, mask, cpu) \
> > > > for((cpu) = (rnp)->grplo + find _first_bit(mask, MASK_BITS(mask)); \
> > > > (cpu) >= (rnp)->grplo && (cpu) <= (rnp)->grphi; \
> > > > (cpu) = (rnp)->grplo + find _next_bit(mask, ...,
> > > > leaf_node_cpu_bit(rnp, cpu) + 1))) \
> > > > if (!cpu_possible(cpu)) \
> > > > continue; \
> > > > else
> > >
> > > What is the purpose of the cpu_possible() check?
> > >
> > To filter out CPUs in range [grplo, grphi] but not in cpu_possible_mask.
> Hmm.. if rcu_cpu_starting(cpu) is never called with "impossible" cpu,
> IOW, ->qsmask and ->expmask never mask "impossible" cpus, then this is
> just an over-care check.
> I think I probably will remove this check eventually, let me audit the
> code a little more for safety ;-)
FWIW, back when I wrote bc75e99983df1efd ("rcu: Correctly handle sparse
possible cpus"), the only places I saw accesses to (percpu) data for
!possible cpus were the places I fixed up. IIRC I tested with a version
of the patch below.
That won't catch erroneous non-percpu accesses, but it covers part of
the problem, at least. ;)