From: Yang Shi <yang.shi@linux.alibaba.com>
To: mhocko@suse.com, mgorman@techsingularity.net, riel@surriel.com,
hannes@cmpxchg.org, akpm@linux-foundation.org,
dave.hansen@intel.com, keith.busch@intel.com,
dan.j.williams@intel.com, fengguang.wu@intel.com,
fan.du@intel.com, ying.huang@intel.com, ziy@nvidia.com
Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [v3 PATCH 6/9] mm: vmscan: don't demote for memcg reclaim
Date: Fri, 14 Jun 2019 07:29:34 +0800 [thread overview]
Message-ID: <1560468577-101178-7-git-send-email-yang.shi@linux.alibaba.com> (raw)
In-Reply-To: <1560468577-101178-1-git-send-email-yang.shi@linux.alibaba.com>
The memcg reclaim happens when the limit is breached, but demotion just
migrate pages to the other node instead of reclaiming them. This sounds
pointless to memcg reclaim since the usage is not reduced at all.
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
mm/vmscan.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 428a83b..fb931ded 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1126,12 +1126,16 @@ static inline struct page *alloc_demote_page(struct page *page,
}
#endif
-static inline bool is_demote_ok(int nid)
+static inline bool is_demote_ok(int nid, struct scan_control *sc)
{
/* Just do demotion with migrate mode of node reclaim */
if (!(node_reclaim_mode & RECLAIM_MIGRATE))
return false;
+ /* It is pointless to do demotion in memcg reclaim */
+ if (!global_reclaim(sc))
+ return false;
+
/* Current node is cpuless node */
if (!node_state(nid, N_CPU_MEM))
return false;
@@ -1326,7 +1330,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
* Demotion only happen from primary nodes
* to cpuless nodes.
*/
- if (is_demote_ok(page_to_nid(page))) {
+ if (is_demote_ok(page_to_nid(page), sc)) {
list_add(&page->lru, &demote_pages);
unlock_page(page);
continue;
@@ -2226,7 +2230,7 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,
* anonymous page deactivation is pointless.
*/
if (!file && !total_swap_pages &&
- !is_demote_ok(pgdat->node_id))
+ !is_demote_ok(pgdat->node_id, sc))
return false;
inactive = lruvec_lru_size(lruvec, inactive_lru, sc->reclaim_idx);
@@ -2307,7 +2311,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,
*
* If current node is already PMEM node, demotion is not applicable.
*/
- if (!is_demote_ok(pgdat->node_id)) {
+ if (!is_demote_ok(pgdat->node_id, sc)) {
/*
* If we have no swap space, do not bother scanning
* anon pages.
@@ -2316,18 +2320,18 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,
scan_balance = SCAN_FILE;
goto out;
}
+ }
- /*
- * Global reclaim will swap to prevent OOM even with no
- * swappiness, but memcg users want to use this knob to
- * disable swapping for individual groups completely when
- * using the memory controller's swap limit feature would be
- * too expensive.
- */
- if (!global_reclaim(sc) && !swappiness) {
- scan_balance = SCAN_FILE;
- goto out;
- }
+ /*
+ * Global reclaim will swap to prevent OOM even with no
+ * swappiness, but memcg users want to use this knob to
+ * disable swapping for individual groups completely when
+ * using the memory controller's swap limit feature would be
+ * too expensive.
+ */
+ if (!global_reclaim(sc) && !swappiness) {
+ scan_balance = SCAN_FILE;
+ goto out;
}
/*
@@ -2676,7 +2680,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
*/
pages_for_compaction = compact_gap(sc->order);
inactive_lru_pages = node_page_state(pgdat, NR_INACTIVE_FILE);
- if (get_nr_swap_pages() > 0 || is_demote_ok(pgdat->node_id))
+ if (get_nr_swap_pages() > 0 || is_demote_ok(pgdat->node_id, sc))
inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON);
if (sc->nr_reclaimed < pages_for_compaction &&
inactive_lru_pages > pages_for_compaction)
@@ -3362,7 +3366,7 @@ static void age_active_anon(struct pglist_data *pgdat,
struct mem_cgroup *memcg;
/* Aging anon page as long as demotion is fine */
- if (!total_swap_pages && !is_demote_ok(pgdat->node_id))
+ if (!total_swap_pages && !is_demote_ok(pgdat->node_id, sc))
return;
memcg = mem_cgroup_iter(NULL, NULL, NULL);
--
1.8.3.1
next prev parent reply other threads:[~2019-06-13 23:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 23:29 [v3 RFC PATCH 0/9] Migrate mode for node reclaim with heterogeneous memory hierarchy Yang Shi
2019-06-13 23:29 ` [v3 PATCH 1/9] mm: define N_CPU_MEM node states Yang Shi
2019-06-13 23:29 ` [v3 PATCH 2/9] mm: Introduce migrate target nodemask Yang Shi
2019-06-13 23:29 ` [v3 PATCH 3/9] mm: page_alloc: make find_next_best_node find return migration target node Yang Shi
2019-06-13 23:29 ` [v3 PATCH 4/9] mm: migrate: make migrate_pages() return nr_succeeded Yang Shi
2019-06-13 23:29 ` [v3 PATCH 5/9] mm: vmscan: demote anon DRAM pages to migration target node Yang Shi
2019-06-13 23:29 ` Yang Shi [this message]
2019-06-13 23:29 ` [v3 PATCH 7/9] mm: vmscan: check if the demote target node is contended or not Yang Shi
2019-06-13 23:29 ` [v3 PATCH 8/9] mm: vmscan: add page demotion counter Yang Shi
2019-06-13 23:29 ` [v3 PATCH 9/9] mm: numa: add page promotion counter Yang Shi
2019-06-27 2:57 ` [v3 RFC PATCH 0/9] Migrate mode for node reclaim with heterogeneous memory hierarchy Yang Shi
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=1560468577-101178-7-git-send-email-yang.shi@linux.alibaba.com \
--to=yang.shi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=fan.du@intel.com \
--cc=fengguang.wu@intel.com \
--cc=hannes@cmpxchg.org \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=riel@surriel.com \
--cc=ying.huang@intel.com \
--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 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).