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: <1617359934-7812-1-git-send-email-neilsun@yunify.com>
Date:   Fri,  2 Apr 2021 18:38:54 +0800
From:   Neil Sun <neilsun@...ify.com>
To:     akpm@...ux-foundation.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Cc:     Neil Sun <neilsun@...ify.com>
Subject: [PATCH] mm/vmscan.c: drop_slab_node with task's memcg

This patch makes shrink_slab() with task's memcg in drop_slab_node(),
so we can free reclaimable slab objects belongs to memcg /lxc/i-vbe1u8o7
with following command:

cgexec -g memory:/lxc/i-vbe1u8o7 sysctl vm.drop_caches=2

Test with following steps:

root@...l0pwrt8:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi       265Mi        62Gi       1.0Mi       290Mi        61Gi
Swap:          31Gi          0B        31Gi
root@...l0pwrt8:~# (cd /tmp && /root/generate_slab_cache)
root@...l0pwrt8:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi       266Mi        60Gi       1.0Mi       2.2Gi        61Gi
Swap:          31Gi          0B        31Gi
root@...l0pwrt8:~# cgcreate -g memory:/lxc/i-vbe1u8o7
root@...l0pwrt8:~# cgexec -g memory:/lxc/i-vbe1u8o7 /root/generate_slab_cache
root@...l0pwrt8:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi       267Mi        58Gi       1.0Mi       4.1Gi        61Gi
Swap:          31Gi          0B        31Gi
root@...l0pwrt8:~# cgexec -g memory:/lxc/i-vbe1u8o7 sysctl vm.drop_caches=2
vm.drop_caches = 2
root@...l0pwrt8:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi       268Mi        60Gi       1.0Mi       2.2Gi        61Gi
Swap:          31Gi          0B        31Gi
root@...l0pwrt8:~# sysctl vm.drop_caches=2
vm.drop_caches = 2
root@...l0pwrt8:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi       267Mi        62Gi       1.0Mi       290Mi        61Gi
Swap:          31Gi          0B        31Gi

Signed-off-by: Neil Sun <neilsun@...ify.com>
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 562e87cb..81d770a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -702,7 +702,7 @@ void drop_slab_node(int nid)
 			return;
 
 		freed = 0;
-		memcg = mem_cgroup_iter(NULL, NULL, NULL);
+		memcg = mem_cgroup_from_task(current);
 		do {
 			freed += shrink_slab(GFP_KERNEL, nid, memcg, 0);
 		} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ