archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <>
To: Michal Hocko <>
Cc: Andrew Morton <>,
	Johannes Weiner <>,
	Vladimir Davydov <>,,,
Subject: Re: Process memory accounting (cgroups) accuracy
Date: Fri, 2 Jul 2021 12:40:28 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 02/07/2021 11:08, Michal Hocko wrote:
> On Fri 02-07-21 09:50:11, Krzysztof Kozlowski wrote:
> [...]
>> The questions: How accurate are now the cgroup counters?
> The precision depends on the number of CPUs the workload is running on
> as we do a per-cpu charge caching to optimize the accounting. This is
> MEMCG_CHARGE_BATCH (32) pages currently. You can learn more by checking
> try_charge function (mm/memcontrol.c).

This explains the 32 pages, thanks!

>> I understood they should charge only pages allocated by the process, so
>> why mmap(4 kB) causes max_usage_in_bytes=132 kB?
> Please note that kernel allocations (marked by __GFP_ACCOUNT) are
> accounted as well so this is not only about mmaped memory.
>> Why mmap(4 MB) causes max_usage_in_bytes=4 MB + 34 pages?
> The specific number will depend on the executing - e.g. use up all but 3
> pages from CPU0 batch and have 31 pages on another cpu.
>> What is being accounted there (stack guards?)?
>> Or maybe the entire LTP test checking so carefully memcg limits is useless?
> Well, I haven't really checked details of those tests and their
> objective but aiming for an absolute precision is not really something
> that is very useful IMHO. We are very likely to do optimizations like
> the one mentioned above as the runtime tends to be much more important
> than to-the-page precision.
> Hope this clarifies this a bit.

Yes, thanks!

Best regards,

      reply	other threads:[~2021-07-02 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02  7:50 Process memory accounting (cgroups) accuracy Krzysztof Kozlowski
2021-07-02  9:08 ` Michal Hocko
2021-07-02 10:40   ` Krzysztof Kozlowski [this message]

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \

* 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;
as well as URLs for NNTP newsgroup(s).