Received: by 2002:ac8:5491:0:b0:40f:fb00:664b with SMTP id h17csp607789qtq; Thu, 10 Aug 2023 10:21:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEl58c1NKfPGdUTGnY9DAhouM4CnoGNfoUmj80htCGddwj7TPw5w9+gE3dC2crV3x8mcD+0 X-Received: by 2002:a17:906:9755:b0:98d:abd4:4000 with SMTP id o21-20020a170906975500b0098dabd44000mr3052494ejy.35.1691688086533; Thu, 10 Aug 2023 10:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691688086; cv=none; d=google.com; s=arc-20160816; b=gqd0yQvIFncTmXyP1doEF/3DgBonf/bdaf/njoUq526g+i4rdmvtNRlFtBhT07QA/T RovM/JB6obzcMQJ7jU2Wtj/Bfh5FAIxZG6Ty2v82oxkApr3bK8nOMu4pqPOyfMit3601 CP08rPdoGdvK3g2lg7MEdHyia7lbT+8wOXbMAwOLCAFohn2Gtcr4KCH6Ycw0GskXxoNg Sgx7aQy3tQoljphDcG9V0uzAHvGFsNQyb65QcKOch11qScd95WWjL8yBzm0xcb/X+bY5 VczAltKl3KgpHcEeJdJNipKA5reM3ORYNylfJmJFMcEk9TxfOtsm/XIxQ1bG4KLUranV imhg== 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=81VWuf1Jqzz86k9wDN7LrYfBK2s1ZDCqD4SXLtwC3uA=; fh=2pBnSfjX50e7Wv5klf1T27fGwt6nBz7bVyyBTq15zE4=; b=KdM/KgxeJtpxHp6XfC9NilGLy/k+LrFh7gycCT1/2D9hv/NcJ2kiboDTGHAu2JugqD uO9RbrQwV21koDLEfncL5Rpj6JGiUUiXBQdRzaVyqb0yOir55nShEqiAw+t/ttlNvRHW rh/OJFGNUoaIaop+EP/Azj8i45Ro1DonsF9GyShjWdxNBRLMJV77iNpkAND7Oi9rgd0Y bRsrpGdsbDE125Y3dDANryRLih/AhCcfi6mypv5Iw9HZ0YlKVUXm9KFiWydMhv4vUbsW eSqnasBxrqtGloJx9Gssn6YjjSoO98tu/j78sOjGKjMnNDFxS+HNctMre/pU/HxpOEnJ x4TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="vGJ6/1Wt"; 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 z26-20020aa7cf9a000000b005236537c1b8si1744137edx.109.2023.08.10.10.21.01; Thu, 10 Aug 2023 10:21:26 -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="vGJ6/1Wt"; 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 S235641AbjHJQgr (ORCPT + 99 others); Thu, 10 Aug 2023 12:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235008AbjHJQgf (ORCPT ); Thu, 10 Aug 2023 12:36:35 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF5E103 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-out2.suse.de (Postfix) with ESMTPS id 614A21F750; 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=81VWuf1Jqzz86k9wDN7LrYfBK2s1ZDCqD4SXLtwC3uA=; b=vGJ6/1WteLNGdLHhKpW6hrMYCuWBe6WzoYcWBYsk/0kPZb7z0w1EKu7Caou9OwoQqM0QPD hTllK+yJdN9fv7kLVpgI2tCN5xKxsmExHBA4r/mVMBQaMFAfb4YFTFCu538cEnR6H1DKSn dLBkK+T1U+VHRemqTiutB021iD242/0= 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=81VWuf1Jqzz86k9wDN7LrYfBK2s1ZDCqD4SXLtwC3uA=; b=9x9XyqLN8gJpEQKeJMyMY/R1t7RGpoiajCpyEbPmS092cPUZLAJeo+as7qvBiBUDFncs97 rZ5jw5kHYfhuUuBA== 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 329D1139D1; Thu, 10 Aug 2023 16:36:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GPC5CxES1WSEPQAAMHmgww (envelope-from ); Thu, 10 Aug 2023 16:36:33 +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 5/7] maple_tree: Remove MA_STATE_PREALLOC Date: Thu, 10 Aug 2023 18:36:33 +0200 Message-ID: <20230810163627.6206-14-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=-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 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 From: "Liam R. Howlett" MA_SATE_PREALLOC was added to catch any writes that try to allocate when the maple state is being used in preallocation mode. This can safely be removed in favour of the percpu array of nodes. Note that mas_expected_entries() still expects no allocations during operation and so MA_STATE_BULK can be used in place of preallocations for this case, which is primarily used for forking. Signed-off-by: Liam R. Howlett Signed-off-by: Vlastimil Babka --- lib/maple_tree.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 926bee7a274a..8bd4a79537d8 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -68,11 +68,9 @@ * Maple state flags * * MA_STATE_BULK - Bulk insert mode * * MA_STATE_REBALANCE - Indicate a rebalance during bulk insert - * * MA_STATE_PREALLOC - Preallocated nodes, WARN_ON allocation */ #define MA_STATE_BULK 1 #define MA_STATE_REBALANCE 2 -#define MA_STATE_PREALLOC 4 #define ma_parent_ptr(x) ((struct maple_pnode *)(x)) #define ma_mnode_ptr(x) ((struct maple_node *)(x)) @@ -1280,11 +1278,8 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp) return; mas_set_alloc_req(mas, 0); - if (mas->mas_flags & MA_STATE_PREALLOC) { - if (allocated) - return; - WARN_ON(!allocated); - } + if (mas->mas_flags & MA_STATE_BULK) + return; if (!allocated || mas->alloc->node_count == MAPLE_ALLOC_SLOTS) { node = (struct maple_alloc *)mt_alloc_one(gfp); @@ -5596,7 +5591,7 @@ void mas_destroy(struct ma_state *mas) mas->mas_flags &= ~MA_STATE_REBALANCE; } - mas->mas_flags &= ~(MA_STATE_BULK|MA_STATE_PREALLOC); + mas->mas_flags &= ~MA_STATE_BULK; total = mas_allocated(mas); while (total) { @@ -5645,9 +5640,6 @@ int mas_expected_entries(struct ma_state *mas, unsigned long nr_entries) * of nodes during the operation. */ - /* Optimize splitting for bulk insert in-order */ - mas->mas_flags |= MA_STATE_BULK; - /* * Avoid overflow, assume a gap between each entry and a trailing null. * If this is wrong, it just means allocation can happen during @@ -5664,8 +5656,9 @@ int mas_expected_entries(struct ma_state *mas, unsigned long nr_entries) /* Add working room for split (2 nodes) + new parents */ mas_node_count(mas, nr_nodes + 3); - /* Detect if allocations run out */ - mas->mas_flags |= MA_STATE_PREALLOC; + /* Optimize splitting for bulk insert in-order */ + mas->mas_flags |= MA_STATE_BULK; + if (!mas_is_err(mas)) return 0; -- 2.41.0