linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nico Pache <npache@redhat.com>
To: linux-mm@kvack.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org
Cc: hannes@cmpxchg.org, npache@redhat.com, aquini@redhat.com,
	shakeelb@google.com, llong@redhat.com
Subject: [PATCH v2] vm_swappiness=0 should still try to avoid swapping anon memory
Date: Fri,  6 Aug 2021 22:21:29 -0400	[thread overview]
Message-ID: <20210807022129.8842-1-npache@redhat.com> (raw)

Since commit b91ac374346b ("mm: vmscan: enforce inactive:active ratio at the
reclaim root") swappiness can start prematurely swapping anon memory.
This is due to the assumption that refaulting anon should always allow
the shrinker to target anon memory. Add a check for swappiness being
>0 before indiscriminately targeting Anon.

This does not completely disable swapping, but rather tames the
refaulting aspect of the code that allows for the deactivating of anon
memory.

A similar solution may be possible in the get_scan_count() part of the
code, which determines the reclaim pressure for each LRU; however I
believe that kind of solution may be too aggressive, and not allow other
parts of the code (like direct reclaim) from targeting the active_anon
list. This way we stop the problem at the heart of what is causing the
issue, with the least amount of interference in other code paths.

Furthermore, shrink_lruvec can modify the reclaim pressure of each LRU,
which may make the get_scan_count solution even trickier.

Changelog:
 -v2: made this mem_cgroup specific so now it will work with v1, v2, and
   no cgroups. I've also touched up my commit log.

Signed-off-by: Nico Pache <npache@redhat.com>
---
 mm/vmscan.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4620df62f0ff..89d4e84011b7 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2909,8 +2909,9 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 
 		refaults = lruvec_page_state(target_lruvec,
 				WORKINGSET_ACTIVATE_ANON);
-		if (refaults != target_lruvec->refaults[0] ||
-			inactive_is_low(target_lruvec, LRU_INACTIVE_ANON))
+		if (mem_cgroup_swappiness(sc->target_mem_cgroup) &&
+			(refaults != target_lruvec->refaults[0] ||
+			inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)))
 			sc->may_deactivate |= DEACTIVATE_ANON;
 		else
 			sc->may_deactivate &= ~DEACTIVATE_ANON;
-- 
2.31.1



             reply	other threads:[~2021-08-07  2:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-07  2:21 Nico Pache [this message]
2021-08-07  6:14 ` Alexey Avramov
2021-08-09 21:19   ` Nico Pache

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=20210807022129.8842-1-npache@redhat.com \
    --to=npache@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=aquini@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=llong@redhat.com \
    --cc=shakeelb@google.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