* [PATCH] lib: fix lock initialization in region allocation benchmark
@ 2026-09-11 15:52 Yury Norov
2026-09-15 15:28 ` Liam R. Howlett
0 siblings, 1 reply; 2+ messages in thread
From: Yury Norov @ 2026-09-11 15:52 UTC (permalink / raw)
To: Liam R. Howlett, Alice Ryhl, Andrew Ballance, Yury Norov,
Rasmus Villemoes, Andrew Morton, Matthew Wilcox, Eliot Courtney,
maple-tree, linux-mm, linux-kernel, linux-fsdevel
Cc: Yury Norov
The Maple Tree benchmark uses MTREE_INIT() for a stack-allocated tree.
Its static spinlock initializer leaves lockdep to use the lock address
as the class key. Since the address is on the stack, the first allocation
triggers "INFO: trying to register non-static key" and disables lockdep.
The IDA benchmark has the same problem through IDA_INIT(), but runs after
Maple Tree and therefore encounters an already disabled lockdep.
Use mt_init_flags() and ida_init() to initialize the locks with persistent
lock-class keys. Keep initialization outside the timed allocation paths.
Fixes: f4806cc63cc6 ("lib: test bitmap vs IDA vs Maple Tree performance for region allocations")
Closes: https://lore.kernel.org/oe-lkp/202609101106.771b567e-lkp@intel.com
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
lib/region_alloc_benchmark.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/region_alloc_benchmark.c b/lib/region_alloc_benchmark.c
index e88b4cf55c62..a644f3d5431a 100644
--- a/lib/region_alloc_benchmark.c
+++ b/lib/region_alloc_benchmark.c
@@ -78,11 +78,13 @@ static size_t __init ida_size(unsigned long nr_ids)
static unsigned long __init benchmark_ida(unsigned long cap)
{
- struct ida ida = IDA_INIT(ida);
+ struct ida ida;
unsigned long cnt, idx, off, nr_ids = 0;
ktime_t alloc_time, free_time;
int id = -ENOSPC;
+ ida_init(&ida);
+
alloc_time = ktime_get();
for (cnt = 0; cnt <= cap; cnt++) {
for (off = 0; off < reg_sz[cnt]; off++) {
@@ -125,12 +127,14 @@ static unsigned long __init benchmark_ida(unsigned long cap)
static unsigned long __init benchmark_maple_tree(unsigned long cap)
{
- struct maple_tree mt = MTREE_INIT(mt, MT_FLAGS_ALLOC_RANGE);
+ struct maple_tree mt;
unsigned long cnt, idx;
ktime_t alloc_time, free_time;
size_t sz;
int ret;
+ mt_init_flags(&mt, MT_FLAGS_ALLOC_RANGE);
+
alloc_time = ktime_get();
for (cnt = 0; cnt <= cap; cnt++) {
ret = mtree_alloc_range(&mt, &idx, xa_mk_value(cnt + 1),
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib: fix lock initialization in region allocation benchmark
2026-09-11 15:52 [PATCH] lib: fix lock initialization in region allocation benchmark Yury Norov
@ 2026-09-15 15:28 ` Liam R. Howlett
0 siblings, 0 replies; 2+ messages in thread
From: Liam R. Howlett @ 2026-09-15 15:28 UTC (permalink / raw)
To: Yury Norov
Cc: Alice Ryhl, Andrew Ballance, Rasmus Villemoes, Andrew Morton,
Matthew Wilcox, Eliot Courtney, maple-tree, linux-mm,
linux-kernel, linux-fsdevel, Yury Norov
On 26/09/11 11:52AM, Yury Norov wrote:
> The Maple Tree benchmark uses MTREE_INIT() for a stack-allocated tree.
> Its static spinlock initializer leaves lockdep to use the lock address
> as the class key. Since the address is on the stack, the first allocation
> triggers "INFO: trying to register non-static key" and disables lockdep.
>
> The IDA benchmark has the same problem through IDA_INIT(), but runs after
> Maple Tree and therefore encounters an already disabled lockdep.
>
> Use mt_init_flags() and ida_init() to initialize the locks with persistent
> lock-class keys. Keep initialization outside the timed allocation paths.
>
> Fixes: f4806cc63cc6 ("lib: test bitmap vs IDA vs Maple Tree performance for region allocations")
> Closes: https://lore.kernel.org/oe-lkp/202609101106.771b567e-lkp@intel.com
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
Acked-by: Liam R. Howlett (Oracle) <liam@infradead.org>
> ---
> lib/region_alloc_benchmark.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/region_alloc_benchmark.c b/lib/region_alloc_benchmark.c
> index e88b4cf55c62..a644f3d5431a 100644
> --- a/lib/region_alloc_benchmark.c
> +++ b/lib/region_alloc_benchmark.c
> @@ -78,11 +78,13 @@ static size_t __init ida_size(unsigned long nr_ids)
>
> static unsigned long __init benchmark_ida(unsigned long cap)
> {
> - struct ida ida = IDA_INIT(ida);
> + struct ida ida;
> unsigned long cnt, idx, off, nr_ids = 0;
> ktime_t alloc_time, free_time;
> int id = -ENOSPC;
>
> + ida_init(&ida);
> +
> alloc_time = ktime_get();
> for (cnt = 0; cnt <= cap; cnt++) {
> for (off = 0; off < reg_sz[cnt]; off++) {
> @@ -125,12 +127,14 @@ static unsigned long __init benchmark_ida(unsigned long cap)
>
> static unsigned long __init benchmark_maple_tree(unsigned long cap)
> {
> - struct maple_tree mt = MTREE_INIT(mt, MT_FLAGS_ALLOC_RANGE);
> + struct maple_tree mt;
> unsigned long cnt, idx;
> ktime_t alloc_time, free_time;
> size_t sz;
> int ret;
>
> + mt_init_flags(&mt, MT_FLAGS_ALLOC_RANGE);
> +
> alloc_time = ktime_get();
> for (cnt = 0; cnt <= cap; cnt++) {
> ret = mtree_alloc_range(&mt, &idx, xa_mk_value(cnt + 1),
> --
> 2.53.0
>
>
> --
> maple-tree mailing list
> maple-tree@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/maple-tree
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-15 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 15:52 [PATCH] lib: fix lock initialization in region allocation benchmark Yury Norov
2026-09-15 15:28 ` Liam R. Howlett
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).