From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbcERGE7 (ORCPT ); Wed, 18 May 2016 02:04:59 -0400 Received: from foss.arm.com ([217.140.101.70]:54941 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750759AbcERGE6 (ORCPT ); Wed, 18 May 2016 02:04:58 -0400 Date: Fri, 13 May 2016 02:27:01 +0100 From: Mark Rutland To: "Paul E. McKenney" Cc: catalin.marinas@arm.com, dennis.chen@arm.com, jiangshanlai@gmail.com, josh@joshtriplett.org, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, rostedt@goodmis.org, steve.capper@arm.com, will.deacon@arm.com Subject: Re: [PATCHv2] rcu: tree: correctly handle sparse possible CPUs Message-ID: <20160513012701.GA7629@svinekod> References: <20160516191947.GH3528@linux.vnet.ibm.com> <1463480530-5674-1-git-send-email-mark.rutland@arm.com> <20160517190106.GJ3528@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160517190106.GJ3528@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.