From nobody Fri Sep 12 09:44:22 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65BD2C04E69 for ; Thu, 10 Aug 2023 16:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235498AbjHJQgo (ORCPT ); Thu, 10 Aug 2023 12:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234937AbjHJQgf (ORCPT ); Thu, 10 Aug 2023 12:36:35 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9302E0 for ; Thu, 10 Aug 2023 09:36:34 -0700 (PDT) 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 302EE2187B; Thu, 10 Aug 2023 16:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691685393; 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=19h9QNSgdzIWywJanN9veEOMa6s1Xj+q+Cz0v3FP+f4=; b=vzqZq8M1QVHjJzcAciJEyysHegc4ljBQedRS1OxPDkK3CHjdyrBTf+D6vESZxsfkhbcdVL MIoyrdIPrePiMNwI+qW9AoKZpWA5gzajN/uBrziCUIySW9YuqYE3Yf3g2M13Ovrbehg/dr vI+tbRZzkrG3tO2oaTs0iBlNzeiRoys= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691685393; 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=19h9QNSgdzIWywJanN9veEOMa6s1Xj+q+Cz0v3FP+f4=; b=NWWqKFNbDZBln4sSAtj33wuORgNzUuDPhyE63EaKkKg3gsXILvYYR+v0b3lf9S97ya6XCE f5wjW2+XbXSXUoCg== 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 F1D3C138E0; Thu, 10 Aug 2023 16:36:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IBVjOhAS1WSEPQAAMHmgww (envelope-from ); Thu, 10 Aug 2023 16:36:32 +0000 From: Vlastimil Babka To: "Liam R. Howlett" , Matthew Wilcox , Suren Baghdasaryan , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Vlastimil Babka Subject: [RFC v2 4/7] maple_tree: avoid bulk alloc/free to use percpu array more Date: Thu, 10 Aug 2023 18:36:32 +0200 Message-ID: <20230810163627.6206-13-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810163627.6206-9-vbabka@suse.cz> References: <20230810163627.6206-9-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Using bulk alloc/free on a cache with percpu array should not be necessary and the bulk alloc actually bypasses the array (the prefill functionality currently relies on this). The simplest change for now is just to convert the respective maple tree wrappers to do a loop of normal alloc/free. We can optimize later versions if needed. --- lib/maple_tree.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 1196d0a17f03..926bee7a274a 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -161,12 +161,20 @@ static inline struct maple_node *mt_alloc_one(gfp_t g= fp) =20 static inline int mt_alloc_bulk(gfp_t gfp, size_t size, void **nodes) { - return kmem_cache_alloc_bulk(maple_node_cache, gfp, size, nodes); + int i; + + for (i =3D 0; i < size; i++) { + nodes[i] =3D kmem_cache_alloc(maple_node_cache, gfp); + if (!nodes[i]) + break; + } + return i; } =20 static inline void mt_free_bulk(size_t size, void __rcu **nodes) { - kmem_cache_free_bulk(maple_node_cache, size, (void **)nodes); + for (size_t i =3D 0; i < size; i++) + kmem_cache_free(maple_node_cache, nodes[i]); } =20 static void mt_free_rcu(struct rcu_head *head) --=20 2.41.0