lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210807022129.8842-1-npache@redhat.com>
Date:   Fri,  6 Aug 2021 22:21:29 -0400
From:   Nico Pache <npache@...hat.com>
To:     linux-mm@...ck.org, akpm@...ux-foundation.org,
        linux-kernel@...r.kernel.org
Cc:     hannes@...xchg.org, npache@...hat.com, aquini@...hat.com,
        shakeelb@...gle.com, llong@...hat.com
Subject: [PATCH v2] vm_swappiness=0 should still try to avoid swapping anon memory

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@...hat.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ