Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1766872rdb; Mon, 9 Oct 2023 02:06:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn5jpreRG/k0agHUTEFgLHFUFE38jTR0Zeg694guJ/Vzrmt/fIjqAl1jP3wEHlpBB9iipK X-Received: by 2002:a17:902:ed54:b0:1c6:845:27c5 with SMTP id y20-20020a170902ed5400b001c6084527c5mr15773785plb.61.1696842368985; Mon, 09 Oct 2023 02:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696842368; cv=none; d=google.com; s=arc-20160816; b=ulqG76acyKim3ZdhR1B2AbEd/uz0miiY1X1Z6KcX7EkXFckxZ/oirtCkQ1aieMfOmS zDLVfKHDy7+z8KX5/KTcCfsuMWHFyl+G1qcYx6d3j3zDldQETadOxw2HGdL3hXWSWvmg w3YtD+3DcKlQPaabqlXekfV+fbogblpITBcQ1Mjk5ZAhToDBwt+ThN9AA0K3PR+F4a4w XhqblIUz0fj577ypzqqxY6IrHhzpcWfGJC7v/QdcQ5uqyrl9YD9SLY36I+AJ8c0H9wUa GZuc3IDMSMOjihMRDBu0hYrTUa0FMr6ejv8vhtJN7CD7ePEk/0I36hb3TdyZiWpTYZXc tXAQ== 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; bh=8v1OZEFv5O146V21vBTm5TeKaYSuxLzybT1UdN8aEPI=; fh=W1ujNbDikRM6mL+MA7cZ93eipzimk+g+Mb7QYnlff5s=; b=QG4vCbyZ/7p4+lc2jteK4fmN5X+ZpVD2Nbux7IB9Tb04HEUy5Dy3P77vUQdxPCNCVg z9RDZ+ewlKvGZJX0zj9CTSFwRikquD1c5np76Gy6/ZT+pO+9K51ro9L/0Ka5NI5I2M/h KSn5npL55BfbGK5Hjcqmf3KQnqxu9UTXQwmWkiHg4Zw0iw8KFNWGuqb1EYSbs5TVYBje cHK0+QhvYUles200m3D9kclpJfjjiobNGSPhmLmkQ+wi+ikg9Ap9SG4/61VIEaxTvd1F ENEu+CvGvotvtbz5AJ4qTH/AG3fjoEd8nrkrNDyaDhYg38/WuTiz1YLyzJMpIHLfiXOw hTDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=I0rKt1N8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f12-20020a170902ab8c00b001b9d0ad0d40si8865631plr.128.2023.10.09.02.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=I0rKt1N8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 620A6807E7AA; Mon, 9 Oct 2023 02:06:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345789AbjJIJF1 (ORCPT + 99 others); Mon, 9 Oct 2023 05:05:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345723AbjJIJFD (ORCPT ); Mon, 9 Oct 2023 05:05:03 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7843E137 for ; Mon, 9 Oct 2023 02:04:36 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-690fa0eea3cso3869930b3a.0 for ; Mon, 09 Oct 2023 02:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1696842276; x=1697447076; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8v1OZEFv5O146V21vBTm5TeKaYSuxLzybT1UdN8aEPI=; b=I0rKt1N8inTZu5TielcQ78yFa9SEsOe2OWu6araY0ZfraOJaaAmedCcPJ8CWWhUcOu Ygd9cQxVAbwLZnYO77L+LgGYmKXUlwE+jMyrWzSNhFhoqpkqpIJl0IiZxZvHJJnxWdL8 ToFaUFJFTYkdhUSVbsduwioY7qIDG6WbV3Fk1wf/A2+oOj2T3+Ac4hgEHx83vAZ7zab7 X6xM4X5WHfED8xfQPwVijbEKTlH3yxu4fTwO6IDvQ8q7Tb4f86MixB9iYSxftu7ZiwAA AxS0PdJ41fSeqy1PHlJoF6VcqupLSIOCkn9FQgXR7AkNldBOfOT2nm6be2kTtb2DnRM7 WHAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696842276; x=1697447076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8v1OZEFv5O146V21vBTm5TeKaYSuxLzybT1UdN8aEPI=; b=EvuMjsfXTzSeKhsytfU5RaLg/x69GiiXQSpiMZIE0Oxr6u7OCWP3LqAd/wLA0vr3Yz MjOEGW9yMwaDmd69m2Fl5bKoOhcNljGCPdU20RN2XGg7iDVqj1OxS+4e1J8l3XmDphH7 ZlPFhovc6DseO9kdeF+b1Q9sUQ6B9onRjt/8Niys7IwPL/Pvh+LK1s322p7hoDCdA6Kn nhamKC32BYr+X7c0bvoOaieHVw/addAaQfaH0WIeLW0XiBEAN0p3uh3o2XO79gaNY1F4 /8ModotSMyzh8Rv6wgelR0VgTOShORqkuj1fpKyZxibNw/Ij7CTnUz7du3JF1/nROaij VUzQ== X-Gm-Message-State: AOJu0YxPZYFTQXBSt0Fvhg7ewCM3qT1Q0YXJwG3gTifOvETl/jLk4Jf9 QsOKUZc4OG6zQgb/FsXDWu3M0Q== X-Received: by 2002:a05:6a00:158c:b0:690:b7a1:ac51 with SMTP id u12-20020a056a00158c00b00690b7a1ac51mr19018763pfk.31.1696842275718; Mon, 09 Oct 2023 02:04:35 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id fk3-20020a056a003a8300b00690ca4356f1sm5884847pfb.198.2023.10.09.02.04.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Oct 2023 02:04:35 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com, corbet@lwn.net, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, mjguzik@gmail.com, mathieu.desnoyers@efficios.com, npiggin@gmail.com, peterz@infradead.org, oliver.sang@intel.com, mst@redhat.com Cc: zhangpeng.00@bytedance.com, maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v4 08/10] maple_tree: Update check_forking() and bench_forking() Date: Mon, 9 Oct 2023 17:03:18 +0800 Message-Id: <20231009090320.64565-9-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20231009090320.64565-1-zhangpeng.00@bytedance.com> References: <20231009090320.64565-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 02:06:04 -0700 (PDT) X-Spam-Level: ** Updated check_forking() and bench_forking() to use __mt_dup() to duplicate maple tree. Signed-off-by: Peng Zhang --- lib/test_maple_tree.c | 61 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 27d424fad797..bcd07c220a13 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -1837,36 +1837,37 @@ static noinline void __init check_forking(struct maple_tree *mt) { struct maple_tree newmt; - int i, nr_entries = 134; + int i, nr_entries = 134, ret; void *val; MA_STATE(mas, mt, 0, 0); - MA_STATE(newmas, mt, 0, 0); + MA_STATE(newmas, &newmt, 0, 0); + + mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE); for (i = 0; i <= nr_entries; i++) mtree_store_range(mt, i*10, i*10 + 5, xa_mk_value(i), GFP_KERNEL); + mt_set_non_kernel(99999); - mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE); - newmas.tree = &newmt; - mas_reset(&newmas); - mas_reset(&mas); mas_lock(&newmas); - mas.index = 0; - mas.last = 0; - if (mas_expected_entries(&newmas, nr_entries)) { + mas_lock_nested(&mas, SINGLE_DEPTH_NESTING); + + ret = __mt_dup(mt, &newmt, GFP_NOWAIT | __GFP_NOWARN); + if (ret) { pr_err("OOM!"); BUG_ON(1); } - rcu_read_lock(); - mas_for_each(&mas, val, ULONG_MAX) { - newmas.index = mas.index; - newmas.last = mas.last; + + mas_set(&newmas, 0); + mas_for_each(&newmas, val, ULONG_MAX) { mas_store(&newmas, val); } - rcu_read_unlock(); - mas_destroy(&newmas); + + mas_unlock(&mas); mas_unlock(&newmas); + + mas_destroy(&newmas); mt_validate(&newmt); mt_set_non_kernel(0); mtree_destroy(&newmt); @@ -1974,12 +1975,11 @@ static noinline void __init check_mas_store_gfp(struct maple_tree *mt) #if defined(BENCH_FORK) static noinline void __init bench_forking(struct maple_tree *mt) { - struct maple_tree newmt; - int i, nr_entries = 134, nr_fork = 80000; + int i, nr_entries = 134, nr_fork = 80000, ret; void *val; MA_STATE(mas, mt, 0, 0); - MA_STATE(newmas, mt, 0, 0); + MA_STATE(newmas, &newmt, 0, 0); for (i = 0; i <= nr_entries; i++) mtree_store_range(mt, i*10, i*10 + 5, @@ -1988,25 +1988,24 @@ static noinline void __init bench_forking(struct maple_tree *mt) for (i = 0; i < nr_fork; i++) { mt_set_non_kernel(99999); mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE); - newmas.tree = &newmt; - mas_reset(&newmas); - mas_reset(&mas); - mas.index = 0; - mas.last = 0; - rcu_read_lock(); + mas_lock(&newmas); - if (mas_expected_entries(&newmas, nr_entries)) { - printk("OOM!"); + mas_lock_nested(&mas, SINGLE_DEPTH_NESTING); + ret = __mt_dup(mt, &newmt, GFP_NOWAIT | __GFP_NOWARN); + if (ret) { + pr_err("OOM!"); BUG_ON(1); } - mas_for_each(&mas, val, ULONG_MAX) { - newmas.index = mas.index; - newmas.last = mas.last; + + mas_set(&newmas, 0); + mas_for_each(&newmas, val, ULONG_MAX) { mas_store(&newmas, val); } - mas_destroy(&newmas); + + mas_unlock(&mas); mas_unlock(&newmas); - rcu_read_unlock(); + + mas_destroy(&newmas); mt_validate(&newmt); mt_set_non_kernel(0); mtree_destroy(&newmt); -- 2.20.1