]> git.baikalelectronics.ru Git - kernel.git/commit
idr: Make 1-based IDRs more efficient
authorMatthew Wilcox <mawilcox@microsoft.com>
Thu, 30 Nov 2017 18:45:11 +0000 (13:45 -0500)
committerMatthew Wilcox <mawilcox@microsoft.com>
Tue, 6 Feb 2018 21:41:29 +0000 (16:41 -0500)
commit80f8ade3965bb289b155d9d043ddf2419f89659d
treed1d3b3754641b22e51cc0fdeecb02a0ac7b31b54
parent75c5147678f77d880eb638f3a059e47dd8357ed3
idr: Make 1-based IDRs more efficient

About 20% of the IDR users in the kernel want the allocated IDs to start
at 1.  The implementation currently searches all the way down the left
hand side of the tree, finds no free ID other than ID 0, walks all the
way back up, and then all the way down again.  This patch 'rebases' the
ID so we fill the entire radix tree, rather than leave a gap at 0.

Chris Wilson says: "I did the quick hack of allocating index 0 of the
idr and that eradicated idr_get_free() from being at the top of the
profiles for the many-object stress tests. This improvement will be
much appreciated."

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
include/linux/idr.h
lib/idr.c
tools/testing/radix-tree/idr-test.c