Re: [PATCH v3] drivers/base/memory.c: cache blocks in radix tree to accelerate lookup

From: David Hildenbrand
Date: Wed Dec 18 2019 - 04:01:06 EST


On 17.12.19 20:32, Scott Cheloha wrote:
> Searching for a particular memory block by id is slow because each block
> device is kept in an unsorted linked list on the subsystem bus.
>
> Lookup is much faster if we cache the blocks in a radix tree. Memory
> subsystem initialization and hotplug/hotunplug is at least a little faster
> for any machine with more than ~100 blocks, and the speedup grows with
> the block count.
>
> Signed-off-by: Scott Cheloha <cheloha@xxxxxxxxxxxxxxxxxx>
> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
> ---
> v2 incorporates suggestions from David Hildenbrand.
>
> v3 changes:
> - Rebase atop "drivers/base/memory.c: drop the mem_sysfs_mutex"
>
> - Be conservative: don't use radix_tree_for_each_slot() in
> walk_memory_blocks() yet. It introduces RCU which could
> change behavior. Walking the tree "by hand" with
> find_memory_block_by_id() is slower but keeps the patch
> simple.

Fine with me (splitting it out, e.g., into an addon patch), however, as
readers/writers run mutually exclusive, there is nothing to worry about
here. RCU will not make a difference.

Thanks!

--
Thanks,

David / dhildenb