From: Johannes Weiner <hannes@cmpxchg.org>
To: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mm: memcontrol: make tree_{stat,events} fetch all stats
Date: Fri, 5 Feb 2016 10:37:16 -0500 [thread overview]
Message-ID: <20160205153716.GA15544@cmpxchg.org> (raw)
In-Reply-To: <20160205095821.GA29522@esperanza>
On Fri, Feb 05, 2016 at 12:58:21PM +0300, Vladimir Davydov wrote:
> @@ -2745,14 +2745,20 @@ static void tree_events(struct mem_cgroup *memcg, unsigned long *events)
>
> static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
> {
> - unsigned long stat[MEMCG_NR_STAT];
> - unsigned long val;
> + unsigned long val = 0;
>
> if (mem_cgroup_is_root(memcg)) {
> - tree_stat(memcg, stat);
> - val = stat[MEM_CGROUP_STAT_CACHE] + stat[MEM_CGROUP_STAT_RSS];
> - if (swap)
> - val += stat[MEM_CGROUP_STAT_SWAP];
> + struct mem_cgroup *iter;
> +
> + for_each_mem_cgroup_tree(iter, memcg) {
> + val += mem_cgroup_read_stat(iter,
> + MEM_CGROUP_STAT_CACHE);
> + val += mem_cgroup_read_stat(iter,
> + MEM_CGROUP_STAT_RSS);
> + if (swap)
> + val += mem_cgroup_read_stat(iter,
> + MEM_CGROUP_STAT_SWAP);
> + }
> } else {
> if (!swap)
> val = page_counter_read(&memcg->memory);
Looks good to me, thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2016-02-05 15:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 13:03 Vladimir Davydov
2016-02-04 13:03 ` [PATCH 2/3] mm: memcontrol: report slab usage in cgroup2 memory.stat Vladimir Davydov
2016-02-04 20:46 ` Johannes Weiner
2016-02-04 13:03 ` [PATCH 3/3] mm: memcontrol: report kernel stack " Vladimir Davydov
2016-02-04 20:52 ` Johannes Weiner
2016-02-05 10:01 ` Vladimir Davydov
2016-02-04 20:45 ` [PATCH 1/3] mm: memcontrol: make tree_{stat,events} fetch all stats Johannes Weiner
2016-02-05 9:58 ` Vladimir Davydov
2016-02-05 15:37 ` Johannes Weiner [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=20160205153716.GA15544@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vdavydov@virtuozzo.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