All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Michal Hocko <mhocko@suse.com>
Cc: Yafang Shao <laoar.shao@gmail.com>,
	linux-mm@kvack.org, Mel Gorman <mgorman@techsingularity.net>,
	Yafang Shao <shaoyafang@didiglobal.com>
Subject: Re: [PATCH] mm/compaction: introduce a helper compact_zone_counters_init()
Date: Tue, 23 Jul 2019 14:40:07 -0700	[thread overview]
Message-ID: <20190723144007.9660c3c98068caeba2109ded@linux-foundation.org> (raw)
In-Reply-To: <20190723081218.GD4552@dhcp22.suse.cz>

On Tue, 23 Jul 2019 10:12:18 +0200 Michal Hocko <mhocko@suse.com> wrote:

> On Tue 23-07-19 04:08:15, Yafang Shao wrote:
> > This is the follow-up of the
> > commit "mm/compaction.c: clear total_{migrate,free}_scanned before scanning a new zone".
> > 
> > These counters are used to track activities during compacting a zone,
> > and they will be set to zero before compacting a new zone in all compact
> > paths. Move all these common settings into compact_zone() for better
> > management. A new helper compact_zone_counters_init() is introduced for
> > this purpose.
> 
> The helper seems excessive a bit because we have a single call site but
> other than that this is an improvement to the current fragile and
> duplicated code.
> 
> I would just get rid of the helper and squash it to your previous patch
> which Andrew already took to the mm tree.

--- a/mm/compaction.c~mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix-fix
+++ a/mm/compaction.c
@@ -2068,19 +2068,6 @@ bool compaction_zonelist_suitable(struct
 	return false;
 }
 
-
-/*
- * Bellow counters are used to track activities during compacting a zone.
- * Before compacting a new zone, we should init these counters first.
- */
-static void compact_zone_counters_init(struct compact_control *cc)
-{
-	cc->total_migrate_scanned = 0;
-	cc->total_free_scanned = 0;
-	cc->nr_migratepages = 0;
-	cc->nr_freepages = 0;
-}
-
 static enum compact_result
 compact_zone(struct compact_control *cc, struct capture_control *capc)
 {
@@ -2091,7 +2078,15 @@ compact_zone(struct compact_control *cc,
 	const bool sync = cc->mode != MIGRATE_ASYNC;
 	bool update_cached;
 
-	compact_zone_counters_init(cc);
+	/*
+	 * These counters track activities during zone compaction.  Initialize
+	 * them before compacting a new zone.
+	 */
+	cc->total_migrate_scanned = 0;
+	cc->total_free_scanned = 0;
+	cc->nr_migratepages = 0;
+	cc->nr_freepages = 0;
+
 	cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
 	ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
 							cc->classzone_idx);
_


  parent reply	other threads:[~2019-07-23 21:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23  8:08 [PATCH] mm/compaction: introduce a helper compact_zone_counters_init() Yafang Shao
2019-07-23  8:12 ` Michal Hocko
2019-07-23  8:24   ` Yafang Shao
2019-07-23 21:40   ` Andrew Morton [this message]
2019-07-24 13:35     ` Vlastimil Babka
2019-07-25  0:19       ` Andrew Morton
2019-07-25  0:25         ` Andrew Morton
2019-07-25 11:42           ` 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=20190723144007.9660c3c98068caeba2109ded@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=shaoyafang@didiglobal.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.