From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbcERSB5 (ORCPT ); Wed, 18 May 2016 14:01:57 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:52396 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751967AbcERSBz (ORCPT ); Wed, 18 May 2016 14:01:55 -0400 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Wed, 18 May 2016 11:01:53 -0700 From: "Paul E. McKenney" To: Andrey Ryabinin Cc: Mark Rutland , Catalin Marinas , dennis.chen@arm.com, jiangshanlai@gmail.com, josh@joshtriplett.org, LKML , mathieu.desnoyers@efficios.com, Steven Rostedt , steve.capper@arm.com, Will Deacon Subject: Re: [PATCH] rcu: tree: correctly handle sparse possible CPUs Message-ID: <20160518180153.GA3528@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <1463417306-3826-1-git-send-email-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16051818-0017-0000-0000-00002F433E90 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 18, 2016 at 06:15:23PM +0300, Andrey Ryabinin wrote: > 2016-05-16 19:48 GMT+03:00 Mark Rutland : > > > /* > > + * 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? Thanx, Paul