From: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Nikolay Borisov <n.borisov-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Access rules for current->memcg
Date: Tue, 21 Jul 2015 14:25:48 +0200 [thread overview]
Message-ID: <20150721122548.GK11967@dhcp22.suse.cz> (raw)
In-Reply-To: <55AE1FB7.8050107-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
On Tue 21-07-15 13:32:23, Nikolay Borisov wrote:
>
>
> On 07/21/2015 12:48 PM, Michal Hocko wrote:
> > On Tue 21-07-15 12:08:40, Nikolay Borisov wrote:
[...]
> >> I looked more carefully into the code and saw that the page_counters
> >> (which back memory/memsw.limit/usage_in_bytes) are charged during the
> >> try_charge whereas the per-cpu statistics (which back the info in
> >> memory.stats) are updated after committing the charge. I assume in the
> >> case where charges are not canceled the data in memory.stats and
> >> memory.memsw.max_usage_in_bytes - memory.usage_in_bytes should be identical?
> >
> > I am not sure what you mean here. max_usage_in_bytes is a historical
> > value which was the maximum charge used at some point in time.
> > usage_in_bytes is always the _current_ value of the charge counter.
> > max_usage_in_bytes-usage_in_bytes doesn't tell you much really.
> >
>
> I have misunderstood me I have never, ever referred to max_usage. What I
> meant was that the information that memory.stat file provides is
> acquired by reading the memcg->stat->count[counter] and those values are
> updated when mem_cgroup_commit_charge() is invoked.
True
> And
> mem_cgroup_commit_charge is invoked AFTER mem_cgroup_try_charge, which
> updates the charge counters.
Still true and you should realize that the commit is called very shortly
after the charge. The race window is not really interesting for anything
practical.
> So my point was that whether I read the
> swap value (for example) from the memory.stats file or whether I
> manually do the maths with subtraction as previously shown the 2 values
> should match.
Your subtraction simply doesn't work and doesn't tell you how much
memory is swapped out from the memcg as explained in other email.
> Essentially whether information should be queried form the charge
> counter or from the mem_cgroup_stat_cpu struct. Does that make sense?
memory.stat will tell you the information you are looking for. You
simply cannot calculate those numbers from the counters.
--
Michal Hocko
SUSE Labs
prev parent reply other threads:[~2015-07-21 12:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 13:34 Access rules for current->memcg Nikolay Borisov
[not found] ` <55A7B2D0.1030506-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-16 14:59 ` Michal Hocko
[not found] ` <20150716145902.GA10758-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-16 15:11 ` Nikolay Borisov
[not found] ` <55A7C9B4.3010907-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-16 15:22 ` Michal Hocko
[not found] ` <20150716152239.GA22529-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-16 21:21 ` Nikolay Borisov
[not found] ` <CAJFSNy6sLX82+3ZW_COr__pDTd9aSGgL1bjryMKKcVPhEN0F9g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-17 7:13 ` Michal Hocko
[not found] ` <20150717071339.GA24787-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-17 7:16 ` Nikolay Borisov
[not found] ` <55A8ABC9.7090701-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-20 11:17 ` Michal Hocko
[not found] ` <20150720111707.GE1211-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-20 11:22 ` Nikolay Borisov
[not found] ` <55ACD9F8.2040802-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-21 7:48 ` Michal Hocko
[not found] ` <20150721074834.GF11967-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-21 9:08 ` Nikolay Borisov
[not found] ` <55AE0C18.5000304-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-21 9:24 ` Johannes Weiner
2015-07-21 9:48 ` Michal Hocko
[not found] ` <20150721094832.GI11967-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-07-21 10:32 ` Nikolay Borisov
[not found] ` <55AE1FB7.8050107-/eCPMmvKun9pLGFMi4vTTA@public.gmane.org>
2015-07-21 12:25 ` Michal Hocko [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:
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=20150721122548.GK11967@dhcp22.suse.cz \
--to=mhocko-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=n.borisov-/eCPMmvKun9pLGFMi4vTTA@public.gmane.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