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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F0DDECD6DA for ; Wed, 11 Feb 2026 18:24:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64F9B6B0005; Wed, 11 Feb 2026 13:24:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FDB56B0089; Wed, 11 Feb 2026 13:24:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FFC76B008A; Wed, 11 Feb 2026 13:24:38 -0500 (EST) 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 3DABB6B0005 for ; Wed, 11 Feb 2026 13:24:38 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 092F1D6BB4 for ; Wed, 11 Feb 2026 18:24:38 +0000 (UTC) X-FDA: 84433001436.17.4244C95 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf28.hostedemail.com (Postfix) with ESMTP id 0944BC000C for ; Wed, 11 Feb 2026 18:24:35 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YSwi50FD; spf=pass (imf28.hostedemail.com: domain of boqun@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=boqun@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=1770834276; 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:dkim-signature; bh=8MvqNmSQwpT4/+ikv8C4uKJXx/Cpay4DtAwscanL//M=; b=DWgrpm2OWcT8OcZz92KH0pFBiZEM0L4wl9z4yoM8yy5j1RNqryPqWYqRl8WeUat2xkfqZW hpKHG9xEvhGXSRqeJgPpfUUVyCLMUCIIWHUi0+wFIsWBGhMeB3H7UfQ+tER7uZ3UmWjzAn eAnTKv+ELUWjlbuUSarc3GyulFgMv50= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YSwi50FD; spf=pass (imf28.hostedemail.com: domain of boqun@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=boqun@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1770834276; a=rsa-sha256; cv=none; b=QfkRHySQL7yPsK4ERzVm6bvuli3VqY3ADX52/tj3ZS7quGY4pYV2HYPnOfJ7R5PkIvpzgb wJg3PKOUiFuHCF6FyO3zqe8ktGiGQaUzNsw34HppsV17QGm9kWdhYE1IIwS3ZlynfPS84K e3WXaR83fWJFF8pytfKAHcVFe9Xxcyo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 5FB2360122; Wed, 11 Feb 2026 18:24:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28370C4AF0B; Wed, 11 Feb 2026 18:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770834275; bh=HpiSg+mkwqHgx2x64frOPx+L7lBkmxTpS7thY1MR8H8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YSwi50FDOsk1M8piqFrSGHTqEtzTxSyhZiXCPiXDV2um4XknRBy9JTiuLBRG+UaBR PaoxsAxaF81vnYM6yDQspUdBCwORgF9i7ifnYPM1PHNyPiC+GBgPeXFkFgMHfUQIgH zt9F7PzzjlutkStzFYa5U+En1y5JyWALfn15c18mWq9NiYYyyRSAl1geZc9saD1UwA gCtdofuUrjwyZ2m8+huGmuGbw/4zIvnTVy9OFE1TLbkhOy3aaAmjDyloG54c5wC+jT mtKB5TC5OLBf50JrCdrzQQvKM+UJVhFO/1Pi+jOSogEZt6r7U9uHOBbO+8pArzRPn2 6BuhTa3Ew8jpg== Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 46457F40068; Wed, 11 Feb 2026 13:24:33 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 11 Feb 2026 13:24:33 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtdefvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkeertddttdejnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnsehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnh epteelkeejledtledtvefhhedtfeeghfeuhfeljeevffelgeeltefhieefvdeuteehnecu ffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshho nhgrlhhithihqdduieejtdelkeegjeduqddujeejkeehheehvddqsghoqhhunheppehkvg hrnhgvlhdrohhrghesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthhopedvgedpmhho uggvpehsmhhtphhouhhtpdhrtghpthhtohepthgrmhhirhgusehgmhgrihhlrdgtohhmpd hrtghpthhtoheplhhirghmrdhhohiflhgvthhtsehorhgrtghlvgdrtghomhdprhgtphht thhopegrlhhitggvrhihhhhlsehgohhoghhlvgdrtghomhdprhgtphhtthhopegrrdhhih hnuggsohhrgheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepohhjvggurgeskhgvrhhn vghlrdhorhhgpdhrtghpthhtoheprghlvgigrdhgrgihnhhorhesghhmrghilhdrtghomh dprhgtphhtthhopegsohhquhhnrdhfvghnghesghhmrghilhdrtghomhdprhgtphhtthho pehgrghrhiesghgrrhihghhuohdrnhgvthdprhgtphhtthhopegsjhhorhhnfegpghhhse hprhhothhonhhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i8dbe485b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Feb 2026 13:24:32 -0500 (EST) Date: Wed, 11 Feb 2026 10:24:31 -0800 From: Boqun Feng To: Tamir Duberstein Cc: "Liam R. Howlett" , Alice Ryhl , Andreas Hindborg , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Trevor Gross , Danilo Krummrich , Lorenzo Stoakes , Vlastimil Babka , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Daniel Gomez , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 05/12] rust: xarray: use `xas_load` instead of `xa_load` in `Guard::load` Message-ID: References: <20260209-xarray-entry-send-v3-0-f777c65b8ae2@kernel.org> <20260209-xarray-entry-send-v3-5-f777c65b8ae2@kernel.org> <6sd4numrxigibwynr2lfmtdj5uabggrx2l57igtjbnq4uwddrm@wipmwcmqbkjn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam12 X-Stat-Signature: 4ua99r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E9uRGBmTV/2EcoU5IrQSN2X+mFzkwBnM5A2Xahq7R8YOAK3G3sfDGDkB1k+T/YrQNWKCa7htCnRUqaKDaHKHKeyOg73ApUWheEdasdvkek7HWkxV3oHEhVQ3mVKm9iiotFnMjWbULqVlVMigSYR604zMk/H/roY+sDY4rO92+5A0Sq7l+lOS1C3YwkEXnak/ThGd+mRLkNJQM83ZMK5QpWavLdNQZTrK9gHmDpy3P5JII8ugdKXJc5hMPIEczdz3tvXiPj9zdDMjDxHLUhbU1/v3ze6fYOV2JzDtZRfirxgtkg/M1q8oZKduJxTXWLIO5owMBjRBxH2OZDf0sSvGR4Gcn5OVO5/3H/3XgaPqI3xOlrABnjaqPdtBroTmv8PpzU1m0qm5bWIAVrvKcKd3lTMAR65waj+IZ/FfYCr7jf9dAV3nm9Q6jqhm5aUAIbjQl8lETET2SDqs= 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 Wed, Feb 11, 2026 at 01:19:23PM -0500, Tamir Duberstein wrote: > On Wed, Feb 11, 2026 at 10:00 AM Boqun Feng wrote: > > > > On Wed, Feb 11, 2026 at 09:32:36AM -0500, Liam R. Howlett wrote: > > > * Alice Ryhl [260210 16:34]: > > > > On Tue, Feb 10, 2026 at 10:23 PM Tamir Duberstein wrote: > > > > > > > > > > On Tue, Feb 10, 2026 at 12:59 PM Liam R. Howlett > > > > > wrote: > > > > > > Is this a temporary limitation? > > > > > > > > > > Maybe? I don't think RfL has good abstractions for RCU yet. For > > > > > example, exposing load directly on the xarray using xa_load would > > > > > require a way to guarantee that the returned pointer's target isn't > > > > Well, if we only return a pointer, we don't need to guarantee that, > > right? Because it's up to the user to provide that guarantee. So we > > could have XArray::load() (not Guard::load()) that just calls xa_load(). > > Also see below. > > > > > > > being concurrently mutated (e.g. under the xarray lock). I'm not aware > > > > > of anyone asking for this, though. > > > > > > > > It's relatively easy to add an rcu-backed load using the RCU > > > > abstractions we have today. I already shared an RFC containing such a > > > > method for the maple tree, and it would not be much different for > > > > xarray. > > > > https://lore.kernel.org/all/20260116-rcu-box-v1-0-38ebfbcd53f0@google.com/ > > > > I need to point out a difference between xas_load() and Alice's usage > > (also what Tamir mentioned above) there, what Alice needs (at least from > > her patchset) is the existence of the object is protected by RCU, i.e. > > if there is someone else dropping the object, a RCU read lock would > > still guarantee the access to the object is valid. > > > > However, the internal RCU usage of both xarray and maple tree is to > > protect the *internal* data structure if I'm not missing anything, i.e. > > an writer may change the array or the tree while a reader is reading, > > the internal structure itself is still consistent and valid. But the > > nothing guarantees the object you read is still valid. For example, you > > can have an xa_erase() racing with an xa_load(): > > > > > > ptr = xa_erase(xa, idx); > > ptr = xa_load(xa, idx); > > reclaim(ptr); > > use(ptr); // <- object may be gone > > > > the users of xarray needs to use other mechanism to guarantee the > > existence of the object. > > > > In Alice's case, she in fact used an RCU read side critical section with > > a larger scope to protect the object as well, which is definitely nice > > to have, but not only way of using maple/xarray. > > > > > > > > > > > > It would probably be worth having two loads then, one that does > > > rcu_read_lock()/unlock() and one for writer/advanced users like we have > > > on the C side of things. > > > > > > > Agreed. But we may need more ;-) > > > > Here IIUC that Andreas does is adding a `load()` for `Guard` of > > `XArray`, which is the load for a writer and most certainly you won't > > need to take an RCU read lock for that. The load of a reader can be > > added as I suggested above (similar as your "rcu_read_lock()/unlock()" > > suggestion above), but no object existence guarantee. We likely > > need a third API that can provide the object existence similar to what > > Alice had in maple tree. > > > > > Or at least name the load() function to indicate which is implemented > > > today? > > > > > > > It's a namespace thing ;-) , the function in this patch is > > kernel::xarray::Guard::load(), and as I suggest here > > kernel::xarray::XArray::load() should be the same as xa_load(). > > Just to clarify: `kernel::xarray::XArray::load()` does not currently > exist and no one has yet asked for it. > Yeah ;-) I meant to say we can add it if there is a user and we can use xa_load() to implement that. Regards, Boqun > > > > Regards, > > Boqun > > > > > At least on the maple tree side, we have both interfaces and users for > > > both. I just found the change to remove the rcu safety odd because I > > > assumed both are needed. > > > > > > Thanks, > > > Liam > >