From patchwork Tue Jan 4 00:10:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12702875 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 05FB2C433EF for ; Tue, 4 Jan 2022 00:11:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A56A36B0098; Mon, 3 Jan 2022 19:11:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 74B756B00A2; Mon, 3 Jan 2022 19:11:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3BA26B00A4; Mon, 3 Jan 2022 19:11:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 7835A6B0098 for ; Mon, 3 Jan 2022 19:11:00 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3993D181355E9 for ; Tue, 4 Jan 2022 00:11:00 +0000 (UTC) X-FDA: 78990674280.13.EF709DD Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf10.hostedemail.com (Postfix) with ESMTP id 9FF6DC0007 for ; Tue, 4 Jan 2022 00:10:47 +0000 (UTC) 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 C28A41F3AB; Tue, 4 Jan 2022 00:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1641255058; 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=Ht0n9p2pCeOge5Mzq1bWzoCpt8zfS9QEh0IeqT/nkIk=; b=i82qMw144vx7y8ym9aF3luWXziPiX4BI0ZwGCZcw6XMN2ZRCtNuR8yW47N5X+11XjIvQU7 h57gESyTaejwmn6nZlmORpzVDeWm52bJo025rcQxhyB3BxEw9lk4dBTLgwxSrm47By+X1a bpiKhU0Z4gLRdLP7r1yv2HMs+eXlTtA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1641255058; 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=Ht0n9p2pCeOge5Mzq1bWzoCpt8zfS9QEh0IeqT/nkIk=; b=1N8UL86AQArnFzAZJKOiZh59stUKm9rP5fHVHqJYZSgLyF0XmawiXDwXkfO0BkKoJXTRBx aP1rDRplemVEBJCw== 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 9A2A1139EE; Tue, 4 Jan 2022 00:10:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qCwQJZKQ02FEQwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 00:10:58 +0000 From: Vlastimil Babka To: Matthew Wilcox , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: linux-mm@kvack.org, Andrew Morton , Johannes Weiner , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, patches@lists.linux.dev, Vlastimil Babka Subject: [PATCH v4 29/32] mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled Date: Tue, 4 Jan 2022 01:10:43 +0100 Message-Id: <20220104001046.12263-30-vbabka@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104001046.12263-1-vbabka@suse.cz> References: <20220104001046.12263-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2420; h=from:subject; bh=j3xoBT34DCarlz/GMl3e6asupXBOQM4dCmkib4lGaR0=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBh05CCFrb+KuFwzFQ+bmHVznWpgqDx7aboRjno/K/h sk5pREaJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYdOQggAKCRDgIcpz8YmpEIgpB/ 4htE7W7aIl/yrIxq7V9F8N6Us/tvtME6T0Z7Zbenq5r5qfr4szFvGRuSQRG/QGqxhp0t9VKzjEzLMK +MumWge0ooFwIlFXDAK1eUSfWVordsGJ2b9FmqpOmr6BG2DLfIFFRvkzAGPH3rOoQ1nHmKOcSOK1vS KuMJg8R7vHRXO47MEOesqU3uspWZ5kAwVBHk7Nw1x0QpF6z+tcH+mCr7IW0/AwE6lkllKf+N1NanFB A6DkDV1mTOBsr3Z0+HFF8dbDMhIVhkypdwkmAWXXvLGshuPqWkJL1maysF86o70aa8BwXh3kcvU/TC ESGiRQ5Ha9CVY53v9zfj7wKRm6UE44 X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=i82qMw14; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=1N8UL86A; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9FF6DC0007 X-Stat-Signature: 8o71xxnwhgn6mohp7qewubqmaeosqwu8 X-HE-Tag: 1641255047-510086 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: The fields 'next' and 'slabs' are only used when CONFIG_SLUB_CPU_PARTIAL is enabled. We can put their definition to #ifdef to prevent accidental use when disabled. Currenlty show_slab_objects() and slabs_cpu_partial_show() contain code accessing the slabs field that's effectively dead with CONFIG_SLUB_CPU_PARTIAL=n through the wrappers slub_percpu_partial() and slub_percpu_partial_read_once(), but to prevent a compile error, we need to hide all this code behind #ifdef. Signed-off-by: Vlastimil Babka Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Roman Gushchin --- mm/slab.h | 2 ++ mm/slub.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 362832f465e6..ac8be7dab535 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -25,10 +25,12 @@ struct slab { union { struct list_head slab_list; struct rcu_head rcu_head; +#ifdef CONFIG_SLUB_CPU_PARTIAL struct { struct slab *next; int slabs; /* Nr of slabs left */ }; +#endif }; struct kmem_cache *slab_cache; /* Double-word boundary */ diff --git a/mm/slub.c b/mm/slub.c index d08ba1025aae..261474092e43 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5258,6 +5258,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, total += x; nodes[node] += x; +#ifdef CONFIG_SLUB_CPU_PARTIAL slab = slub_percpu_partial_read_once(c); if (slab) { node = slab_nid(slab); @@ -5270,6 +5271,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, total += x; nodes[node] += x; } +#endif } } @@ -5469,9 +5471,10 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) { int objects = 0; int slabs = 0; - int cpu; + int cpu __maybe_unused; int len = 0; +#ifdef CONFIG_SLUB_CPU_PARTIAL for_each_online_cpu(cpu) { struct slab *slab; @@ -5480,12 +5483,13 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) if (slab) slabs += slab->slabs; } +#endif /* Approximate half-full slabs, see slub_set_cpu_partial() */ objects = (slabs * oo_objects(s->oo)) / 2; len += sysfs_emit_at(buf, len, "%d(%d)", objects, slabs); -#ifdef CONFIG_SMP +#if defined(CONFIG_SLUB_CPU_PARTIAL) && defined(CONFIG_SMP) for_each_online_cpu(cpu) { struct slab *slab;