From patchwork Mon Nov 13 19:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13454363 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 623F5C41535 for ; Mon, 13 Nov 2023 19:14:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 788246B027C; Mon, 13 Nov 2023 14:14:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0176B0275; Mon, 13 Nov 2023 14:14:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4209F6B027B; Mon, 13 Nov 2023 14:14:17 -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 207AA6B0275 for ; Mon, 13 Nov 2023 14:14:17 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ECEC1B5934 for ; Mon, 13 Nov 2023 19:14:16 +0000 (UTC) X-FDA: 81453881712.09.F78BC9E Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf04.hostedemail.com (Postfix) with ESMTP id 0C12C4001C for ; Mon, 13 Nov 2023 19:14:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=vks2zsCM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=NVLU6T7U; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699902855; a=rsa-sha256; cv=none; b=hMpeqQ4/aPEu+r1UqrLzfuumvCLp7rrmRItqI+l4KXJjhf+n8NJ4S7LNNJoAF+8Mknu0mA fPSx1S6Upgn3vXbqpy6FzZLOvGHv3pCoHZRlHCpahMlsLHPrDsvvo3pL5EmtuWJR7ed3n5 M1NQMRF3tKRMplAR31K3eOozIuCqbRo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=vks2zsCM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=NVLU6T7U; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699902855; 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=s3nv+0Sqzbudyo8axulOBmhTAGTu9yIEYPQrJtiVg8g=; b=FvOrl31pfMtizGP09EpQnAqx/SXC3qsEqlczWZyUI8JLdC5Rm5n8zTF/r2iVOvVx9F7JJz L/0pN2MS0kDnXRVUGZG32xbS5BPRo5LSIPh38ieDqIiv5Wm1P2hL9ipucomUJ04wm79ryw AjM3VK0mdyUQQver23haQudYzLZwbBM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7F8F31F88B; Mon, 13 Nov 2023 19:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1699902852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3nv+0Sqzbudyo8axulOBmhTAGTu9yIEYPQrJtiVg8g=; b=vks2zsCM2llHj2sCCNK9iUCdg8yLjPuDMFNCq4IalcG7o90NBHa+OTVb0fXGiJrhrwpwYi eoM6HhnvLwPRECQzx2k/FUKvIv7EsitvuHas9JkZUEjuQNDLF/nXp8s710eafRrHg4uXmO K8nDzHTLl4j/Sw18qemcBGyijZRNTPg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1699902852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3nv+0Sqzbudyo8axulOBmhTAGTu9yIEYPQrJtiVg8g=; b=NVLU6T7UIVzg+w41i7fPZrmuaz6c4SpNekbAkxpwCsyh8sjZD+OYPyG+lLTH+jGSwt97x2 yJeIxfuLzOomJoAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 350B613907; Mon, 13 Nov 2023 19:14:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6KdtDIR1UmVFOgAAMHmgww (envelope-from ); Mon, 13 Nov 2023 19:14:12 +0000 From: Vlastimil Babka To: David Rientjes , Christoph Lameter , Pekka Enberg , Joonsoo Kim Cc: Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Kees Cook , kasan-dev@googlegroups.com, cgroups@vger.kernel.org, Vlastimil Babka Subject: [PATCH 09/20] mm/slab: move struct kmem_cache_cpu declaration to slub.c Date: Mon, 13 Nov 2023 20:13:50 +0100 Message-ID: <20231113191340.17482-31-vbabka@suse.cz> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231113191340.17482-22-vbabka@suse.cz> References: <20231113191340.17482-22-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0C12C4001C X-Stat-Signature: z3c5xsbeztfffeofexpbmqteuxxpgj68 X-Rspam-User: X-HE-Tag: 1699902854-241310 X-HE-Meta: U2FsdGVkX1/kYcFPF3iz3Esvm+8NWyf/dnKhkP5il019Lli8l9sno0PmLWO4z/tE/VJrcc6sExylBZjyz2OtV8ESB5Nq3P8UeapHuMBuMDuMmDCQm6MGep8m059wKH555UEGtUZf/GsReVuySJn0VsoRtAI4AKLhrBC/C561mvQ/A+uTSrJolpbJ1fSGMk9ex6KPG4nSz9vCe13Ww2aA6GMpafpZfSvG/1SG1Tdq6+uHRMF6jBo8AG+5wGbBMY9i6a5DtDPedWuDlxE/n7OUfb9hD7b8IKOigSSSADzcCkALlXe1NjxMJrpwxuQ1qw0FgdUFdbekL5l0aYDgTNnQZ1/idW2+4XoHYNI50K0uaiqgA8hwtcqlLy5o6VfGZ1jy5dk18yxiXRl7GoLfuvcD0sqNdq7qclmHBqRLudNV/eXdRnXIwOBtiTlZEWnq6b7bgU32IAXFDuy6cV/juCauxXvRvOnvsj0FWYwtuOQNiKEZiN5hwYn7Dd0WRLVrmjySjuWVyC2jkk2KhkwCHkA2osZyMbctFcoTUBFn/6UjNdILF2FoxAabTrnPfqe8dkeW7hwgQ1NHYeztCsrGdrYNtTkM3AaNlHfjPqpGqXBIRCuvma3eHX2bV0xEB9a38PLHfnl5evKgdR7YpFbSWc0OXjr8cFx9v7CADSHPe/OJjC8HJiM6cQy7O8vQX7sKsbu2fUBi/xmgbRRTrfjZ0VIZrOUh73G2vC6ep2ISgPJijIawxtU9vcVNJK3eBMKpLJSR3GtfwxaHakyguT26WAEFirXB0/72n3thhUM4B/nihjUJd5ahy2pmBrkUXrro8xUQwwuBy0TdnhKAPEkrgRVab/75yg7o2AJj1HyJV+M7dVddvc4rwRyrypJwipN9ZrnQJZoc5sVXcDZWHXK7aQNOZk5RLqSYj5g3KcKNdHtxnrxhGN7yX9DM4qH7COIvIKhBuPpWZmbKpBdOenjzD1m x/sQ3fsO xMdarkt7DPAQW08Z+b6OMXroh/7H6j+RSB6BxC8a/KPlnsD+FF0On9LGuAT++fiqvOg5tEq2FYitwh0W0mWk+k2qRWv5SeFr/wExq1auo6Ka4LezS/83DiwocQ5eB66lG3RmF6RAI/2farWQgAbAOAICquAvNZN9ADz8nC8iJ0aA1UftUGR+6KwXbqmHVs9YqfjkZIIUDuIpsBbJqTWDXC57vQ3nXwGfxR671oyJZK3VaM11vhQjcrWlaExnoEON12qOA1PPqsgMjAwQv3YzULUa6CwaMNtcYietR69nkHj21Web7EAnED+9xZA== 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: Nothing outside SLUB itself accesses the struct kmem_cache_cpu fields so it does not need to be declared in slub_def.h. This allows also to move enum stat_item. Signed-off-by: Vlastimil Babka Reviewed-by: Kees Cook --- include/linux/slub_def.h | 54 ---------------------------------------- mm/slub.c | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index deb90cf4bffb..a0229ea42977 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h @@ -12,60 +12,6 @@ #include #include -enum stat_item { - ALLOC_FASTPATH, /* Allocation from cpu slab */ - ALLOC_SLOWPATH, /* Allocation by getting a new cpu slab */ - FREE_FASTPATH, /* Free to cpu slab */ - FREE_SLOWPATH, /* Freeing not to cpu slab */ - FREE_FROZEN, /* Freeing to frozen slab */ - FREE_ADD_PARTIAL, /* Freeing moves slab to partial list */ - FREE_REMOVE_PARTIAL, /* Freeing removes last object */ - ALLOC_FROM_PARTIAL, /* Cpu slab acquired from node partial list */ - ALLOC_SLAB, /* Cpu slab acquired from page allocator */ - ALLOC_REFILL, /* Refill cpu slab from slab freelist */ - ALLOC_NODE_MISMATCH, /* Switching cpu slab */ - FREE_SLAB, /* Slab freed to the page allocator */ - CPUSLAB_FLUSH, /* Abandoning of the cpu slab */ - DEACTIVATE_FULL, /* Cpu slab was full when deactivated */ - DEACTIVATE_EMPTY, /* Cpu slab was empty when deactivated */ - DEACTIVATE_TO_HEAD, /* Cpu slab was moved to the head of partials */ - DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */ - DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */ - DEACTIVATE_BYPASS, /* Implicit deactivation */ - ORDER_FALLBACK, /* Number of times fallback was necessary */ - CMPXCHG_DOUBLE_CPU_FAIL,/* Failure of this_cpu_cmpxchg_double */ - CMPXCHG_DOUBLE_FAIL, /* Number of times that cmpxchg double did not match */ - CPU_PARTIAL_ALLOC, /* Used cpu partial on alloc */ - CPU_PARTIAL_FREE, /* Refill cpu partial on free */ - CPU_PARTIAL_NODE, /* Refill cpu partial from node partial */ - CPU_PARTIAL_DRAIN, /* Drain cpu partial to node partial */ - NR_SLUB_STAT_ITEMS -}; - -#ifndef CONFIG_SLUB_TINY -/* - * When changing the layout, make sure freelist and tid are still compatible - * with this_cpu_cmpxchg_double() alignment requirements. - */ -struct kmem_cache_cpu { - union { - struct { - void **freelist; /* Pointer to next available object */ - unsigned long tid; /* Globally unique transaction id */ - }; - freelist_aba_t freelist_tid; - }; - struct slab *slab; /* The slab from which we are allocating */ -#ifdef CONFIG_SLUB_CPU_PARTIAL - struct slab *partial; /* Partially allocated frozen slabs */ -#endif - local_lock_t lock; /* Protects the fields above */ -#ifdef CONFIG_SLUB_STATS - unsigned stat[NR_SLUB_STAT_ITEMS]; -#endif -}; -#endif /* CONFIG_SLUB_TINY */ - #ifdef CONFIG_SLUB_CPU_PARTIAL #define slub_percpu_partial(c) ((c)->partial) diff --git a/mm/slub.c b/mm/slub.c index 63d281dfacdb..64170a1ccbba 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -330,6 +330,60 @@ static void debugfs_slab_add(struct kmem_cache *); static inline void debugfs_slab_add(struct kmem_cache *s) { } #endif +enum stat_item { + ALLOC_FASTPATH, /* Allocation from cpu slab */ + ALLOC_SLOWPATH, /* Allocation by getting a new cpu slab */ + FREE_FASTPATH, /* Free to cpu slab */ + FREE_SLOWPATH, /* Freeing not to cpu slab */ + FREE_FROZEN, /* Freeing to frozen slab */ + FREE_ADD_PARTIAL, /* Freeing moves slab to partial list */ + FREE_REMOVE_PARTIAL, /* Freeing removes last object */ + ALLOC_FROM_PARTIAL, /* Cpu slab acquired from node partial list */ + ALLOC_SLAB, /* Cpu slab acquired from page allocator */ + ALLOC_REFILL, /* Refill cpu slab from slab freelist */ + ALLOC_NODE_MISMATCH, /* Switching cpu slab */ + FREE_SLAB, /* Slab freed to the page allocator */ + CPUSLAB_FLUSH, /* Abandoning of the cpu slab */ + DEACTIVATE_FULL, /* Cpu slab was full when deactivated */ + DEACTIVATE_EMPTY, /* Cpu slab was empty when deactivated */ + DEACTIVATE_TO_HEAD, /* Cpu slab was moved to the head of partials */ + DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */ + DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */ + DEACTIVATE_BYPASS, /* Implicit deactivation */ + ORDER_FALLBACK, /* Number of times fallback was necessary */ + CMPXCHG_DOUBLE_CPU_FAIL,/* Failures of this_cpu_cmpxchg_double */ + CMPXCHG_DOUBLE_FAIL, /* Failures of slab freelist update */ + CPU_PARTIAL_ALLOC, /* Used cpu partial on alloc */ + CPU_PARTIAL_FREE, /* Refill cpu partial on free */ + CPU_PARTIAL_NODE, /* Refill cpu partial from node partial */ + CPU_PARTIAL_DRAIN, /* Drain cpu partial to node partial */ + NR_SLUB_STAT_ITEMS +}; + +#ifndef CONFIG_SLUB_TINY +/* + * When changing the layout, make sure freelist and tid are still compatible + * with this_cpu_cmpxchg_double() alignment requirements. + */ +struct kmem_cache_cpu { + union { + struct { + void **freelist; /* Pointer to next available object */ + unsigned long tid; /* Globally unique transaction id */ + }; + freelist_aba_t freelist_tid; + }; + struct slab *slab; /* The slab from which we are allocating */ +#ifdef CONFIG_SLUB_CPU_PARTIAL + struct slab *partial; /* Partially allocated frozen slabs */ +#endif + local_lock_t lock; /* Protects the fields above */ +#ifdef CONFIG_SLUB_STATS + unsigned int stat[NR_SLUB_STAT_ITEMS]; +#endif +}; +#endif /* CONFIG_SLUB_TINY */ + static inline void stat(const struct kmem_cache *s, enum stat_item si) { #ifdef CONFIG_SLUB_STATS