From patchwork Fri Jan 17 11:32:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13943227 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 9CB79C02183 for ; Fri, 17 Jan 2025 11:32:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1C71280003; Fri, 17 Jan 2025 06:32:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCD02280001; Fri, 17 Jan 2025 06:32:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6CC7280003; Fri, 17 Jan 2025 06:32:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A617F280001 for ; Fri, 17 Jan 2025 06:32:57 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B7204121B15 for ; Fri, 17 Jan 2025 11:32:35 +0000 (UTC) X-FDA: 83016731070.24.07DC68A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id B1CFE180003 for ; Fri, 17 Jan 2025 11:32:33 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737113554; 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:references; bh=aLZ1PM6YyDOwJbiF/v+9hODXAZR70SwR582vHD5wYx8=; b=JglDg5oblFtXcJE+SjYWS/wn0Fjkn8GtQuFtDrg9z2qCulSG0XqeEissTYQa9nktLQurSA 86I9X/oTTYdfThdohcmkter42LZKGdsVAsJIJginRSVVyz1HECWBXtPJOh9bEH3UfVode8 +D3BHQzCTsbudVq4paqjtlAbDC4YTho= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737113554; a=rsa-sha256; cv=none; b=EhZGUphxQtInhIxujHzNIqCMgOOQxohUeCWHrszqzpnpLvVizZPZESpLqU59dCXJw6e1dq 7M3uYltAG+Q+2r4gW77uPCK+GYrSL5i5+fDipYE/WqfaixsF7fyxeRm1gqQkJcRgO4DKwd gnmGS3GObE4HXB9dZSUtrwmcLBm4BoU= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 059F81476; Fri, 17 Jan 2025 03:33:01 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F1BF73F73F; Fri, 17 Jan 2025 03:32:30 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH] mm/slab: simplify SLAB_* flag handling Date: Fri, 17 Jan 2025 11:32:26 +0000 Message-ID: <20250117113226.3484784-1-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B1CFE180003 X-Stat-Signature: 7mrim6nx54r59mhp5zoee6r4pk5fh6ef X-Rspam-User: X-HE-Tag: 1737113553-751680 X-HE-Meta: U2FsdGVkX19CRZLY8wYAQxIN64YNDl3r3nGwSBwy6dKPQOOeFM7OKGFdcPRcsqmrOXX9vQJ/mZ6QP9fRLkyp4GNgoAKn0HNyl1o2B3nbzAMGRs77M2p0SLx00zuGfFcSzH6O1wasDPESInajqRFyWgbzWKFIpECg/bG5iRP5+iklz4ENQK/HMnic8lEbA6OjhhUsg2l1QjZ5dxS1aiDayn8IhnwlgcHaZ3XxTL71J3O+t5mUqMpLYsK5GCVy29wYfZ7gVI1IhLsFziBtUkPz4GCwvPm87fFI24UUE6vPil6Hi59Yc1WFJE3YLkEin8fHCiVTqbxgMjBfzjBoM3dFPDavW+d/KIf5KHw4ayhDbRRzaHyqhPEDJMcxM4QQ/MeyaNWjrJxh9HXnGrsKrdHJNco2BSljL6+ldsK5UvAskQvNgd9hYb2cHeRRfJFvMlO/agtEzTm0szZMtlob1hEPa1XAmQSBWyPQ/RzSy1kmH316jU2Rhvd17c4Iol9yGTpcenAl3IFvPMX8Lb+CeGkcOXyE6WQPCTNJdSTt369fjikYXsmdwX7kZ79sG47grDKNvWy1iGhMj3zJJfPCWzJ/FVMhmwMJz7z4UZXl6C/uVpjNzZ0lovtmnslx/CCREzbLPe4IfNHwzi7y39LwM+M+HzPABwVjnu9ZaRoTcoZSS41NX4b22FZLept8wubQounvdwiBKLOn8ElcZhkJ3DG7Z2KMk6aaLYBWpLCXsPnmXb93sQQFJZjXyLIPURbcGtVnTv0U4sdqmii4Pd5jBK6++gYM8P4XFThHcXaFCOSDpz3xmtXN5hZX+gvP2bwVbtEeVBg12jTWdMbJkPZ3zPnlTMVxO4h2DJwucueTZjQLPT9cvCDT1M20kp36mrtl3VEj4kVjf91OQriLJlRzU7itV4b0t6DvGKTknlSzwLmyp4KJ+ezz7/zESARZXNDKl80nL49jDWsCvvZv+hk9rqW 4NtWKFIW tKylQS5Alm1YnPvCd9I++Ge1hN/dIjyECVNXArm22aTw3da2gpXt5iJiG2GsyGfWU9AeNRJ6wKOhQF0eUitdzjotn+k4sGTx3wTPmjM813f0gqdeDp93I5FyLNkah/9e5UmnZ6zpcAEmBlxGDaoIT8oG2SRniMfHwTMwaZztod3mwd3qB+R6usGnzr46Zk2ZqbgZUKVyUnSx+fHHGAxYggjiDbG+atZbQqNxZurlyZy9jYjChQ7VsBv0S7AO9oxdrRQAYW6UhhTh5ucYMeQHzh/zUT45PYjiz2l531Ht5ZUqArjSQ1oHZibnHgAYQS1tXMxwDk3AcyrLbxB2d3Qm7PMQUzhdaCEimMC9j76Yko1pp/+2qBdJjpN2JwBJWodBTiCTH96sI1r1JYd4H9bdr4ZGozpi1lxDPsadE1mf/DKKkLLelx6f/0ywuEylkdzTQ3p1JFNNtq8sXodskcZCZCzM7nR87udEdQGmwd92TWRa7Irg= 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: SLUB is the only remaining allocator. We can therefore get rid of the logic for allocator-specific flags: * Merge SLAB_CACHE_FLAGS into SLAB_CORE_FLAGS. * Remove SLAB_FLAGS_PERMITTED (effectively the same as CACHE_CREATE_MASK aside from debug flags being unconditionally included). While at it also remove misleading comments that suggest that multiple allocators are available. Signed-off-by: Kevin Brodsky --- Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab.h | 28 +++++----------------------- mm/slab_common.c | 12 ------------ 2 files changed, 5 insertions(+), 35 deletions(-) base-commit: 9bffa1ad25b8b3b95d8f463e5c24dabe3c87d54d diff --git a/mm/slab.h b/mm/slab.h index 632fedd71fea..392f4763dee8 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -457,10 +457,12 @@ static inline bool is_kmalloc_normal(struct kmem_cache *s) return !(s->flags & (SLAB_CACHE_DMA|SLAB_ACCOUNT|SLAB_RECLAIM_ACCOUNT)); } -/* Legal flag mask for kmem_cache_create(), for various configurations */ #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \ SLAB_CACHE_DMA32 | SLAB_PANIC | \ - SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS ) + SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS | \ + SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \ + SLAB_TEMPORARY | SLAB_ACCOUNT | \ + SLAB_NO_USER_FLAGS | SLAB_KMALLOC | SLAB_NO_MERGE) #ifdef CONFIG_SLUB_DEBUG #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ @@ -469,27 +471,7 @@ static inline bool is_kmalloc_normal(struct kmem_cache *s) #define SLAB_DEBUG_FLAGS (0) #endif -#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \ - SLAB_TEMPORARY | SLAB_ACCOUNT | \ - SLAB_NO_USER_FLAGS | SLAB_KMALLOC | SLAB_NO_MERGE) - -/* Common flags available with current configuration */ -#define CACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS | SLAB_CACHE_FLAGS) - -/* Common flags permitted for kmem_cache_create */ -#define SLAB_FLAGS_PERMITTED (SLAB_CORE_FLAGS | \ - SLAB_RED_ZONE | \ - SLAB_POISON | \ - SLAB_STORE_USER | \ - SLAB_TRACE | \ - SLAB_CONSISTENCY_CHECKS | \ - SLAB_NOLEAKTRACE | \ - SLAB_RECLAIM_ACCOUNT | \ - SLAB_TEMPORARY | \ - SLAB_ACCOUNT | \ - SLAB_KMALLOC | \ - SLAB_NO_MERGE | \ - SLAB_NO_USER_FLAGS) +#define CACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS) bool __kmem_cache_empty(struct kmem_cache *); int __kmem_cache_shutdown(struct kmem_cache *); diff --git a/mm/slab_common.c b/mm/slab_common.c index a29457bef626..3b07cdaac3ae 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -305,18 +305,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, goto out_unlock; } - /* Refuse requests with allocator specific flags */ - if (flags & ~SLAB_FLAGS_PERMITTED) { - err = -EINVAL; - goto out_unlock; - } - - /* - * Some allocators will constraint the set of valid flags to a subset - * of all flags. We expect them to define CACHE_CREATE_MASK in this - * case, and we'll just provide them with a sanitized version of the - * passed flags. - */ flags &= CACHE_CREATE_MASK; /* Fail closed on bad usersize of useroffset values. */