vmscan: do not force-scan file lru if its absolute size is small
Subsystems (3)
PATCH 1/1 vmscan: do not force-scan file lru if its absolute size is small
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (lru_size >> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to SCAN_FRACT as usual.
--- mm/vmscan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmscan.c +2 -1
@@ -2046,7 +2046,8 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness,* There is enough inactive page cache, do not reclaim * anything from the anonymous working set right now. */ -if (!inactive_file_is_low (lruvec)) { +if (!inactive_file_is_low (lruvec) && +get_lru_size (lruvec,LRU_INACTIVE_FILE ) >> sc->priority >0 ) { scan_balance =SCAN_FILE ; goto out; }
Signature · 7 lines
2.1.4 -- 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 12 lines · Vladimir Davydov
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (
lru_size>> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.
Quoted 7 lines
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to
SCAN_FRACTas usual.Signed-off-by Vladimir Davydov <[email protected]>
This makes sense, the inactive:active ratio of the file list alone does not give the full picture to decide whether to skip anonymous.
mm/vmscan.c static void get_scan_count(struct lruvec *lruvec, int swappiness, · line 2050
Quoted 7 lines
mm/vmscan.c +2
-1@@ -2046,7 +2046,8 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness,* There is enough inactive page cache, do not reclaim * anything from the anonymous working set right now. */ -if (!inactive_file_is_low (lruvec)) { +if (!inactive_file_is_low (lruvec) && +get_lru_size (lruvec,LRU_INACTIVE_FILE ) >> sc->priority >0 ) {
The > 0 seems unnecessary, no? There are too many > in this line :-)
--
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>
Andrew Morton
maintainerQuoted 26 lines · On Fri, 20 Nov 2015 13:37:07 -0500 Johannes Weiner <[email protected]> wrote:
Quoted 12 lines · Vladimir Davydov
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (
lru_size>> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.Quoted 7 lines
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to
SCAN_FRACTas usual.Signed-off-by Vladimir Davydov <[email protected]>This makes sense, the inactive:active ratio of the file list alone does not give the full picture to decide whether to skip anonymous.
Acked-by Johannes Weiner <[email protected]>
Quoted 9 lines
mm/vmscan.c static void get_scan_count(struct lruvec *lruvec, int swappiness, · line 2050
Quoted 7 lines
mm/vmscan.c +2
-1@@ -2046,7 +2046,8 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness,* There is enough inactive page cache, do not reclaim * anything from the anonymous working set right now. */ -if (!inactive_file_is_low (lruvec)) { +if (!inactive_file_is_low (lruvec) && +get_lru_size (lruvec,LRU_INACTIVE_FILE ) >> sc->priority >0 ) {The > 0 seems unnecessary, no? There are too many > in this line :-)
And an update to the code comment would be helpful.
PATCH v2 1/1 vmscan: do not force-scan file lru if its absolute size is small
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (lru_size >> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to SCAN_FRACT as usual.
---
Changes in v2:
- remove unnecessary > 0 (Johannes)
- elaborate on the comment (Andrew)
mm/vmscan.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
mm/vmscan.c +9 -3
@@ -2043,10 +2043,16 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness, }/* -* There is enough inactive page cache, do not reclaim -* anything from the anonymous working set right now. +* If there is enough inactive page cache, i.e. if the size of the +* inactive list is greater than that of the active list *and* the +* inactive list actually has some pages to scan on this priority, we +* do not reclaim anything from the anonymous working set right now. +* Without the second condition we could end up never scanning an +* lruvec even if it has plenty of old anonymous pages unless the +* system is under heavy pressure. */ -if (!inactive_file_is_low (lruvec)) { +if (!inactive_file_is_low (lruvec) && +get_lru_size (lruvec,LRU_INACTIVE_FILE ) >> sc->priority) { scan_balance =SCAN_FILE ; goto out; }
Signature · 7 lines
2.1.4 -- 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 12 lines · Vladimir Davydov
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (
lru_size>> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.
Quoted 5 lines
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to
SCAN_FRACTas usual.
Yes this makes sense. FWIW I have a similar patch waiting for feedback from testing which catches the other extreme case when we force anon pages scan without any progress from the kswapd context (I hope I get to post it soon).
get_scan_count is getting more and more convoluted :/
Quoted 1 line
Signed-off-by Vladimir Davydov <[email protected]>
Thanks!
Quoted 40 lines
---
Changes in v2:
- remove unnecessary > 0 (Johannes)
- elaborate on the comment (Andrew)mm/vmscan.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)mm/vmscan.c +9
-3@@ -2043,10 +2043,16 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness, }/* -* There is enough inactive page cache, do not reclaim -* anything from the anonymous working set right now. +* If there is enough inactive page cache, i.e. if the size of the +* inactive list is greater than that of the active list *and* the +* inactive list actually has some pages to scan on this priority, we +* do not reclaim anything from the anonymous working set right now. +* Without the second condition we could end up never scanning an +* lruvec even if it has plenty of old anonymous pages unless the +* system is under heavy pressure. */ -if (!inactive_file_is_low (lruvec)) { +if (!inactive_file_is_low (lruvec) && +get_lru_size (lruvec,LRU_INACTIVE_FILE ) >> sc->priority) { scan_balance =SCAN_FILE ; goto out; }Signature · 7 lines
2.1.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
Quoted 12 lines · Vladimir Davydov
We assume there is enough inactive page cache if the size of inactive file lru is greater than the size of active file lru, in which case we force-scan file lru ignoring anonymous pages. While this logic works fine when there are plenty of page cache pages, it fails if the size of file lru is small (several MB): in this case (
lru_size>> prio) will be 0 for normal scan priorities, as a result, if inactive file lru happens to be larger than active file lru, anonymous pages of a cgroup will never get evicted unless the system experiences severe memory pressure, even if there are gigabytes of unused anonymous memory there, which is unfair in respect to other cgroups, whose workloads might be page cache oriented.
Quoted 7 lines
This patch attempts to fix this by elaborating the "enough inactive page cache" check: it makes it not only check that inactive lru size > active lru size, but also that we will scan something from the cgroup at the current scan priority. If these conditions do not hold, we proceed to
SCAN_FRACTas usual.Signed-off-by Vladimir Davydov <[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>