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 6968FCFB424 for ; Sun, 6 Oct 2024 20:39:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2CF26B014C; Sun, 6 Oct 2024 16:39:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8E3A6B014D; Sun, 6 Oct 2024 16:39:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2F306B0170; Sun, 6 Oct 2024 16:39:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 91D2A6B014C for ; Sun, 6 Oct 2024 16:39:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3A2D71C69D7 for ; Sun, 6 Oct 2024 20:39:36 +0000 (UTC) X-FDA: 82644343152.29.493485C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 61F7A140007 for ; Sun, 6 Oct 2024 20:39:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lSmFUlv0; spf=pass (imf23.hostedemail.com: domain of "SRS0=68x4=RC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=68x4=RC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org"; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728247041; h=from:from:sender:reply-to: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1R8gSzolUMHwtOKkmCdMTwxw/UKAs4O9DXdOnH8u25o=; b=XUiEJe+f5vpZdeUwLQIxoO+S+gGjlStT9EU5e+mNv8HNJ4/OJbrEhncPBh1PxNGTptmQQG fK6V4OOHtCS5NlCeWmNL/gi3lTmSmp/85zmJuVhsVFdVHjuU+aXBDuma+FPCOJIo95yzIh Vhkbyc59DLW5V/znzb5dIKPvdEuqvJg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728247041; a=rsa-sha256; cv=none; b=OW6C4a8ZWn7bZHqX0YqjEDiR1DKUAkBXYs/15S7NmCYBim9a7nalFL5VCGoMdKO9D7JghY S2+bswz46ovaHYJKjRfvz6pSsU30S5Ov/xGPKylMankFWi8hOjLBNATZFxJdaGGfK/8Rae BGAKFGntOPLW6H07T5H3EW7TBYrBjKg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lSmFUlv0; spf=pass (imf23.hostedemail.com: domain of "SRS0=68x4=RC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=68x4=RC=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org"; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0FB425C560E; Sun, 6 Oct 2024 20:39:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E09FDC4CECC; Sun, 6 Oct 2024 20:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728247173; bh=uvcPrAbHbiaDImYhVusfABjiDJeHc/gUavwIa8OLfBo=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=lSmFUlv0C4p33ry2q52EFi9b2nAhonpNcPanfJ65jyMalZJ/CQeTWSFr3zOSeIcgp lubrQtb45RzbKV74YTbIrp+xd2qxURNkZE3xgK+vUIVN22qDvuWfaKvcWXJtE0wRN0 JAUv2wRT/e2i/mGld176Gvxk9voUxNRE6kAVACOv2QigsRGLNbRuXhrb0O18hpeF37 Q1Z5lzGNgPghyGOPAmOCdkULCurrnCRA9LnGg3OQgLjps/xpn8eyKrFMAYZ9w6xfqC 9KRZsRxTvlDPJm39wV39UnNI0famAItlSOXuxYzyq6KZniQEhCdn9Q4panjqmnpl7r 8tzLbyROJoLWw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7B3E1CE09EE; Sun, 6 Oct 2024 13:39:32 -0700 (PDT) Date: Sun, 6 Oct 2024 13:39:32 -0700 From: "Paul E. McKenney" To: David Laight Cc: 'Mathieu Desnoyers' , Boqun Feng , "linux-kernel@vger.kernel.org" , Linus Torvalds , Andrew Morton , Peter Zijlstra , Nicholas Piggin , Michael Ellerman , Greg Kroah-Hartman , Sebastian Andrzej Siewior , Will Deacon , Alan Stern , 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 , Jonas Oberhauser , "rcu@vger.kernel.org" , "linux-mm@kvack.org" , "lkmm@lists.linux.dev" , Gary Guo , Nikita Popov , "llvm@lists.linux.dev" Subject: Re: [RFC PATCH v2 2/4] Documentation: RCU: Refer to ptr_eq() Message-ID: Reply-To: paulmck@kernel.org References: <20241004182734.1761555-1-mathieu.desnoyers@efficios.com> <20241004182734.1761555-3-mathieu.desnoyers@efficios.com> <72af935f4a2a4e23b68845d2f6855103@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72af935f4a2a4e23b68845d2f6855103@AcuMS.aculab.com> X-Stat-Signature: c86r8buq5kf9ac689a6xom9y8bqwpn4n X-Rspamd-Queue-Id: 61F7A140007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728247174-177901 X-HE-Meta: U2FsdGVkX19dRzqwnbvBq4VVg1s6yK58avonblWCV35zfyMpPf7h19qMT5t7XESmzfouHd5o2t4tsDUnIsnAzCY89d6N7aoR0GhlWvJFQmHXXbHQxeRL1mS1CBAWJuejP5JarZeMLJ86FcSRpA1YCrhtZPjA3QURI5xrlPq0nP0ZFCYFzFHkFpPz6cjuWd+UYJt2Lf+8R+M7Vh/VLVZz0qbEKzfy0iK0m6BHdtrgV5G76wjlcRXk2vlG4e0f6MPIVq3TggTcXVC4r/+kZnOCG8gIjlHRXm58Mjrs+bVqN/2msTYWx6vFS5XbxOe91anSAo4AfuR8Abb9lSXKcaaOOZVOriq7ss99CYBk/pNzT150NpROg74J+co+7kyVucl0TolorFu4gA6JVREM5x6QVoyl1fkhsvmV/O/mzIbdcrTxQxdppFkZI5aLGTWUfkO4VeDWO6UUdg9ZiFXr+Lj0VTqFit4YZ/i0mvYn8oQ+8hxmWy9X5aWksQfcxZ3opHEz5Dorfy9x7lgQuTpSSgzdIjPxWPDIBqZzEbzadSJ2yK2bvUO1vVvU1fBwMobzC9HanhkYcfo0Fu/qE7kJfoVZycgf3LIGL1GD+me5okSVu5ZAdhfQWHh/iQ8fO6y+kt33CBQd60bEcd3jl+ixethIraFY5WpUufMnuK2wFTN2BWsjGs8GZuEoBqmtge31gcKwTVsaWfT3fkSISv3TMeUBRdyemvpFCl1/JMKx9opG5bqO/lHu0EuTsYkWsO8Zt69nBVWJkKSR6x8SID2Ha+IkNsdPmEmVpqMTJd433CES8+yTJ3Kowldz+VniP3QBuNuplfRTQiXyydBSJF5V5PQqObwcEVqvfqbWBn2vq6uyj8DDIqra7k2Qn6mX+Hu7KThyZCKXgLtNTp7VCoZe94+1HE30oqDRlOrlySI60fMJp8PIObkd3Y+kjo+SCUbpQE8xoCl8/X2ygE/SXUhwGwZ G6rhy+cG Y5kLknRgNBn3zxMx4WJxjx4+Zz09Epf4j3wOZm1GbRf4fOYq4KWkt9hFX/CZAqaSotSjyQubN4HEGSZTWX4U3q5uBS7EEuayZkFjERzdtHYlFiDvpkSzsCNIEbOFaErxJMIo5DxhWQBQ/MZLdw1nH0Qk5dAU9akF78iV4Vjl5+gxPjG9p4YjkGgmGGe7Uoo2yrhsvs6/2y0Q8LVVihHhmUA/3rlIBS+XsnCTA6DB34MsQKy+z5KXpE4IG+uFom3GYao7+ZZEAbOJAQu2t/PqvYMnq334rH/mjuODdQj4nKEQQpv6dSuaocFr1jagF1qFYm1UQWnbqeVFFcdmMlzF4ZgWuN423bVvCErhXWNQOy0d5vf0/jZn0JWCmZtdu7xycxLIqDU9inDDIFGcjE3C0HQP0tvtsDf5ArEWQhLZVwvu93LFisb9nSThpCfm2vJNDo7icfZwHN5ppeXN8uQ0DqY3lIcwhLU4d+92LU6SDoBxBhol1zUW/w/K1IS9ZSYN2QXwXrSGVPBMd5jlbPPoCamrmVUHb3FnMvIAD9Yf7kDzVbngoPiWTYnxvXzTuwNtt/GagabAGipgazy8ymZ//7BPkmB+3z1LvMGP16Fvj9HWVmghmD9XTYHWk1m2ALbaxkz2jKglUwDD3nLPMMq7E+87UoSDRjz8N+78ttVxZWy3+97/NG37tMtsImZvNbnKg1POoBSW29Vop1JWI9xW/1Te7WOZCFI+nN+ROKRuECGO8D0zqDezq5PdSNuGsBdamshbY 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: On Sun, Oct 06, 2024 at 07:52:49PM +0000, David Laight wrote: > From: Mathieu Desnoyers > > Sent: 04 October 2024 19:28 > > > > Refer to ptr_eq() in the rcu_dereference() documentation. > > > > ptr_eq() is a mechanism that preserves address dependencies when > > comparing pointers, and should be favored when comparing a pointer > > obtained from rcu_dereference() against another pointer. > > Why does this ever really matter for rcu? > > The check just ensure that any speculative load uses > a specific one of the pointers when they are different. > This can only matter if you care about the side effects > of the speculative load. It can matter when there are static variables used during OOM. The code must check the pointer against the addresses of the static variables to work out how to free them, which can enable the compiler to do specialization optimizations that destroy the address dependencies. Which is OK if those static variables are compile-time initialized or some such. But not if they get new values each time they go into the list, as this can result in the reader seeing pre-initialization garbage. An admittedly rare but very real use case. Thanx, Paul > But rcu is all about (things like) lockless list following. > So you need to wait until it is impossible for another > execution context to have a reference to some memory > before actually completely invalidating it (ie kfree()). > > And that 50 line comment is pointless. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) >