[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e769009-b69c-8a2f-a7b3-46e1ce0fe8be@redhat.com>
Date: Fri, 1 Nov 2019 20:20:40 +0100
From: David Hildenbrand <david@...hat.com>
To: Scott Cheloha <cheloha@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: nathanl@...ux.ibm.com, ricklind@...ux.vnet.ibm.com
Subject: Re: [PATCH] drivers/base/memory.c: memory subsys init: skip search
for missing blocks
On 01.11.19 20:00, David Hildenbrand wrote:
> On 01.11.19 19:10, Scott Cheloha wrote:
>> Add a flag to init_memory_block() to enable/disable searching for a
>> matching block before creating a device for the block and adding it to
>> the memory subsystem's bus.
>>
>> When the memory subsystem is being initialized there is no need to check
>> if a given block has already been added to its bus. The bus is new, so the
>> block in question cannot yet have a corresponding device.
>>
>> The search for a missing block is O(n) so this saves substantial time at
>> boot if there are many such blocks to add.
>>
>> Signed-off-by: Scott Cheloha <cheloha@...ux.vnet.ibm.com>
>> ---
>> drivers/base/memory.c | 18 +++++++++++-------
>> 1 file changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
>> index 55907c27075b..1160df4a8feb 100644
>> --- a/drivers/base/memory.c
>> +++ b/drivers/base/memory.c
>> @@ -643,17 +643,21 @@ int register_memory(struct memory_block *memory)
>> }
>>
>> static int init_memory_block(struct memory_block **memory,
>> - unsigned long block_id, unsigned long state)
>> + unsigned long block_id, unsigned long state,
>> + bool may_exist)
>> {
>> struct memory_block *mem;
>> unsigned long start_pfn;
>> int ret = 0;
>>
>> - mem = find_memory_block_by_id(block_id);
>> - if (mem) {
>> - put_device(&mem->dev);
>> - return -EEXIST;
>> + if (may_exist) {
>> + mem = find_memory_block_by_id(block_id);
>> + if (mem) {
>> + put_device(&mem->dev);
>> + return -EEXIST;
>> + }
>
> No, I don't really like that. Can we please speed up the lookup via a
> radix tree as noted in the comment of "find_memory_block()".
>
> /*
> * For now, we have a linear search to go find the appropriate
> * memory_block corresponding to a particular phys_index. If
> * this gets to be a real problem, we can always use a radix
> * tree or something here.
> *
> * This could be made generic for all device subsystems.
> */
>
> This will speed up all users of walk_memory_blocks() similarly.
> Especially, it will also speed up link_mem_sections() used during boot,
> which relies on walk_memory_blocks().
>
Also, I think this check that I added back than should not happen in the
wild. If we care, we could turn that into a
VM_BUG_ON(find_memory_block_by_id(block_id)).
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists