All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yajun Deng" <yajun.deng@linux.dev>
To: "Vlastimil Babka" <vbabka@suse.cz>, akpm@linux-foundation.org
Cc: mgorman@techsingularity.net, david@redhat.com,
	rppt@linux.ibm.com, osalvador@suse.de, rppt@kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org, ziy@nvidia.com
Subject: Re: [PATCH v2] mm/page_alloc: optimize find_suitable_fallback() and fallbacks array
Date: Fri, 10 Feb 2023 08:12:23 +0000	[thread overview]
Message-ID: <58d940aba3433bc6928e91c2272a8410@linux.dev> (raw)
In-Reply-To: <c68af237-11b1-aafa-3a0b-132690f825d6@suse.cz>

February 10, 2023 3:58 PM, "Vlastimil Babka" <vbabka@suse.cz> wrote:

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

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.


      reply	other threads:[~2023-02-10  8:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 10:11 [PATCH v2] mm/page_alloc: optimize find_suitable_fallback() and fallbacks array Yajun Deng
2023-02-09 15:50 ` Zi Yan
2023-02-10  1:57   ` Yajun Deng
2023-02-10  2:14     ` Zi Yan
2023-02-10  2:33       ` Yajun Deng
2023-02-10  2:51         ` Yajun Deng
2023-02-10  7:58           ` Vlastimil Babka
2023-02-10  8:12             ` Yajun Deng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58d940aba3433bc6928e91c2272a8410@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=osalvador@suse.de \
    --cc=rppt@kernel.org \
    --cc=rppt@linux.ibm.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.