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


Groups > linux.kernel > #1402731

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

From Mark Rutland <mark.rutland@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs
Date 2016-05-18 08:10 +0200
Message-ID <rA2Q9-6EU-1@gated-at.bofh.it> (permalink)
References <rzwng-2Fv-9@gated-at.bofh.it> <rzKqf-3kb-37@gated-at.bofh.it> <rzSxs-7q-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, May 17, 2016 at 12:01:06PM -0700, Paul E. McKenney wrote:
> On Tue, May 17, 2016 at 11:22:10AM +0100, Mark Rutland wrote:
> >  /*
> > + * 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))
> 
> What if the rnp->grplo corresponds to a non-existent CPU?

Good point, I had evidently not considered that.

> Would something like this handle that possibility?
> 
> +#define for_each_leaf_node_possible_cpu(rnp, cpu) \
> +	for ((cpu) = cpumask_next(rnp->grplo - 1, cpu_possible_mask); \
> +	     cpu <= rnp->grphi; \
> +	     cpu = cpumask_next((cpu), cpu_possible_mask))
> 
> Or maybe like this, with less duplicated code but very strange style:
> 
> +#define for_each_leaf_node_possible_cpu(rnp, cpu) \
> +	for ((cpu) = rnp->grplo - 1; \
> +	     cpu = cpumask_next((cpu), cpu_possible_mask), cpu <= rnp->grphi; 1)
> 
> The first one is probably far better, assuming that it works, but I could
> not resist inflicting the second one on you.  ;-)

:)

Those both look like they should work, I'll fold the former in.

> > +/*
> > + * 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))
> 
> Same question here.

Likewise.

I'll also see about fixing the build issue you spotted in the other reply; that
appears to be a typo (missing 'possible_' in the macro invocation).

I'm away from my development machine at the moment, so that may not appear
until next week.

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