linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "ming.ling" <ming.ling@spreadtrum.com>
To: akpm@linux-foundation.org, mgorman@techsingularity.net,
	vbabka@suse.cz, hannes@cmpxchg.org, mhocko@suse.com,
	baiyaowei@cmss.chinamobile.com, iamjoonsoo.kim@lge.com,
	minchan@kernel.org, rientjes@google.com, hughd@google.com,
	kirill.shutemov@linux.intel.com
Cc: riel@redhat.com, mgorman@suse.de, aquini@redhat.com,
	corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"ming.ling" <ming.ling@spreadtrum.com>
Subject: [PATCH] mm: exclude isolated non-lru pages from NR_ISOLATED_ANON or NR_ISOLATED_FILE.
Date: Wed, 28 Sep 2016 17:31:03 +0800	[thread overview]
Message-ID: <1475055063-1588-1-git-send-email-ming.ling@spreadtrum.com> (raw)

Non-lru pages don't belong to any lru, so accounting them to
NR_ISOLATED_ANON or NR_ISOLATED_FILE doesn't make any sense.
It may misguide functions such as pgdat_reclaimable_pages and
too_many_isolated.

This patch adds NR_ISOLATED_NONLRU to vmstat and moves isolated non-lru
pages from NR_ISOLATED_ANON or NR_ISOLATED_FILE to NR_ISOLATED_NONLRU.
And with non-lru pages in vmstat, it helps to optimize algorithm of
function too_many_isolated oneday.

Signed-off-by: ming.ling <ming.ling@spreadtrum.com>
---
 include/linux/mmzone.h |  1 +
 mm/compaction.c        | 12 +++++++++---
 mm/migrate.c           | 14 ++++++++++----
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7f2ae99..dc0adba 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -169,6 +169,7 @@ enum node_stat_item {
 	NR_VMSCAN_IMMEDIATE,	/* Prioritise for reclaim when writeback ends */
 	NR_DIRTIED,		/* page dirtyings since bootup */
 	NR_WRITTEN,		/* page writings since bootup */
+	NR_ISOLATED_NONLRU,	/* Temporary isolated pages from non-lru */
 	NR_VM_NODE_STAT_ITEMS
 };
 
diff --git a/mm/compaction.c b/mm/compaction.c
index 9affb29..8da1dca 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -638,16 +638,21 @@ isolate_freepages_range(struct compact_control *cc,
 static void acct_isolated(struct zone *zone, struct compact_control *cc)
 {
 	struct page *page;
-	unsigned int count[2] = { 0, };
+	unsigned int count[3] = { 0, };
 
 	if (list_empty(&cc->migratepages))
 		return;
 
-	list_for_each_entry(page, &cc->migratepages, lru)
-		count[!!page_is_file_cache(page)]++;
+	list_for_each_entry(page, &cc->migratepages, lru) {
+		if (PageLRU(page))
+			count[!!page_is_file_cache(page)]++;
+		else
+			count[2]++;
+	}
 
 	mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_ANON, count[0]);
 	mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, count[1]);
+	mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_NONLRU, count[2]);
 }
 
 /* Similar to reclaim, but different enough that they don't share logic */
@@ -659,6 +664,7 @@ static bool too_many_isolated(struct zone *zone)
 			node_page_state(zone->zone_pgdat, NR_INACTIVE_ANON);
 	active = node_page_state(zone->zone_pgdat, NR_ACTIVE_FILE) +
 			node_page_state(zone->zone_pgdat, NR_ACTIVE_ANON);
+	/* Is it necessary to add NR_ISOLATED_NONLRU?? */
 	isolated = node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE) +
 			node_page_state(zone->zone_pgdat, NR_ISOLATED_ANON);
 
diff --git a/mm/migrate.c b/mm/migrate.c
index f7ee04a..cd5abb2 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -168,8 +168,11 @@ void putback_movable_pages(struct list_head *l)
 			continue;
 		}
 		list_del(&page->lru);
-		dec_node_page_state(page, NR_ISOLATED_ANON +
-				page_is_file_cache(page));
+		if (PageLRU(page))
+			dec_node_page_state(page, NR_ISOLATED_ANON +
+					page_is_file_cache(page));
+		else
+			dec_node_page_state(page, NR_ISOLATED_NONLRU);
 		/*
 		 * We isolated non-lru movable page so here we can use
 		 * __PageMovable because LRU page's mapping cannot have
@@ -1121,8 +1124,11 @@ out:
 		 * restored.
 		 */
 		list_del(&page->lru);
-		dec_node_page_state(page, NR_ISOLATED_ANON +
-				page_is_file_cache(page));
+		if (PageLRU(page))
+			dec_node_page_state(page, NR_ISOLATED_ANON +
+					page_is_file_cache(page));
+		else
+			dec_node_page_state(page, NR_ISOLATED_NONLRU);
 	}
 
 	/*
-- 
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2016-09-28  9:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28  9:31 ming.ling [this message]
2016-09-29  8:01 ` Michal Hocko
2016-09-30  2:37 ` Minchan Kim
2016-09-30 10:15   ` Ming Ling
     [not found] ` <201609290806.u8T86Ik0052869@TPSPAM01.spreadtrum.com>
2016-09-30  4:41   ` Ming Ling

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=1475055063-1588-1-git-send-email-ming.ling@spreadtrum.com \
    --to=ming.ling@spreadtrum.com \
    --cc=akpm@linux-foundation.org \
    --cc=aquini@redhat.com \
    --cc=baiyaowei@cmss.chinamobile.com \
    --cc=corbet@lwn.net \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=rientjes@google.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