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 6271EC3DA4A for ; Wed, 14 Aug 2024 20:53:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A63886B00C4; Wed, 14 Aug 2024 16:53:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A14796B00C5; Wed, 14 Aug 2024 16:53:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DB8A6B00C6; Wed, 14 Aug 2024 16:53:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6FE556B00C4 for ; Wed, 14 Aug 2024 16:53:52 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2A4991211E4 for ; Wed, 14 Aug 2024 20:53:52 +0000 (UTC) X-FDA: 82452052704.05.99AB8B6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 58C3E18000A for ; Wed, 14 Aug 2024 20:53:50 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=J0zFhJJg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723668750; 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=MfmwKEjVevQ6BjMvy2J3CtNB1rS83E0HllQXWhuHyQ4=; b=07pFSPx+tuFfH/5/mCcI7RKCcHdX96lrYgm8+v1SXpzMgv0L0nLpv2vklnXM46N6azjBcl KxlnKVG6D41PwTxoOhdthwnEWJmSZqcNXuNcm0Uu3wIuItgpgRBnZYZXurtyvtnk+2/WvX P/18jlFOBNaviTSRF9x0mBAkKJuKCvw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723668750; a=rsa-sha256; cv=none; b=SRj4Pf8P1cPXXyIyCrSfTIjzJvIXDypffVOj70hDL2CSFyAvd+obEQpfBQBF8KtYrs8Zhd 5xss6OBaHa2cv7qU+hsjmIqB89SsOvoFPSwRYu6FHhcsFVczsMinHlfxoIh5jHwk8gc+eN MxoOOZ7X0d8CVT4lvu6NtS6HXCuTxw0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=J0zFhJJg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7CCCA61CCB; Wed, 14 Aug 2024 20:53:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E95BC116B1; Wed, 14 Aug 2024 20:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723668829; bh=b8U7/CVYHFqEb0myiU2fWm7aWYNYOtrimMUhZTNfUoA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=J0zFhJJgVxjIWb6mDLr2ZcnWHqCV8whhcOoSvCgqco4CtV44gEGmdN3z3KyFoWurh yhdV4Yd0OdXXlSiEfo0ojfadxkPP1Qqhvh5t4u7TnxAarU3gKqWBbJtkwi2Q/1cn59 vKthCyXWivsTZzW+IbPaNb/YFsgfIegWFa7rydgcGqsSbzcJpUWMmBXIrs/QWuWOyX ILU59WhDNJniZLQetykQBgXZ71+ZFoVRLyXE9P8MYHOdNzH/+OQpA4Uk7xgb0VEoOf /BTUloyoX1aZN8VCjPWZ1K3gFyLq8tAt3H8BCaE7oFMw8C0gRzXzrS51439tXvWIvC B4NDgBawX3kpQ== Message-ID: Date: Wed, 14 Aug 2024 22:53:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 00/26] Generic `Allocator` support for Rust To: Boqun Feng 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 References: <20240812182355.11641-1-dakr@kernel.org> From: Danilo Krummrich Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 58C3E18000A X-Stat-Signature: ccukmtrq364o7f8hq1yuys4katu3kgpm X-Rspam-User: X-HE-Tag: 1723668830-627225 X-HE-Meta: U2FsdGVkX18vC6Q39zuT4hBvzUt2Dsb2dPrc3RXHuAu6RhlzdGt6kAuw1MtWQmNZ6BHb5dTen38XsjMKNL0092Kzy8PfMZ5v0COqbYyWMqBhAyLZkLubHmUFs2ETzCrxwf3AlrU2XCqX5Co8SSo9/o4CFVtqHcxE/rS7TICKYihmJRJ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ZLFJbOdD7mdTIqu80KaBMG5+1Su8wDNg9uwHnviD0HQeKANUMSSdkCNx3z+KXFatzKFq8cAl+/oeYZvxcXpQqMsXtfsTzd5RBQsSHujNwwlTCG7UOVCUOhxhLeB6ZHCfe4w1jqDA= 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 8/14/24 9:32 PM, Boqun Feng wrote: > 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 ;-) I'll rebase later on and send you a branch. > > 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 >> > [...] >