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 2E835C02194 for ; Tue, 4 Feb 2025 11:50:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC7E56B007B; Tue, 4 Feb 2025 06:50:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A77D26B008A; Tue, 4 Feb 2025 06:50:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93F756B008C; Tue, 4 Feb 2025 06:50:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6F2736B007B for ; Tue, 4 Feb 2025 06:50:43 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8FB761C7F15 for ; Tue, 4 Feb 2025 11:50:24 +0000 (UTC) X-FDA: 83082094368.17.3F59A91 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by imf09.hostedemail.com (Postfix) with ESMTP id 9679C140009 for ; Tue, 4 Feb 2025 11:50:22 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=asahilina.net header.s=default header.b=UpP6qAhQ; spf=pass (imf09.hostedemail.com: domain of lina@asahilina.net designates 212.63.210.85 as permitted sender) smtp.mailfrom=lina@asahilina.net; dmarc=pass (policy=quarantine) header.from=asahilina.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738669822; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j3EzVOEwKWKrPM/mZJNKqKBF5/NxTBjjANAiO0DZyQ4=; b=79PDUYWmYTPBb/AR4UcH+boTgdzz1Phxl04/2EUjWolljLyXikjCb3JlJEWcZMvulN5WeD WY+bOIlR/8zfxi4MQ6wqUfIp7G0FnjNLPfdWImEURZ2kjbOkhNRt/++7rof5LXq3v8NByW E1TXFeFnuLFgSZLPxpbJzRbUhQ295/8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=asahilina.net header.s=default header.b=UpP6qAhQ; spf=pass (imf09.hostedemail.com: domain of lina@asahilina.net designates 212.63.210.85 as permitted sender) smtp.mailfrom=lina@asahilina.net; dmarc=pass (policy=quarantine) header.from=asahilina.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738669822; a=rsa-sha256; cv=none; b=L4sURgTkqFkAaM3yxbeUsOHF1HBdvZ6iTwI2Yy364+QDK26mxKrkkhkAM0CVd28gI0GbIL LKpKJ8VcVfSYauJuixYhP5ktrTYL4zmHPvgeB2GHI7kjUtO0n7o8IaRec1yzceU3uPdy7q +Hlo7mHhBAdZi1DHRG5UJY9OHLoJTG0= Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: lina@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id 20C0E42E70; Tue, 4 Feb 2025 11:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1738669820; bh=mQbQ2uNB03ZheDQ+0nud+bkQdw5vLiAPIUojJBlYWn0=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=UpP6qAhQLqeveWyfHJ0rOPqELWItz2HA4hFMYJibz0g/QJhx8wbZOlJ5ihfGclVnP +EeEW5rI/CAzWCxk+GG8Yli/Ut0qfq0yj7BYWw5sciHFyAvpBmPxJPHVUx00fQBu7a z09X+pSv/fR17qJRdhbgzkuX3ZSR9MC8IYnMSIfxtFWHda1olUTMh9b+DXQxmm1IfT PUZd+tWwwhQb/kZs2oDuEv+Mq69+SBQEYBko/kdbRgM+fz3eSHd1dNKs7c/7DDdT/L imx5k3GDl4p1dau1w7pTP6LlJ575tvzZpjngUWvB4c5cIRNzRgcFvEfJ4SsJDYaF0R 1+V9lEkAvZKeg== Message-ID: <8f098064-d2d5-4a02-8306-0a3d31557bab@asahilina.net> Date: Tue, 4 Feb 2025 20:50:17 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/6] rust: addr: Add a module to declare core address types To: Boqun Feng Cc: Miguel Ojeda , Alex Gaynor , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_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 References: <20250202-rust-page-v1-0-e3170d7fe55e@asahilina.net> <20250202-rust-page-v1-4-e3170d7fe55e@asahilina.net> Content-Language: en-US From: Asahi Lina In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9679C140009 X-Stat-Signature: jty7sr9ty3ut4d3g571y4sd43y5h9o7p X-Rspam-User: X-HE-Tag: 1738669822-554203 X-HE-Meta: U2FsdGVkX19R9ppvV04Y40tYx84c4KgtLZaqbCWTTATzuBoaVc7qN45hFmduLiFfEiddbXi6OrBteQKKoixnkykyM4VP4V8adtnkwR+XWqlj/pNuIqPJ33Ue+HkTA9FLNKmc/ibeLsR8VK2eerqun8Z1W1/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NTLF4z0f2jvVsPbwO+ipYrv75eSryWpxpbsQUwEnGnQ3ZXhIszAOrZ6sy3kOLZllArrXyoJT1CqR9pRw9YxE4O1hJANMMSlULsAtvo6bxKDRYq9jV6aYuhvoWWfCUpzHlU+tX3JbUXynnIfv4a4wPh+fD9B9tYPjFgEvXQ24Pe9a9rGj7N+AzIm6whIbfVIEptSJL94hmSDJ9rM5xAHnHVPP/fhpjDm/IuY= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.499997, 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 2/4/25 12:04 AM, Boqun Feng wrote: > 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? I think in kernel-speak "mm" is usually userspace memory management and kernel page allocation and memory management, but doesn't include device stuff (I/O ranges, DMA, etc.) or the low-level concepts of memory in an architecture. The types I declare here are more relevant to device/arch code, so I don't think they really belong under "mm", it's more general (mm deals with them and so do other parts of the kernel code). On the other hand, I think page.rs itself would fit under mm, since it deals with the kernel mm's idea of pages and their allocation. > > Regards, > Boqun > >> pub mod alloc; >> #[cfg(CONFIG_BLOCK)] >> pub mod block; >> >> -- >> 2.47.1 >> > ~~ Lina