libfs: Convert simple directory offsets to use a Maple Tree
authorChuck Lever <chuck.lever@oracle.com>
Sat, 17 Feb 2024 20:24:16 +0000 (15:24 -0500)
committerChristian Brauner <brauner@kernel.org>
Wed, 21 Feb 2024 08:34:26 +0000 (09:34 +0100)
commit0e4a862174f2a8d1653a8a9cf0815020e1d3af24
treedd4d0a1647de2dc9bea821206c378a9afc242260
parentf92e1a829d64dd66fa173c6934f03817d9e68d43
libfs: Convert simple directory offsets to use a Maple Tree

Test robot reports:
> kernel test robot noticed a -19.0% regression of aim9.disk_src.ops_per_sec on:
>
> commit: a2e459555c5f9da3e619b7e47a63f98574dc75f1 ("shmem: stable directory offsets")
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

Feng Tang further clarifies that:
> ... the new simple_offset_add()
> called by shmem_mknod() brings extra cost related with slab,
> specifically the 'radix_tree_node', which cause the regression.

Willy's analysis is that, over time, the test workload causes
xa_alloc_cyclic() to fragment the underlying SLAB cache.

This patch replaces the offset_ctx's xarray with a Maple Tree in the
hope that Maple Tree's dense node mode will handle this scenario
more scalably.

In addition, we can widen the simple directory offset maximum to
signed long (as loff_t is also signed).

Suggested-by: Matthew Wilcox <willy@infradead.org>
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202309081306.3ecb3734-oliver.sang@intel.com
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://lore.kernel.org/r/170820145616.6328.12620992971699079156.stgit@91.116.238.104.host.secureserver.net
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/libfs.c
include/linux/fs.h