linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@techsingularity.net>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	Vlastimil Babka <vbabka@suse.cz>, Arnd Bergmann <arnd@arndb.de>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Rik van Riel <riel@redhat.com>,
	Yafang Shao <shaoyafang@didiglobal.com>
Subject: Re: [PATCH] mm/compaction: use proper zoneid for compaction_suitable()
Date: Fri, 26 Jul 2019 08:09:39 +0100	[thread overview]
Message-ID: <20190726070939.GA2739@techsingularity.net> (raw)
In-Reply-To: <1564062621-8105-1-git-send-email-laoar.shao@gmail.com>

On Thu, Jul 25, 2019 at 09:50:21AM -0400, Yafang Shao wrote:
> By now there're three compaction paths,
> - direct compaction
> - kcompactd compcation
> - proc triggered compaction
> When we do compaction in all these paths, we will use compaction_suitable()
> to check whether a zone is suitable to do compaction.
> 
> There're some issues around the usage of compaction_suitable().
> We don't use the proper zoneid in kcompactd_node_suitable() when try to
> wakeup kcompactd. In the kcompactd compaction paths, we call
> compaction_suitable() twice and the zoneid isn't proper in the second call.
> For proc triggered compaction, the classzone_idx is always zero.
> 
> In order to fix these issues, I change the type of classzone_idx in the
> struct compact_control from const int to int and assign the proper zoneid
> before calling compact_zone().
> 

What is actually fixed by this?

> This patch also fixes some comments in struct compact_control, as these
> fields are not only for direct compactor but also for all other compactors.
> 
> Fixes: ebff398017c6("mm, compaction: pass classzone_idx and alloc_flags to watermark checking")
> Fixes: 698b1b30642f("mm, compaction: introduce kcompactd")
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Yafang Shao <shaoyafang@didiglobal.com>
> ---
>  mm/compaction.c | 12 +++++-------
>  mm/internal.h   | 10 +++++-----
>  2 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index ac4ead0..984dea7 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -2425,6 +2425,7 @@ static void compact_node(int nid)
>  			continue;
>  
>  		cc.zone = zone;
> +		cc.classzone_idx = zoneid;
>  
>  		compact_zone(&cc, NULL);
>  
> @@ -2508,7 +2509,7 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat)
>  			continue;
>  
>  		if (compaction_suitable(zone, pgdat->kcompactd_max_order, 0,
> -					classzone_idx) == COMPACT_CONTINUE)
> +					zoneid) == COMPACT_CONTINUE)
>  			return true;
>  	}
>  

This is a semantic change. The use of the classzone_idx here and not
classzone_idx is so that the watermark check takes the lowmem reserves
into account in the __zone_watermark_ok check. This means that
compaction is more likely to proceed but not necessarily correct.

> @@ -2526,7 +2527,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
>  	struct compact_control cc = {
>  		.order = pgdat->kcompactd_max_order,
>  		.search_order = pgdat->kcompactd_max_order,
> -		.classzone_idx = pgdat->kcompactd_classzone_idx,
>  		.mode = MIGRATE_SYNC_LIGHT,
>  		.ignore_skip_hint = false,
>  		.gfp_mask = GFP_KERNEL,
> @@ -2535,7 +2535,7 @@ static void kcompactd_do_work(pg_data_t *pgdat)
>  							cc.classzone_idx);
>  	count_compact_event(KCOMPACTD_WAKE);
>  
> -	for (zoneid = 0; zoneid <= cc.classzone_idx; zoneid++) {
> +	for (zoneid = 0; zoneid <= pgdat->kcompactd_classzone_idx; zoneid++) {
>  		int status;
>  
>  		zone = &pgdat->node_zones[zoneid];

This variable can be updated by a wakeup while the loop is executing
making the loop more difficult to reason about given the exit conditions
can change.

Please explain what exactly this patch is fixing and why it should be
done because it currently appears to be making a number of subtle
changes without justification.

-- 
Mel Gorman
SUSE Labs


  reply	other threads:[~2019-07-26  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 13:50 [PATCH] mm/compaction: use proper zoneid for compaction_suitable() Yafang Shao
2019-07-26  7:09 ` Mel Gorman [this message]
2019-07-26 10:06   ` Yafang Shao
2019-07-26 10:26     ` Mel Gorman
2019-07-26 11:13       ` Yafang Shao

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=20190726070939.GA2739@techsingularity.net \
    --to=mgorman@techsingularity.net \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=laoar.shao@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=riel@redhat.com \
    --cc=shaoyafang@didiglobal.com \
    --cc=vbabka@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).