From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 495FBCEACEA for ; Tue, 1 Oct 2024 17:12:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D22A5680027; Tue, 1 Oct 2024 13:12:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD2A7680023; Tue, 1 Oct 2024 13:12:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4B1F680027; Tue, 1 Oct 2024 13:12:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 964C7680023 for ; Tue, 1 Oct 2024 13:12:03 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2606E16145A for ; Tue, 1 Oct 2024 17:12:03 +0000 (UTC) X-FDA: 82625676126.15.15755E4 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by imf18.hostedemail.com (Postfix) with ESMTP id 427171C0016 for ; Tue, 1 Oct 2024 17:11:59 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727802552; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BcrzFROg7/P70Bo7spvVAbSaVBCRrT7prwitrJc0+rY=; b=LlsCQB+6dDcNg63mUxPIe5nbe74n3y1+uMTSkNzxTUPoAOscI2I17+Xgv1EXiZZ2PszWCb oDQl5UV8H0hM8C+hxxI6HqQ8B32Vt8FQXMM2AOAeoH9ig+EUPG1JPWyPIRFEkCYLIKzmdx TYcfqei804wPbgptry+fLfzYOiF+ExM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727802552; a=rsa-sha256; cv=none; b=2wfYKnlkuckYhjDxzFyE6u0yY0PTr2Ds3FlaHV6b2VTIVQebfVhewii5vh9IU+Ny4LnW/i p148NnKHwziUOnJStxAN3TaA9fSU+zaKvX9datgJQrCrP/OQ5dNgjrLGkFsyLXM6+FztkD ajA5G7JN/236FesqWZ86ApEZIuiKVdg= Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-168-XvUvi8mePi2CL2iOlFSWgg-1; Tue, 01 Oct 2024 18:11:55 +0100 X-MC-Unique: XvUvi8mePi2CL2iOlFSWgg-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 1 Oct 2024 18:11:05 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 1 Oct 2024 18:11:05 +0100 From: David Laight To: 'Alan Stern' , Jonas Oberhauser CC: Mathieu Desnoyers , Linus Torvalds , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Sebastian Andrzej Siewior , "Paul E. McKenney" , Will Deacon , Peter Zijlstra , Boqun Feng , John Stultz , Neeraj Upadhyay , Frederic Weisbecker , "Joel Fernandes" , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Lai Jiangshan , Zqiang , Ingo Molnar , Waiman Long , "Mark Rutland" , Thomas Gleixner , Vlastimil Babka , "maged.michael@gmail.com" , Mateusz Guzik , Gary Guo , "rcu@vger.kernel.org" , "linux-mm@kvack.org" , "lkmm@lists.linux.dev" Subject: RE: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency Thread-Topic: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency Thread-Index: AQHbE2njI9qt6nx11kSrjhsE5O+AlrJyIkGg Date: Tue, 1 Oct 2024 17:11:05 +0000 Message-ID: References: <20240928135128.991110-1-mathieu.desnoyers@efficios.com> <20240928135128.991110-2-mathieu.desnoyers@efficios.com> <02c63e79-ec8c-4d6a-9fcf-75f0e67ea242@rowland.harvard.edu> <9539c551-5c91-42db-8ac1-cff1d6d7c293@huaweicloud.com> <2cdda043-1ad9-40cf-a157-0c16a0ffb046@rowland.harvard.edu> <5d7d8a59-57f5-4125-95bb-fda9c193b9cf@huaweicloud.com> <82e97ad5-17ad-418d-8791-22297acc7af4@rowland.harvard.edu> In-Reply-To: <82e97ad5-17ad-418d-8791-22297acc7af4@rowland.harvard.edu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 427171C0016 X-Stat-Signature: thktrsq1sxsyij1xmjhd6ur99e76okzr X-Rspam-User: X-HE-Tag: 1727802719-893154 X-HE-Meta: U2FsdGVkX19BDUU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BgnN10rrjyr36qmr6S2VB0SVktD+Bj/XHbeisYc9xaxCxD7eEGCIeGiTmAtlcw7sNkNYz2gc3aQ2xRUdK5gRvgqfQpjupIOQKLVXUS5UCyTqwQGdH5uyVXgjCyQ9OQMna4qRFRn6KSZlO2sYLo3nDwA/96xp+whiXhoAnGvU01/Jb6ZDqxML8NQLIIsiPauTUKfVNVdZwVftbjB8RxyklPKGQ3qGUUAKI0J2CddFQgKEWe/qX4Cz7halvLI2YZn3ONB0hH8acVa3CQOEuDIVDMDZNqht+mnn9eqA6WFBdDexdKE3x1sOBh/3Gmfw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alan Stern > Sent: 30 September 2024 19:53 >=20 > On Mon, Sep 30, 2024 at 07:05:06PM +0200, Jonas Oberhauser wrote: > > > > > > Am 9/30/2024 um 6:43 PM schrieb Alan Stern: > > > On Mon, Sep 30, 2024 at 01:26:53PM +0200, Jonas Oberhauser wrote: > > > > > > > > > > > > Am 9/28/2024 um 4:49 PM schrieb Alan Stern: > > > > > > > > I should also point out that it is not enough to prevent the compil= er from > > > > using @a instead of @b. > > > > > > > > It must also be prevented from assigning @b=3D@a, which it is often= allowed to > > > > do after finding @a=3D=3D@b. > > > > > > Wouldn't that be a bug? > > > > That's why I said that it is often allowed to do it. In your case it > > wouldn't, but it is often possible when a and b are non-atomic & > > non-volatile (and haven't escaped, and I believe sometimes even then). > > > > It happens for example here with GCC 14.1.0 -O3: > > > > int fct_hide(void) > > { > > int *a, *b; > > > > do { > > a =3D READ_ONCE(p); > > asm volatile ("" : : : "memory"); > > b =3D READ_ONCE(p); > > } while (a !=3D b); > > OPTIMIZER_HIDE_VAR(b); > > return *b; > > } > > > > > > > > ldr r1, [r2] > > ldr r3, [r2] > > cmp r1, r3 > > bne .L6 > > mov r3, r1 // nay... >=20 > A totally unnecessary instruction, which accomplishes nothing other than > to waste time, space, and energy. But nonetheless, allowed -- I agree. >=20 > The people in charge of GCC's optimizer might like to hear about this, > if they're not already aware of it... >=20 > > ldr r0, [r3] // yay! > > bx lr >=20 > One could argue that in this example the compiler _has_ used *a instead > of *b. However, such an argument would have more force if we had > described what we are talking about more precisely. The 'mov r3, r1' has nothing to do with 'a'. It is a more general problem that OPTIMISER_HIDE_VAR() pretty much always ends up allocating a different internal 'register' for the output and then allocating a separate physical rehgister. There doesn't seem to be a later optimisation path to remove 'pointless' register moves. =09David >=20 > Yes, we do want to prevent compilers from doing this. I'm not sure that > it really needs to be mentioned in the comments or commit description, > though. >=20 > Alan - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)