lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c68af237-11b1-aafa-3a0b-132690f825d6@suse.cz>
Date:   Fri, 10 Feb 2023 08:58:28 +0100
From:   Vlastimil Babka <vbabka@...e.cz>
To:     Yajun Deng <yajun.deng@...ux.dev>, Zi Yan <ziy@...dia.com>
Cc:     akpm@...ux-foundation.org, 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
Subject: Re: [PATCH v2] mm/page_alloc: optimize find_suitable_fallback() and
 fallbacks array

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.

> 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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ