lkml.org 
[lkml]   [2023]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] mm/page_alloc: optimize find_suitable_fallback() and fallbacks array
From
On 2/10/23 03:51, Yajun Deng wrote:
> February 10, 2023 10:33 AM, "Yajun Deng" <yajun.deng@linux.dev> wrote:
>
>> February 10, 2023 10:14 AM, "Zi Yan" <ziy@nvidia.com> wrote:
>>
>>> On 9 Feb 2023, at 20:57, Yajun Deng wrote:
>>>
>>>> February 9, 2023 11:50 PM, "Zi Yan" <ziy@nvidia.com> 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.

\
 
 \ /
  Last update: 2023-03-27 00:17    [W:0.058 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site