Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4596853rwb; Tue, 8 Aug 2023 10:42:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHza5mnbFmnAn8JIK7uTrFMi7wWXaNVEXAe0xSVZuJxJEoneOVjYstv4pxyhj8tQdL3RADh X-Received: by 2002:a17:90b:4b42:b0:268:3ea0:7160 with SMTP id mi2-20020a17090b4b4200b002683ea07160mr307272pjb.0.1691516521540; Tue, 08 Aug 2023 10:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691516521; cv=none; d=google.com; s=arc-20160816; b=uS9Y2o2R7ETuYDz9q+lAndF/ngQifKbntra8VRtF0g/roQALLc+flXqp55y1WTWZS7 LaeZIuqluZuGRH89XFJSMvT24DN45khgK+DZdKbS5OjrygkHQYG5ajBywl3M0XEpbkXU 3nJmK+zyWBgRtejYmx+Dj8uyfBk70/UDEFRWALQk9viFOudpkJfbVL/4gnIEv0rPiC1q RkpkVL/cb0dZqAIkGfoJFWkMM2Ly49bb9n6UucezWwnyN1P3QmzIA49Z5G9PS7sa00wJ tC8HG92jN+NcUrgT4IEjdv3BjJZWjQTI3JT/c/LJRavOhmaRZK92IPRp/hDSEYitERwP KVtA== 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=i6TQwXZ4v9nk5j9z/G1P0QjfrlA/rpwYdzHk2PVBTRo=; fh=sDCYtOtQNr4J8m+XjxLSaS1eoEDwapxZAeFBp4YZzdY=; b=BSfmq+GnRXGIDyxAxuAIvJ68fL5inLOsXKv0mXzEBe6T2g/mOcM4KOs1jcdvWFQP6g i1+aC6fcIvaRzahUyu8PsofO0pDucjwq9ZraLkwuew5/w/93kEvhVzfFzjhyy7tbt563 9mOjX72NMkrJPZgf4LZwJcl6rPdm9gEgMN6OIh1k8r4XUCe5BTS+KbRPIrJaJcL54l8M bWKFHQSkGZReAO+l7IqX6bAZavCn7hMErA8d8oyOOUptbJK22KV8MXFzXFhai5zC+W8B tHGKzuRYBmxemjQVRKkLfDbaC/KJ168rgTCT7EzWVuRC5uoSbFbruCXc5LKy1b3kIy2z onmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=sMK735vG; dkim=neutral (no key) header.i=@suse.cz; 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 az6-20020a170902a58600b001b9ce7a85cbsi7288064plb.281.2023.08.08.10.41.49; Tue, 08 Aug 2023 10:42:01 -0700 (PDT) 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=sMK735vG; dkim=neutral (no key) header.i=@suse.cz; 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 S232955AbjHHQff (ORCPT + 99 others); Tue, 8 Aug 2023 12:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232972AbjHHQeb (ORCPT ); Tue, 8 Aug 2023 12:34:31 -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 1E62090AE for ; Tue, 8 Aug 2023 08:52:32 -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 5CA9E2248A; Tue, 8 Aug 2023 09:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691488433; 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=i6TQwXZ4v9nk5j9z/G1P0QjfrlA/rpwYdzHk2PVBTRo=; b=sMK735vGrxWU1VYbx6RUmceJoQbzNocoGXJWDnHnQMuYYl5OwU3eFj+3qgZ8Ba0mFBaNLq Oq7pXw3+pm/6X820956mlj1IpRt+1zQo128JYQOLdIXM+09UMZwOMLvmaDtJEvC7VeLAxw oWjOyz1mC/TZfMdOelpD4y7kBG9k37Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691488433; 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=i6TQwXZ4v9nk5j9z/G1P0QjfrlA/rpwYdzHk2PVBTRo=; b=qySqY3LEh48iTLSTZF1kLGV3kFsl/U5DLBfmwlVvoTvtGqeP3Z4gT7neP5svnR3Q21mOnH hlN2F/r3TLQ+AODw== 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 2649513451; Tue, 8 Aug 2023 09:53:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AFq7CLEQ0mSBJQAAMHmgww (envelope-from ); Tue, 08 Aug 2023 09:53:53 +0000 From: Vlastimil Babka To: "Liam R. Howlett" , Matthew Wilcox , 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 v1 4/5] maple_tree: avoid bulk alloc/free to use percpu array more Date: Tue, 8 Aug 2023 11:53:47 +0200 Message-ID: <20230808095342.12637-11-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808095342.12637-7-vbabka@suse.cz> References: <20230808095342.12637-7-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,URIBL_BLOCKED autolearn=no 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 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 is just to convert the respective maple tree wrappers to do a loop of normal alloc/free. --- lib/maple_tree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 1196d0a17f03..7a8e7c467d7c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -161,12 +161,19 @@ static inline struct maple_node *mt_alloc_one(gfp_t gfp) 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 allocated = 0; + for (size_t i = 0; i < size; i++) { + nodes[i] = kmem_cache_alloc(maple_node_cache, gfp); + if (nodes[i]) + allocated++; + } + return allocated; } 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 = 0; i < size; i++) + kmem_cache_free(maple_node_cache, nodes[i]); } static void mt_free_rcu(struct rcu_head *head) -- 2.41.0