From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
To: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: corbet@lwn.net, akpm@linux-foundation.org, willy@infradead.org,
brauner@kernel.org, surenb@google.com,
michael.christie@oracle.com, peterz@infradead.org,
mathieu.desnoyers@efficios.com, npiggin@gmail.com,
avagin@gmail.com, linux-mm@kvack.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 5/6] maple_tree: Update check_forking() and bench_forking()
Date: Thu, 7 Sep 2023 16:14:02 -0400 [thread overview]
Message-ID: <20230907201402.znapmmzbdh4wpsg5@revolver> (raw)
In-Reply-To: <20230830125654.21257-6-zhangpeng.00@bytedance.com>
* Peng Zhang <zhangpeng.00@bytedance.com> [230830 08:57]:
> Updated check_forking() and bench_forking() to use __mt_dup() to
> duplicate maple tree. Also increased the number of VMAs, because the
> new way is faster.
>
> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
> ---
> 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 0ec0c6a7c0b5..72fba7cce148 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 = 300, ret;
check_forking can probably remain at 134, I set it to to 134 as a
'reasonable' value. Unless you want 300 to test some specific case in
your case?
> 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(&mas);
> +
> + 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 = 300, 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(&mas);
Should probably switch this locking to not nest as well, since you have
to make the test framework cope with it already :/
> + 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
>
next prev parent reply other threads:[~2023-09-07 20:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 12:56 [PATCH v2 0/6] Introduce __mt_dup() to improve the performance of fork() Peng Zhang
2023-08-30 12:56 ` [PATCH v2 1/6] maple_tree: Add two helpers Peng Zhang
2023-09-07 20:13 ` Liam R. Howlett
2023-09-08 2:45 ` Peng Zhang
2023-08-30 12:56 ` [PATCH v2 2/6] maple_tree: Introduce interfaces __mt_dup() and mtree_dup() Peng Zhang
2023-09-07 20:13 ` Liam R. Howlett
2023-09-08 9:26 ` Peng Zhang
2023-09-08 16:05 ` Liam R. Howlett
2023-09-11 12:59 ` Peng Zhang
2023-09-11 13:36 ` Liam R. Howlett
2023-08-30 12:56 ` [PATCH v2 3/6] maple_tree: Add test for mtree_dup() Peng Zhang
2023-09-07 20:13 ` Liam R. Howlett
2023-09-08 9:38 ` Peng Zhang
2023-09-25 4:06 ` Peng Zhang
2023-09-25 7:44 ` Liam R. Howlett
2023-09-25 8:30 ` Peng Zhang
2023-08-30 12:56 ` [PATCH v2 4/6] maple_tree: Skip other tests when BENCH is enabled Peng Zhang
2023-08-30 12:56 ` [PATCH v2 5/6] maple_tree: Update check_forking() and bench_forking() Peng Zhang
2023-08-31 13:40 ` kernel test robot
2023-09-01 10:58 ` Peng Zhang
2023-09-07 18:03 ` Liam R. Howlett
2023-09-07 18:16 ` Matthew Wilcox
2023-09-08 9:47 ` Peng Zhang
2023-09-07 20:14 ` Liam R. Howlett [this message]
2023-08-30 12:56 ` [PATCH v2 6/6] fork: Use __mt_dup() to duplicate maple tree in dup_mmap() Peng Zhang
2023-09-07 20:14 ` Liam R. Howlett
2023-09-08 9:58 ` Peng Zhang
2023-09-08 16:07 ` Liam R. Howlett
2023-09-15 10:51 ` Peng Zhang
2023-09-15 10:56 ` Peng Zhang
2023-09-15 20:00 ` Liam R. Howlett
2023-09-18 13:14 ` Peng Zhang
2023-09-18 17:59 ` Liam R. Howlett
2023-08-30 13:05 ` [PATCH v2 0/6] Introduce __mt_dup() to improve the performance of fork() Peng Zhang
2023-09-07 20:19 ` Liam R. Howlett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230907201402.znapmmzbdh4wpsg5@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=michael.christie@oracle.com \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=surenb@google.com \
--cc=willy@infradead.org \
--cc=zhangpeng.00@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).