[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yl8Dk+a1YDwupLMv@cmpxchg.org>
Date: Tue, 19 Apr 2022 14:46:43 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Nico Pache <npache@...hat.com>
Cc: linux-mm@...ck.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, aquini@...hat.com,
shakeelb@...gle.com, llong@...hat.com, mhocko@...e.com,
hakavlad@...ox.lv
Subject: Re: [PATCH v3] vm_swappiness=0 should still try to avoid swapping
anon memory
Hi Nico,
On Tue, Apr 19, 2022 at 02:11:53PM -0400, Nico Pache wrote:
> I think its is important to note the issue we are seeing has greatly improved
> since the initial posting. However we have noticed that the issue is still
> present (and significantly worse) when cgroupV1 is set.
>
> We were initially testing with CgroupV1 and later found that the issue was not
> as bad in CgroupV2 (but was still an noticeable issue). This is also resulting
> in the splitting of THPs in the host kernel.
When swappiness is 0, cgroup limit reclaim has a fixed SCAN_FILE
branch, so it shouldn't ever look at anon. I'm assuming you're getting
global reclaim mixed in. Indeed, I think we can try harder not to swap
for global reclaim if the user asks for that.
Can you try the below patch?
diff --git a/mm/vmscan.c b/mm/vmscan.c
index ba19edbc2452..0aa929151386 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2729,11 +2729,9 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
}
/*
- * Global reclaim will swap to prevent OOM even with no
- * swappiness, but memcg users want to use this knob to
- * disable swapping for individual groups completely when
- * using the memory controller's swap limit feature would be
- * too expensive.
+ * For cgroups, swappiness=0 means never swap. Historically,
+ * cgroup users have relied on this as it was cheaper than
+ * setting a swap limit of 0.
*/
if (cgroup_reclaim(sc) && !swappiness) {
scan_balance = SCAN_FILE;
@@ -2754,7 +2752,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
* If the system is almost out of file pages, force-scan anon.
*/
if (sc->file_is_tiny) {
- scan_balance = SCAN_ANON;
+ scan_balance = SCAN_EQUAL;
goto out;
}
@@ -2767,6 +2765,12 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
goto out;
}
+ /* swappiness=0 means no swap until OOM is imminent */
+ if (!swappiness && sc->priority) {
+ scan_balance = SCAN_FILE;
+ goto out;
+ }
+
scan_balance = SCAN_FRACT;
/*
* Calculate the pressure balance between anon and file pages.
Powered by blists - more mailing lists