From: Johannes Weiner <hannes@cmpxchg.org>
To: linux-mm@kvack.org
Cc: Michal Hocko <mhocko@suse.cz>, Greg Thelen <gthelen@google.com>,
Vladimir Davydov <vdavydov@parallels.com>,
Tejun Heo <tj@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 4/4] mm: memcontrol: add memory.vmstat to default hierarchy
Date: Fri, 8 Aug 2014 17:38:14 -0400 [thread overview]
Message-ID: <1407533894-25845-5-git-send-email-hannes@cmpxchg.org> (raw)
In-Reply-To: <1407533894-25845-1-git-send-email-hannes@cmpxchg.org>
Provide basic per-memcg vmstat-style statistics on LRU sizes,
allocated and freed pages, major and minor faults.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
Documentation/cgroups/unified-hierarchy.txt | 8 ++++++
mm/memcontrol.c | 40 +++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/Documentation/cgroups/unified-hierarchy.txt b/Documentation/cgroups/unified-hierarchy.txt
index ef1db728a035..512e9a2b2e06 100644
--- a/Documentation/cgroups/unified-hierarchy.txt
+++ b/Documentation/cgroups/unified-hierarchy.txt
@@ -384,6 +384,14 @@ that purpose, a hard upper limit can be set through 'memory.max'.
- memory.usage_in_bytes is renamed to memory.current to be in line
with the new limit naming scheme
+- memory.stat has been replaced by memory.vmstat, which provides
+ page-based statistics in the style of /proc/vmstat.
+
+ As cgroups are now always hierarchical and no longer allow tasks in
+ intermediate levels, the local state is irrelevant and all
+ statistics represent the state of the entire hierarchy rooted at the
+ given group.
+
5. Planned Changes
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a69ff21c8a9a..4959460fa170 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6283,6 +6283,42 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
return nbytes;
}
+static u64 tree_events(struct mem_cgroup *memcg, int event)
+{
+ struct mem_cgroup *mi;
+ u64 val = 0;
+
+ for_each_mem_cgroup_tree(mi, memcg)
+ val += mem_cgroup_read_events(mi, event);
+ return val;
+}
+
+static int memory_vmstat_show(struct seq_file *m, void *v)
+{
+ struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
+ struct mem_cgroup *mi;
+ int i;
+
+ for (i = 0; i < NR_LRU_LISTS; i++) {
+ u64 val = 0;
+
+ for_each_mem_cgroup_tree(mi, memcg)
+ val += mem_cgroup_nr_lru_pages(mi, BIT(i));
+ seq_printf(m, "%s %llu\n", vmstat_text[NR_LRU_BASE + i], val);
+ }
+
+ seq_printf(m, "pgalloc %llu\n",
+ tree_events(memcg, MEM_CGROUP_EVENTS_PGPGIN));
+ seq_printf(m, "pgfree %llu\n",
+ tree_events(memcg, MEM_CGROUP_EVENTS_PGPGOUT));
+ seq_printf(m, "pgfault %llu\n",
+ tree_events(memcg, MEM_CGROUP_EVENTS_PGFAULT));
+ seq_printf(m, "pgmajfault %llu\n",
+ tree_events(memcg, MEM_CGROUP_EVENTS_PGMAJFAULT));
+
+ return 0;
+}
+
static struct cftype memory_files[] = {
{
.name = "current",
@@ -6298,6 +6334,10 @@ static struct cftype memory_files[] = {
.read_u64 = memory_max_read,
.write = memory_max_write,
},
+ {
+ .name = "vmstat",
+ .seq_show = memory_vmstat_show,
+ },
};
struct cgroup_subsys memory_cgrp_subsys = {
--
2.0.3
--
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>
next prev parent reply other threads:[~2014-08-08 21:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-08 21:38 [patch 0/4] mm: memcontrol: populate unified hierarchy interface v2 Johannes Weiner
2014-08-08 21:38 ` [patch 1/4] mm: memcontrol: use generic direct reclaim code to meet the allocation Johannes Weiner
2014-08-08 21:38 ` [patch 2/4] mm: memcontrol: add memory.current and memory.high to default hierarchy Johannes Weiner
2014-08-08 21:38 ` [patch 3/4] mm: memcontrol: add memory.max " Johannes Weiner
2014-08-08 21:38 ` Johannes Weiner [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-08-04 21:14 [patch 0/4] mm: memcontrol: populate unified hierarchy interface Johannes Weiner
2014-08-04 21:14 ` [patch 4/4] mm: memcontrol: add memory.vmstat to default hierarchy Johannes Weiner
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=1407533894-25845-5-git-send-email-hannes@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=cgroups@vger.kernel.org \
--cc=gthelen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=tj@kernel.org \
--cc=vdavydov@parallels.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