Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp708978lqd; Wed, 24 Apr 2024 14:41:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGifq79iZ8AHJSekRvrZcGwxFxbpbAsUxghBpBabgkG22RkKFesgrAMhhhNBKfTXIDyNAK2CQAWwHikxlSUUEhdi8x+NA8ybTwE7I99A== X-Google-Smtp-Source: AGHT+IG3YXy6ASZiPo2shDireHDIYfZ3P8xqHPIVVHlLS6iSFJPZBJ5Cy5FyM7m8Ux36jLbjEvsj X-Received: by 2002:a17:90a:5513:b0:2a2:5e65:f434 with SMTP id b19-20020a17090a551300b002a25e65f434mr3648088pji.16.1713994882682; Wed, 24 Apr 2024 14:41:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713994882; cv=pass; d=google.com; s=arc-20160816; b=TWwKHL/MFgNc6hp3l37JqpfO4OGBGe3nAlnTdPESs04rmkMqQ/g7pDqSZw1JCntMcq UihB8B+p3imU/qcofZyquSUuA0bdm7w8Uvybj8YWvtsQgDNo8a3ebV46EEPcSQ3vwZdW 83o4W0Ur9rkWpWB//zusUw8QHXGW8KLFYUy2r/HQxH2vx/AeKINu01Oc/kjJv1x0wn7P fVupi5biokNEuXpi+f/WSoGbmqnSIkGr0c9+6igh5GtiyxHFfpRo/pXhMxX8D4DX42Ze /ch0PriK8mvMcN1pWZXCn84ZW4aZxbGF7bliT2D/bZg7wmFYvEbhbdSKNf1s3hAIn5cD T2Qg== 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=6DE0gOuM6fqjcPRbynz9LQpOkql4Ebi3pYsD8G1TJgY=; fh=5JJxyF/e0bxsGEg4Kq8WZSeFZwthlemPAyW2T2IRD5c=; b=0gwWH9JtA2ujQrYrEZIVkXW+KRZ0UTfzuZJLI7oJp1lZthn7zN5EUN32xyaMP30r4C 0EAlze7+/kiMfSQz3OePsYIRHtUmfd5ujp4DnOcOZ1YYKYqRiCZUADWePHhwusS8kYpv nkPlSfDaKAeLTVTYGTqagd9TRjdAmRlnAVf4nGSRdSrDmeIqGf589ly0hFlklukY1SUN AmO+ETKpbjeSzMSD0aov7FIc//JS9vXmTzSdmTjrjWmaYYQWOpHJGpYhNksc72w6yo2O 5yb0NqnrB74k+z4ugc9sws0v3SydJEQlloBkAdq0AJSaMGd5zjIoqUlGcDuW88VRGNla /Rnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FIdBORo9; 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-157742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157742-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q41-20020a17090a17ac00b002aca29d0c08si8963933pja.105.2024.04.24.14.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 14:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FIdBORo9; 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-157742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157742-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4A19F286A45 for ; Wed, 24 Apr 2024 21:41:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA85115746F; Wed, 24 Apr 2024 21:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FIdBORo9" Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 90766156999 for ; Wed, 24 Apr 2024 21:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713994870; cv=none; b=Ic9FXJblM+3tjPBen8glPvutfBzT1WwgOpClcjzuJRp8UmAQeKMyvHL0zIT4wk3Ceo1C6cX3G5zsuFin8Leat9oD5LuC5Xb4XwoReIZ7BiIAeVjPjMoWbk+5E3qNaAG3gbyTw1eMP8/GGL7Bl016Rn/jrDKeX4Kvqyj+43FyzEs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713994870; c=relaxed/simple; bh=dMZ82hcwMjPtLdK0cTsVIA5XzWAQXcfcJoTMZY0cUd4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mWE9RxejAl7YUS5JP1EyuKxZcn8+cf/o5IojUzRKN6HpRP4NzbLk+aLUSyg37HG2loJywnSIhNxn6KjJgFllMkMmSlQ7BQ6CrXbsFsKCyBPg1jfvJo9+/NDW9ahOOLRa+3CqSvIXQaUeptnTreMaorWqtJsQDdvlBpTf6zZA5is= 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=FIdBORo9; arc=none smtp.client-ip=209.85.210.53 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-ot1-f53.google.com with SMTP id 46e09a7af769-6eb7ee5a776so226606a34.3 for ; Wed, 24 Apr 2024 14:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713994866; x=1714599666; 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=6DE0gOuM6fqjcPRbynz9LQpOkql4Ebi3pYsD8G1TJgY=; b=FIdBORo9AaGGGzddaCAjitXb1Cywj0IxdJ7FRFSKoKEDio4C1vlyUkc1/gVptC1VAh QWMh7h0ldujnzpmBSuI6DswWZocKg6fKPo42+m1lgAPa75yupMC9e+1oIY7pgRopcCVp HwEpBS2QGNWnV5nFHiW5Cr2GzBFX9lGdZZxjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713994866; x=1714599666; 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=6DE0gOuM6fqjcPRbynz9LQpOkql4Ebi3pYsD8G1TJgY=; b=brWCxtJUZJ2UUYUpeP6FmiXBSlQSbKkcLkO9jS4mgd4Yqp06U6kJjJeOIljIrcfwis L+iifdzcYgUdsCLS4d1Gu8qeR9pQKGyhz72ybSzvWJS/Ix5sMBMKQXVPNskGxAylRh8F PZ5yNixYeKV8WRE4xMHoRGn/j8xPMDugmNVLFl46cwVwOeozpryf/W6McdvlrLy1Mcgj L7vwI8xduvEYwYukxgccQG6dK5AIDeW/QBVkSUF/EmQ21EBpW2XQep61HQSVdheEv1hg Ur/QxbICPEk9fIAQXhy7sysi1pyjcgNSrqIytianGOHR6kOBMnjWsS8MgnAvpe6ohF2b bxpQ== X-Forwarded-Encrypted: i=1; AJvYcCXQjD4u1oGOC/1ARGAzIZpdzNJBjRk0lqFWxwMUjj7z2WFd/n/cs9MXU3cWHjSW4uDjaq2dGkR3eZbx1lF151y6Rdpo2+lqP6kOIkw1 X-Gm-Message-State: AOJu0YyfPvBvKujMPcT4+3hdE5k2VTf9J+ojB5Mx6eXLYj5+WwGYQpB2 HPbNAJe+kNfjhvluD8ctjOpmU7Ascpe3sLPR09IAwmcFBRNaaCuJVY1w52PnVA== X-Received: by 2002:a05:6830:1d61:b0:6e6:b125:b8d0 with SMTP id l1-20020a0568301d6100b006e6b125b8d0mr4471407oti.13.1713994866613; Wed, 24 Apr 2024 14:41:06 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id i193-20020a636dca000000b005f7ff083182sm9774009pgc.36.2024.04.24.14.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 14:41:05 -0700 (PDT) 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 , Thomas Graf , Herbert Xu , julien.voisin@dustri.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 1/6] mm/slab: Introduce kmem_buckets typedef Date: Wed, 24 Apr 2024 14:40:58 -0700 Message-Id: <20240424214104.3248214-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424213019.make.366-kees@kernel.org> References: <20240424213019.make.366-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=1775; i=keescook@chromium.org; h=from:subject; bh=dMZ82hcwMjPtLdK0cTsVIA5XzWAQXcfcJoTMZY0cUd4=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmKXxu1YqNqwqk+P9UKDsX65CurgWZ4S/pDrKwg o4x/WCX9JeJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZil8bgAKCRCJcvTf3G3A JgHJD/47Q2MOcnzIviSgiD9VouiFmZpwzwVRRYkpLKsHQDoOvqMkZvk/eKBcgJq7gI4b4L0nlze 3A4oC+r7H2g5vpgNw2p9z0EvkqMxob05GHM58weuoSuAoQlXoGaw8CGnTLUzMStUBs7/mjNJP7N jOKumU3iDrflgcJc8zmRfTB9E2KEATWvOZpmZXea50xRjV/3n4cNGXAFgjVoaJv0vle6qpuUpb6 4OjdpzYsgmcST6rSqXidR/GKMAB9VIysWDYtFpipd8ZaFlRYrPqxbk9P/tbMGhgzbo+vVyvufOf 9GZtcQ8ed6xSFYIBM/lH9glEEfR8YyZQxwBlds599HevRmXmoSWUPAj2emDPcIvv9Nf/tBXqHHH EWle9HYub+cnGXO/ZZ7LHLFRn/1xE9ZnjnDir4uCUoHG2fQSN2yQimLPC7cQJ+aTFR+m0dAh/c/ IuScgHhC15yj0hphSDAQKOWHZdYclS69YaXCB6e8Z3GigOOs7SyRG+YXT5td5GtFI7ySlTKt9ql FdT7fBLlt3yFZUbcU9V/WM/2KZIR5WW8tMM2o74bV5l26yXIbdLO/yM3/Xy7OqmuhR4PIKn84Hb XLjEi93Mic+97/CkVzIvgfpa1UrRqOJQZVeWYgnDsADwKhZyn5oSzRhJesWrnlZSD/WDntlCm6P 3QTXTa8PTS1ijDg== 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 4cc37ef22aae..c8164d5db420 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 8664da88e843..db9e1b15efd5 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); -- 2.34.1