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 46146C3DA7F for ; Thu, 15 Aug 2024 14:10:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B98E46B0109; Thu, 15 Aug 2024 10:10:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B48286B010A; Thu, 15 Aug 2024 10:10:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5E146B010B; Thu, 15 Aug 2024 10:10:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 880026B0109 for ; Thu, 15 Aug 2024 10:10:35 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2D4ED14017F for ; Thu, 15 Aug 2024 14:10:35 +0000 (UTC) X-FDA: 82454665230.15.969CDB6 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by imf21.hostedemail.com (Postfix) with ESMTP id 4C51D1C0018 for ; Thu, 15 Aug 2024 14:10:33 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=proton.me header.s=protonmail header.b=eaqSD0u5; dmarc=pass (policy=quarantine) header.from=proton.me; spf=pass (imf21.hostedemail.com: domain of benno.lossin@proton.me designates 185.70.43.16 as permitted sender) smtp.mailfrom=benno.lossin@proton.me ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723730952; 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=BDHaQFo8dDeUDSWWnczHxuH+Hb4dCYs/6Cp/V24JuiQ=; b=5qr8fT9J+r7AbAHZkFteuuCVTd+Cje4zQp6F71SrM5i9MSal0TQV085uskJpn+dPaz8aZX k/g5G77E5yKGwutH6RuvcNHO2xEmnuCVa1A0zZ7d6nITLp2iBWH1a5PBugh5oIFrmD73tD lhRzgDw7REcB89tjUBZbdf4LlHYqZ1k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723730952; a=rsa-sha256; cv=none; b=57bsfqkdi0sKK6UGgVXWw+ajMHL+X5Qr16Gqrwp5NuJixmPdmBrFXMQqKQBBghhVLurCnM lVMlGA3Ft/OWmJAxM/HKuwrmmt5V4JQ1ws2j0igvVWO786lQyPV9w9ZqRJvisaes0PV3Fq 8UQzo6bIfpQA1MoJObGE+XfzZ11/hwA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=proton.me header.s=protonmail header.b=eaqSD0u5; dmarc=pass (policy=quarantine) header.from=proton.me; spf=pass (imf21.hostedemail.com: domain of benno.lossin@proton.me designates 185.70.43.16 as permitted sender) smtp.mailfrom=benno.lossin@proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1723731030; x=1723990230; bh=BDHaQFo8dDeUDSWWnczHxuH+Hb4dCYs/6Cp/V24JuiQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=eaqSD0u5FIVhekwomHdqa7qqVPhLldaCA2i9Uer6UkdNF+AtVw/u59xrQ24n14Ykb ogdgNAx9ikn3GlbX4HGHbbbNuoqz1N0c00lK3saGzWZPTltSbuIS5ga2FhLHBOZpRy Ufwm+37qwf8EIPjE66iMmbsSwif/LtmYwKywwybZraLauX0rmc47xRDU+AXV0TYBsZ 7LreQGALq77u/wCqW1j5XIVKjGnr2nhCyiFHUBFcpX4d4d0/xbqzqzsxRjzsl+Guyh aRPXfR2qqwxSYYScz/nZ2ilyt3UoAiGyecPdsTPQqWbZP15iMY6Cr7rq+PKzFniasl o8xbdXbqrzDmg== Date: Thu, 15 Aug 2024 14:10:24 +0000 To: Danilo Krummrich From: 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 Subject: Re: [PATCH v5 09/26] rust: alloc: implement kernel `Box` Message-ID: <66ed33bf-b17a-406f-b277-501ea9f002bf@proton.me> In-Reply-To: References: <20240812182355.11641-1-dakr@kernel.org> <20240812182355.11641-10-dakr@kernel.org> <56ebda7b-c570-4dc6-8456-ab768d3a4b77@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 90b6225e273150ef957894a0d74fa40346620329 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4C51D1C0018 X-Stat-Signature: 7suaiwmmsydaf9kmqityubk7rjbuyb98 X-Rspam-User: X-HE-Tag: 1723731033-780915 X-HE-Meta: U2FsdGVkX1/oPnFWKHiLFGCziKZBpyuJXI7ULZJwdaDnV6Ld2HNTYtw1+CLvej7mBVH/5N1gUbt6n5g/AMwIxjjsCo8qiqDfWhrf+89ceRI7faAQRaL5VkiHOI12O0Wyy7dplvZPTpICYXrg1IJrTmPThj1LPS5lyP3+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phmHX0ock+Iw0PwS+ym4urDBpykfkP/7lkmtICKbhDKWp5epLK2FC/VRCbZI2lxg3fjIN7O9NrsJ5vghEY3zE08VXy5sRH+3D3rQ7GRQtDldBp8NxCxI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000021, 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 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 =3D KBox::new(24_u64, GFP_KERNEL)?; >>>>> +/// >>>>> +/// assert_eq!(*b, 24_u64); >>>>> +/// >>>>> +/// # Ok::<(), Error>(()) >>>>> +/// ``` >>>>> +pub type KBox =3D 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 thi= ngs 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. >=20 > There are no dedicated sections, but... >=20 >> 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. >=20 > ...this stuff should be covered by the document, e.g.: >=20 > "The maximal size of a chunk that can be allocated with kmalloc is limite= d. 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." >=20 > or >=20 > "For large allocations you can use vmalloc() and vzalloc(), or directly r= equest > pages from the page allocator. The memory allocated by vmalloc and relate= d > 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. Would be a good idea to talk about how we can improve this at Kangrejos. --- Cheers, Benno