Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp295229lqs; Tue, 5 Mar 2024 02:10:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqJZYQNwJcnKoMM5tbZumtU5ADafJfoFsAJamwnKqSbflbFggbHvigI0Q6+upKarIlfDpHd2XYewFDETJyeIVHTXgDHtP9iyh7TKVrLg== X-Google-Smtp-Source: AGHT+IGiQ5OMwYdEK1YNPARbZDpyxpe5yCevth9RcNEuLzUTXd5mpuv4j0xhHbgkfGIveYH0ASGr X-Received: by 2002:aa7:cfc6:0:b0:567:a53d:1c10 with SMTP id r6-20020aa7cfc6000000b00567a53d1c10mr236117edy.30.1709633455563; Tue, 05 Mar 2024 02:10:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709633455; cv=pass; d=google.com; s=arc-20160816; b=TST+nO+afT0JlelcjTY9/BXRJmEvJhylKz+krakUSSpveVne44ew54Wmym8XlcbjZ4 vCo1ph75wyD+a0FlDApszrQxZF139+zeXPAC/1z5cYdlYPDynVdOd0jSSyDq5iP1uThq 2hyGl5OiDzergoqLRcipeN17herxIrW3vfuloxm/dtez/v5Q8TfDVLDcS2KN6gh3SzBT X1J12ln3hHqZohZqIjq4Fdznn4Q3H+UkaX7DNCLw626dkn1WPh3c8CM0jUncanOYwlvD zauwGegdGs5YRJN1VQVhL8lf7I38g5SLohz+Cd6s/RZTChhf0pHqqwWhIlue2F7tUQjd Fy4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=D8rMBFW0tg47V1vhR+hT7ZAeuwLlaibSycxaH+YicYQ=; fh=LcqwzXHSk8vZqq9oSJQSEUJuo6FkNWOLwu6x2xXuOXk=; b=pvcVd2qn3/9tO3n+UEpxhJit67j26oG8EizDPoRdGmDEheSByDuWYXSMjaOGvRKLwW vT5/uLtPmroJdvAlBtBBhQB2ViLIL2xI0TR4Havi60pQpX5rfbuBrv3AtYAJ2cY9mBws tqU3b5mo6FHoJ8pijZG+qKKRxoC1QPIa9EHAaQlsJHa+LcppZ4T4NaMVrFKILqRIoVcI klEuLYsoXikj3Y0JGpPSySvxccMZwlKeEOjq0kPHXv1NmasiYjtEMeRnX3LQ9Vjm0evT ggx8yEbCyec+2KJ2ox+xx9Ka2wDXMRe4cMzXMDSStUzy9Ne3luPfnp/SpfYbzYVrUKag y+ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VnyWQvGo; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-92050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r25-20020a50d699000000b0056724e587b8si2495746edi.252.2024.03.05.02.10.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:10:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VnyWQvGo; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-92050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 26A311F219C4 for ; Tue, 5 Mar 2024 10:10:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4647754BF7; Tue, 5 Mar 2024 10:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VnyWQvGo" Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEB6F5490B for ; Tue, 5 Mar 2024 10:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709633430; cv=none; b=Cdhm/UxbgOgkWAStbKoFYtzLCv/QEK9jy06U+rpJNL0bM3J4lhola/oKBAQgrN2zoSCJZWut55W5B+KmCrBtLQyPYkrFBOhAs/HPhvdnYPQLxO6hsNpRU7xLUyMk1CkmSPAqh0k62UBjpSHzp06D9+pS3u9RuDdfcaISGEWxc4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709633430; c=relaxed/simple; bh=Wyo8wzm4MTDz4JStiYyO080jO0R+E8V6S6bv9ZTR4iA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=geCDlgPACiAHPxeHdBAgCbqRX6CGHA3URgC4UZ/nxjuSWDI4k2NM/1YnQ36S2X7HIv8+2cA3NV2NwlzE02OMsVkE9/bDB293Xnglm+96NuNLgMetdLuNFoRrq9C5lHmbsfyj/IyrluZZOEhged9o4jpF44POgJ925p6uNJOayGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=VnyWQvGo; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3c1ec2d05feso961355b6e.0 for ; Tue, 05 Mar 2024 02:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709633428; x=1710238228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D8rMBFW0tg47V1vhR+hT7ZAeuwLlaibSycxaH+YicYQ=; b=VnyWQvGoaTrXEWac3DWanC0wt1NS9T9vvxs3BxvbDsM5KF/8Nfn8o/Pz4snNDmj72v eby0QoOYbUA1lQlEnKfMK97JUMbps0xP5dJmqaBY/2xaND9S+Z1wBBqRFkZqlI6eWpmp jPmLVRClTxt2ovLmsrd1pTzTPL0ayxxcTBz3M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709633428; x=1710238228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D8rMBFW0tg47V1vhR+hT7ZAeuwLlaibSycxaH+YicYQ=; b=EANnZvQfB8GgmqbVsCsrt0J5w7hWUkFQR2+IXdJvayfOYo4buIcJ3CCagItz81SeKg HuvBL4YY0mKyJNqsvRCRM8gJ3qzivTWSLe1qcystKyuh5eiWnhX2t8tGYf7F+WELfdiZ lZ/pFF9FIn2u7kbRYBZo+gDjkS9LIl36b168nDIJW15hBWWJEEvwMCphF3gHggqefZSs XePT6WWZYwClSgXs+9qQSgTBogi6b7eAdUaAc7lj9kyI9dR/8K/8BdvwIvbZIyk/WezY zxbLwsMaNYFehcv+LnRp3WvqnwGdN2rxOkK2QevaRURJ4wHFBmEAiP+Gn5ZR/mXoKJr6 xqVQ== X-Forwarded-Encrypted: i=1; AJvYcCWD55LaSCjUvdGJprqdnOibGYQx+gLJsa8TwtlMOEGpMhoC2hjVd2odLMqXzIBCJxHdy9+/Xj01IA0J5ODhLu5MWHPtqrlFxZ5cChA1 X-Gm-Message-State: AOJu0YwK2PmsFpd1ijGErvPIEr516+PbdIwSjVIPnCALu9c8pbLZey5g b0JAL3Umw9dnJqRHIzxfLHQ85rupAwkycR812NJaDCQcmFp0WGWDFfCnOPgbGA== X-Received: by 2002:a05:6808:607:b0:3c1:559b:4290 with SMTP id y7-20020a056808060700b003c1559b4290mr1272920oih.42.1709633427854; Tue, 05 Mar 2024 02:10:27 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id y185-20020a638ac2000000b005df41b00ee9sm8692546pgd.68.2024.03.05.02.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:10:27 -0800 (PST) From: Kees Cook To: Vlastimil Babka Cc: Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, "GONG, Ruiqi" , Xiu Jianfeng , Suren Baghdasaryan , Kent Overstreet , Jann Horn , Matteo Rizzo , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 1/9] slab: Introduce kmem_buckets typedef Date: Tue, 5 Mar 2024 02:10:17 -0800 Message-Id: <20240305101026.694758-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305100933.it.923-kees@kernel.org> References: <20240305100933.it.923-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1794; i=keescook@chromium.org; h=from:subject; bh=Wyo8wzm4MTDz4JStiYyO080jO0R+E8V6S6bv9ZTR4iA=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBl5u+QdzwZRrBHJ6q6tZF3ljbnIROOFCv0Jfi5y dLhu0dVnMWJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZebvkAAKCRCJcvTf3G3A JhRGEACXqOYvigduxdiLg5s3NKoZ5sAGZvlIOApR3AAy5NlVdVm3El7+ClqD7kAsaRASlCZzfCE SnrdJUJTmH8pIf9m0+2frgqPwuRmMlb09607iDkUQPLPN1YxJMR27tBwJWq9BgA3ubUWo+QsdgT YXE7VP7nPQdqREOzraeyi2MHH+U3DNUaP61lbMW6KxmdVKDTNvRohGXZ4t+fDkAx3qPc5WUijJu +T0ZdLwbHIqRgXmTleQTynxNAt+ias93uGlGLgEDjoQZXs3asvnUvukRlD4dRoL8Jw9iQijFq1Q Dt4OD7yUPU+PD4XJr3GZIJhcJtIYM4IVHGlAVfYnKDclM8zlcITotaYHXQpXMql4PslEEE4eao3 2lj3oguta9XJ6ZA8lMy1oJUDczWNwOLRtiE4ocEojO7GA2/sMkSDKFBWiQoXoqqozQ72/GOfjya z0P7wyB5UCUQt13UQzDHMpYOQ/D5+iqge17qSf3KrlYD3bDZTO0UxJ6zzyDqVGApKdVJXmzv1nS 5BCsV9JIyHRHMs1bxaWyexVgrO27nMe+VW7LxuZWBm53lHjxxXQXT0bPu26dEUkeQrRMBN6BrfR Hi8QkUDZmoqSL/wiOIGv/c+qZfMpokFWp+beQoz6lhK2cuoYx+8nFdtG2JAcDlfnXKJ5RU+DLD4 BUBdZTAp9dA4F9w== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit 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 --- Cc: Vlastimil Babka Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org --- 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 b5f5ee8308d0..55059faf166c 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -375,8 +375,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 238293b1dbe1..8787cf17d6e4 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -649,8 +649,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://bugs.llvm.org/show_bug.cgi?id=42570 */ }; EXPORT_SYMBOL(kmalloc_caches); -- 2.34.1