From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B3A13B2A0; Thu, 25 Sep 2025 18:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758823698; cv=none; b=Oinemvpeww3lU4XCl/+fAnnYGFaKPZMOl7I4Xex1WMtT6w8sSvPsmiMM0WD5ObKmSc5rRSXki+9LdeTfkdmeX/SEu1d+keljGNxK1reUwk1xFy/eUC7/PIzgTnab9k/wrrc6pcDIGmIL90JbbNG3kJk9zL5fmULixNoGR0Wu2m0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758823698; c=relaxed/simple; bh=IhODLG7SpC8UqyOFOuzbmh0gcIPtUBtutMgkCPYtEUk=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=jOGYwBLFZ9p16NJJzqnY7v6CnJqMHkhAMnzjYXivAlY69n/dBV5uqAuD+l2Iehra23a1VRA6rP+fSLtvmCqiL3YZbomzvcPJTB4v6TxGY5OXCQ2VHk4dD1W1VuC2i3NDE7DCoGMYYaRQKJkbhWb5wmNZ2pahh7ZFkL5JuLqfFg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VCu6O0CK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VCu6O0CK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3DCDC4CEF7; Thu, 25 Sep 2025 18:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758823698; bh=IhODLG7SpC8UqyOFOuzbmh0gcIPtUBtutMgkCPYtEUk=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=VCu6O0CK3C1ef63EnTIG+lUmaIsdZkkSe1ltZTKpv+91uTh6+AjhH0TkIsDJJy1Us AIcqy1EbJe/0A6P/lr1YLsOkv5kUc+dhLl33PWTq2LSCeEXhFCaKAvrd+xhA7b546P 3CWDoQc01y+F1MYSoCIqWM/trQ7FaCxKUApR3QpeRphIY8FE2voJMj/gH2nK/+vTlQ ndlsHXiGA0f57OJkWXLJ9PUTJKQ0IECqwTG5OaHDHihAtmnJpoKmljf0T9f2cu08wz WF7Sj+sPjU3rfdgQ6DOUK3RUAbKQg3V1BwyLw4G/8qdx1KykUGS9BXE7XnYSANZP3O tkYHsJILaJzYw== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 25 Sep 2025 20:08:13 +0200 Message-Id: Subject: Re: [PATCH] rust: slab: add basic slab module Cc: "Elijah" , "Elijah Wright" , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , , , "Lorenzo Stoakes" , "Vlastimil Babka" , "Uladzislau Rezki" , To: "Liam R. Howlett" From: "Danilo Krummrich" References: <20250924193643.4001-1-git@elijahs.space> <73d7d53f-439b-44a9-98ca-0b1c8fbc1661@elijahs.space> In-Reply-To: On Thu Sep 25, 2025 at 8:02 PM CEST, Liam R. Howlett wrote: > * Danilo Krummrich [250925 13:43]: >> On Thu Sep 25, 2025 at 7:20 PM CEST, Elijah wrote: >>=20 > > ... > >>=20 >> > I was thinking of maybe creating something like KBox for kmem_cache bu= t=20 >> > I didn't want to touch allocator code yet, I figured I would just crea= te=20 >> > the groundwork for that to exist. rbtree.rs uses KBox now but I'm not= =20 >> > sure it should, at least if it's going to scale to many nodes >>=20 >> Ok, so you want to support kmemcache for rbtree nodes. Ideally, you shou= ld also >> have a use-case for that, but given that we'll also need kmemcache in ot= her >> drivers (such as Nova) anyways, I think that's fine. > > This seems different than what exists on the C side, at least to me. > The rbtree is implemented by embedding the links to the prev/next into > the struct which is using the tree. > > The above sounds like the nodes of the rbtree are allocated on its own > and not part of another allocation on the rust side? > > That is, the kmemcache would allocate the struct that contains the > rbtree linkage (or nodes, I guess), but not the nodes alone. On the Rust side the rbtree's Node structure looks like this: struct Node { links: bindings::rb_node, key: K, value: V, } The allocation would be for the entire rbtree::Node and not only for the C struct rb_node.