From: Yongqiang Liu <liuyongqiang13@huawei.com>
To: Michal Hocko <mhocko@suse.com>, Yang Shi <shy828301@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
<aarcange@redhat.com>, <hughd@google.com>, <mgorman@suse.de>,
<cl@gentwo.org>, <n-horiguchi@ah.jp.nec.com>,
<zokeefe@google.com>, <rientjes@google.com>,
Matthew Wilcox <willy@infradead.org>, <peterx@redhat.com>,
"Wangkefeng (OS Kernel Lab)" <wangkefeng.wang@huawei.com>,
"zhangxiaoxu (A)" <zhangxiaoxu5@huawei.com>,
<kirill.shutemov@linux.intel.com>,
Lu Jialin <lujialin4@huawei.com>
Subject: Re: [QUESTION] memcg page_counter seems broken in MADV_DONTNEED with THP enabled
Date: Tue, 29 Nov 2022 21:19:02 +0800 [thread overview]
Message-ID: <f383dc2c-10b9-6b3d-6ffa-00b35ab52bf4@huawei.com> (raw)
In-Reply-To: <Y4W+joR1rIug0ydA@dhcp22.suse.cz>
在 2022/11/29 16:10, Michal Hocko 写道:
> On Mon 28-11-22 12:01:37, Yang Shi wrote:
>> On Sat, Nov 26, 2022 at 5:10 AM Yongqiang Liu <liuyongqiang13@huawei.com> wrote:
>>> Hi,
>>>
>>> We use mm_counter to how much a process physical memory used. Meanwhile,
>>> page_counter of a memcg is used to count how much a cgroup physical
>>> memory used.
>>> If a cgroup only contains a process, they looks almost the same. But with
>>> THP enabled, sometimes memory.usage_in_bytes in memcg may be twice or
>>> more than rss
>>> in proc/[pid]/smaps_rollup as follow:
> [...]
>>> node_page_stat which shows in meminfo was also decreased. the
>>> __split_huge_pmd
>>> seems free no physical memory unless the total THP was free.I am
>>> confused which
>>> one is the true physical memory used of a process.
>> This should be caused by the deferred split of THP. When MADV_DONTNEED
>> is called on the partial of the map, the huge PMD is split, but the
>> THP itself will not be split until the memory pressure is hit (global
>> or memcg limit). So the unmapped sub pages are actually not freed
>> until that point. So the mm counter is decreased due to the zapping
>> but the physical pages are not actually freed then uncharged from
>> memcg.
> Yes, and this is not really bound to THP. Consider a page cache. It can
> be accessed via syscalls when it doesn't correspondent to rss at all
> while it is still charged to a memcg. Or it can be mapped and then later
> unmapped so it disappear from rss while it is still charged until it
> gets reclaimed by the memory pressure. Or it can be an in-memory object
> that is not bound to any process life time (e.g. tmpfs). Or it can be a
> kernel memory charged to a memcg which is not covered by rss because it
> is either not mapped or it is unknown to rss counters.
Thanks ! it's very nice to me.
next prev parent reply other threads:[~2022-11-29 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-26 13:09 Yongqiang Liu
2022-11-28 20:01 ` Yang Shi
2022-11-29 8:10 ` Michal Hocko
2022-11-29 13:19 ` Yongqiang Liu [this message]
2022-11-29 17:49 ` Yang Shi
2022-11-29 13:14 ` Yongqiang Liu
2022-11-29 17:23 ` Yang Shi
2022-12-01 2:22 ` Yongqiang Liu
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=f383dc2c-10b9-6b3d-6ffa-00b35ab52bf4@huawei.com \
--to=liuyongqiang13@huawei.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lujialin4@huawei.com \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=peterx@redhat.com \
--cc=rientjes@google.com \
--cc=shy828301@gmail.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=zhangxiaoxu5@huawei.com \
--cc=zokeefe@google.com \
/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