linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Liu Jing <liujing@cmss.chinamobile.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Liu Jing <liujing@cmss.chinamobile.com>
Subject: The percpu memory used by memcg cannot be cleared
Date: Fri, 30 Aug 2024 01:06:44 +0800	[thread overview]
Message-ID: <20240829170644.15588-1-liujing@cmss.chinamobile.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3587 bytes --]

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


step3:view /proc/cgroup and /proc/meminfo  files

[root@localhost ~]# cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset           10                   1           1
cpu              4                     1           1
cpuacct         4                     1           1
blkio            13                     1          1
memory          14                 2009             1
devices         6                   94             1

[root@localhost ~]# cat /proc/meminfo | grep Percpu
Percpu:           600576 kB


step4:when I use "echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty", I find the num_cgroups of memory and percpu  have no changed

[root@localhost ~]# echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty
[root@localhost ~]# cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset              10               1            1
cpu                 4                 1           1
cpuacct              4               1             1
blkio                 13              1             1
memory              14              2039            1
devices             6               87               1

[root@localhost ~]# cat /proc/meminfo | grep Percpu
Percpu:           600576 kB


step 5: when I use swapon -a to open swap, then echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty again

[root@localhost ~]# swapon -a
[root@localhost ~]# echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty


step 6: view /proc/cgroup and /proc/meminfo  files ,I found the the num_cgroups of memory and percpu  have been reduced. 
[root@localhost ~]# cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset              10             1                 1
cpu               4                1                 1
cpuacct            4                1                  1
blkio            13                1                  1
memory            14              185                 1
devices           6               87                 1
freezer           9                1                 1

[root@localhost ~]# cat /proc/meminfo | grep Percpu
Percpu:           120832 kB
--------------------------------------------------------------------------------------------------------


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. 
I want to know why ,I look forward to hearing back from the community.
Thanks.




             reply	other threads:[~2024-08-30  5:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29 17:06 Liu Jing [this message]
2024-08-30  7:08 ` Michal Hocko
2024-08-30  3:22 liujing
2024-08-30  7:13 ` Yosry Ahmed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240829170644.15588-1-liujing@cmss.chinamobile.com \
    --to=liujing@cmss.chinamobile.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox