Received: by 2002:ac8:5491:0:b0:40f:fb00:664b with SMTP id h17csp628130qtq; Thu, 10 Aug 2023 11:00:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHJGpI+5ZqMrsB8QSTuE8cDWsjqifQJR6cj/Q4Mnlk2Znaoawz7GzOtjc4X8l3ZGzXfMwQ X-Received: by 2002:a17:903:546:b0:1b9:e8e4:620e with SMTP id jo6-20020a170903054600b001b9e8e4620emr2365985plb.47.1691690429509; Thu, 10 Aug 2023 11:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691690429; cv=none; d=google.com; s=arc-20160816; b=eWM0gJtAQd9PvTDCfOCPtr0lSZgHVWlfDuYsE0dPg1cYnF7cEvEvcEXrfooYg1wjvo qznmokgv0MKhS3a6eJ0GcOs0of8xykOnfodQM+eUenfPymIWUG2DuOOddHTxhbxIsHlP qv2eB+DaIhj4W4TVPlMa2NNA0DqbRRJmJGYQepNCalgb2YGac7jwz1hh2MJN+mBSsqvM QqZkoN+lyFRQWG9Lw2xgdk7UtCMpAGB9A012q20iwIvIhwe5A4CJNmv1j935eTduyy8e zSvKaIRrMGgMkxCUDhYs31Xrs42WPswy1FUIjuf9IFrLLORzxluCWazjtsRM4YKdW/cI opag== 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=19h9QNSgdzIWywJanN9veEOMa6s1Xj+q+Cz0v3FP+f4=; fh=2pBnSfjX50e7Wv5klf1T27fGwt6nBz7bVyyBTq15zE4=; b=0spHx8WUhigVVu3ES1ldaOOeTBRx71MTMMJ6klvGUFpV9hniXB7IJ0Z8ISr7L4ImxF SEkTN65FqCyaXInxBegIqiEtfJM/q9lHEajGbmcDPxW8m+cBm4u/Ssvo0sBtgW5h7cOI FFsFq0eVb2/2Ky6sXidR9lzUbTF+E/YRMuSfIJXaakjGfa5ZojJ4BALzLJfL2mcsXdpE 9YsN/JHL5wEvOn5D6AbMfqBZC7u0SgwOpskPG7QZbiLIJhCIx1/b6pnnaWegjHNShqk7 lbSsVhVbJFJXUbApub0imi8KG9v4f60Lt0rF4LCUJJV2C5d3Zxs45Ynx98ykvy9k5UPf qR3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=vzqZq8M1; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 a6-20020a170902ecc600b001b7eb771d5esi1904732plh.527.2023.08.10.11.00.17; Thu, 10 Aug 2023 11:00:29 -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=vzqZq8M1; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S235470AbjHJQgn (ORCPT + 99 others); Thu, 10 Aug 2023 12:36:43 -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: 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 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 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 i; + + for (i = 0; i < size; i++) { + nodes[i] = kmem_cache_alloc(maple_node_cache, gfp); + if (!nodes[i]) + break; + } + return i; } 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