Skip to content

Commit 0ca5e29

Browse files
Long Liopsiff
authored andcommitted
xarray: inline xas_descend to improve performance
mainline inclusion from mainline-v6.10-rc1 category: performance The commit 63b1898 ("XArray: Disallow sibling entries of nodes") modified the xas_descend function in such a way that it was no longer being compiled as an inline function, because it increased the size of xas_descend(), and the compiler no longer optimizes it as inline. This had a negative impact on performance, xas_descend is called frequently to traverse downwards in the xarray tree, making it a hot function. Inlining xas_descend has been shown to significantly improve performance by approximately 4.95% in the iozone write test. Machine: Intel(R) Xeon(R) Gold 6240 CPU @ 2.60GHz #iozone i 0 -i 1 -s 64g -r 16m -f /test/tmptest Before this patch: kB reclen write rewrite read reread 67108864 16384 2230080 3637689 6315197 5496027 After this patch: kB reclen write rewrite read reread 67108864 16384 2340360 3666175 6272401 5460782 Percentage change: 4.95% 0.78% -0.68% -0.64% This patch introduces inlining to the xas_descend function. While this change increases the size of lib/xarray.o, the performance gains in critical workloads make this an acceptable trade-off. Size comparison before and after patch: .text .data .bss file 0x3502 0 0 lib/xarray.o.before 0x3602 0 0 lib/xarray.o.after Link: https://lkml.kernel.org/r/20240416061628.3768901-1-leo.lilong@huawei.com Signed-off-by: Long Li <leo.lilong@huawei.com> Cc: Hou Tao <houtao1@huawei.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: yangerkun <yangerkun@huawei.com> Cc: Zhang Yi <yi.zhang@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit ba59180) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 17c9590 commit 0ca5e29

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/xarray.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ static void *xas_start(struct xa_state *xas)
200200
return entry;
201201
}
202202

203-
static void *xas_descend(struct xa_state *xas, struct xa_node *node)
203+
static __always_inline void *xas_descend(struct xa_state *xas,
204+
struct xa_node *node)
204205
{
205206
unsigned int offset = get_offset(xas->xa_index, node);
206207
void *entry = xa_entry(xas->xa, node, offset);

0 commit comments

Comments
 (0)