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 9A124C02192 for ; Mon, 3 Feb 2025 15:05:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8E76B0083; Mon, 3 Feb 2025 10:04:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA88B6B0085; Mon, 3 Feb 2025 10:04:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C49366B0088; Mon, 3 Feb 2025 10:04:59 -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 A6CD56B0083 for ; Mon, 3 Feb 2025 10:04:59 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CC87214020A for ; Mon, 3 Feb 2025 15:04:07 +0000 (UTC) X-FDA: 83078953776.02.579522C Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf14.hostedemail.com (Postfix) with ESMTP id 75C88100014 for ; Mon, 3 Feb 2025 15:04:05 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CmmEPMU9; spf=pass (imf14.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.222.174 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=1738595045; 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=mfs45TBGa9cOMjq+1YHkVGnJDn3Ark/UOv4RQa6undA=; b=S7qm5/qLpc6BuwJT8Nan1PTBM19j8JNZRseJ7y+idwYdMVW6pkIqS9XRnV2iIzh5Y3oK6h czEVKTajUpdRiaEVIBcIHdcnxp+qBJyH+l2xpNM0TvuQo8qWNPdCgIX0KF8BgA+WWKfeL0 L3znHw/g96Xu4/FNTlZc5v4pP7LSGv8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CmmEPMU9; spf=pass (imf14.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.222.174 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=1738595045; a=rsa-sha256; cv=none; b=Zh0o485rTt2roExXGvQfBQ/+ZnBwQ3utOTrNsPTWLDgexGk+o6NiBG7VXclQMLPukMdM9C UvGAO1f3DgW3OVmQrbHpusNaW29yeNB0Fr+9AgSBXfUNpQLpCqTqR7D2EWtuqGTSmLI1me vcnCViZPFzGdyV/AG1a6Y3d2FDVcIBU= Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b6f95d2eafso466018485a.3 for ; Mon, 03 Feb 2025 07:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738595044; x=1739199844; 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=mfs45TBGa9cOMjq+1YHkVGnJDn3Ark/UOv4RQa6undA=; b=CmmEPMU9U1dLo/ZNlVvi6W2BtJUTNV6E/mgs5visH0vKM/87Mp5rT0p48X2r/CXD+t BqULcMwYdMq7f8sC5IyEN8U9IFxRKQ9SzKMSeoCqFxHDhtRgt7uHuuy3jvY6Qm0fJSiK ipSbdlipyI1A8J26UC5tkc27VWki5te4oe50vKcAgW0R/xB/LcUEIQOYCcBpoIBxBSRq wTIkk2JvFF5Akq3idusG0thOCE1yRZMjRY+xWBS3pXL2ZRQBB+G3AzZeukeXFRM8Bk8W 3mHcZlAIERdYRCdYNWBBAZyvEey8bWdBaSk40XN/pQdUs5+guOYdypcgK3h8GtqJ4uRo Qezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738595044; x=1739199844; 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=mfs45TBGa9cOMjq+1YHkVGnJDn3Ark/UOv4RQa6undA=; b=XXzId61T0KDA1ha7RFxmC1/yn08nt5Kguu01QJ1RXqgi9082ABXMd0YDz2Q+hsr2J1 AsYHtRdsIQzpp2pOPp/qBHe8gx2EyQ+w62cZeJTmd/gmFfA2UZgsdjDA3yY7eujhFNN/ eyzdP8zobsoihlbH0hBGec5K6AKG1PLn8mHugqveUWfBF94PXp7h4B1D8tB/QJg3Ir18 OedB59XyTWddgHVj/B7BMwmeW7yeV3+fcsgILX8UzKgULqlYd+qX4WNkbsi5D1w2uX4A OaZFYxFyJwOYMce9Jq+HbdRtiAR5DYcbShPO8rPGhGgf2u6xUGQGm10MOGcBXoCsvY50 doUQ== X-Forwarded-Encrypted: i=1; AJvYcCXaJxQZEvqPwQSd8xZSD03IXa/2vcEHslk5jNBEfzvTfkaRUsnI4OLE5J/wcDeIJCd0zX+Wu/fSmg==@kvack.org X-Gm-Message-State: AOJu0Yw4PmWdq4yRp92fZjrwngl/kuJLYUvFsByc4Vxd0sAdDjdSL27Z JKOyfFkIyOe1znlCo/3fzKDUz+lBWUr9j7TnpzAN8xsOYI/xpsJZ X-Gm-Gg: ASbGncu98TDXWN4cPAnb/pAAjdsyKiXAL20Z/yevwtBGLq9EWHJDltk3TEDVPyD0rbi GwpLgcJNdeNDJn6USKEeDpi4SjmVUm8zSeMPTOWiR2Wy3C6BJB68fIBitZ1ppYIB7HjuE8JDfum w6JnlFkU4lq441/hK7d93Aa1/TpbsbhW9+tenwQtvpWCUboeBghWr5weRCJIVc9uUbk6oznjDLZ Yg7w1kI+WjHCmz2oTlp+tO5dtug1LqQqVwDp5kRvZnAopzvbNzLhQfwdJuJr1UYNBY0ddK6P33y fDjJxKphrmUywxQXBPYKkM3JaWTNgBVXoc0419Q/Oc4xrljqej/8DOy7IR4US94ZS6Rh/QplcOd A8G9Hag== X-Google-Smtp-Source: AGHT+IEcSkEvwfTpeA1pv4/nxSgMr4TNNL/PIqYjwCQvL7oYKhCCodXASw4imJoTjH5+ZyEo67Tebw== X-Received: by 2002:a05:620a:4486:b0:7b6:d241:d4ae with SMTP id af79cd13be357-7bffcda58e5mr3118721285a.42.1738595044348; Mon, 03 Feb 2025 07:04:04 -0800 (PST) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a8bba3csm537156985a.3.2025.02.03.07.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 07:04:03 -0800 (PST) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfauth.phl.internal (Postfix) with ESMTP id 347401200068; Mon, 3 Feb 2025 10:04:03 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 03 Feb 2025 10:04:03 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddujeelvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddv necuhfhrohhmpeeuohhquhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilh drtghomheqnecuggftrfgrthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleel ieevtdeguefhgeeuveeiudffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghl ihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepgh hmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthhopedvfedpmhho uggvpehsmhhtphhouhhtpdhrtghpthhtoheplhhinhgrsegrshgrhhhilhhinhgrrdhnvg htpdhrtghpthhtohepohhjvggurgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghl vgigrdhgrgihnhhorhesghhmrghilhdrtghomhdprhgtphhtthhopehgrghrhiesghgrrh ihghhuohdrnhgvthdprhgtphhtthhopegsjhhorhhnfegpghhhsehprhhothhonhhmrghi lhdrtghomhdprhgtphhtthhopegsvghnnhhordhlohhsshhinhesphhrohhtohhnrdhmvg dprhgtphhtthhopegrrdhhihhnuggsohhrgheskhgvrhhnvghlrdhorhhgpdhrtghpthht oheprghlihgtvghrhihhlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepthhmghhroh hsshesuhhmihgthhdrvgguuh X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 10:04:02 -0500 (EST) Date: Mon, 3 Feb 2025 07:04:01 -0800 From: Boqun Feng To: Asahi Lina Cc: Miguel Ojeda , Alex Gaynor , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Jann Horn , Matthew Wilcox , Paolo Bonzini , Danilo Krummrich , Wedson Almeida Filho , Valentin Obst , Andrew Morton , linux-mm@kvack.org, airlied@redhat.com, Abdiel Janulgue , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev Subject: Re: [PATCH 4/6] rust: addr: Add a module to declare core address types Message-ID: References: <20250202-rust-page-v1-0-e3170d7fe55e@asahilina.net> <20250202-rust-page-v1-4-e3170d7fe55e@asahilina.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250202-rust-page-v1-4-e3170d7fe55e@asahilina.net> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 75C88100014 X-Stat-Signature: 5u8b3wwebnpc5hmq9acfr1wdym9np8oy X-Rspam-User: X-HE-Tag: 1738595045-200178 X-HE-Meta: U2FsdGVkX1/yJCykPf+JcyHgknaRud8tAZxWu9m4xOATdpKAXcelbaTIDKdgB1PwqAI7buFNGCocjln105N0kMslqCkXKE7Alrm/FGXPzDLCb6VDwwehlfrXEye8rb5mDPVziBKUW0GJ/X12/qvaQonSCLypyCNidoEQWO9lTbFgDg6kY84FJC3qYeDT76fxNPnGxcY9q1YHx29ykVIXimFGRnk7tcykcJkrK/58gxHcJX/LLaZ/eVJinhQz3jO+W7a/jMiY3fr718mJWU9wgkeZnZJ+IVa9B1zqTbse3j4kAb9k5kB5Vyhxve6hH+7cZJlRCGaLZu7ubK4z4/zQcaypb6FiBf9TsVku6CNROrfjhbimRT3GRYxmD5GYEsoQgZxYb3NTmiy40UbMS6uCL3XmafSAFIrTycWFyI7GJMBrq7Z0RyWCtSB2cOYZuWRowdhZGr+mnx9wjpg0RCKPnElfFlN4clf9FLb8m84w2F+N7m71D3LsupCx6smqdUGHzZNWcZH2ycPuV29vEThO6PZlQoIePVdJ+jznfd1MypvsyyyTkA6I3Zu8aCgsvxnWifPJW4vuXGDoREIQeSeLHVpez7HI6UJFqMiGNhQrZgvZU9or5vVOLRs9uXUSzb65FkA96mscVWvCkWUNFftr1t+isvbOf/LwNYrgQhXK3ZAU3zFTzfKf2x/aWYT696NKQHNsstubeOiEcT2DY13Rb1iJuA3DArrHxvOc2dMfgxXv+lEg4eqYEIES6oA2JxuUKRinICsZmrAU25mQqGxOJys4n9glELu4BbBputv92YM0uDSvyNZ/U84gU7wpngCpFr4IpC4ooEPRmLVpB6OYhKMygVy1csla+Lmtc+dCukAFqWQoYfo+RjdRKUmHXjQ/R6EIln1gZF5favAKsaMXjyhWecPqJWZDX6ywKX5pPLnyORZQF4P691Ag7rMPcoOJx1Gw6xqvcApY1cbljVS uKcIxXPZ dBwmvftvVWTqWxXUtDl3eTcNHezEVOHTXyj4SLZ/Uy1gxUsoXytwNc9TgB3bcY7ww9zcHeIWd1+y+Fv7EFun7EchUuBE6F6ycyByFyL880CJGcROHT6r6GToiz5sWHbD7qFuXgEirn6dBDHGKTvhewdxCVf0vrrpJeFUEI55R471by/DRDxN8CL47syLCjt9fxHnTG8ec3g600Vfcyrbbu5Tcxa6+z9J5yrsaKtdCDPQ7DFk7pSuDxwko+pSr7HdE+Q/FlDxZy69VaIftA1a+o2yb7m6RM94qDwbo4YuanraNCC83hvo/v+YTXRE6his2KC/kOZ2tT2LJxpaBK62uIw/VPBovhH0OoONH3q1K2We3CGI0SXtqWEdTiK7UYXRTZD96wFC+gmW3WbrACekhmumxU/TEjtnMOL13Y13l/9/XCAh0JouvGQbZj/bAkHhAwOTMlnOGSAjqr+9ytoLhV7yqD1uaB3NSObM8ju/+BBqcHxQXy5P+xw1Yhs9ECalckEl+ X-Bogosity: Unsure, tests=bogofilter, spamicity=0.499902, 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 Sun, Feb 02, 2025 at 10:05:46PM +0900, Asahi Lina wrote: > Encapsulates the core physical/DMA address types, so they can be used by > Rust abstractions. > > Signed-off-by: Asahi Lina > --- > rust/kernel/addr.rs | 15 +++++++++++++++ > rust/kernel/lib.rs | 1 + > 2 files changed, 16 insertions(+) > > diff --git a/rust/kernel/addr.rs b/rust/kernel/addr.rs > new file mode 100644 > index 0000000000000000000000000000000000000000..06aff10a0332355597060c5518d7fd6e114cf630 > --- /dev/null > +++ b/rust/kernel/addr.rs > @@ -0,0 +1,15 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +//! Kernel core address types. > + > +use bindings; > +use core::ffi; I think we should use crate::ffi here. See: d072acda4862 "rust: use custom FFI integer types" > + > +/// A physical memory address (which may be wider than the CPU pointer size) > +pub type PhysicalAddr = bindings::phys_addr_t; > +/// A DMA memory address (which may be narrower than `PhysicalAddr` on some systems) > +pub type DmaAddr = bindings::dma_addr_t; > +/// A physical resource size, typically the same width as `PhysicalAddr` > +pub type ResourceSize = bindings::resource_size_t; > +/// A raw page frame number, not to be confused with the C `pfn_t` which also encodes flags. > +pub type Pfn = ffi::c_ulong; > diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs > index e1065a7551a39e68d6379031d80d4be336e652a3..eb1a80ba8ff83ab2d1b3b1d11fed4fb704c7a4f5 100644 > --- a/rust/kernel/lib.rs > +++ b/rust/kernel/lib.rs > @@ -29,6 +29,7 @@ > > pub use ffi; > > +pub mod addr; I want to share my worry on this `pub mod` list in kernel/lib.rs may get too long ;-) I was about to suggest putting `addr` and `page` into `mm` after Alice's patchset merged, however, seems that `mm` mod only cover userspace memory management (which is not my impression of what "mm" in kernel development), thoughts? Alice, do you think we should extend `mm` mod to contain all memory management mods? Regards, Boqun > pub mod alloc; > #[cfg(CONFIG_BLOCK)] > pub mod block; > > -- > 2.47.1 >