[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <F8AD9915-061E-4829-8670-B35D5F2DFC03@redhat.com>
Date: Thu, 9 Jan 2020 23:35:28 +0100
From: David Hildenbrand <david@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: David Hildenbrand <david@...hat.com>,
Scott Cheloha <cheloha@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
nathanl@...ux.ibm.com, ricklind@...ux.vnet.ibm.com,
mhocko@...e.com, Scott Cheloha <cheloha@...ux.ibm.com>
Subject: Re: [PATCH v4] drivers/base/memory.c: cache blocks in radix tree to accelerate lookup
> Am 09.01.2020 um 23:28 schrieb Andrew Morton <akpm@...ux-foundation.org>:
>
> On Thu, 9 Jan 2020 23:17:09 +0100 David Hildenbrand <david@...hat.com> wrote:
>
>>
>>
>>>> Am 09.01.2020 um 23:00 schrieb Andrew Morton <akpm@...ux-foundation.org>:
>>>
>>> On Thu, 9 Jan 2020 15:25:16 -0600 Scott Cheloha <cheloha@...ux.vnet.ibm.com> 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.
>>>>
>>>> ...
>>>>
>>>> @@ -56,6 +57,13 @@ static struct bus_type memory_subsys = {
>>>> .offline = memory_subsys_offline,
>>>> };
>>>>
>>>> +/*
>>>> + * Memory blocks are cached in a local radix tree to avoid
>>>> + * a costly linear search for the corresponding device on
>>>> + * the subsystem bus.
>>>> + */
>>>> +static RADIX_TREE(memory_blocks, GFP_KERNEL);
>>>
>>> What protects this tree from racy accesses?
>>
>> I think the device hotplug lock currently (except during boot where no races can happen).
>>
>
> So this?
>
> --- a/drivers/base/memory.c~drivers-base-memoryc-cache-blocks-in-radix-tree-to-accelerate-lookup-fix
> +++ a/drivers/base/memory.c
> @@ -61,6 +61,9 @@ static struct bus_type memory_subsys = {
> * Memory blocks are cached in a local radix tree to avoid
> * a costly linear search for the corresponding device on
> * the subsystem bus.
> + *
> + * Protected by mem_hotplug_lock in mem_hotplug_begin(), and by the guaranteed
> + * single-threadness at boot time.
> */
> static RADIX_TREE(memory_blocks, GFP_KERNEL);
>
>
> But are we sure this is all true?
I think the device hotplug lock, not the memory hotplug lock. Will double check later.
>
Powered by blists - more mailing lists