From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.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 CCAE23EAC76 for ; Wed, 17 Jun 2026 11:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781696197; cv=none; b=F46p1ichGCvT1JY4XxypHbNhYuEZdl9EFf8MX+fc7tVQ1HfFsGrOVnTrbY7cWaGqmxf+hxkSrzWIaHbbAsUoicT18/K0ySdF1JWUMesUk2Idfw53gddfZVT4iHOYRBZfpDxGUdlNbrupjxfzLnzVruC5qw6u7+zEdjNsQNx/QY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781696197; c=relaxed/simple; bh=rOcDjKNM7agwOLTLfbY1xAQ9bt9q2fdtORORxk4X9p0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Gvw5na6TacpkKG5PRQYPNd1rROaK3OMK0/sZNR95J2FLorgwUH+slaNjfWb/BPNZcpFBbT7Lx7t82L7vHBdcaxD/0VEUdaTcjw7kQnK/ZRhXEWxXuMNNbM7TJgxKJ29I7qrMRSCjV3O4XE3wqCQk78V87azD3WiRU3lysYBpj+o= 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=DO0PL1lz; arc=none smtp.client-ip=209.85.208.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="DO0PL1lz" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-693de2ea19bso963148a12.0 for ; Wed, 17 Jun 2026 04:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781696193; x=1782300993; 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=UYicJoYFI4w4qF8sCnn+jRXzXN1/GRmTZzaGc7Ox2u4=; b=DO0PL1lz29qKPDyulPg8ifez7mjDclhJ1lmjNppxCX8OOS/xe8hvN1/XIWXHklL92+ asFHBAnT3gg97rxzzYW2ejWRkLpCJzpks6rhZVsQExYfsGOyzGby37HsAsWmx0HYU9W0 cEEDJIRqd9ybX0myXUevPrxqy4bt5RNU7LW1xsgVrGKCZwMZjDKU50PziLZfsTpjsrYd mINieITCXsvsjwsleB8Bmtiuf51VrdH/VyMW+hgqOf2hRS5MDsSvqKYN3SxTnb7+Ec6w FAQwf5rzp8gRPutt8WH3laCVwbanmd/imcEXAaD4aip6e3BKj4MrW6pB4M6IgjGimmkw Ib+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781696193; x=1782300993; 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=UYicJoYFI4w4qF8sCnn+jRXzXN1/GRmTZzaGc7Ox2u4=; b=olNt4zBLkypvipLOrdTBVqoeHfuxGL4x7a3Nst7ibtg9PXviNt4GWyEFeDaCqWrIlk gr6jlZPUGqzv89PoBzYCGxxpiyePVrnVke+KEc5T2BayRZp6smXU0TVgjX54iQWFjCaj GjAiMojf0p7Gifi10O6MoAwZsOe94+NlO3jML7a94NBsv+fS4ydbvmCQyVCzHFKz2byj F6lG5dVCjBtzqXZV5YYiLGe93W7GbxAy1mGlBo+tVaW4Y9GhrShIwSXEvrIM8qmtXhWC DN0nJQ3knBcTau2HFZTjAxUHel/U6PvWTwPRoGobY1JVpUk9k+v6AHDsgvDc8HkVhf1w F6Gw== X-Forwarded-Encrypted: i=1; AFNElJ9FcOCtHMLo7boYNyTLp5G9l3ZrOL0Q1avFJjfhWD7vf0mTlfTfmr3XlrDwVDnApgdrFMstJrQ0xa9j4Eg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0N/N57aba7iC+MjeEzuaJ7JPCRga5jE/nwP0zoNE+v/fx+g4C 1DI0RbnW/4+15+8TpZa6eEdcjN8zcIYLsLtl6H9en+8tgTD7tXC8D12E+SK+mJlEdo+V6gWwCZs iQgKjQ1N0K2A6TwvX7Q== X-Received: from edea23.prod.google.com ([2002:a05:6402:a197:b0:695:72e1:a5a0]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a50:cbc1:0:b0:68f:9fd9:435a with SMTP id 4fb4d7f45d1cf-69554cac360mr960260a12.17.1781696192851; Wed, 17 Jun 2026 04:36:32 -0700 (PDT) Date: Wed, 17 Jun 2026 11:36:31 +0000 In-Reply-To: <20260604-unique-ref-v17-5-7b4c3d2930b9@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260604-unique-ref-v17-0-7b4c3d2930b9@kernel.org> <20260604-unique-ref-v17-5-7b4c3d2930b9@kernel.org> Message-ID: Subject: Re: [PATCH v17 05/10] rust: page: convert to `Ownable` From: Alice Ryhl To: Andreas Hindborg Cc: Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , Paul Moore , Serge Hallyn , "Rafael J. Wysocki" , David Airlie , Simona Vetter , Alexander Viro , Christian Brauner , Jan Kara , Daniel Almeida , Viresh Kumar , Nishanth Menon , Stephen Boyd , Bjorn Helgaas , "Krzysztof =?utf-8?Q?Wilczy=C5=84ski?=" , Boqun Feng , Uladzislau Rezki , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Igor Korotin , Pavel Tikhomirov , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-block@vger.kernel.org, linux-security-module@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, driver-core@lists.linux.dev, Asahi Lina Content-Type: text/plain; charset="utf-8" On Thu, Jun 04, 2026 at 10:11:17PM +0200, Andreas Hindborg wrote: > From: Asahi Lina > > This allows Page references to be returned as borrowed references, > without necessarily owning the struct page. > > Signed-off-by: Asahi Lina > [ Andreas: Fix formatting and add a safety comment. ] > Signed-off-by: Andreas Hindborg > --- > rust/kernel/page.rs | 38 +++++++++++++++++++++++++------------- > 1 file changed, 25 insertions(+), 13 deletions(-) > > diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs > index 3bdcee0e16a8..844c75e54134 100644 > --- a/rust/kernel/page.rs > +++ b/rust/kernel/page.rs > @@ -10,6 +10,11 @@ > bindings, > error::code::*, > error::Result, > + types::{ > + Opaque, > + Ownable, > + Owned, // > + }, > uaccess::UserSliceReader, // > }; > use core::{ > @@ -105,7 +110,7 @@ pub const fn page_align(addr: usize) -> Option { > /// > /// [`VBox`]: kernel::alloc::VBox > /// [`Vmalloc`]: kernel::alloc::allocator::Vmalloc > -pub struct BorrowedPage<'a>(ManuallyDrop, PhantomData<&'a Page>); > +pub struct BorrowedPage<'a>(ManuallyDrop>, PhantomData<&'a Page>); BorrowedPage<'a> is no longer needed because it's just &Page. Alice