[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <58d940aba3433bc6928e91c2272a8410@linux.dev>
Date: Fri, 10 Feb 2023 08:12:23 +0000
From: "Yajun Deng" <yajun.deng@...ux.dev>
To: "Vlastimil Babka" <vbabka@...e.cz>, akpm@...ux-foundation.org
Cc: mgorman@...hsingularity.net, david@...hat.com, rppt@...ux.ibm.com,
osalvador@...e.de, rppt@...nel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, ziy@...dia.com
Subject: Re: [PATCH v2] mm/page_alloc: optimize find_suitable_fallback()
and fallbacks array
February 10, 2023 3:58 PM, "Vlastimil Babka" <vbabka@...e.cz> wrote:
> On 2/10/23 03:51, Yajun Deng wrote:
>
>> February 10, 2023 10:33 AM, "Yajun Deng" <yajun.deng@...ux.dev> wrote:
>>
>>> February 10, 2023 10:14 AM, "Zi Yan" <ziy@...dia.com> wrote:
>>
>> On 9 Feb 2023, at 20:57, Yajun Deng wrote:
>>
>> February 9, 2023 11:50 PM, "Zi Yan" <ziy@...dia.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.
>
Yes, you are right.
>> 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.
I agree with that.
Powered by blists - more mailing lists