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 B2FCDE64006 for ; Thu, 21 Nov 2024 19:12:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 517DB6B009D; Thu, 21 Nov 2024 14:12:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C8506B009E; Thu, 21 Nov 2024 14:12:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 341636B009F; Thu, 21 Nov 2024 14:12:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 122666B009D for ; Thu, 21 Nov 2024 14:12:37 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 93B50AEBE5 for ; Thu, 21 Nov 2024 19:12:36 +0000 (UTC) X-FDA: 82811046696.25.8F2528D Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf16.hostedemail.com (Postfix) with ESMTP id 7A8AD18000A for ; Thu, 21 Nov 2024 19:11:41 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Eund4wbX; spf=pass (imf16.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.160.169 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732216170; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7l+Cnz3oOSITA9Sni+tfmSuPMOvtijlXLQ9PbqOF+pk=; b=f1LGZmxN1qClsI5rJ4Yj8OEEQjmhGAUVLkqG2afOSXtaG74tq/SGtI7z4wF4GfjyJmOCZZ YIrWGB2DY9uhO4vADv78NrW9vWyiFsB0jDhJ+01mvkDOg6XlOj1yRD9luSGKCwtGpEd8ot jCmg6bBd5n0KK5xVZj4e2DK+i4wcjR8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Eund4wbX; spf=pass (imf16.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.160.169 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732216170; a=rsa-sha256; cv=none; b=jBk2Ql2m00pRFa5aa3DAsE7hqboxuuUF3YtaOlQvPzoNsvD/mobmdZgIjCHvpKkvk/jbMQ 9gWHYU1XnumwK0A2dkropvdlCu4QR93+ZB+QNx79peEt4Vy7gyO1Uk/INwQiaLP5aWRskT 3b8jWHVbt0zTwv2jeJd0IH9HT/PVRnM= Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-460ad98b043so11341721cf.1 for ; Thu, 21 Nov 2024 11:12:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732216353; x=1732821153; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=7l+Cnz3oOSITA9Sni+tfmSuPMOvtijlXLQ9PbqOF+pk=; b=Eund4wbXjN1y5s+v0dghHfn8aX+i6aOQA1c9je5FtsjAthkNpNs+1TwLtAli9JJycU Nls4WVPEEeS4hHvtdigw9Nyq9BMNMZuxzUmzHrpkxFNK4sF52InlOn/AEsW6gkXVmluW gx5B3fJ7zX309Gjmu6l0DKq5YI8yS5D4vH26k4i32tSngoFdjpJOmHRI+mUhvvteXzZo jYQF/ofD/aJ5yttviDamCgHGqpjEQKDwVWS+EpXPwmBlUhUuGPguvIackZgbkMXEzIaB s2DtDuQBGtaXkkJdt6ZjeEloBI2nYK1xo6hJQF7jNCWAHxzY0PNVRAMGiHet9OykKDAn BeTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732216353; x=1732821153; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7l+Cnz3oOSITA9Sni+tfmSuPMOvtijlXLQ9PbqOF+pk=; b=XDVoBJku+rVU/ik5IEciHltBG2tnSlgGnDGPip2V4O9ZpAIfP6F4Vjj/90xM3Ivy92 0gZJaYXs/x6wYvbZWLhRweYXRI2l34P+GZebIPyuhklgS6bOmuJI/tNpUD+cvrJ5JJkK OCiMF9PPzyKWZW04kzY/Xw0QP5BBK2hFh/VickDbTq6AGVPSv8n6hMe4pjwpSnb//Epc wIE9U43uctsUdS/O2pfNyrLHNR9P1fatcYs7yDeqju/mGII9zfKakTYortztUvi5h3kf ahAcM9BNYt4PTWujZZLxIqPIqCPywyIE1hm/v4wKSw76iAeruZrSfYriD9EvIcRgF6PZ 5eNA== X-Forwarded-Encrypted: i=1; AJvYcCXK9pKaAIPnLWcMmenB4tM8uk7Btj6zIcYlLau9jrinLlwkYTRE3ODjdhLPeZP2CTEie+mtKW0ENA==@kvack.org X-Gm-Message-State: AOJu0YzYgbxAMmmHJjjZVe22UnV7c0eLVS93eYWAJMfx0GxZAq9npXtX IBZYa52O7lIhiYdmm69+WHLROGNgBJ8w678dFF0Jday+EMrJiAVS X-Gm-Gg: ASbGncsqKmtWSOD2KYl6XYRJR+4Vuk92n9Klu/UJ9hdg5D/5AnE9EYdnPh092XCvETc xhLf6JsNt7Crh+3SucdI2BKNbbsVA+wiX7RrFEhdvoWBGuc+foiKnVs3sFQ00mbA+FoRuAM2xuZ bOMKDw+DhRhPf7vD9tF2uuDjvi1fpg35TLuqHUb4KjHndUqhgOPFbbR/+AndOK/qWaywoOXAxH/ OGsYx/ueKz1DVi6/GTDa0jgUzOeNYuh77MdTiTm/Qoy00SiiryB8qV6At7FHx12uOLGXbL63D/U G93bARSYhmQerL662WXdXrmuctOZEt0giyDLipi7 X-Google-Smtp-Source: AGHT+IH32n1uDGPzo8idMNiROjH+9JYUnYBsUU9edzhv7RQpAuUmS3rb30OFpTzBk5owI83bpmzA5g== X-Received: by 2002:a05:622a:107:b0:465:2fba:71b5 with SMTP id d75a77b69052e-4653cbbbf0emr5704111cf.13.1732216353323; Thu, 21 Nov 2024 11:12:33 -0800 (PST) Received: from fauth-a1-smtp.messagingengine.com (fauth-a1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4653c40e789sm2148911cf.42.2024.11.21.11.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 11:12:32 -0800 (PST) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfauth.phl.internal (Postfix) with ESMTP id 03EA01200043; Thu, 21 Nov 2024 14:12:32 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Thu, 21 Nov 2024 14:12:32 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeeigdduvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvden ucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrd gtohhmqeenucggtffrrghtthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleei vedtgeeuhfegueevieduffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhi thihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmh grihhlrdgtohhmsehfihigmhgvrdhnrghmvgdpnhgspghrtghpthhtohepvddtpdhmohgu vgepshhmthhpohhuthdprhgtphhtthhopegrsgguihgvlhdrjhgrnhhulhhguhgvsehgmh grihhlrdgtohhmpdhrtghpthhtohepfihilhhlhiesihhnfhhrrgguvggrugdrohhrghdp rhgtphhtthhopegrlhhitggvrhihhhhlsehgohhoghhlvgdrtghomhdprhgtphhtthhope hruhhsthdqfhhorhdqlhhinhhugiesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegrlhgvgidrghgrhi hnohhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepghgrrhihsehgrghrhihguhhordhn vghtpdhrtghpthhtohepsghjohhrnhefpghghhesphhrohhtohhnmhgrihhlrdgtohhmpd hrtghpthhtohepsggvnhhnohdrlhhoshhsihhnsehprhhothhonhdrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Nov 2024 14:12:31 -0500 (EST) Date: Thu, 21 Nov 2024 11:12:30 -0800 From: Boqun Feng To: Abdiel Janulgue Cc: Matthew Wilcox , Alice Ryhl , rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Wedson Almeida Filho , Valentin Obst , open list , Andrew Morton , "open list:MEMORY MANAGEMENT" , airlied@redhat.com, Kairui Song Subject: Re: [PATCH v3 0/2] rust: page: Add support for existing struct page mappings Message-ID: References: <20241119112408.779243-1-abdiel.janulgue@gmail.com> <98a46b27-c4bb-4540-8f75-f176c3f2fae1@gmail.com> <650846e4-b6a0-472d-a14e-4357d20faadb@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7A8AD18000A X-Stat-Signature: ngjxkiminhinrfqq5ac8fnadnh4fezpd X-Rspam-User: X-HE-Tag: 1732216301-665238 X-HE-Meta: U2FsdGVkX1/IIL5QrBvtPxluAcftq34i75tpJ4yW2Qln72fUuogMV+TR1KFG51i1wXV7AFLAAuoe8o/IPT2GPiN6aBkY+3Oe6ckNLL5KyF/vmT3P1DTaGNGjAtLiKU03D55QbwtujgcpzIRLwDA+e7zrvg+mUNeeW7yRC61LYaRvH5HftXCbXcjV2D6SiGWrSVFuvSZxKqgZSnyqlLEnN0ymjQvhpX2EkD8F65F6nj+D+fohLZh37+xvmA4cmBJRKR9KAmWH6eo0aAGS6PEGM2Ojh43Q9cIfZeF2eJXgqZscxPzXsLMecDCZ+NpbqNNOg4/VvZ32YB4PrHEj/hhNuRcgMmfYzz7lmrg2tn1hQDNC4UY8c91+gwKlJUaHIC8OvNdiv0CHN/REXK0dicliYZWOQ3x8Qz827tEqYqCFZ7en40x7DyATf+rSvqNvEHBa93qGaNkL7S8GXwluW5N3etloFsRzKDAYRTwrCE9qGsnPowDKBby45Q1PKYkAAqC0VyQYF/ZeO1LeO7vqmnBJ0Ft2F2HIIgINq0s+KNGcMu+QUDjm7qKDnWj1/nhSK1G57xu/JcE5QMhzdgqtjoz6XrcVr/uQ62gVI9hy7UyHdZfaiPH9tcZdQMYUBHAG1g/bmwaABxM9Mhd4JkSIGuhkmXNXbI4rotWqffsQy/fQOwN8NlNwOPozb1qGh3uafieFFTewwq7bMBIV9FsIJSZPgGjrZZmrPJCYKAuAOxOD+t4fQL0zU+F7scrc6szo7htHNYHtUQZqB8T4ta82ZGiNa+QjnmznI6oUa3bLq26EpqQ3SXQvJlBu8ZvC8qAf9MwtOjvh0FaUPHbH8hrXkPBSOc3qqkHug3NgXYP/Zt8WW4/Q+RvzFzKNtdaES1NtMME/JwVtm9JNcw8bn6fYHBQID7tgUnKwzY968Ezag7Y6qAcXBfhpQ94wvr+XifvJhvmx3tM6wdtmDEHJBcudMnZ +U/LN55m rTCXegd98d0esQ6Ca8Rnnb/G5kxVRQcbiMIwMWjZADSqmFGDx5Of4wGsrjUrhC3eIjQlWW5CcbGbsXyrbG9G2o3r0JynxRAB578dht+lZQ818asuGIRSLYKDxIuC54fziEXBlXYkSG3CL15QKTxdRT7Qnxpe8clA5QiVhI+O5rbhl/K0Qitv0Csivbse1qUAsmJsvSUu6njOsa4jfVY+49dDIUleSUF0K/CgOQZ+0B7twfYKwKPnRXiaoHT804Zw2+aCPZQST0nMc5HzjiYYBEkQAjndZTSaKpfk/OvWXiWk6HTGllv829tDJEPp14SshEmCGg3Cdfg+S8iXr+1OFBsQh19K+ME3kxSW9enE7KK+lUmveo7qdBJOjpIdD7xJjGbhH59Kw1yQPXJveh2wJsWV70uwAk0PHQUTSJbAOQxZnhx1gGpXgj+bq5aufhtW/ZJAt 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 Thu, Nov 21, 2024 at 11:10:45AM -0800, Boqun Feng wrote: > [Cc Kairui in case he's interested] > (forgot to cc...) > On Thu, Nov 21, 2024 at 11:30:13AM +0200, Abdiel Janulgue wrote: > > Hi Boqun, Matthew: > > > > On 21/11/2024 02:24, Boqun Feng wrote: > > > > > So if I understand correctly, what Abdiel needs here is a way to convert > > > > > a virtual address to the corresponding page, would it make sense to just > > > > > use folio in this case? Abdiel, what's the operation you are going to > > > > > call on the page you get? > > > > > > > > Yes that's basically it. The goal here is represent those existing struct > > > > page within this rust Page abstraction but at the same time to avoid taking > > > > over its ownership. > > > > > > > > Boqun, Alice, should we reconsider Ownable and Owned trait again? :) > > > > > > > > > > Could you use folio in your case? If so, we can provide a simple binding > > > for folio which should be `AlwaysRefcounted`, and re-investigate how > > > page should be wrapped. > > > > > > > I'm not sure. Is there a way to get the struct folio from a vmalloc'd > > address, e.g vmalloc_to_folio()? > > > > I think you can use page_folio(vmalloc_to_page(..)) to get the folio, > but one thing to notice is that folio is guaranteed to be a non-tail > page, so if you want to do something later for the particular page (if > it's a tail page), you will need to know the offset of the that page in > folio. You can do something like below: > > pub fn page_slice_to_folio<'a>(page: &PageSlice) -> Result<(&'a Folio, usize)> { > ... > let page = vmalloc_to_page(ptr); > > let folio = page_folio(page); > let offset = folio_page_idx(folio, page); > > Ok((folio, offset)) > } > > And you have a folio -> page function like: > > pub struct Folio(Opaque); > > impl Folio { > pub fn nth_page(&self, n: usize) -> &Page { > &*(nth_page(self.0.get(), n)) > } > } > > Of course, this is me acting as I know MM ;-) but I feel this is the way > to go. And if binder can use folio as well (I don't see a reason why > not, but it's extra work, so defer to Alice), then we would only need > the `pub struct Page { inner: Opaque }` part in your > patch #1, and can avoid doing `Ownable` or `AlwaysRefcounted` for > `Page`. > > Thoughts? > > Regards, > Boqun > > > Regards, > > Abdiel