From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796305353; b=GEuPcjmEFV2togWPwmbbSEtpeGnJCYbs2EYBKNB9nVHipbxpHKzGLBxRfZ8zKowJEvJZ JqpNWGmDcxO4LMKSZwPEkCyM7x6S7y2mVcMmaLvXsBLh/JGwgB3JP0tjFlM3ZJ3BTMvXp 0gFmzPgEMyzcLAE4q6wMK34l254rPLbELYQLsHuaLuuD4RLoH8H+ftagdNsNO+5W8wEbO 1J63zcNZMIwhwj51hldUoKwoOVgFQcELRWC4+2oLjb63rR6jxvaKEC6kqgzNX3S2I4p5D go29SLk8QwL9sc2EQYs1mtT8ZY47xEfDjNlpoF/AM6nXssKoiI2xJFN6OsUAJO5EFLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796305353; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer; bh=Pm9BMt8IKPQ7U2Xbh6WNxfeAOfmdLucXIMa+Gdyqqfc=; b=iFpJ7LtOLL4WjSmV7PIiaTa7Tpv4vI3cNCGz0jWkpu1TutucX8rwYa4T6/95gi2sgyW0 GjEzwn+0iIaaW0UuxF8p61YBXRLxxbioj3E3Po6nJhyCahMGlaicTh8wy8y56V58wqBdb u+l9Cd2hvhCmvZ37GbbOIHWIGunlrq44Jc2+U9OpzizQZlGZCIossCeISDFW+KKF+j3xA SMyiALdXssj6w/b1lnxK0oaJMlR5n+FCpCdS/TMu3NvhPnW7zJvBoTZb4FSysuR6zUYM3 /W32waX+dqJ6n7Llxv49f91nMAvKjruOxYndt0P6KsVfEcBqhV9wOvky+qUjolpVXFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nmVDXGTe; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8351E606A33F for ; Thu, 3 Dec 2026 13:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nmVDXGTe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AD441F00896; Thu, 3 Dec 2026 13:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796305353; bh=Pm9BMt8IKPQ7U2Xbh6WNxfeAOfmdLucXIMa+Gdyqqfc=; h=From:Subject:Date:To:Cc; b=nmVDXGTeAaoPrICqWotv2xDamKIeMoeUThXVUEEnTP36dadQtdCPOMxatr/bNQVcj u6N0greJVL2XJujSS9+XEcfbd3f99GWgn8PQJPs1vWpSKB0NWMmg348V6qX9qRnE55 n8eIkYP4pdVp37ajy31Y5pii28E2c98IJaxoMl9uC3t5oNzRFGkQH4VNSYiAYs/S7V 0ucVFzWm0Vg9SVO6fV7T7BL4TWXYz7WrJf2TzIAq8aDwRCPWSIQSLkOCBKMya67yGq 7y+pMJpU98Iw15HtbmPjmpiGD3kgLdM3zlf4DFsv1cYOZS9IdahhO/RCplCenoYb5d k7dhbtbo1uzRg== From: "Vlastimil Babka (SUSE)" Subject: [PATCH v2 0/3] kmem_buckets entry point rework Date: Thu, 03 Dec 2026 14:42:17 +0100 Message-Id: <20261203-kmalloc-entry-rework-v2-0-d718dc4fd906@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIALlxEWsC/22NQQ6CMBBFr0K6dgxTtIgr72FYtDhCBVszRZSQ3 l1Aly5f8v97kwjEloI4JpNgGmyw3s0gN4moGu1qAnuZWchUKkRU0N511/kKyPU8AtPLcws6RSU LlIU6GDFfH0xX+1615/LL4WluVPWLa1k0NvSex7U74LL7JeTuf2JASCHLDaoMtcrN/tQSO+q2n mtRxhg/k9Ed+8sAAAA= X-Change-ID: 20261116-kmalloc-entry-rework-a0162912968b To: Harry Yoo Cc: Chris Down , Kees Cook , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 When pondering the boot-time slab hardening features patchset [1] it occured to me that the kmem_buckets handling could be redone in a way that there are no kmem_buckets pointers in kmalloc_node() and two more functions, and we can drop some of the tedious parameter declaring and passing macros (except those for randomizing tokens). So instead add own entry points for kmem_buckets enabled allocations. The first patch is a preparatory cleanup. In v1 it also attempted to make the new entry points cheaper (in terms of binary size) by making a bet that one extra call in the allocation fastpath is better than many functions inlining the same code. Since it was however visible as 10% slowdown in the proposed slab kunit benchmark [2], in v2 the new intermediate function is also inlined. It still removes some duplicated code) and we pay the binary size of the new entry points (about 1k each). In the last patch we however save passing an unnecessary bucket parameter in all the kmalloc_node() callers. With v2, the benchmark [2] shows no difference in performance. If this is accepted, [1] should be rebased on it as it makes the slab_buckets boot-time handling really straightforward. In fact CONFIG_SLAB_BUCKETS could be repurposed to only control the default behavior, while the code is always compiled in. [1] https://lore.kernel.org/all/cover.1794506262.git.chris@chrisdown.name/ [2] https://lore.kernel.org/all/20261129212551.1812084-3-rientjes@google.com/ Signed-off-by: Vlastimil Babka (SUSE) --- Changes in v2: - Make sure token parameter is passed to the new entry points (Harry). - Inline ___do_kmalloc_node() as explained above. - Link to v1: https://patch.msgid.link/20261124-kmalloc-entry-rework-v1-0-37b1631a67b5@kernel.org --- Vlastimil Babka (SUSE) (3): mm/slab: add ___do_kmalloc_node() to deduplicate code mm/slab: add own entry points for kmem_buckets_alloc() family mm/slab: drop BUCKET_PARAMS and KMALLOC_PARAMS macros include/linux/slab.h | 64 ++++++++++------------ mm/slub.c | 149 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 133 insertions(+), 80 deletions(-) --- base-commit: bc8dbe6c5b86e3e6331f589166afb7d310b604d2 change-id: 20261116-kmalloc-entry-rework-a0162912968b