From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: linux-mm@kvack.org, mgorman@suse.de,
kamezawa.hiroyu@jp.fujitsu.com, dhillf@gmail.com,
aarcange@redhat.com, mhocko@suse.cz, akpm@linux-foundation.org,
hannes@cmpxchg.org
Cc: linux-kernel@vger.kernel.org, cgroups@kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH -V1 2/9] hugetlbfs: Add usage and max usage files to hugetlb cgroup
Date: Mon, 20 Feb 2012 16:51:35 +0530 [thread overview]
Message-ID: <1329736902-26870-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1329736902-26870-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
fs/hugetlbfs/hugetlb_cgroup.c | 12 ++++++++++++
include/linux/hugetlb.h | 2 ++
include/linux/hugetlb_cgroup.h | 1 +
mm/hugetlb.c | 21 +++++++++++++++++++++
4 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/fs/hugetlbfs/hugetlb_cgroup.c b/fs/hugetlbfs/hugetlb_cgroup.c
index b5b3cb8..75dbdd8 100644
--- a/fs/hugetlbfs/hugetlb_cgroup.c
+++ b/fs/hugetlbfs/hugetlb_cgroup.c
@@ -99,6 +99,18 @@ int hugetlb_cgroup_write(struct cgroup *cgroup, struct cftype *cft,
return ret;
}
+int hugetlb_cgroup_reset(struct cgroup *cgroup, unsigned int event)
+{
+ int name, idx;
+ struct hugetlb_cgroup *h_cgroup = cgroup_to_hugetlbcgroup(cgroup);
+
+ idx = MEMFILE_TYPE(event);
+ name = MEMFILE_ATTR(event);
+
+ res_counter_reset_max(&h_cgroup->memhuge[idx]);
+ return 0;
+}
+
static int hugetlbcgroup_can_attach(struct cgroup_subsys *ss,
struct cgroup *new_cgrp,
struct cgroup_taskset *set)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 2b6b231..4392b6a 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -228,6 +228,8 @@ struct hstate {
unsigned int surplus_huge_pages_node[MAX_NUMNODES];
/* cgroup control files */
struct cftype cgroup_limit_file;
+ struct cftype cgroup_usage_file;
+ struct cftype cgroup_max_usage_file;
char name[HSTATE_NAME_LEN];
};
diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
index 2330dd0..11cd6c4 100644
--- a/include/linux/hugetlb_cgroup.h
+++ b/include/linux/hugetlb_cgroup.h
@@ -18,4 +18,5 @@
extern u64 hugetlb_cgroup_read(struct cgroup *cgroup, struct cftype *cft);
extern int hugetlb_cgroup_write(struct cgroup *cgroup, struct cftype *cft,
const char *buffer);
+extern int hugetlb_cgroup_reset(struct cgroup *cgroup, unsigned int event);
#endif
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f643f72..865b41f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1814,6 +1814,13 @@ int register_hugetlb_cgroup_files(struct cgroup_subsys *ss,
ret = cgroup_add_file(cgroup, ss, &h->cgroup_limit_file);
if (ret)
return ret;
+ ret = cgroup_add_file(cgroup, ss, &h->cgroup_usage_file);
+ if (ret)
+ return ret;
+ ret = cgroup_add_file(cgroup, ss, &h->cgroup_max_usage_file);
+ if (ret)
+ return ret;
+
}
return ret;
}
@@ -1845,6 +1852,20 @@ static int hugetlb_cgroup_file_init(struct hstate *h, int idx)
cft->read_u64 = hugetlb_cgroup_read;
cft->write_string = hugetlb_cgroup_write;
+ /* Add the usage file */
+ cft = &h->cgroup_usage_file;
+ snprintf(cft->name, MAX_CFTYPE_NAME, "%s.usage_in_bytes", buf);
+ cft->private = MEMFILE_PRIVATE(idx, RES_USAGE);
+ cft->read_u64 = hugetlb_cgroup_read;
+
+ /* Add the MAX usage file */
+ cft = &h->cgroup_max_usage_file;
+ snprintf(cft->name, MAX_CFTYPE_NAME,
+ "%s.max_usage_in_bytes", buf);
+ cft->private = MEMFILE_PRIVATE(idx, RES_MAX_USAGE);
+ cft->trigger = hugetlb_cgroup_reset;
+ cft->read_u64 = hugetlb_cgroup_read;
+
return 0;
}
#else
--
1.7.9
next prev parent reply other threads:[~2012-02-20 11:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 11:21 [PATCH -V1 0/9] hugetlbfs: Add cgroup resource controller for hugetlbfs Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 1/9] hugetlbfs: Add new HugeTLB cgroup Aneesh Kumar K.V
2012-02-20 11:21 ` Aneesh Kumar K.V [this message]
2012-02-20 11:21 ` [PATCH -V1 3/9] hugetlbfs: Add new region handling functions Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 4/9] hugetlbfs: Add controller support for shared mapping Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 5/9] hugetlbfs: Add controller support for private mapping Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 6/9] hugetlbfs: Switch to new region APIs Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 7/9] hugetlbfs: Add truncate region functions Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 8/9] hugetlbfs: Add task migration support Aneesh Kumar K.V
2012-02-20 11:21 ` [PATCH -V1 9/9] hugetlbfs: Add HugeTLB controller documentation Aneesh Kumar K.V
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=1329736902-26870-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@kernel.org \
--cc=dhillf@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
/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).