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 4BE97C52D7C for ; Thu, 15 Aug 2024 14:17:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7310C6B010B; Thu, 15 Aug 2024 10:17:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BA2C6B010C; Thu, 15 Aug 2024 10:17:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55AAD6B010D; Thu, 15 Aug 2024 10:17:45 -0400 (EDT) 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 375786B010B for ; Thu, 15 Aug 2024 10:17:45 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D1B00161624 for ; Thu, 15 Aug 2024 14:17:44 +0000 (UTC) X-FDA: 82454683248.15.1AF2D68 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id 626751C0016 for ; Thu, 15 Aug 2024 14:17:40 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kuHd6kMf; spf=pass (imf20.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 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=1723731389; 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=n2LRVP8mmD6yU8tzkGaukgUuyJEJU5u4x6/r0auxEpA=; b=fu2gT5W9P11tzRdt49z8u0Bp/DNYNU86tE8e9n9AHY+hEL2CLK0u0rt9FEn+FOBxsO/R1g wvj7Uhn/qWD7dAhlF9yRqxhHEz8oR7w2NVeyplNowfqlzqnyfViflbYrsnAs4o1qksARPS iraaKSOcvkk/QnfP/zHm+i239fQDPfY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723731389; a=rsa-sha256; cv=none; b=rzoBXIGfrhX7wqJTlT8ZvHlJBjxpM8UGBPFVqPajy8zEZhlfoWpmJnIEDWXU5irkYJ+fgE kvgt9p626nwHUlusL3vlNuTxk/fBOKgSWwtrQOVwca5AuLDBXHX/lrUSEVMmZYrIY0VY29 uVSiRbzIqHff7cM0jxTBw6YmzEJJf4M= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kuHd6kMf; spf=pass (imf20.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A00BCCE0D9A; Thu, 15 Aug 2024 14:17:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A1FC32786; Thu, 15 Aug 2024 14:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723731456; bh=Kby6yhzXoUk+UkDsvLSOc5svMZXjS9dbjQp2GqhLQNY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=kuHd6kMfGvDjRn+edV5fGItrR6OXVpZzUpcArLByZhhRNzXDa5CL6Sh2EVHSdJnRz 2b4JgMX/44zfYQj6M1pwTs/syPaRkVIPPv3IlrbeVuBJMBj9E70rWz3mc5rXSxj9C3 VoDRfa2tMUn3FLGOG+rHOg6DLyT2H3QnNI4TY5M6qjGmHkFsIOFTHIP4EO7pZjZFRc kvFF26IilTJMeFi8CZGPCIwhdi7hE+cihojFF2S+E5I94XD54XrpeU6AhSyQ1ihLMH EugGWpLHK+wqvJWUscTtooPQf2abet8NVMYNHzntIbUBNmFnwEXXzv7aGdu/yzF7SP UFnJR9ytvnKpg== Message-ID: <3ca1824a-8918-460d-bd99-fd88cdf92329@kernel.org> Date: Thu, 15 Aug 2024 16:17:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 09/26] rust: alloc: implement kernel `Box` To: Benno Lossin Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, 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> <20240812182355.11641-10-dakr@kernel.org> <56ebda7b-c570-4dc6-8456-ab768d3a4b77@proton.me> <66ed33bf-b17a-406f-b277-501ea9f002bf@proton.me> From: Danilo Krummrich Content-Language: en-US In-Reply-To: <66ed33bf-b17a-406f-b277-501ea9f002bf@proton.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 626751C0016 X-Stat-Signature: pqw571b3tm8n5mkuw5gtr86c33enybmj X-HE-Tag: 1723731460-951278 X-HE-Meta: U2FsdGVkX18Z+A4MjJWihy9JEEVe0m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B2OwO14bEZVRm+mUe9Ku9F3SiO9AlQeVkCTFYO98qgrHfTyGIwAiAVIYU5mqJN09He4nx1HWTF7qYdeOooQgFuU8pkchJkp2QStECUwf+AocKZpkUckMky4368CYEpkPq86nRTg1Rha783dThdFpXE6P5Vc/gAHt1CuLADNtu5g5Pabya3pebFJ/3HWlepAAcsKTcsEBGjTopo= 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/15/24 4:10 PM, Benno Lossin wrote: > On 15.08.24 16:00, Danilo Krummrich wrote: >> On Thu, Aug 15, 2024 at 01:24:47PM +0000, Benno Lossin wrote: >>> On 14.08.24 23:58, Danilo Krummrich wrote: >>>> On Wed, Aug 14, 2024 at 05:01:34PM +0000, Benno Lossin wrote: >>>>> On 12.08.24 20:22, Danilo Krummrich wrote: >>>>>> +/// >>>>>> +/// # Examples >>>>>> +/// >>>>>> +/// ``` >>>>>> +/// let b = KBox::new(24_u64, GFP_KERNEL)?; >>>>>> +/// >>>>>> +/// assert_eq!(*b, 24_u64); >>>>>> +/// >>>>>> +/// # Ok::<(), Error>(()) >>>>>> +/// ``` >>>>>> +pub type KBox = Box; >>>>>> + >>>>>> +/// Type alias for `Box` with a `Vmalloc` allocator. >>>>> >>>>> Same here, add that this is supposed to be used for big values (or is >>>>> this also a general-purpose allocator, just not guaranteeing that the >>>>> memory is physically contiguous? in that case I would document it >>>>> here and also on `Vmalloc`). >>>> >>>> Same as above, I'd rather not duplicate that. But I'm happy to link things in, >>>> just not sure what's the best way doing it. >>> >>> I took a look at the link and there is the "Selecting memory allocator" >>> section, but there isn't really just a vmalloc or kmalloc section, it is >>> rather stuff that we would put in the module documentation. >> >> There are no dedicated sections, but... >> >>> What I would write on these types would be what to use these boxes for. >>> eg large allocations, general purpose etc. I don't think that that is >>> easily accessible from the docs that you linked above. >> >> ...this stuff should be covered by the document, e.g.: >> >> "The maximal size of a chunk that can be allocated with kmalloc is limited. The >> actual limit depends on the hardware and the kernel configuration, but it is a >> good practice to use kmalloc for objects smaller than page size." >> >> or >> >> "For large allocations you can use vmalloc() and vzalloc(), or directly request >> pages from the page allocator. The memory allocated by vmalloc and related >> functions is not physically contiguous." > > Yeah, but for that you have to read big chunks of the document and item > docs in Rust are often very short, since you only need to know what that > one item does. In this specific case I'd argue that the contents of this document should be read and understood by everyone who attempts to write kernel code anyways, hence linking it should be fine. > Would be a good idea to talk about how we can improve this at Kangrejos. > > --- > Cheers, > Benno >