follow up nodereclaim for 32b fix
Subsystems (4)
Michal Hocko
reviewercover follow up nodereclaim for 32b fix
Hi,
I have previously posted this as an RFC [1] but there didn't seem to be any objections other than some requests to reorganize the changes in a slightly different way so I am reposting the series and asking for inclusion.
This is a follow up on top of [2]. The patch 1 cleans up the code a bit. I haven't seen any real issues or bug reports but conceptualy ignoring the maximum eligible zone in get_scan_count is wrong by definition. This is what patch 2 does. Patch 3 removes inactive_reclaimable_pages which was a kind of hack around for the problem which should have been addressed at get_scan_count.
There is one more place which needs a special handling which is not a part of this series. too_many_isolated can get confused as well. I already have some preliminary work but it still needs some testing so I will post it separatelly.
Michal Hocko (3):
mm, vmscan: cleanup lru size claculations mm, vmscan: consider eligible zones in get_scan_count Revert "mm: bail out in shrink_inactive_list()"
include/linux/mmzone.h | 2 +- mm/vmscan.c | 116 +++++++++++++++++++------------------------------ mm/workingset.c | 2 +- 3 files changed, 46 insertions(+), 74 deletions(-)
[1] http://lkml.kernel.org/r/[email protected]
[2] http://lkml.kernel.org/r/[email protected]
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
reviewerPATCH 1/3 mm, vmscan: cleanup lru size claculations
From: Michal Hocko <[email protected]>
lruvec_lru_size returns the full size of the LRU list while we sometimes need a value reduced only to eligible zones (e.g. for lowmem requests). inactive_list_is_low is one such user. Later patches will add more of them. Add a new parameter to lruvec_lru_size and allow it filter out zones which are not eligible for the given context.
--- include/linux/mmzone.h | 2 +- mm/vmscan.c | 89 +++++++++++++++++++++++++------------------------- mm/workingset.c | 2 +- 3 files changed, 46 insertions(+), 47 deletions(-)
include/linux/mmzone.h +1 -1
@@ -780,7 +780,7 @@ static inline struct pglist_data *lruvec_pgdat(struct lruvec *lruvec)#endif } -extern unsigned long lruvec_lru_size (struct lruvec *lruvec,enum lru_list lru); +extern unsigned long lruvec_lru_size (struct lruvec *lruvec,enum lru_list lru,int zone_idx);#ifdef CONFIG_HAVE_MEMORY_PRESENT void memory_present (int nid,unsigned long start,unsigned long end);
mm/vmscan.c +44 -45
138 lines not on this page · raw message
mm/workingset.c +1 -1
@@ -267,7 +267,7 @@ bool workingset_refault(void *shadow) } lruvec =mem_cgroup_lruvec (pgdat, memcg); refault =atomic_long_read (&lruvec->inactive_age); - active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE ); + active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE ,MAX_NR_ZONES );rcu_read_unlock ();/*
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
reviewerPATCH 2/3 mm, vmscan: consider eligible zones in get_scan_count
In reply to Michal HockoFrom: Michal Hocko <[email protected]>
get_scan_count considers the whole node LRU size when
- doing SCAN_FILE due to many page cache inactive pages
- calculating the number of pages to scan
in both cases this might lead to unexpected behavior especially on 32b systems where we can expect lowmem memory pressure very often.
A large highmem zone can easily distort SCAN_FILE heuristic because there might be only few file pages from the eligible zones on the node lru and we would still enforce file lru scanning which can lead to trashing while we could still scan anonymous pages.
The later use of lruvec_lru_size can be problematic as well. Especially when there are not many pages from the eligible zones. We would have to skip over many pages to find anything to reclaim but shrink_node_memcg would only reduce the remaining number to scan by SWAP_CLUSTER_MAX at maximum. Therefore we can end up going over a large LRU many times without actually having chance to reclaim much if anything at all. The closer we are out of memory on lowmem zone the worse the problem will be.
Fix this by filtering out all the ineligible zones when calculating the lru size for both paths and consider only sc->reclaim_idx zones.
--- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/vmscan.c +2 -2
@@ -2235,7 +2235,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,* system is under heavy pressure. */ if (!inactive_list_is_low (lruvec, true, sc, false) && -lruvec_lru_size (lruvec,LRU_INACTIVE_FILE ,MAX_NR_ZONES ) >> sc->priority) { +lruvec_lru_size (lruvec,LRU_INACTIVE_FILE , sc->reclaim_idx) >> sc->priority) { scan_balance =SCAN_FILE ; goto out; }
@@ -2302,7 +2302,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,unsigned long size;unsigned long scan; - size =lruvec_lru_size (lruvec, lru,MAX_NR_ZONES ); + size =lruvec_lru_size (lruvec, lru, sc->reclaim_idx); scan = size >> sc->priority;if (!scan && pass && force_scan)
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] mm, vmscan: consider eligible zones in get_scan_count
Quoted 23 lines · Michal Hocko
From: Michal Hocko <[email protected]>
get_scan_countconsiders the whole node LRU size when
- doingSCAN_FILEdue to many page cache inactive pages
- calculating the number of pages to scanin both cases this might lead to unexpected behavior especially on 32b systems where we can expect lowmem memory pressure very often.
A large highmem zone can easily distort
SCAN_FILEheuristic because there might be only few file pages from the eligible zones on the node lru and we would still enforce file lru scanning which can lead to trashing while we could still scan anonymous pages.The later use of
lruvec_lru_sizecan be problematic as well. Especially when there are not many pages from the eligible zones. We would have to skip over many pages to find anything to reclaim butshrink_node_memcgwould only reduce the remaining number to scan bySWAP_CLUSTER_MAXat maximum. Therefore we can end up going over a large LRU many times without actually having chance to reclaim much if anything at all. The closer we are out of memory on lowmem zone the worse the problem will be.
Quoted 6 lines
Fix this by filtering out all the ineligible zones when calculating the lru size for both paths and consider only
sc->reclaim_idxzones.Acked-by Minchan Kim <[email protected]>Acked-by Hillf Danton <[email protected]>Signed-off-by Michal Hocko <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] mm, vmscan: consider eligible zones in get_scan_count
In reply to Michal HockoHi Andrew,
it turned out that this is not a theoretical issue after all. Trevor (added to the CC) was seeing pre-mature OOM killer triggering [1] bisected to b2e18757f2c9 ("mm, vmscan: begin reclaiming pages on a per-node basis").
After some going back and forth it turned out that b4536f0c829c ("mm,
memcg: fix the active list aging for lowmem requests when memcg is enabled") helped a lot but it wasn't sufficient on its own. We also need this patch to make the oom behavior stable again. So I suggest backporting this to stable as well. Could you update the changelog as follows?
The patch would need to be tweaked a bit to apply to 4.10 and older but I will do that as soon as it hits the Linus tree in the next merge window.
[1] http://lkml.kernel.org/r/[email protected]
Quoted 23 lines · Michal Hocko
From: Michal Hocko <[email protected]>
get_scan_countconsiders the whole node LRU size when
- doingSCAN_FILEdue to many page cache inactive pages
- calculating the number of pages to scanin both cases this might lead to unexpected behavior especially on 32b systems where we can expect lowmem memory pressure very often.
A large highmem zone can easily distort
SCAN_FILEheuristic because there might be only few file pages from the eligible zones on the node lru and we would still enforce file lru scanning which can lead to trashing while we could still scan anonymous pages.The later use of
lruvec_lru_sizecan be problematic as well. Especially when there are not many pages from the eligible zones. We would have to skip over many pages to find anything to reclaim butshrink_node_memcgwould only reduce the remaining number to scan bySWAP_CLUSTER_MAXat maximum. Therefore we can end up going over a large LRU many times without actually having chance to reclaim much if anything at all. The closer we are out of memory on lowmem zone the worse the problem will be.
Quoted 3 lines
Fix this by filtering out all the ineligible zones when calculating the lru size for both paths and consider only
sc->reclaim_idxzones.
Quoted 32 lines
Acked-by Minchan Kim <[email protected]>Acked-by Hillf Danton <[email protected]>Signed-off-by Michal Hocko <[email protected]>--- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/vmscan.c +2
-2@@ -2235,7 +2235,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,* system is under heavy pressure. */ if (!inactive_list_is_low (lruvec, true, sc, false) && -lruvec_lru_size (lruvec,LRU_INACTIVE_FILE ,MAX_NR_ZONES ) >> sc->priority) { +lruvec_lru_size (lruvec,LRU_INACTIVE_FILE , sc->reclaim_idx) >> sc->priority) { scan_balance =SCAN_FILE ; goto out; }@@ -2302,7 +2302,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,unsigned long size;unsigned long scan; - size =lruvec_lru_size (lruvec, lru,MAX_NR_ZONES ); + size =lruvec_lru_size (lruvec, lru, sc->reclaim_idx); scan = size >> sc->priority;if (!scan && pass && force_scan)Signature · 1 line
2.11.0
Signature · 2 lines
Michal Hocko SUSE Labs
Andrew Morton
maintainerRe: [PATCH 2/3] mm, vmscan: consider eligible zones in get_scan_count
Quoted 16 lines · On Mon, 6 Feb 2017 09:10:07 +0100 Michal Hocko <[email protected]> wrote:
Hi Andrew,
it turned out that this is not a theoretical issue after all. Trevor (added to the CC) was seeing pre-mature OOM killer triggering [1] bisected tob2e18757f2c9("mm, vmscan: begin reclaiming pages on a per-node basis").
After some going back and forth it turned out thatb4536f0c829c("mm,
memcg: fix the active list aging for lowmem requests when memcg is enabled") helped a lot but it wasn't sufficient on its own. We also need this patch to make the oom behavior stable again. So I suggest backporting this to stable as well. Could you update the changelog as follows?The patch would need to be tweaked a bit to apply to 4.10 and older but I will do that as soon as it hits the Linus tree in the next merge window.
Quoted 5 lines
...
Fixes b2e18757f2c9 ("mm, vmscan: begin reclaiming pages on a per-node basis")Cc stable # 4.8+Tested-by Trevor Cordes <[email protected]>
No probs.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
reviewerPATCH 3/3 Revert "mm: bail out in shrink_inactive_list()"
In reply to Michal HockoFrom: Michal Hocko <[email protected]>
This reverts commit 91dcade47a3d0e7c31464ef05f56c08e92a0e9c2.
inactive_reclaimable_pages shouldn't be needed anymore since that get_scan_count is aware of the eligble zones ("mm, vmscan:
consider eligible zones in get_scan_count").
--- mm/vmscan.c | 27 --------------------------- 1 file changed, 27 deletions(-)
mm/vmscan.c +0 -27
@@ -1701,30 +1701,6 @@ static int current_may_throttle(void)bdi_write_congested (current->backing_dev_info); } -static bool inactive_reclaimable_pages (struct lruvec *lruvec, -struct scan_control *sc,enum lru_list lru) -{ -int zid; -struct zone *zone; -int file =is_file_lru (lru); -struct pglist_data *pgdat =lruvec_pgdat (lruvec); - -if (!global_reclaim (sc)) -return true; - -for (zid = sc->reclaim_idx; zid >=0 ; zid--) { - zone = &pgdat->node_zones[zid]; -if (!managed_zone (zone)) -continue ; - -if (zone_page_state_snapshot (zone,NR_ZONE_LRU_BASE + -LRU_FILE * file) >=SWAP_CLUSTER_MAX ) -return true; - } - -return false; -} -/* * shrink_inactive_list() is a helper for shrink_node(). It returns the number * of reclaimed pages
@@ -1743,9 +1719,6 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,struct pglist_data *pgdat =lruvec_pgdat (lruvec);struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; -if (!inactive_reclaimable_pages (lruvec, sc, lru)) -return 0 ; -while (unlikely (too_many_isolated (pgdat, file, sc))) {congestion_wait (BLK_RW_ASYNC ,HZ /10 );
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/3] Revert "mm: bail out in shrink_inactive_list()"
Quoted 11 lines · Michal Hocko
From: Michal Hocko <[email protected]>
This reverts commit
91dcade47a3d0e7c31464ef05f56c08e92a0e9c2.
inactive_reclaimable_pagesshouldn't be needed anymore since thatget_scan_countis aware of the eligble zones ("mm, vmscan:
consider eligible zones inget_scan_count").Acked-by Hillf Danton <[email protected]>Acked-by Minchan Kim <[email protected]>Signed-off-by Michal Hocko <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 18 lines · Michal Hocko
Hi,
I have previously posted this as an RFC [1] but there didn't seem to be any objections other than some requests to reorganize the changes in a slightly different way so I am reposting the series and asking for inclusion.This is a follow up on top of [2]. The patch 1 cleans up the code a bit. I haven't seen any real issues or bug reports but conceptualy ignoring the maximum eligible zone in
get_scan_countis wrong by definition. This is what patch 2 does. Patch 3 removesinactive_reclaimable_pageswhich was a kind of hack around for the problem which should have been addressed atget_scan_count.There is one more place which needs a special handling which is not a part of this series.
too_many_isolatedcan get confused as well. I already have some preliminary work but it still needs some testing so I will post it separatelly.
Quoted 5 lines
Michal Hocko (3):
mm, vmscan: cleanup lru size claculations mm, vmscan: consider eligible zones inget_scan_countRevert "mm: bail out inshrink_inactive_list()"
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>