Purpose of maple_node objects to be its size aligned

From: Charan Teja Kalla
Date: Tue Jan 23 2024 - 06:06:25 EST


I am just curious about the purpose of maple node slab objects to be its
size aligned, but I can understand why they need to be cache aligned.

void __init maple_tree_init(void)
{
maple_node_cache = kmem_cache_create("maple_node",
sizeof(struct maple_node),
sizeof(struct maple_node),// Alignment of the slab object.
SLAB_PANIC, NULL);
}

Reason for the ask is, when slub debug enabled with option Z, the change
[1] makes the total object to be 256 * 3 (=768)bytes. This turns out to
be a problem in debug builds where the unreclaimable slab consumption
itself is very high thus exerting the memory pressure on the system.

maple_node:
orginal object size = 256b
after slub_debug enabled = 768b


If, there is no special requirement, other than just needs to be cache
aligned, thinking of the below:

--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -6283,8 +6283,8 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp)
void __init maple_tree_init(void)
{
maple_node_cache = kmem_cache_create("maple_node",
- sizeof(struct maple_node), sizeof(struct
maple_node),
- SLAB_PANIC, NULL);
+ sizeof(struct maple_node), 0,
+ SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
}


[1]d86bd1bece6f ("mm/slub: support left redzone")

Thanks,
charan