[PATCH] mm/vmscan: when the swappiness is set to 0, memory swapping should be prohibited during the global reclaim process.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we use zram as swap disks, global reclaim may cause the memory in some
cgroups with memory.swappiness set to 0 to be swapped into zram. This memory
won't be swapped back immediately after the free memory increases. Instead,
it will continue to occupy the zram space, which may result in no available
zram space for the cgroups with swapping enabled. Therefore, I think that
when the vm.swappiness is set to 0, global reclaim should also refrain
from memory swapping, just like these cgroups.

Signed-off-by: yc1082463 <yc1082463@xxxxxxxxx>
---
 mm/vmscan.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c767d71c43d7..bdbb0fc03412 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2426,14 +2426,7 @@ static void get_scan_count(struct lruvec *lruvec,
struct scan_control *sc,
                goto out;
        }

-       /*
-        * 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.
-        */
-       if (cgroup_reclaim(sc) && !swappiness) {
+       if (!swappiness) {
                scan_balance = SCAN_FILE;
                goto out;
        }
--
2.34.1

--0000000000006a5e6f062f1af4dc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">From 512ea4430805983e949526cce2179d0c37f54450 Mon Sep 17 0=
0:00:00 2001<br>From: yc1082463 &lt;<a href=3D"mailto:yc1082463@xxxxxxxxx";>=
yc1082463@xxxxxxxxx</a>&gt;<br>Date: Thu, 27 Feb 2025 15:28:28 +0800<br>Sub=
ject: [PATCH] mm/vmscan: when the swappiness is set to 0, memory swapping<b=
r>=C2=A0should be prohibited during the global reclaim process.<br><br>When=
 we use zram as swap disks, global reclaim may cause the memory in some<br>=
cgroups with memory.swappiness set to 0 to be swapped into zram. This memor=
y<br>won&#39;t be swapped back immediately after the free memory increases.=
 Instead,<br>it will continue to occupy the zram space, which may result in=
 no available<br>zram space for the cgroups with swapping enabled. Therefor=
e, I think that<br>when the vm.swappiness is set to 0, global reclaim shoul=
d also refrain<br>from memory swapping, just like these cgroups.<br><br>Sig=
ned-off-by: yc1082463 &lt;<a href=3D"mailto:yc1082463@xxxxxxxxx";>yc1082463@=
gmail.com</a>&gt;<br>---<br>=C2=A0mm/vmscan.c | 9 +--------<br>=C2=A01 file=
 changed, 1 insertion(+), 8 deletions(-)<br><br>diff --git a/mm/vmscan.c b/=
mm/vmscan.c<br>index c767d71c43d7..bdbb0fc03412 100644<br>--- a/mm/vmscan.c=
<br>+++ b/mm/vmscan.c<br>@@ -2426,14 +2426,7 @@ static void get_scan_count(=
struct lruvec *lruvec, struct scan_control *sc,<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<=
br><br>- =C2=A0 =C2=A0 =C2=A0 /*<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0* Global r=
eclaim will swap to prevent OOM even with no<br>- =C2=A0 =C2=A0 =C2=A0 =C2=
=A0* swappiness, but memcg users want to use this knob to<br>- =C2=A0 =C2=
=A0 =C2=A0 =C2=A0* disable swapping for individual groups completely when<b=
r>- =C2=A0 =C2=A0 =C2=A0 =C2=A0* using the memory controller&#39;s swap lim=
it feature would be<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0* too expensive.<br>- =
=C2=A0 =C2=A0 =C2=A0 =C2=A0*/<br>- =C2=A0 =C2=A0 =C2=A0 if (cgroup_reclaim(=
sc) &amp;&amp; !swappiness) {<br>+ =C2=A0 =C2=A0 =C2=A0 if (!swappiness) {<=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 scan_balance =3D=
 SCAN_FILE;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto=
 out;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>--<br>2.34.1<br></div>

--0000000000006a5e6f062f1af4dc--




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux