From patchwork Tue Nov 16 00:16:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12620735 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5B75C433EF for ; Tue, 16 Nov 2021 00:17:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5A28863215 for ; Tue, 16 Nov 2021 00:17:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5A28863215 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A64F36B00A5; Mon, 15 Nov 2021 19:16:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AE466B00A9; Mon, 15 Nov 2021 19:16:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D103E6B0092; Mon, 15 Nov 2021 19:16:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 2F8A26B0092 for ; Mon, 15 Nov 2021 19:16:44 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E19598249980 for ; Tue, 16 Nov 2021 00:16:43 +0000 (UTC) X-FDA: 78812877444.27.B7E1810 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf16.hostedemail.com (Postfix) with ESMTP id A5FD4F000092 for ; Tue, 16 Nov 2021 00:16:31 +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-out1.suse.de (Postfix) with ESMTPS id 4FEBC21991; Tue, 16 Nov 2021 00:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637021802; 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=VmPmevT2hvAeOXfgHtg1HRCtB5KckPvueh7KRGHM1Zs=; b=oL+8IvyqYLBla1yUsnaMaEt8kLNEZ0BHuOafhLKLWPRbaI6qnAt7UlI73k1BfauHhRepDi lTqCTn5dGKgtyzvuW1xrF2ZhmPZnwkM42iA/MCNfnqqoC8xaV5KKSnLoVtEGpxHCmPOHAl NqxVbsmPK0dwKTW++fS5HPjRP1sCD8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637021802; 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=VmPmevT2hvAeOXfgHtg1HRCtB5KckPvueh7KRGHM1Zs=; b=dSf4Sx3EldstvRSiDODj2m85k1AzXxWHe06jxIldQ0h22MrMRWtxZQjzRYoneIRzb5JX63 iNv9CiA/4DiTvOAA== 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 3398613F72; Tue, 16 Nov 2021 00:16:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EH39C2r4kmFjXAAAMHmgww (envelope-from ); Tue, 16 Nov 2021 00:16:42 +0000 From: Vlastimil Babka To: Matthew Wilcox , linux-mm@kvack.org, Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: Vlastimil Babka Subject: [RFC PATCH 32/32] mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled Date: Tue, 16 Nov 2021 01:16:28 +0100 Message-Id: <20211116001628.24216-33-vbabka@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211116001628.24216-1-vbabka@suse.cz> References: <20211116001628.24216-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2322; h=from:subject; bh=PsIhUueRvAUA0Ew0irYBQbDHZZsfIRw3ogIySK8O4xs=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhkvhaLJEoZMYrxM+PpujG69ISs8nul5dpTDcBIXmT 7B3hIoeJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYZL4WgAKCRDgIcpz8YmpEGMSB/ 9GBFAT+wW6MI86dxRf8guYytqXZ7xw8sVi1EVBEiUy+dtcjtbUY1QnQLfCYOJ4v++rUP5VzIc5RcLX 479g+MKJ4C8qHRJ3OWPoi7EOjiiWcVSa5s7zcjO79jZHbeMBLciNqxIffGWkB9hgmsVDoK3m90fOMH AMlysWHA1p83ox7QmAzd2Ic9Z2zDaJhwqCx+hVxvSGdXHLtXJ0+kuXqGBtDA4w2ELM/qEGOOR7HZ+D hgM+hKd0xdc0dXRaS08oKodqNRWbqkNgnWp0CCSU9unwr5wPbhiLKRjE4R1MCm355GEDPS0ESE1C61 RK3/FQzXKfoEkLv53VmYAV7/JD8iOm X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Stat-Signature: eix8knauuskuqc4oafreqy8jntrfizn8 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=oL+8Ivyq; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=dSf4Sx3E; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A5FD4F000092 X-HE-Tag: 1637021791-548649 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 --- 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 31490e1f7c91..326f1032168c 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 1ff3fa2ab528..39027dc8c45a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5256,6 +5256,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); @@ -5268,6 +5269,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, total += x; nodes[node] += x; } +#endif } } @@ -5467,9 +5469,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; @@ -5478,12 +5481,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;