On Fri 30-08-24 01:06:44, Liu Jing wrote: > hello,linux boss > > I found a problem in the process of using linux memcg,When I turned swap off, the memcg memory I created with the following script could not be deleted with echo 0 > memory.force_empty, as explained below。 > > ---------------------------------------------------------------------------------------------------------- > step1:swapoff -a > > > step2:use this script to create memcg > > #!/bin/bash > mkdir -p /tmp/test > for i in 'seq 2000' > do > sudo mkdir -p /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i} > sudo echo $$ > /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i}/tasks > sudo echo 'data' > /tmp/test/test$ {i} > sudo echo $$ > /sys/fs/cgroup/memory/user.slice/user-0.slice/tasks > sudo rmdir /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i} > done [...] I assume you /tmp is tmpfs backed. > Therefore, I want to know why swap affects memcg memory reclamation, > echo 0 > memory.force_empty this interface should force the memory > used by the cgroup to be reclaimed. If the above is true then you simply do not have any backing storage to reclaim to. You need swap to reclaim tmpfs/shmem memory. -- Michal Hocko SUSE Labs