]> git.baikalelectronics.ru Git - kernel.git/commit
regmap: rbtree: Reduce number of nodes, take 2
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 29 Aug 2013 08:26:33 +0000 (10:26 +0200)
committerMark Brown <broonie@linaro.org>
Thu, 29 Aug 2013 12:32:40 +0000 (13:32 +0100)
commit0ad98f7295f663e609ce4413b6e4a25911cfde25
treed85e8d1fe6d2bd9fc5eb3a461338b2f4735166e4
parenta0f4c122dc1205b32eaaa5ec3f9b8d7f76a5c664
regmap: rbtree: Reduce number of nodes, take 2

Support for reducing the number of nodes and memory consumption of the rbtree
cache by allowing for small unused holes in the node's register cache block was
initially added in commit 7dd60417 ("regmap: Cut down on the average # of nodes
in the rbtree cache"). But the commit had problems and so its effect was
reverted again in commit 22058a5 ("regmap: rbtree: Fix overlapping rbnodes.").
This patch brings the feature back of reducing the average number of nodes,
which will speedup node look-up, while at the same time also reducing the memory
usage of the rbtree cache. This patch takes a slightly different approach than
the original patch though. It modifies the adjacent node look-up to not only
consider nodes that are just one to the left or the right of the register but
any node that falls in a certain range around the register. The range is
calculated based on how much memory it would take to allocate a new node
compared to how much memory it takes adding a set of unused registers to an
existing node. E.g. if a node takes up 24 bytes and each register in a block
uses 1 byte the range will be from the register address - 24 to the register
address + 24. If we find a node that falls within this range it is cheaper or as
expensive to add the register to the existing node and have a couple of unused
registers in the node's cache compared to allocating a new node.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/regmap/regcache-rbtree.c