mm/vmscan: don't shrink active list once more in case we reached nr_to_reclaim

Submitted by Konstantin Khorenko on March 30, 2019, 7:57 a.m.

Details

Message ID 20190330075710.28139-1-khorenko@virtuozzo.com
State New
Series "mm/vmscan: don't shrink active list once more in case we reached nr_to_reclaim"
Headers show

Commit Message

Konstantin Khorenko March 30, 2019, 7:57 a.m.
From: Andrey Ryabinin <aryabinin@virtuozzo.com>

In shrink_zone() we shrink list in cycle and break if nr_to_reclaim is
reached.
But after the while cycle we check and may go to the second run in case
(!sc->has_inactive && !sc->may_shrink_active) without honoring the
nr_reclaimed up to the moment.

Don't do extra work.

Found while working on
https://jira.sw.ru/browse/PSBM-92480

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 mm/vmscan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/vmscan.c b/mm/vmscan.c
index d84ba1a5c4f8..1f5f48dd3cf1 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2600,7 +2600,8 @@  static void shrink_zone(struct zone *zone, struct scan_control *sc,
 		} while ((memcg = mem_cgroup_iter(root, memcg, &reclaim)));
 
 		if ((!sc->has_inactive || !sc->nr_reclaimed)
-		    && !sc->may_shrink_active) {
+		    && !sc->may_shrink_active
+		    && (sc->nr_reclaimed < sc->nr_to_reclaim)) {
 			sc->may_shrink_active = 1;
 			retry = true;
 			continue;