Message ID | 20230407040718.99064-1-zhangpeng.00@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/2] maple_tree: Add a test case to check maple_alloc | expand |
* Peng Zhang <zhangpeng.00@bytedance.com> [230407 00:09]: > Add a test case to check whether the number of maple_alloc structures is > actually equal to mas->alloc->total. Please have a look at check_new_node() as there are tests there already and see if it covers what you are trying to test. > > Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> > --- > tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c > index 958ee9bdb316..26389e0dcfff 100644 > --- a/tools/testing/radix-tree/maple.c > +++ b/tools/testing/radix-tree/maple.c > @@ -55,6 +55,28 @@ struct rcu_reader_struct { > struct rcu_test_struct2 *test; > }; > > +static int get_alloc_node_count(struct ma_state *mas) > +{ > + int count = 1; > + struct maple_alloc *node = mas->alloc; > + > + if (!node || ((unsigned long)node & 0x1)) > + return 0; > + while (node->node_count) { > + count += node->node_count; > + node = node->slot[0]; > + } > + return count; > +} > + > +static void check_mas_alloc_node_count(struct ma_state *mas) > +{ > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 1, GFP_KERNEL); > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 3, GFP_KERNEL); > + MT_BUG_ON(mas->tree, get_alloc_node_count(mas) != mas->alloc->total); > + mas_destroy(mas); > +} > + > /* > * check_new_node() - Check the creation of new nodes and error path > * verification. > @@ -69,6 +91,8 @@ static noinline void check_new_node(struct maple_tree *mt) > > MA_STATE(mas, mt, 0, 0); > > + check_mas_alloc_node_count(&mas); > + > /* Try allocating 3 nodes */ > mtree_lock(mt); > mt_set_non_kernel(0); > -- > 2.20.1 >
* Liam R. Howlett <Liam.Howlett@Oracle.com> [230407 23:17]: > * Peng Zhang <zhangpeng.00@bytedance.com> [230407 00:09]: > > Add a test case to check whether the number of maple_alloc structures is > > actually equal to mas->alloc->total. > > Please have a look at check_new_node() as there are tests there already > and see if it covers what you are trying to test. Sorry, sent this too fast. I'll have a look after the holiday here. > > > > > Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> > > --- > > tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c > > index 958ee9bdb316..26389e0dcfff 100644 > > --- a/tools/testing/radix-tree/maple.c > > +++ b/tools/testing/radix-tree/maple.c > > @@ -55,6 +55,28 @@ struct rcu_reader_struct { > > struct rcu_test_struct2 *test; > > }; > > > > +static int get_alloc_node_count(struct ma_state *mas) > > +{ > > + int count = 1; > > + struct maple_alloc *node = mas->alloc; > > + > > + if (!node || ((unsigned long)node & 0x1)) > > + return 0; > > + while (node->node_count) { > > + count += node->node_count; > > + node = node->slot[0]; > > + } > > + return count; > > +} > > + > > +static void check_mas_alloc_node_count(struct ma_state *mas) > > +{ > > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 1, GFP_KERNEL); > > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 3, GFP_KERNEL); > > + MT_BUG_ON(mas->tree, get_alloc_node_count(mas) != mas->alloc->total); > > + mas_destroy(mas); > > +} > > + > > /* > > * check_new_node() - Check the creation of new nodes and error path > > * verification. > > @@ -69,6 +91,8 @@ static noinline void check_new_node(struct maple_tree *mt) > > > > MA_STATE(mas, mt, 0, 0); > > > > + check_mas_alloc_node_count(&mas); > > + > > /* Try allocating 3 nodes */ > > mtree_lock(mt); > > mt_set_non_kernel(0); > > -- > > 2.20.1 > >
* Peng Zhang <zhangpeng.00@bytedance.com> [230407 00:09]: > Add a test case to check whether the number of maple_alloc structures is > actually equal to mas->alloc->total. Thanks for the test case. Can you please send the code to fix the issue first in the future? This way the verification code can be used to bisect any issues. > > Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> > --- > tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c > index 958ee9bdb316..26389e0dcfff 100644 > --- a/tools/testing/radix-tree/maple.c > +++ b/tools/testing/radix-tree/maple.c > @@ -55,6 +55,28 @@ struct rcu_reader_struct { > struct rcu_test_struct2 *test; > }; > > +static int get_alloc_node_count(struct ma_state *mas) > +{ > + int count = 1; > + struct maple_alloc *node = mas->alloc; > + > + if (!node || ((unsigned long)node & 0x1)) > + return 0; > + while (node->node_count) { > + count += node->node_count; > + node = node->slot[0]; > + } > + return count; > +} > + > +static void check_mas_alloc_node_count(struct ma_state *mas) > +{ > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 1, GFP_KERNEL); > + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 3, GFP_KERNEL); > + MT_BUG_ON(mas->tree, get_alloc_node_count(mas) != mas->alloc->total); > + mas_destroy(mas); > +} > + > /* > * check_new_node() - Check the creation of new nodes and error path > * verification. > @@ -69,6 +91,8 @@ static noinline void check_new_node(struct maple_tree *mt) > > MA_STATE(mas, mt, 0, 0); > > + check_mas_alloc_node_count(&mas); > + > /* Try allocating 3 nodes */ > mtree_lock(mt); > mt_set_non_kernel(0); > -- > 2.20.1 >
在 2023/4/10 20:41, Liam R. Howlett 写道: > * Peng Zhang <zhangpeng.00@bytedance.com> [230407 00:09]: >> Add a test case to check whether the number of maple_alloc structures is >> actually equal to mas->alloc->total. > Thanks for the test case. Can you please send the code to fix the issue > first in the future? This way the verification code can be used to > bisect any issues. Ok, I will exchange the order of the two patches in the next version. > >> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> >> --- >> tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++ >> 1 file changed, 24 insertions(+) >> >> diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c >> index 958ee9bdb316..26389e0dcfff 100644 >> --- a/tools/testing/radix-tree/maple.c >> +++ b/tools/testing/radix-tree/maple.c >> @@ -55,6 +55,28 @@ struct rcu_reader_struct { >> struct rcu_test_struct2 *test; >> }; >> >> +static int get_alloc_node_count(struct ma_state *mas) >> +{ >> + int count = 1; >> + struct maple_alloc *node = mas->alloc; >> + >> + if (!node || ((unsigned long)node & 0x1)) >> + return 0; >> + while (node->node_count) { >> + count += node->node_count; >> + node = node->slot[0]; >> + } >> + return count; >> +} >> + >> +static void check_mas_alloc_node_count(struct ma_state *mas) >> +{ >> + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 1, GFP_KERNEL); >> + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 3, GFP_KERNEL); >> + MT_BUG_ON(mas->tree, get_alloc_node_count(mas) != mas->alloc->total); >> + mas_destroy(mas); >> +} >> + >> /* >> * check_new_node() - Check the creation of new nodes and error path >> * verification. >> @@ -69,6 +91,8 @@ static noinline void check_new_node(struct maple_tree *mt) >> >> MA_STATE(mas, mt, 0, 0); >> >> + check_mas_alloc_node_count(&mas); >> + >> /* Try allocating 3 nodes */ >> mtree_lock(mt); >> mt_set_non_kernel(0); >> -- >> 2.20.1 >>
diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c index 958ee9bdb316..26389e0dcfff 100644 --- a/tools/testing/radix-tree/maple.c +++ b/tools/testing/radix-tree/maple.c @@ -55,6 +55,28 @@ struct rcu_reader_struct { struct rcu_test_struct2 *test; }; +static int get_alloc_node_count(struct ma_state *mas) +{ + int count = 1; + struct maple_alloc *node = mas->alloc; + + if (!node || ((unsigned long)node & 0x1)) + return 0; + while (node->node_count) { + count += node->node_count; + node = node->slot[0]; + } + return count; +} + +static void check_mas_alloc_node_count(struct ma_state *mas) +{ + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 1, GFP_KERNEL); + mas_node_count_gfp(mas, MAPLE_ALLOC_SLOTS + 3, GFP_KERNEL); + MT_BUG_ON(mas->tree, get_alloc_node_count(mas) != mas->alloc->total); + mas_destroy(mas); +} + /* * check_new_node() - Check the creation of new nodes and error path * verification. @@ -69,6 +91,8 @@ static noinline void check_new_node(struct maple_tree *mt) MA_STATE(mas, mt, 0, 0); + check_mas_alloc_node_count(&mas); + /* Try allocating 3 nodes */ mtree_lock(mt); mt_set_non_kernel(0);
Add a test case to check whether the number of maple_alloc structures is actually equal to mas->alloc->total. Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> --- tools/testing/radix-tree/maple.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)