From patchwork Mon Mar 17 14:33:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 14019362 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 C09B4C282EC for ; Mon, 17 Mar 2025 14:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00812280008; Mon, 17 Mar 2025 10:33:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED59B280006; Mon, 17 Mar 2025 10:33:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4E3A280008; Mon, 17 Mar 2025 10:33:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B0769280006 for ; Mon, 17 Mar 2025 10:33:55 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7842CAF274 for ; Mon, 17 Mar 2025 14:33:56 +0000 (UTC) X-FDA: 83231287272.07.ACEACDB Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf13.hostedemail.com (Postfix) with ESMTP id 6557C2001C for ; Mon, 17 Mar 2025 14:33:54 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742222034; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3EVlniODC9+hhKZCQb+SM/h0CLL+7VBtgi7rAjrWwLw=; b=oROhOER2aGybuMr9Dc2Zr33DpYd6K4AaFCg1OCnT/EAoTROBXJHjZE0r413Nv2pt4DbTE8 CQJRME5sfLWdtJwY5gbQx/A1exeFUrDZQG1HAawE09IM8uXN/97iXZTnHZfQrw6zJ4Ib02 mF358GDhbfd1xCrlR1TxUGf4TR280nc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742222034; a=rsa-sha256; cv=none; b=LluCFQ7LmRLG9IfJAUGt7W+onKTrTkFliH6edBqzc7i7216YeP1wvUyKMkgDsqExtyIMQE /TbHw2Iui/MoFX9GAUIE6gcvvTZ/si+QrIW/M5xg0y1lK2b7uB04FCq6Lx51GP7/RKpNRO LHby/XxnLgnu0LhsfIy1ul0/c6xlqWI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4B665215D5; Mon, 17 Mar 2025 14:33:34 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 36D2A139D2; Mon, 17 Mar 2025 14:33:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OPgSDb4y2GcycQAAD6G6ig (envelope-from ); Mon, 17 Mar 2025 14:33:34 +0000 From: Vlastimil Babka Date: Mon, 17 Mar 2025 15:33:09 +0100 Subject: [PATCH RFC v3 8/8] maple_tree: use percpu sheaves for maple_node_cache MIME-Version: 1.0 Message-Id: <20250317-slub-percpu-caches-v3-8-9d9884d8b643@suse.cz> References: <20250317-slub-percpu-caches-v3-0-9d9884d8b643@suse.cz> In-Reply-To: <20250317-slub-percpu-caches-v3-0-9d9884d8b643@suse.cz> To: Suren Baghdasaryan , "Liam R. Howlett" , Christoph Lameter , David Rientjes Cc: Roman Gushchin , Harry Yoo , Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, maple-tree@lists.infradead.org, vbabka@suse.cz X-Mailer: b4 0.14.2 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6557C2001C X-Stat-Signature: rxjxdnjgmjj5p78zjsotk3bgn1snphm7 X-HE-Tag: 1742222034-980321 X-HE-Meta: U2FsdGVkX18nmY6KcypfnoVQqGwYGIONaXe6lucwDnPmph4oKrlijZa13UcrjbENYsckSaYnaXliu2lNpBO1+YEb1r6PIrBr6f1Rf9hXcmoKRhm0+OSI4mMwPRBzq7juyovzucZ489DHuvssPVP3PWCij8U7aUnImPuOtRiPltKdQS50kmBizu+mHaarCcNZ4OE1OsBikK1q17KJHWmKJz2A3v+EXYMVhJ//mAYt1fNVy8cdg7uTlkev1c4Ped2D3cvsIdCi76Hc2gI7e8XUI3fHvhF8+bIVrsvH/s0a6wD1hWm3MqeNW8AnUIHlSHSlQ1aPMxcXzDWtsp7LkCe8qMvXqlpota4UEU7+xIAMFIQ+2DlJQ9rYvaSgPTAw8htX3Ki562viz8bDmUT1Owi73lEuxHBmY1SrLNKNOp9Q3my5LROUngIJKwSkSJ5T5cy8HXzWg9MFaAMpwz4LsCa2dhWGggC9ibvnfqy5NlcZ/qyXKLQYZmZHhhvRfK0nTqahTow6az3FvQ/0P7UPaKmtHLzjY1eW7lZAwL2PTcH7OrrsHYSTjTeHzOMPLlmM42PGH2c57HXHsF81/UjEx8enrDvFZYLP1XfWuOcq4n3uYEyYMlJxHrLCh5Uq5SFexRdC3a10Eerm2c0bz4eX3ZizINXCRkz28L6ofFheJZG4JRpIHsYS8O2T0+Peb4+tGVQ2/+d0JRNHN40wZRrxhBxVrGbTMtb/Jv5MmEBG19qs1XiAx3Q0RHdVXwivzDFxfsYBneHVQYx2YePVlcsSMsw1mLpxQTAjoA+Z/hyO+afYatw+7yBOH16Jf8qG8wHC1/ehSWvRS03GbbHKFQ1Nw/kAraFFheejODspHlBWr+6ME5yg4P9jEX7T6IZXhx/C0hnv0gY9+Imqqx+sUiA+VzWSPV6PAA3r5Jfk1CCURaFdHaldy7yejRYo5zjuMCZ0by3tFH9GaXWe5eOw/JDiEvp 0w9YcsQZ dqM0U7CoVdji7G8D2PsE11CQj4cBnlhXyRNvdDgijnQ9Yvoz+oTug9TQ0+k6XLhYLQxdx5AmlN/deYa4wfZcFgJdxtC+tb7H/LRXQRaLPEsNsC8NSsV1PuFOztL/FxBle8J7D8Mw5Bz0wFRxseLXzV8z6pqxmG/jLa5pbgk3Ti8bl7m7vr6W8mFnBeQ== 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: Setup the maple_node_cache with percpu sheaves of size 32 to hopefully improve its performance. Change the single node rcu freeing in ma_free_rcu() to use kfree_rcu() instead of the custom callback, which allows the rcu_free sheaf batching to be used. Note there are other users of mt_free_rcu() where larger parts of maple tree are submitted to call_rcu() as a whole, and that cannot use the rcu_free sheaf, but it's still possible for maple nodes freed this way to be reused via the barn, even if only some cpus are allowed to process rcu callbacks. Signed-off-by: Vlastimil Babka Reviewed-by: Suren Baghdasaryan --- lib/maple_tree.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index f7153ade1be5f16423f0ca073846a7f3dfa60523..56e7a00f6f0941bff163091c999a873e4273f071 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -208,7 +208,7 @@ static void mt_free_rcu(struct rcu_head *head) static void ma_free_rcu(struct maple_node *node) { WARN_ON(node->parent != ma_parent_ptr(node)); - call_rcu(&node->rcu, mt_free_rcu); + kfree_rcu(node, rcu); } static void mas_set_height(struct ma_state *mas) @@ -6258,9 +6258,14 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp) void __init maple_tree_init(void) { + struct kmem_cache_args args = { + .align = sizeof(struct maple_node), + .sheaf_capacity = 32, + }; + maple_node_cache = kmem_cache_create("maple_node", - sizeof(struct maple_node), sizeof(struct maple_node), - SLAB_PANIC, NULL); + sizeof(struct maple_node), &args, + SLAB_PANIC); } /**