From: Anton Vorontsov <anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: KAMEZAWA Hiroyuki
<kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>,
Balbir Singh
<bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
KOSAKI Motohiro
<kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: [PATCH RFC] memcg: MEMCG_NR_FILE_MAPPED should update _STAT_CACHE as well
Date: Mon, 23 Apr 2012 01:28:35 -0700 [thread overview]
Message-ID: <20120423082835.GA32359@lizard> (raw)
In-Reply-To: <20120305091934.588c160b.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
...otherwise the we're getting the wrong numbers in usage_in_bytes.
On Mon, Mar 05, 2012 at 09:19:34AM +0900, KAMEZAWA Hiroyuki wrote:
[...]
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 228d646..c8abdc5 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -3812,6 +3812,9 @@ static inline u64 mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
> >
> > val = mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_CACHE);
> > val += mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_RSS);
> > + val += mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED);
> >
> > 1. Is there any particular reason we don't currently account file mapped
> > memory in usage_in_bytes?
> >
> > To me, MEM_CGROUP_STAT_FILE_MAPPED hunk seems logical even if we
> > don't use it for lowmemory notifications.
> >
> > Plus, it seems that FILE_MAPPED _is_ accounted for the non-root
> > cgroups, so I guess it's clearly a bug for the root memcg?
>
> CACHE includes all file caches. Why do you think FILE_MAPPED is not included in CACHE ?
There were tons of changes in the memcg lately, but I believe the issue
is still there.
For example, looking into this code flow:
-> page_add_file_rmap() (mm/rmap.c)
-> mem_cgroup_inc_page_stat(page, MEMCG_NR_FILE_MAPPED) (include/linux/memcontrol.h)
-> void mem_cgroup_update_page_stat(page, MEMCG_NR_FILE_MAPPED, 1) (mm/memcontrol.c)
And then:
void mem_cgroup_update_page_stat(struct page *page,
enum mem_cgroup_page_stat_item idx, int val)
{
...
switch (idx) {
case MEMCG_NR_FILE_MAPPED:
idx = MEM_CGROUP_STAT_FILE_MAPPED;
break;
default:
BUG();
}
this_cpu_add(memcg->stat->count[idx], val);
...
}
So, clearly, this function only bothers updating _FILE_MAPPED only,
leaving _CACHE alone.
If you're saying that _CACHE meant to include _FILE_MAPPED, then
I guess the patch down below would be a proper fix then... Otherwise
we need to be consistent on stats reporting, and either fall-back
to my original fix (in mem_cgroup_usage()), or think about doing it
some other way...
Signed-off-by: Anton Vorontsov <anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
The patch is against current -next.
Thanks,
mm/memcontrol.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 884e936..760ecf5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1958,6 +1958,8 @@ void mem_cgroup_update_page_stat(struct page *page,
switch (idx) {
case MEMCG_NR_FILE_MAPPED:
+ idx = MEM_CGROUP_STAT_CACHE;
+ this_cpu_add(memcg->stat->count[idx], val);
idx = MEM_CGROUP_STAT_FILE_MAPPED;
break;
default:
--
1.7.9.2
next prev parent reply other threads:[~2012-04-23 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 16:27 [RFC] memcg usage_in_bytes does not account file mapped and slab memory Anton Vorontsov
2012-03-05 0:19 ` KAMEZAWA Hiroyuki
[not found] ` <20120305091934.588c160b.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2012-04-23 8:28 ` Anton Vorontsov [this message]
2012-04-23 8:35 ` [PATCH RFC] memcg: MEMCG_NR_FILE_MAPPED should update _STAT_CACHE as well KAMEZAWA Hiroyuki
2012-04-23 9:33 ` Anton Vorontsov
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=20120423082835.GA32359@lizard \
--to=anton.vorontsov-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
--cc=kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
--cc=patches-QSEj5FYQhm4dnm+yROfE0A@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;
as well as URLs for NNTP newsgroup(s).