Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Andreas Hindborg <a.hindborg@kernel.org>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Uladzislau Rezki" <urezki@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Lyude Paul" <lyude@redhat.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Dave Ertman" <david.m.ertman@intel.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Paul Moore" <paul@paul-moore.com>,
	"Serge Hallyn" <sergeh@kernel.org>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Jan Kara" <jack@suse.cz>,
	"Igor Korotin" <igor.korotin@linux.dev>,
	"Viresh Kumar" <vireshk@kernel.org>, "Nishanth Menon" <nm@ti.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Pavel Tikhomirov" <ptikhomirov@virtuozzo.com>,
	"Michal Wilczynski" <m.wilczynski@samsung.com>,
	"Ira Weiny" <iweiny@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Philipp Stanner" <phasta@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, driver-core@lists.linux.dev,
	linux-block@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH v21 9/9] rust: page: add `ExclusivePage` for race-free page access
Date: Sun, 13 Sep 2026 04:11:23 +0100	[thread overview]
Message-ID: <aqYUWzRSade_Ww67@casper.infradead.org> (raw)
In-Reply-To: <20260910-unique-ref-v21-9-e83257373062@kernel.org>

On Thu, Sep 10, 2026 at 11:00:13AM +0200, Andreas Hindborg wrote:
> `ExclusivePage` wraps a regular page but adds an invariant that the
> page data area does not incur data races. This means `ExclusivePage`
> cannot be mapped to user space or shared with devices, and it
> becomes simpler to directly reference the contents of the page.
> 
> Since `Page` implements `AlwaysRefCounted`, handing out a `&Page`
> from an `ExclusivePage` would allow safe code to obtain an
> `ARef<Page>` to the page and break the aliasing invariant of
> `ExclusivePage`. Thus, do not implement `Deref<Target = Page>` for
> `ExclusivePage`.

Given this description, I wonder if this shouldn't be implemented by
alloc_frozen_pages() / free_frozen_pages().  We'ree certainly trying
to move the C parts of the kernel away from thinking that pages have a
refcount (folios have a refcount; otheer memdescs may or may not have
a refcount).  Do your intended users of this actually have a need for a
refcount?

> +++ b/rust/kernel/page.rs
> @@ -17,7 +17,11 @@
>          AlwaysRefCounted,
>          RefCounted, //
>      },
> -    types::Opaque,
> +    types::{
> +        Opaque,
> +        Ownable,
> +        Owned, //
> +    },

While I'm asking stupid questions, what's the significance of the //
after Owned?  I see it after RefCounted too.


  reply	other threads:[~2026-09-13  3:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  9:00 [PATCH v21 0/9] rust: add `Ownable` trait and `Owned` type Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 1/9] rust: alloc: add `KBox::into_non_null` Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 2/9] rust: types: Add Ownable/Owned types Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 3/9] rust: implement `ForeignOwnable` for `Owned` Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 4/9] rust: rename `AlwaysRefCounted` to `RefCounted` Andreas Hindborg
2026-09-11  9:08   ` Alice Ryhl
2026-09-11 12:29     ` Gary Guo
2026-09-13  9:49       ` Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 5/9] rust: Add missing SAFETY documentation for `ARef` example Andreas Hindborg
2026-09-11  9:09   ` Alice Ryhl
2026-09-10  9:00 ` [PATCH v21 6/9] rust: Add `OwnableRefCounted` Andreas Hindborg
2026-09-11  9:19   ` Alice Ryhl
2026-09-11 13:25     ` Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 7/9] rust: page: convert to `AlwaysRefCounted` Andreas Hindborg
2026-09-11 13:43   ` Alice Ryhl
2026-09-10  9:00 ` [PATCH v21 8/9] rust: page: add `from_raw()` Andreas Hindborg
2026-09-10  9:00 ` [PATCH v21 9/9] rust: page: add `ExclusivePage` for race-free page access Andreas Hindborg
2026-09-13  3:11   ` Matthew Wilcox [this message]
2026-09-13  9:36     ` Andreas Hindborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqYUWzRSade_Ww67@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=david.m.ertman@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=igor.korotin@linux.dev \
    --cc=iweiny@kernel.org \
    --cc=jack@suse.cz \
    --cc=kwilczynski@kernel.org \
    --cc=leon@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=m.wilczynski@samsung.com \
    --cc=matthew.brost@intel.com \
    --cc=nm@ti.com \
    --cc=ojeda@kernel.org \
    --cc=paul@paul-moore.com \
    --cc=phasta@kernel.org \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sergeh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tkjos@android.com \
    --cc=tmgross@umich.edu \
    --cc=urezki@gmail.com \
    --cc=vbabka@kernel.org \
    --cc=vireshk@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox