Re: [PATCH v2] mm/page_alloc: optimize find_suitable_fallback() and fallbacks array

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

 



On 2/10/23 03:51, Yajun Deng wrote:
> February 10, 2023 10:33 AM, "Yajun Deng" <yajun.deng@xxxxxxxxx> wrote:
> 
>> February 10, 2023 10:14 AM, "Zi Yan" <ziy@xxxxxxxxxx> wrote:
>> 
>>> On 9 Feb 2023, at 20:57, Yajun Deng wrote:
>>> 
>>>> February 9, 2023 11:50 PM, "Zi Yan" <ziy@xxxxxxxxxx> wrote:
>>> 
>>> On 9 Feb 2023, at 5:11, Yajun Deng wrote:
>>>> There is no need to execute the next loop if it not return in the first
>>>> loop. So add a break at the end of the loop.
>>> 
>>> Can you explain why? If it is the case, MIGRATE_UNMOVABLE cannot fall back
>>> to MIGRATE_MOVABLE? And MIGRATE_MOVABLE cannot fall back to MIGRATE_UNMOVABLE?
>>> And MIGRATE_RECLAIMABLE cannot fall back to MIGRATE_MOVABLE?
>>>> The return in the loop is only related to 'order', 'migratetype' and 'only_stealable'
>>>> variables. Even if it execute the next loop, it can't change the result. So the loop
>>>> can be broken if the first loop can't return.
>>> 
>>> OK. Got it. Would the code below look better?
>>> 
>>> for (i = 0; i < MIGRATE_PCPTYPES - 1 ; i++) {
>>> fallback_mt = fallbacks[migratetype][i];
>>> if (free_area_empty(area, fallback_mt))
>>> continue;
>>> }
>>> 
>>> if (can_steal_fallback(order, migratetype))
>>> *can_steal = true;
>>> 
>>> if (!only_stealable || *can_steal)
>>> return fallback_mt;
>>> 
>>> return -1;
>> 
>> Yes, I'll submit a v3 patch.
>> Thanks.
>> 
> 
> I found a logical error in your code. It should be like this:
> 
>         for (i = 0; i < MIGRATE_PCPTYPES - 1 ; i++) {
>                 fallback_mt = fallbacks[migratetype][i];
>                 if (!free_area_empty(area, fallback_mt))
>                         break;
>         }
> 
>         if (can_steal_fallback(order, migratetype))
>                 *can_steal = true;
> 
>         if (!only_stealable || *can_steal)
>                 return fallback_mt;
> 
>         return -1;
> 
> This code will modify the logic to the opposite.

It's still wrong, IMHO. If all fallbacks have free_area_empty(), it will
return the last one and not -1. Also will set *can_steal in such case.

> So can anyone tell me if I should use this code or the v2 patch?

Once that bugs are fixed, the result will probably not look much better than
v2, so I don't mind keeping v2.





[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