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

From: Michal Hocko
Date: Thu Jan 16 2020 - 10:22:20 EST


On Wed 15-01-20 20:09:48, David Hildenbrand wrote:
> On 09.01.20 22:25, Scott Cheloha wrote:
> > Searching for a particular memory block by id is an O(n) operation
> > because each memory block's underlying device is kept in an unsorted
> > linked list on the subsystem bus.
> >
> > We can cut the lookup cost to O(log n) if we cache the memory blocks in
> > a radix tree. With a radix tree cache in place both memory subsystem
> > initialization and memory hotplug run palpably faster on systems with a
> > large number of memory blocks.
> >
> > Signed-off-by: Scott Cheloha <cheloha@xxxxxxxxxxxxx>
> > Acked-by: David Hildenbrand <david@xxxxxxxxxx>
> > Acked-by: Nathan Lynch <nathanl@xxxxxxxxxxxxx>
> > Acked-by: Michal Hocko <mhocko@xxxxxxxx>
>
> Soooo,
>
> I just learned that radix trees are nowadays only a wrapper for xarray
> (for quite a while already!), and that the xarray interface shall be
> used in new code.

Good point. I somehow didn't realize this would add more work for a
later code refactoring. The mapping should be pretty straightforward.

Thanks for noticing!

--
Michal Hocko
SUSE Labs