From patchwork Mon Jul 1 19:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13718558 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 2170FC2BD09 for ; Mon, 1 Jul 2024 19:13:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A613D6B009C; Mon, 1 Jul 2024 15:13:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E8BF6B00A0; Mon, 1 Jul 2024 15:13:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A0F16B009F; Mon, 1 Jul 2024 15:13:08 -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 50DE26B009A for ; Mon, 1 Jul 2024 15:13:08 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0444F161D77 for ; Mon, 1 Jul 2024 19:13:07 +0000 (UTC) X-FDA: 82292131656.28.D61DBF7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 2CC3340020 for ; Mon, 1 Jul 2024 19:13:05 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZWa0R0t0; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@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=1719861174; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CxOEO+GaUnU9l2X1JMr3pflfon1oWNou5sDuU09joDk=; b=Hz0bvwf2u3IL9k6GeldhU41mUpIdjPBrTQ3YuMQU6yWj+eJI0aRvREj5SjuiCynJY99aax +IRhMeO0z/O7UG+wfK0PVnkhd9xkUSACMkY2Y0FiMriEuEoicwuyuGSKlCCkYtkfzbkqE3 ukqcb9+exUSM0bgUCNeSneP2QA7Nw+U= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZWa0R0t0; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719861174; a=rsa-sha256; cv=none; b=b1rQIhhddYuqjDm12ALE4elgPlJNveH8xXORo18xBEldsTSPs++vXRtKTH1IbyQHoTkrjL 1aYDD5TaWWKnKfWKOffmxTrWW6Nsb3fcBDNCDBBon+b/ECiSU1kNzbTkbdQ4B/+5yugUtr o4M9bgxy5D2RpyzsUIHcG2plXCZ2FgE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0698161782; Mon, 1 Jul 2024 19:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2F71C116B1; Mon, 1 Jul 2024 19:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719861184; bh=jbXDHZFgMTEqVuIbGpjVHki9R28/opuEqbu8dA+PhS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZWa0R0t0CPMjfv3nmnvMRYyT+0Li3uUEKN+F63bIWHM5FgA0Zb/H43PrpIm3S1wN+ cSuMAUVGcDq0VPaulTBXEjeP2l0TB9xjG+2UEbX0qsjc7rkvAiBsK7+I89ex7LZgPn gSDpEciVyMFmJKwREVaeNILwLmK/hGuEJS/2ULgNgm5mGv1s6E5j7ocWwtsbwUki+K LpaAGUv8GppMD1wiOwENbbpsCWiN8oDvi+xBdQV6MjW9MpuGnMlORr8FgmERKVods9 T5l7dWXqZMYSVX7ZmrKdnfa13VayjeNzXw3WFOR4TiMnCppfx/DXKOHiSND+6cIfI8 fVtSgUXMY0gnA== From: Kees Cook To: Vlastimil Babka Cc: Kees Cook , "GONG, Ruiqi" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , jvoisin , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Xiu Jianfeng , Suren Baghdasaryan , Kent Overstreet , Jann Horn , Matteo Rizzo , Thomas Graf , Herbert Xu , "Gustavo A. R. Silva" , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v6 1/6] mm/slab: Introduce kmem_buckets typedef Date: Mon, 1 Jul 2024 12:12:58 -0700 Message-Id: <20240701191304.1283894-1-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701190152.it.631-kees@kernel.org> References: <20240701190152.it.631-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1406; i=kees@kernel.org; h=from:subject; bh=jbXDHZFgMTEqVuIbGpjVHki9R28/opuEqbu8dA+PhS0=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmgv++6T8pqxaDs77JF9cx/6sa+j5FaKjCYQYlt 8Av1OrjnquJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZoL/vgAKCRCJcvTf3G3A JrDmD/41/LShofUlbbo+pT14hOQzRPFxn19omAUJjuXG/RFbAAjGUsA1LVdU477HcV5iEqq9HwZ yownqKuZBSfRj5jSdbb8lWk+EvNPMJcq/bjuHRBHRVzCIF1dak6lCsCilziR3nDfx0QcIBdh9uM ZfgpyACf83OKtGsnoVrd9PtHkCxzzK4gCsg0cYfwsiMY7lZKRpJkm5Ovl/QeoBlcThOt4kLCnPh VK6h7O4Gi07HVvy/hSMdFhZ/Yg3usgb54keafxYrGlWCSoeYcfA7mccU3Fizf91lu9+yuMRRI+Q B6mnj29oSUPJAd63diYXlmeQHMKkR54f1Ugms2s/O2MuxJ5NN2PeSn3IyL3FbkxJlfCWK0XQ13/ FJoWJFVTtq1PfnOsq/2FR2LpfnPbNPfS/mBp2KVYU1xxcNrOTQ6PmfLN8NZ1dJZnWcctqhlAPvx qAyGmwfuj3emanIzCY/cVU6cLqr6IHmmy9Ejo46YzdG7GTbl1t+0VhPhVwMw+dnIFqJ2tHF6ffU 9S0/hRjxjVGzgpaGI3Rrfzzq/1Rg3PTRcuiXzLrK0K0yBR9YXwRUNuyztoKNbfzA9jitdfiuMBO Ro5XeQMITAZry0tFYeSs/l21CrQNLwzrU/+aIm+fSGZ9J74J2UiWplyhtTCe8DH74SORzWApt9Y atfme+bo8XXfHfg= = X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2CC3340020 X-Stat-Signature: fzexsoyg9mjru36ucgx9j3rwcsxz86h3 X-Rspam-User: X-HE-Tag: 1719861185-97668 X-HE-Meta: U2FsdGVkX19VXiGPhpkMvcylvH6G46chM66qByAcC5tHXvGzHxMkIewFBvRtR3qqOBabeoZB24n3ELm8Iip+8rWFoW8D49qWiOHcHJ2BgaL6/ftdigiIZ9qiSotZlxeLZ14L6IRatie4rHmQ7u6Qic5CBSW0330Ym8CPSHJ9g2iZitAYuT6nMqDvTRxpOd/O1qItK9cpIu3/xmQtap3vWdGrR3Unlb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v5ZadEYngi6dCnHB0+bXIzm3CqjWXlHSAuggS+URr882y9INpIzzBdx3cqhKTFrFV94faficorRoVCzpfa4kMn4Cm 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: Encapsulate the concept of a single set of kmem_caches that are used for the kmalloc size buckets. Redefine kmalloc_caches as an array of these buckets (for the different global cache buckets). Signed-off-by: Kees Cook --- include/linux/slab.h | 5 +++-- mm/slab_common.c | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index ed6bee5ec2b6..8a006fac57c6 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -426,8 +426,9 @@ enum kmalloc_cache_type { NR_KMALLOC_TYPES }; -extern struct kmem_cache * -kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1]; +typedef struct kmem_cache * kmem_buckets[KMALLOC_SHIFT_HIGH + 1]; + +extern kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES]; /* * Define gfp bits that should not be set for KMALLOC_NORMAL. diff --git a/mm/slab_common.c b/mm/slab_common.c index 1560a1546bb1..e0b1c109bed2 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -653,8 +653,7 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name, return s; } -struct kmem_cache * -kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1] __ro_after_init = +kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES] __ro_after_init = { /* initialization for https://llvm.org/pr42570 */ }; EXPORT_SYMBOL(kmalloc_caches);