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 F3E82C3DA4A for ; Wed, 14 Aug 2024 19:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1069D6B0083; Wed, 14 Aug 2024 15:41:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 090856B0085; Wed, 14 Aug 2024 15:41:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E55216B0088; Wed, 14 Aug 2024 15:41:22 -0400 (EDT) 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 C29316B0083 for ; Wed, 14 Aug 2024 15:41:22 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 044B3A1042 for ; Wed, 14 Aug 2024 19:41:21 +0000 (UTC) X-FDA: 82451870004.30.8C85EED Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf17.hostedemail.com (Postfix) with ESMTP id D5AAA4000D for ; Wed, 14 Aug 2024 19:41:19 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nCxRAGpC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723664467; a=rsa-sha256; cv=none; b=okjyTjYacDecOKqVF+IUJMIAzOyBacfhGWVagJtB8kBYgiNkz1dH3a3/ZRWdZGi7KsG/wX waI6XkQKmk6MfFH9d1zuIBKLpNrGMd1H8XGnwbQfWEftUZmyrGlfiZHhA++qv1oy5svCsA U6QrdYCBGSljlIpFJbLDSqRKw5PQHA4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nCxRAGpC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723664467; 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=P7nxP/0wlxFkVaeXCvOut63mGk6zyQ8GTLenWGDTFAU=; b=RVz72g0IjXpH7AuXmsJXrSyOo+O9onL5KF1rpJQs/g8HPGvpqDuM7uDvAjKI47zQHFOU9i it+T8KHQI6/hkIgQRt+rQR5/h3uBN2+4T186Cfi1z/WojwMTFj6/+tgzFI0ydAbIJ381+r RY0RngN3SFyabpKLTR+6Obh4augp6Ps= Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-44fe188d25cso1082761cf.3 for ; Wed, 14 Aug 2024 12:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723664479; x=1724269279; 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=P7nxP/0wlxFkVaeXCvOut63mGk6zyQ8GTLenWGDTFAU=; b=nCxRAGpCc9gxywWqTGicoCx+OKCGXujSImfh/gcVOHFSyu53kPhbZa9uzu+AA0jecW /nRCNFF7AWb1E3MiUMkgWzn1XRzmehyYESbMrCTrwitad2FkfAq4g12iUwKH9o5UHVX/ Uu2XwmHS0bnr8FuvXcvRlUWOusVN7KkqnWskh+iEguQjFb1H4e2Ueug2MohJ9CzsdPbk MrLirStjPJLIAh3hvdh4sbCGyJmbxLAZ+hd5pr1/Yb2X7kKhlBb+/iz0fkaJmYlNOfIC iyuA0r7bE1nxL31CV6jEQO+fRIH970p794Vz/SFF1N/QfX8PLhy6lksU8jPCcdMQm+ed bcqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723664479; x=1724269279; 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=P7nxP/0wlxFkVaeXCvOut63mGk6zyQ8GTLenWGDTFAU=; b=j5IU7a5Dn6hznMBeSKuFSipHqJAaFcc60oouXnK/bkyxRD9py0fi+xle4pi7uLhrl/ 8MqBuf1QlP/HJ2KDDMa8i4NezelDBsMkVmivubKfDq7wZWn34qLoCARO7EHHp9VPAFlC p+CW/I067dd+0DUCMl4BnULtgW5/Ope0ZlDgy7cCU0yagpPSkyJifUdAAdYHVIMQ8q8+ vSQTcdM5+kvY4iX4qeW0Ly8slD8QhXp42LFS04tiJ61HbwslxQitK9O5QxKDjRe7sS6M 6WdjRAtEN7wdYbnaaiGP7qItrcEnl4dib8V/41O5z8okuI/Qd8IyfVkcuVHZ0d4CD2f3 +YEQ== X-Forwarded-Encrypted: i=1; AJvYcCVo3ZuB9g3Y6n5VG5Tx/WmwDkwhAoz3ckCJIxgFxIlTElYQ0FlvGHS9cMEiuAnqQc+G+vp4pJVGSHJf+7Uk7kLbeMc= X-Gm-Message-State: AOJu0YxxrPinRnCb19GDFJCJCdfVNvApy66K96t90aQOxOZp5guK5KPE xN4d2iPr4dHJ7KeVhPl6HukINLOIyocf/y9sVJsKT6Khw81BjZJU X-Google-Smtp-Source: AGHT+IG43s6HRKXNmIoIQMez0b4aDhVLwvUOvUZXa56lx5CPR6BaSlukxg+NEqSky6No4rxSBs7Hyw== X-Received: by 2002:a05:622a:5a8a:b0:44f:f118:d875 with SMTP id d75a77b69052e-4535bb649aemr44940161cf.36.1723664478705; Wed, 14 Aug 2024 12:41:18 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4531c1a7f12sm44629801cf.20.2024.08.14.12.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 12:41:18 -0700 (PDT) Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id E088A120008C; Wed, 14 Aug 2024 15:33:43 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 14 Aug 2024 15:33:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtgedgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddv necuhfhrohhmpeeuohhquhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilh drtghomheqnecuggftrfgrthhtvghrnhephfetvdfgtdeukedvkeeiteeiteejieehvdet heduudejvdektdekfeegvddvhedtnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhn odhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejje ekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhn rghmvgdpnhgspghrtghpthhtohepvdehpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegurghkrheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepohhjvggurgeskhgvrhhn vghlrdhorhhgpdhrtghpthhtoheprghlvgigrdhgrgihnhhorhesghhmrghilhdrtghomh dprhgtphhtthhopeifvggushhonhgrfhesghhmrghilhdrtghomhdprhgtphhtthhopehg rghrhiesghgrrhihghhuohdrnhgvthdprhgtphhtthhopegsjhhorhhnfegpghhhsehprh hothhonhhmrghilhdrtghomhdprhgtphhtthhopegsvghnnhhordhlohhsshhinhesphhr ohhtohhnrdhmvgdprhgtphhtthhopegrrdhhihhnuggsohhrghesshgrmhhsuhhnghdrtg homhdprhgtphhtthhopegrlhhitggvrhihhhhlsehgohhoghhlvgdrtghomh X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Aug 2024 15:33:43 -0400 (EDT) Date: Wed, 14 Aug 2024 12:32:15 -0700 From: Boqun Feng To: Danilo Krummrich Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org, 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 Subject: Re: [PATCH v5 00/26] Generic `Allocator` support for Rust Message-ID: References: <20240812182355.11641-1-dakr@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240812182355.11641-1-dakr@kernel.org> X-Rspam-User: X-Rspamd-Queue-Id: D5AAA4000D X-Rspamd-Server: rspam01 X-Stat-Signature: sngh1mdytbt9jn433m3kca9x51595few X-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HOwDZGwi+2qND/NOGs81+EUWoARgyb7gSbPu0arXEZJ9gQmnaIgmY4YWdoYqSvSSaSxvG8L0nrDhusdcmxTZdoIvzn2u7jCk0kHeYDw8W9RkB1r7xDzmOY85Az/zggBUj/zAz+IGkU+gKKv1qKcP1xNzE77aJq/umGHs2jEDaWEIhZZf+7MElBxYrCXaUfLhIpnAh/TZzxBYQ6Ij+57hauq36Y9PEfJUfYRO/xlwI+ysJ/cfkASJi6ANlO6Z299Jtyhuju8cYoY4ePBKOl3xiPLf8AvQr3aFdVbm3YfGoEjcAZM7APMTPMGE0XCSnaJaN/ulqybIkIcvyViQgMJzk0+mPOHr04s/FbEBRoVqVOhX2+rbjdyna1PxTsdmzhWUfJulwGy7r0PH/86SmbFPckgXoCYbpdljx+vb6RPukECBkgh5t2rNO8vjHOVeweTFi/r3NCtzPAWU4= 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: Hi Danilo, On Mon, Aug 12, 2024 at 08:22:46PM +0200, Danilo Krummrich wrote: > Hi, > > This patch series adds generic kernel allocator support for Rust, which so far > is limited to `kmalloc` allocations. > > In order to abstain from (re-)adding unstable Rust features to the kernel, this > patch series does not extend the `Allocator` trait from Rust's `alloc` crate, > nor does it extend the `BoxExt` and `VecExt` extensions. > > Instead, this series introduces a kernel specific `Allocator` trait, which is > implemented by the `Kmalloc`, `Vmalloc` and `KVmalloc` allocators, also > implemented in the context of this series. > > As a consequence we need our own kernel `Box` and `Vec` types. > Additionally, this series adds the following type aliases: > > ``` > pub type KBox = Box; > pub type VBox = Box; > pub type KVBox = Box; > > > pub type KVec = Vec; > pub type VVec = Vec; > pub type KVVec = Vec; > ``` > > With that, we can start using the kernel `Box` and `Vec` types throughout the > tree and remove the now obolete extensions `BoxExt` and `VecExt`. > > For a final cleanup, this series removes the last minor dependencies to Rust's > `alloc` crate and removes it from the entire kernel build. > > The series ensures not to break the `rusttest` make target by implementing the > `allocator_test` module providing a stub implementation for all kernel > `Allocator`s. > > This patch series passes all KUnit tests, including the ones added by this > series. Additionally, the tests were run with `kmemleak` and `KASAN` enabled, > without any issues. > > This series is based on [1], which hit -mm/mm-unstable, and is also available > in [2]. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=mm/krealloc > [2] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/mm > > Changes in v5: > - (safety) comment / documentation fixes suggested by Alice, Benno and Gary > - remove `Unique` and implement `Send` and `Sync` for `Box` and `Vec` > - use `KMALLOC_MAX_SIZE` for `KVmalloc` test and add a `Kmalloc` test that > expects to fail for `KMALLOC_MAX_SIZE` > - create use constants `KREALLOC`, `VREALLOC` and `KVREALLOC` for > `ReallocFuncs` > - drop `Box::drop_contents` for now, will add it again, once I actually rebase > on the original patch that introduces it I'm trying to put your series on rust-dev, but I hit a few conflicts due to the conflict with `Box::drop_contents`, which has been in rust-dev for a while. And the conflict is not that trivial for me to resolve. So just a head-up, that's a requirement for me to put it on rust-dev for more tests from my end ;-) Regards, Boqun > - improve usage of `size_of_val` in `Box` > - move `InPlaceInit` and `ForeignOwnable` impls into kbox.rs > - fix missing `Box` conversions in rnull.rs > - reworked `Cmalloc` to keep track of the size of memory allocations itself > - remove `GlobalAlloc` together with the `alloc` crate to avoid a linker error > - remove `alloc` from scripts/generate_rust_analyzer.py > [...]