Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4636205rwb; Mon, 21 Nov 2022 09:54:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NByMcTPcKD19i3tycBa1KorLHq3BhjtRcgHQ+wusseFxGVZp3+VwFCY13SkuuU59iC4jz X-Received: by 2002:a63:db0a:0:b0:459:35b1:1396 with SMTP id e10-20020a63db0a000000b0045935b11396mr2161811pgg.593.1669053259035; Mon, 21 Nov 2022 09:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669053259; cv=none; d=google.com; s=arc-20160816; b=rXfz61r1uYQDJhMUKgTfXb2LNji66kUnBXkgX5H4l4K0t7vwYMCs5J4IIl5SkKUkv5 zkY9tUEVvFefrH6KGPuWETXYRdYe3UK7wRDIA9lKuz2it/zX2tPgQLudkTci/WT4Ow4k 7oHFK6PTXjDGT4V4djGCoWkW+JjLE08hgwi4XVfAN+mCCDfxVtrYXI/YKzZJyWUUXLn2 1h0BKZDDX4F7QS+jMLlK801IBl341+C9xvkuxV1Qz8hV0D0LJViqXEZgE7q2xzvBtFhi nQWNlEu/2++2HlO1R8tUVeaiMyAvzId+n/R1+pG76474v01nD3ZdonnA4cYFVoDBA/Wj Ocrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=X3WZS4NhVY+Kjo4XdjOkZd1dtlHURo50T/wAh28ytNE=; b=GAXQRhbL40jcER5vCUvCfwp+uroa7s+TuVrHm6AZ8G3IICJq8qSbFSnh8j/ZqbbTZb YI3yZgneNPNowB3L1Xar480e4pPqrykEmsbqSYC+C4lfaiS9GKSb8PFYw9D4fGNf33uH zpSFJisn4GIv1Mm/xHRD+hyibci8SmYROSWiig2l/pLflrrf13mkZpic7A6A9vo11vK/ jL2oAGqGzsL1RWRId3nH99aGGg0GD3+Q3hE7w3B+NjCuCdXLcWpmi2GRa6K+bEXsaV/v XoJw/3fuo6gjC/0nL2RgY1wYt1DvRhMUM/aJLxSk3qndl2oF2NXxqqLAnOsszV4gXxDc QfTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rdmY920q; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=TkTS9+5m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo11-20020a17090b1c8b00b00214064c6c55si18874909pjb.50.2022.11.21.09.54.07; Mon, 21 Nov 2022 09:54:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rdmY920q; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=TkTS9+5m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbiKURNE (ORCPT + 91 others); Mon, 21 Nov 2022 12:13:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbiKURMX (ORCPT ); Mon, 21 Nov 2022 12:12:23 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E5FCEB91 for ; Mon, 21 Nov 2022 09:12:17 -0800 (PST) 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 9AC7B1F8BB; Mon, 21 Nov 2022 17:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1669050732; 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=X3WZS4NhVY+Kjo4XdjOkZd1dtlHURo50T/wAh28ytNE=; b=rdmY920qgTRyWMDU9Lvdi9t9OF9/QhFDxMqQw+V1STkr7+GbgdShYi31aii2Wq88xE/kCw +zaHdMmfWfiK81ohGzq3zHdcAbX6vepPHK82mRoA1f479p0Ly63ipmonfkzxoY2VjhfVL/ /6EQw1GjfEznRtmefD26Q5u9SXxfX8Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1669050732; 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=X3WZS4NhVY+Kjo4XdjOkZd1dtlHURo50T/wAh28ytNE=; b=TkTS9+5mYVWVSQ0Z3ri95SsgD2DGEbJkaROTw88M754wmWvi7YsmGDX8ymuzHS3hl3KZNO D+slbCc0iTNOp8AA== 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 6C22C13B03; Mon, 21 Nov 2022 17:12:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AJzHGWyxe2MQeQAAMHmgww (envelope-from ); Mon, 21 Nov 2022 17:12:12 +0000 From: Vlastimil Babka To: Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , Andrew Morton , Linus Torvalds , Matthew Wilcox , patches@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka Subject: [PATCH 11/12] mm, slub: don't aggressively inline with CONFIG_SLUB_TINY Date: Mon, 21 Nov 2022 18:12:01 +0100 Message-Id: <20221121171202.22080-12-vbabka@suse.cz> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121171202.22080-1-vbabka@suse.cz> References: <20221121171202.22080-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SLUB fastpaths use __always_inline to avoid function calls. With CONFIG_SLUB_TINY we would rather save the memory. Add a __fastpath_inline macro that's __always_inline normally but empty with CONFIG_SLUB_TINY. bloat-o-meter results on x86_64 mm/slub.o: add/remove: 3/1 grow/shrink: 1/8 up/down: 865/-1784 (-919) Function old new delta kmem_cache_free 20 281 +261 slab_alloc_node.isra - 245 +245 slab_free.constprop.isra - 231 +231 __kmem_cache_alloc_lru.isra - 128 +128 __kmem_cache_release 88 83 -5 __kmem_cache_create 1446 1436 -10 __kmem_cache_free 271 142 -129 kmem_cache_alloc_node 330 127 -203 kmem_cache_free_bulk.part 826 613 -213 __kmem_cache_alloc_node 230 10 -220 kmem_cache_alloc_lru 325 12 -313 kmem_cache_alloc 325 10 -315 kmem_cache_free.part 376 - -376 Total: Before=26103, After=25184, chg -3.52% Signed-off-by: Vlastimil Babka --- mm/slub.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 7f1cd702c3b4..d54466e76503 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -187,6 +187,12 @@ do { \ #define USE_LOCKLESS_FAST_PATH() (false) #endif +#ifndef CONFIG_SLUB_TINY +#define __fastpath_inline __always_inline +#else +#define __fastpath_inline +#endif + #ifdef CONFIG_SLUB_DEBUG #ifdef CONFIG_SLUB_DEBUG_ON DEFINE_STATIC_KEY_TRUE(slub_debug_enabled); @@ -3386,7 +3392,7 @@ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, * * Otherwise we can simply pick the next object from the lockless free list. */ -static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_lru *lru, +static __fastpath_inline void *slab_alloc_node(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags, int node, unsigned long addr, size_t orig_size) { void *object; @@ -3412,13 +3418,13 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_l return object; } -static __always_inline void *slab_alloc(struct kmem_cache *s, struct list_lru *lru, +static __fastpath_inline void *slab_alloc(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags, unsigned long addr, size_t orig_size) { return slab_alloc_node(s, lru, gfpflags, NUMA_NO_NODE, addr, orig_size); } -static __always_inline +static __fastpath_inline void *__kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags) { @@ -3733,7 +3739,7 @@ static void do_slab_free(struct kmem_cache *s, } #endif /* CONFIG_SLUB_TINY */ -static __always_inline void slab_free(struct kmem_cache *s, struct slab *slab, +static __fastpath_inline void slab_free(struct kmem_cache *s, struct slab *slab, void *head, void *tail, void **p, int cnt, unsigned long addr) { -- 2.38.1