Re: [PATCH] mm/page_alloc: break on the first hit of mem range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 27, 2018 at 03:47:40PM -0700, Andrew Morton wrote:
>On Tue, 27 Mar 2018 11:57:07 +0800 Wei Yang <richard.weiyang@xxxxxxxxx> wrote:
>
>> find_min_pfn_for_node() iterate on pfn range to find the minimum pfn for a
>> node. The memblock_region in memblock_type are already ordered, which means
>> the first hit in iteration is the minimum pfn.
>> 
>> This patch returns the fist hit instead of iterating the whole regions.
>> 
>> ...
>>
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -6365,14 +6365,14 @@ unsigned long __init node_map_pfn_alignment(void)
>>  /* Find the lowest pfn for a node */
>>  static unsigned long __init find_min_pfn_for_node(int nid)
>>  {
>> -	unsigned long min_pfn = ULONG_MAX;
>> -	unsigned long start_pfn;
>> +	unsigned long min_pfn;
>>  	int i;
>>  
>> -	for_each_mem_pfn_range(i, nid, &start_pfn, NULL, NULL)
>> -		min_pfn = min(min_pfn, start_pfn);
>> +	for_each_mem_pfn_range(i, nid, &min_pfn, NULL, NULL) {
>> +		break;
>> +	}
>
>That would be the weirdest-looking code snippet in mm/!
>

You mean the only break in a for_each loop? Hmm..., this is really not that
nice. Haven't noticed could get a "best" in this way :-)

>Can't we just use a single and simple call to __next_mem_pfn_range(),
>or something like that?
>

Sounds a better choice, if you like this version, I would rearrange the patch
and send v2.

Have a nice day~

>>
>> ...
>>

-- 
Wei Yang
Help you, Help me




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux