From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755738AbcHVRex (ORCPT ); Mon, 22 Aug 2016 13:34:53 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40954 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755479AbcHVRew (ORCPT ); Mon, 22 Aug 2016 13:34:52 -0400 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com Date: Mon, 22 Aug 2016 10:34:53 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com Subject: Re: [PATCH tip/core/rcu 2/2] documentation: Record reason for rcu_head two-byte alignment Reply-To: paulmck@linux.vnet.ibm.com References: <20160822151413.GA6337@linux.vnet.ibm.com> <1471878883-6660-2-git-send-email-paulmck@linux.vnet.ibm.com> <20160822162553.GJ10153@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160822162553.GJ10153@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082217-0004-0000-0000-000010312F18 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005629; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000183; SDB=6.00748160; UDB=6.00353060; IPR=6.00520825; BA=6.00004672; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012421; XFM=3.00000011; UTC=2016-08-22 17:34:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082217-0005-0000-0000-000078322AB6 Message-Id: <20160822173453.GF3482@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-08-22_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608220180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 22, 2016 at 06:25:53PM +0200, Peter Zijlstra wrote: > On Mon, Aug 22, 2016 at 08:14:43AM -0700, Paul E. McKenney wrote: > > The __call_rcu() assertion that checks only the bottom bit of the > > rcu_head pointer is a bit counter-intuitive in these days of ubiquitous > > 64-bit systems. This commit therefore records the reason for this > > odd alignment check, namely that m68k guarantees only two-byte alignment > > despite being a 32-bit architectures. > > Would not something like: > > #ifdef CONFIG_M68K > /* > * m68k is weird and doesn't have naturally aligned types. > */ > WARN_ON_ONCE((unsigned long)head & 1); > #else > WARN_ON_ONCE((unsigned long)head & (sizeof(unsigned long) - 1)); > #endif > > Be better? That does have much to say for itself, though I would prefer sizeof(void *) to sizeof(unsigned long). But would it make sense to define a mask on a per-architecture basis, with the default being (sizeof(void *) - 1)? Then maybe an IMPROPERLY_ALIGNED_POINTER(): #ifndef CONFIG_ARCH_POINTER_ALIGNMENT #define CONFIG_ARCH_POINTER_ALIGNMENT (sizeof(void *) - 1) #endif #define IMPROPERLY_ALIGNED_POINTER(p) \ ((p) & CONFIG_ARCH_POINTER_ALIGNMENT) m68k would define ARCH_POINTER_ALIGNMENT to 1, and all other arches would leave it undefined. Then __call_rcu() could to this: WARN_ON_ONCE(IMPROPERLY_ALIGNED_POINTER(head)); Seem reasonable? Thanx, Paul