]> git.karo-electronics.de Git - karo-tx-linux.git/commit
idr: implement lookup hint
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:31 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:56 +0000 (16:53 +1100)
commitf49318aed0f21febe9fb7037af8f7d6f720c16bc
treeb1c72e1230cad69a7df54e66a68e110e8a799c77
parentfd53d57c91afbc2089ed9859d7955ef9b05d07ef
idr: implement lookup hint

While idr lookup isn't a particularly heavy operation, it still is too
substantial to use in hot paths without worrying about the performance
implications.  With recent changes, each idr_layer covers 256 slots
which should be enough to cover most use cases with single idr_layer
making lookup hint very attractive.

This patch adds idr->hint which points to the idr_layer which
allocated an ID most recently and the fast path lookup becomes

if (look up target's prefix matches that of the hinted layer)
return hint->ary[ID's offset in the leaf layer];

which can be inlined.

idr->hint is set to the leaf node on idr_fill_slot() and cleared from
free_layer().

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/idr.h
lib/idr.c