From patchwork Mon Aug 12 18:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13760920 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 EC132C531DC for ; Mon, 12 Aug 2024 18:24:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 820226B00A6; Mon, 12 Aug 2024 14:24:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8BD6B00A7; Mon, 12 Aug 2024 14:24:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 622FD6B00A8; Mon, 12 Aug 2024 14:24:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 37A756B00A6 for ; Mon, 12 Aug 2024 14:24:27 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ECB45140332 for ; Mon, 12 Aug 2024 18:24:26 +0000 (UTC) X-FDA: 82444418532.25.C5C6862 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 5DB97C0015 for ; Mon, 12 Aug 2024 18:24:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jwDjo9Cz; spf=pass (imf22.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723487010; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tiEB2Pdo1LxqTZ5vaW5IVzuQ0SoXBJ6b7ud672N8eTg=; b=KMyh8NyQzJypaKVV6ZYp/tvtawk+4JDDbZ+XbJnxgkZXbqzjOqvuEPjULF5E3aeYXKpjby Yaj02sdXgFajcLVknqRCkW0G6fEFVlqBBPgjYIF3Ieoc2O1smsFMgXr6G2vEwVsRTDrB+H X2vjLLQoB2+g+/dQ1QXnTrhQNkmQQ8M= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jwDjo9Cz; spf=pass (imf22.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723487010; a=rsa-sha256; cv=none; b=GnS5blNw3EPh4LD949M7fKW/hf80SXVK/OGUKopn32HGINOpeheCPVjIWDvZ7OwUy72RkD UJ+Gy54vbl3uGHL5Og/QFPoPSl6AE1H327A/TD5kXIMNT+VfNqyK2J7nNzKDYmKB/PQozF Z1B5WmkGqMs4BaqgQKam+1V/bWecnus= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A15C861465; Mon, 12 Aug 2024 18:24:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63A19C4AF0F; Mon, 12 Aug 2024 18:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723487064; bh=8oAuOdisYUjDdGnujzu+qdpGOC9b4wPMkAAnWfvuI7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jwDjo9Cz4msrN2OFv+80NjQx4rMmA203HaSKUMopmbA9GF9wV37pGy0wmAtVUds1f KMhgSVyZ3/x3j2p/33Ix6HNljGcAKQlS+dFv8JEmhsHX80rI7/JAXQKKrfMmP2e5tH TTHy+3GPqdb2nFkTn4mLZKS0VspwdWH3/BdIKLZPMkqeR2xc4tgsPcMLywfYnui0fN mILcDkSB2mO9sY5G80rk+PeTOoAPDCQz3Vxlv2N1H6RhptAoytES93kq/BrFwUJRCa EnW1AdyGLUeQjxjWCaTInoiz4pVCEB5o2ZpTdlTiAMi03PmlgvurTvgjpWC+2J4RC7 a9LV7QnrU4Ngw== From: Danilo Krummrich To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich Subject: [PATCH v5 03/26] rust: alloc: rename `KernelAllocator` to `Kmalloc` Date: Mon, 12 Aug 2024 20:22:49 +0200 Message-ID: <20240812182355.11641-4-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812182355.11641-1-dakr@kernel.org> References: <20240812182355.11641-1-dakr@kernel.org> MIME-Version: 1.0 X-Stat-Signature: shfb3g8fznmr418rkr85ip7cb1wzqabm X-Rspam-User: X-Rspamd-Queue-Id: 5DB97C0015 X-Rspamd-Server: rspam02 X-HE-Tag: 1723487065-374123 X-HE-Meta: U2FsdGVkX1/WXcF2N6Y5hacxULs0EMC36FRZCOyGre8D9JEKOLKeeUcBk9UneA+3NigwWDXobove9HN220wJyC+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MVYVaxvn/fuZl2AMgBZLSWFbTAIDzqi6gOEDY1lgqW+GeNSZjYpwqqxNIEaRFmVNye9AvivWiN4Lz1uOuDKra7GKhmTkx6BXPXnGN6UbgGN5ILdvlb89CI8hWOh63zt2tqUexGsd1sdhvAZKL3PGzLMcDgWyl6KfEZo0aJ0zL4DFLKmNv0Mh/aDfLE5aaUlhcNz6X4dhDR7s9twxS9RW8YXLOB6wxciJ/anZrIleiu2IsJaX 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: Subsequent patches implement `Vmalloc` and `KVmalloc` allocators, hence align `KernelAllocator` to this naming scheme. Reviewed-by: Alice Ryhl Reviewed-by: Benno Lossin Reviewed-by: Gary Guo Signed-off-by: Danilo Krummrich --- rust/kernel/alloc/allocator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs index c83b6dff896d..e32182f91167 100644 --- a/rust/kernel/alloc/allocator.rs +++ b/rust/kernel/alloc/allocator.rs @@ -6,7 +6,7 @@ use core::alloc::{GlobalAlloc, Layout}; use core::ptr; -struct KernelAllocator; +struct Kmalloc; /// Returns a proper size to alloc a new object aligned to `new_layout`'s alignment. fn aligned_size(new_layout: Layout) -> usize { @@ -36,7 +36,7 @@ pub(crate) unsafe fn krealloc_aligned(ptr: *mut u8, new_layout: Layout, flags: F unsafe { bindings::krealloc(ptr as *const core::ffi::c_void, size, flags.0) as *mut u8 } } -unsafe impl GlobalAlloc for KernelAllocator { +unsafe impl GlobalAlloc for Kmalloc { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { // SAFETY: `ptr::null_mut()` is null and `layout` has a non-zero size by the function safety // requirement. @@ -72,7 +72,7 @@ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { } #[global_allocator] -static ALLOCATOR: KernelAllocator = KernelAllocator; +static ALLOCATOR: Kmalloc = Kmalloc; // See . #[no_mangle]