From: Mel Gorman <mgorman@techsingularity.net>
To: Wonhyuk Yang <vvghjk1234@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <Vbabka@suse.cz>,
linux-mm@kvack.org
Subject: Re: [PATCH v2] mm/compactoin: Fix misbehaviors of fast_find_migrateblock()
Date: Thu, 28 Jan 2021 13:25:08 +0000 [thread overview]
Message-ID: <20210128132508.GE3592@techsingularity.net> (raw)
In-Reply-To: <20210128130411.6125-1-vvghjk1234@gmail.com>
On Thu, Jan 28, 2021 at 10:04:11PM +0900, Wonhyuk Yang wrote:
> In the fast_find_migrateblock(), It iterate freelist to find
> proper pageblock. But there are some misbehaviors.
>
> First, if the page we found is equal to cc->migrate_pfn, it
> is considered that we didn't found suitable pageblock. Second,
> if the loop was terminated because order is less than
> PAGE_ALLOC_COSTLY_ORDER, it could be considered that we found
> suitable one. Third, if the skip bit is set on the page block
> and go continue, it doesn't check the nr_scanned. Fourth, if
> the page block's skip bit is set, it check that page block is
> the last of list. But it is unnecessary.
>
> Fixes: 70b44595eafe9 ("mm, compaction: use free lists to quickly locate
> a migration source")
>
> Signed-off-by: Wonhyuk Yang <vvghjk1234@gmail.com>
> ---
> Changes in v2:
> - Follow Vlastimil's suggestions, using bool varable.
> - Fix new misbehavior and remove unecessary .
>
> v1: https://lore.kernel.org/linux-mm/20210123154320.24278-1-vvghjk1234@gmail.com
> ---
> mm/compaction.c | 27 ++++++++++++---------------
> 1 file changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index e5acb9714436..8e5cd9d20435 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1701,6 +1701,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
> unsigned long pfn = cc->migrate_pfn;
> unsigned long high_pfn;
> int order;
> + bool found_block = false;
>
> /* Skip hints are relied on to avoid repeats on the fast search */
> if (cc->ignore_skip_hint)
> @@ -1743,7 +1744,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
> high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance);
>
> for (order = cc->order - 1;
> - order >= PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit;
> + order >= PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit;
> order--) {
> struct free_area *area = &cc->zone->free_area[order];
> struct list_head *freelist;
> @@ -1758,7 +1759,11 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
> list_for_each_entry(freepage, freelist, lru) {
> unsigned long free_pfn;
>
> - nr_scanned++;
> + if (nr_scanned++ >= limit) {
> + move_freelist_tail(freelist, freepage);
> + break;
> + }
> +
> free_pfn = page_to_pfn(freepage);
> if (free_pfn < high_pfn) {
> /*
As nr_scanned is post-incremented, this will still consider if the page
should be used when the limit is reached. ++nr_scanned?
--
Mel Gorman
SUSE Labs
next prev parent reply other threads:[~2021-01-28 13:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 13:04 [PATCH v2] mm/compactoin: Fix misbehaviors of fast_find_migrateblock() Wonhyuk Yang
2021-01-28 13:25 ` Mel Gorman [this message]
2021-01-28 13:50 ` Wonhyuk Yang
2021-01-28 14:01 ` Vlastimil Babka
2021-01-28 14:22 ` Mel Gorman
2021-01-28 14:31 ` Wonhyuk Yang
2021-01-28 14:40 ` Vlastimil Babka
2021-01-28 14:49 ` Wonhyuk Yang
2021-01-28 14:34 ` Vlastimil Babka
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=20210128132508.GE3592@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=Vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=vvghjk1234@gmail.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.