From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96BCE2D8384 for ; Sat, 17 Jan 2026 13:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768655533; cv=none; b=g8Y6vUsWDx3drWYvw+7XTMGipjUeq0L8n2mf3vySmxv285qPCe9X2tDgHzzmzVBqaXrYEBtXy2nQypiQ+xHFuNWe/HVHeP4pvz7D+vrfhiwsDc6XlU/SfCFIyMvYYTg5ZL4y5Kx7aKXQpxnOHHUxw+9BXEvGHqMgC8Z0UKZELVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768655533; c=relaxed/simple; bh=WaWIqYIvzqyysLkFGBt6V3NNILdK5e7uRhOvXIl3cGY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mZz4UErW6zlC/JSbDMi3zpf2HMpLbNVfkx/alQd/a1axmmCloAaIDdyWSHylEXm1H5bA5viW3ShfqT+9fO3CZ6dbDuXja7sHNGtP6XhxU11NvY9+yYsmZpfKhWKMta7KErmnLF/IsRq/tZAK9YQTRY0/8atNwPcpcLGGbUxMKVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=svk2yERT; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="svk2yERT" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4801ad6e51cso24734105e9.2 for ; Sat, 17 Jan 2026 05:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768655530; x=1769260330; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=O/Q6sSsKEIGtbP7mr4JWHCQZmo/e0ttTsHB6ivhULNU=; b=svk2yERTxANYcjxaXKOjvBGLW3Qtu78jYOpIgFX8fiV1d7i1ykHdVg6QTaqe3MRfli Uv8pCk/3mHayah/t4BUQgTuKjLllHEav6DQTrPS/dqlSCQywJqX3jmvg6ZMtA6eTE19h oxv+3RodAKBErLye5TwBfYGqb1jVJZfL7hB6fISciJj+SNG2Kbu5AGTuAeIAgimzCbMg lJSEi6U48uoAnBYOHet0Uy7UgDrPVcZC9/VCzU4uOgRZI3uhqs2R8YwSfDhreq9tX090 BoxxrhkauyCqw8zzB2+G8uH874uMsPX3/rwNXxwIrshlLfNOqpJyiFetYQiIENHJujj+ 8WiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768655530; x=1769260330; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O/Q6sSsKEIGtbP7mr4JWHCQZmo/e0ttTsHB6ivhULNU=; b=XU4VqfjaOpD4aUXwg/SpB0uhG8x9F5A45on+x4xlLTW+vU4e9RY7SyNlyMSYpNSdf2 iplQRQmXieLfK4wtMpEup28jI465YDgFgwccsPMVPurZh7ivB08mpXbS1CAfoauCBtns 6iEbZDYoM2+E2Dme8nVjOIIb5RzlKAMgeCLDYhjlnac3++0+mA4C0dOIEQzX3Uc2t9c2 G4mXj829YITmModVTdVIVKL26wI9qS1aXMdAGggIjl1UQ2NztMA6kQNrWueW2WJF99A0 9uY6B1cNMag0IAIm6q8y1GRzr0gMkSbNA8SrQMNOQNQ2uknHOTJVEiNiX1IlIbWiQ1Jn L00Q== X-Forwarded-Encrypted: i=1; AJvYcCXJhI9/HoP6btA89vMhQd8oxK7RV4FZ3yWAbdZb9nU7aXMXUkcYlIKWU2q8wR/0TpyEg9HEbXoiwNCp20U=@vger.kernel.org X-Gm-Message-State: AOJu0YzOEEVbesWA3U1NJdIqPtXo0G7PXc77Y7KRf6Svo2faBAb5r9zv X90fvrbZVo7ZHosP9uRIUFaNKS61B/CAn3O6zaIQ+O4kml9HDdy+OruEkNXzfK0OgtlqDrIxptW zxSOQUMx//kIf+doWzg== X-Received: from wmdv17.prod.google.com ([2002:a05:600c:12d1:b0:47e:db37:5b61]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4586:b0:477:9ce2:a0d8 with SMTP id 5b1f17b1804b1-4801e29edc9mr73321505e9.0.1768655529859; Sat, 17 Jan 2026 05:12:09 -0800 (PST) Date: Sat, 17 Jan 2026 13:12:08 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260116-rcu-box-v1-0-38ebfbcd53f0@google.com> Message-ID: Subject: Re: [PATCH RFC 0/2] rcu box container for Rust + maple tree load_rcu From: Alice Ryhl To: Boqun Feng Cc: "Paul E. McKenney" , "Liam R. Howlett" , Gary Guo , Miguel Ojeda , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Ballance , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, rcu@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="utf-8" On Sat, Jan 17, 2026 at 08:11:17PM +0800, Boqun Feng wrote: > On Sat, Jan 17, 2026 at 11:55:06AM +0000, Alice Ryhl wrote: > > On Sat, Jan 17, 2026 at 08:06:40AM +0800, Boqun Feng wrote: > > > On Fri, Jan 16, 2026 at 03:46:35PM +0000, Alice Ryhl wrote: > > > > I'm sending this RFC to share an experiment I'm looking at. This may let > > > > us replace the range allocator in Rust Binder with a maple tree. > > > > > > > > > > Thank you, Alice. > > > > > > > An RcuBox is like a Box except that it lets you obtain a &T that > > > > outlives the box by a grace period. It does not allow mutable access to > > > > > > I think the `RcuBox` can be folded into the more generic RCU pointer api > > > [1], e.g. Rcu>> where RcuBoxInner: HasRcuHead. The > > > benefits are at least 1) we use relaxed atomic read for RCU readers > > > which guarantees address dependency that RCU needs under LKMM (while in > > > the RcuBox here, we just use plain reads), 2) we also support mutable > > > access as well. > > > > 1) But mtree_load() does use rcu_dereference() to obtain the pointer? > > 1) "relaxed atomic" does not sound like something that provides an > > address dependency to me. > > If you look at rcu_dereference(), it's a READ_ONCE(), which is the same > as a relaxed atomic load, and yes in LKMM, relaxed atomic load provides > address dependency (Please see the DEPENDENCY part in > tools/memory-model/Documentation/explanation.txt). You argued that we should rename READ_ONCE() to atomic load on that other patch series because "atomic load" naming is better than what LKMM normally uses. Fine, but relaxed atomic load is a much worse name than READ_ONCE() if what you want to convey is "has address dependency". That's not what "relaxed" means! I suppose you can argue that the word "relaxed" means different things in LKMM than it does elsewhere, but I looked over the doc you mentioned, and there the LKMM calls said operation READ_ONCE(). The word "relaxed" does not appear even once. If we're going to change terminology / use new terminology, let's at least pick terminology that's not contradictory with the rest of the world. > > 2) How do you intend to provide mutable access? By waiting a grace > > period? > > Please see the {read_}copy_update() in the RCU patches that I linked. > In short, you don't wait a grace for mutable access, since in RCU, > readers don't block updaters, but instead updater will copy the object, > atomically update the pointer and then get an `RcuOld`, > which you can either synchronize_rcu() or {call,kfree}_rcu(). Hm, ok. I don't really need that. What I want rcu for is the internal maple tree data structure, so mtree_load() doesn't need to block on the maple tree internal spinlock. The contents of the box would be protected by a separate lock (probably via LockedBy). > > > As for the progress of that effort, the Rcu atomic pointer is almost > > > ready [2], I will likely send it early next week. For the `HasRcuHead` > > > part, as you may be aware, I'm working on a generic `HasField` approach > > > to avoid duplication of `Has*` trait and macros [3], that requires some > > > syn adjustments from Gary and Benno, but they should be available next > > > cycle. I will probably send the patches for reviews before that. Once we > > > have that `HasRcuHead` should be easily to add. > > > > > > Given the WIP code I have, I *think* we are not that far from providing > > > what you need for binder. > > > > Hmm, so I looked over [2], and I think my RcuBox is an RcuOld<_> rather > > than an Rcu<_> under this model. Though I can't afford to pay > > I don't think so, `RcuOld` represents an unpublished object while `Rcu` > represents a published object, you can update an `Rcu` pointer to > another object, which is normally how you update with RCU. But maybe > it's easy to discuss this with updater side code in picture. When the RcuBox<_> is an owned value in Rust code, it's unpublished. It's only published while it's foreign-owned by the maple tree. Alice