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

[-- Attachment #1: Type: text/plain, Size: 3936 bytes --]

\r\r\r\r\r\rhello,linux boss\r\r\r\r\r        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。\r\r\r\r\r----------------------------------------------------------------------------------------------------------\r\rstep1:swapoff -a\r\r\r\r\r\r\r\rstep2:use this script to create memcg\r\r\r\r\r\r\r#!/bin/bash\r\rmkdir -p /tmp/test\r\rfor i in 'seq 2000'\r\rdo\r\r        sudo mkdir -p /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i}\r\r        sudo echo $$ > /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i}/tasks\r\r        sudo echo 'data' > /tmp/test/test$ {i}\r\r        sudo echo $$ > /sys/fs/cgroup/memory/user.slice/user-0.slice/tasks\r\r        sudo rmdir /sys/fs/cgroup/memory/user.slice/user-0.slice/test$ {i}\r\rdone\r\r\r\r\r\r\r\rstep3:view /proc/cgroup and /proc/meminfo  files\r\r\r\r\r\r\r[root@localhost ~]# cat /proc/cgroups\r\r#subsys_name    hierarchy       num_cgroups     enabled\r\rcpuset                    10                   1                         1\r\rcpu                          4                     1                        1\r\rcpuacct                    4                     1                       1\r\rblkio                        13                   1                        1\r\rmemory                  14                 2009                   1\r\rdevices                      6                   94                       1\r\r\r\r\r\r\r[root@localhost ~]# cat /proc/meminfo | grep Percpu\r\rPercpu:           600576 kB\r\r\r\r\r\r\r\rstep4: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\r\r\r\r\r\r\r[root@localhost ~]# echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty\r\r[root@localhost ~]# cat /proc/cgroups\r\r#subsys_name    hierarchy       num_cgroups     enabled\r\rcpuset                    10      1       1\r\rcpu                          4       1       1\r\rcpuacct                   4       1       1\r\rblkio                       13      1       1\r\rmemory                  14      2039    1\r\rdevices                    6       87      1\r\r\r\r\r\r\r[root@localhost ~]# cat /proc/meminfo | grep Percpu\r\rPercpu:           600576 kB\r\r\r\r\r\r\r\rstep 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\r\r\r\r\r\r\r[root@localhost ~]# swapon -a\r\r[root@localhost ~]# echo 0 > /sys/fs/cgroup/memory/user.slice/user-0.slice/memory.force_empty\r\r\r\r\r\r\r\rstep 6: view /proc/cgroup and /proc/meminfo  files ,I found the the num_cgroups of memory and percpu  have been reduced. \r\r\r\r[root@localhost ~]# cat /proc/cgroups\r\r#subsys_name    hierarchy       num_cgroups     enabled\r\rcpuset                    10                         1                 1\r\rcpu                         4                          1                 1\r\rcpuacct                  4                          1                  1\r\rblkio                     13                         1                  1\r\rmemory                14                     185                 1\r\rdevices                    6                      87                 1\r\rfreezer                   9                          1                 1\r\r\r\r\r\r\r[root@localhost ~]# cat /proc/meminfo | grep Percpu\r\rPercpu:           120832 kB\r\r--------------------------------------------------------------------------------------------------------\r\r\r\r\r\r\r\rTherefore, 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. \r\rI want to know why ,I look forward to hearing back from the community.\r\rThanks.\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r-----------------------------------------\r\r刘婧   计算产品部\r\r\r\r手机:18896725597\r\r邮箱:liujing@cmss.chinamobile.com\r\r中移(苏州)软件技术有限公司\r\r\r

[-- Attachment #2: Type: text/html, Size: 16267 bytes --]

             reply	other threads:[~2024-08-30  3:22 UTC|newest]

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

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=20240830112239957689310@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