From: Tejun Heo <tj@kernel.org>
To: lizefan@huawei.com, hannes@cmpxchg.org, mhocko@suse.cz,
bsingharora@gmail.com, kamezawa.hiroyu@jp.fujitsu.com
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] memcg: rename cgroup_event to mem_cgroup_event
Date: Sun, 4 Aug 2013 12:07:26 -0400 [thread overview]
Message-ID: <1375632446-2581-6-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1375632446-2581-1-git-send-email-tj@kernel.org>
cgroup_event is only available in memcg now. Let's brand it that way.
While at it, add a comment encouraging deprecation of the feature and
remove the respective section from cgroup documentation.
This patch is cosmetic.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
Documentation/cgroups/cgroups.txt | 19 -------------
mm/memcontrol.c | 57 +++++++++++++++++++++++++--------------
2 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index 638bf17..ca5aee9 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -472,25 +472,6 @@ you give a subsystem a name.
The name of the subsystem appears as part of the hierarchy description
in /proc/mounts and /proc/<pid>/cgroups.
-2.4 Notification API
---------------------
-
-There is mechanism which allows to get notifications about changing
-status of a cgroup.
-
-To register a new notification handler you need to:
- - create a file descriptor for event notification using eventfd(2);
- - open a control file to be monitored (e.g. memory.usage_in_bytes);
- - write "<event_fd> <control_fd> <args>" to cgroup.event_control.
- Interpretation of args is defined by control file implementation;
-
-eventfd will be woken up by control file implementation or when the
-cgroup is removed.
-
-To unregister a notification handler just close eventfd.
-
-NOTE: Support of notifications should be implemented for the control
-file. See documentation for the subsystem.
3. Kernel API
=============
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e988bf1..240ae72 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -242,7 +242,7 @@ struct mem_cgroup_eventfd_list {
/*
* cgroup_event represents events which userspace want to receive.
*/
-struct cgroup_event {
+struct mem_cgroup_event {
/*
* css which the event belongs to.
*/
@@ -5977,14 +5977,27 @@ static void kmem_cgroup_css_offline(struct mem_cgroup *memcg)
#endif
/*
+ * DO NOT USE IN NEW FILES.
+ *
+ * "cgroup.event_control" implementation.
+ *
+ * This is way over-engineered. It tries to support fully configureable
+ * events for each user. Such level of flexibility is completely
+ * unnecessary especially in the light of the planned unified hierarchy.
+ *
+ * Please deprecate this and replace with something simpler if at all
+ * possible.
+ */
+
+/*
* Unregister event and free resources.
*
* Gets called from workqueue.
*/
-static void cgroup_event_remove(struct work_struct *work)
+static void memcg_event_remove(struct work_struct *work)
{
- struct cgroup_event *event = container_of(work, struct cgroup_event,
- remove);
+ struct mem_cgroup_event *event = container_of(work,
+ struct mem_cgroup_event, remove);
struct cgroup_subsys_state *css = event->css;
struct cgroup *cgrp = css->cgroup;
@@ -6005,11 +6018,11 @@ static void cgroup_event_remove(struct work_struct *work)
*
* Called with wqh->lock held and interrupts disabled.
*/
-static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
- int sync, void *key)
+static int memcg_event_wake(wait_queue_t *wait, unsigned mode,
+ int sync, void *key)
{
- struct cgroup_event *event = container_of(wait,
- struct cgroup_event, wait);
+ struct mem_cgroup_event *event =
+ container_of(wait, struct mem_cgroup_event, wait);
struct mem_cgroup *memcg = mem_cgroup_from_css(event->css);
unsigned long flags = (unsigned long)key;
@@ -6038,28 +6051,30 @@ static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
return 0;
}
-static void cgroup_event_ptable_queue_proc(struct file *file,
+static void memcg_event_ptable_queue_proc(struct file *file,
wait_queue_head_t *wqh, poll_table *pt)
{
- struct cgroup_event *event = container_of(pt,
- struct cgroup_event, pt);
+ struct mem_cgroup_event *event =
+ container_of(pt, struct mem_cgroup_event, pt);
event->wqh = wqh;
add_wait_queue(wqh, &event->wait);
}
/*
+ * DO NOT USE IN NEW FILES.
+ *
* Parse input and register new memcg event handler.
*
* Input must be in format '<event_fd> <control_fd> <args>'.
* Interpretation of args is defined by control file implementation.
*/
-static int cgroup_write_event_control(struct cgroup_subsys_state *css,
- struct cftype *cft, const char *buffer)
+static int memcg_write_event_control(struct cgroup_subsys_state *css,
+ struct cftype *cft, const char *buffer)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
struct cgroup *cgrp = css->cgroup;
- struct cgroup_event *event;
+ struct mem_cgroup_event *event;
struct cgroup *cgrp_cfile;
unsigned int efd, cfd;
struct file *efile;
@@ -6082,9 +6097,9 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
return -ENOMEM;
event->css = css;
INIT_LIST_HEAD(&event->list);
- init_poll_funcptr(&event->pt, cgroup_event_ptable_queue_proc);
- init_waitqueue_func_entry(&event->wait, cgroup_event_wake);
- INIT_WORK(&event->remove, cgroup_event_remove);
+ init_poll_funcptr(&event->pt, memcg_event_ptable_queue_proc);
+ init_waitqueue_func_entry(&event->wait, memcg_event_wake);
+ INIT_WORK(&event->remove, memcg_event_remove);
efile = eventfd_fget(efd);
if (IS_ERR(efile)) {
@@ -6130,6 +6145,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
* to be done via struct cftype but cgroup core no longer knows
* about these events. The following is crude but the whole thing
* is for compatibility anyway.
+ *
+ * DO NOT ADD NEW FILES.
*/
if (!strcmp(event->cft->name, "usage_in_bytes")) {
event->register_event = mem_cgroup_usage_register_event;
@@ -6227,8 +6244,8 @@ static struct cftype mem_cgroup_files[] = {
.read_u64 = mem_cgroup_hierarchy_read,
},
{
- .name = "cgroup.event_control",
- .write_string = cgroup_write_event_control,
+ .name = "cgroup.event_control", /* XXX: for compat */
+ .write_string = memcg_write_event_control,
.flags = CFTYPE_NO_PREFIX,
.mode = S_IWUGO,
},
@@ -6561,7 +6578,7 @@ static void mem_cgroup_invalidate_reclaim_iterators(struct mem_cgroup *memcg)
static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
- struct cgroup_event *event, *tmp;
+ struct mem_cgroup_event *event, *tmp;
/*
* Unregister events and notify userspace.
--
1.8.3.1
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: lizefan@huawei.com, hannes@cmpxchg.org, mhocko@suse.cz,
bsingharora@gmail.com, kamezawa.hiroyu@jp.fujitsu.com
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] memcg: rename cgroup_event to mem_cgroup_event
Date: Sun, 4 Aug 2013 12:07:26 -0400 [thread overview]
Message-ID: <1375632446-2581-6-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1375632446-2581-1-git-send-email-tj@kernel.org>
cgroup_event is only available in memcg now. Let's brand it that way.
While at it, add a comment encouraging deprecation of the feature and
remove the respective section from cgroup documentation.
This patch is cosmetic.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
Documentation/cgroups/cgroups.txt | 19 -------------
mm/memcontrol.c | 57 +++++++++++++++++++++++++--------------
2 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index 638bf17..ca5aee9 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -472,25 +472,6 @@ you give a subsystem a name.
The name of the subsystem appears as part of the hierarchy description
in /proc/mounts and /proc/<pid>/cgroups.
-2.4 Notification API
---------------------
-
-There is mechanism which allows to get notifications about changing
-status of a cgroup.
-
-To register a new notification handler you need to:
- - create a file descriptor for event notification using eventfd(2);
- - open a control file to be monitored (e.g. memory.usage_in_bytes);
- - write "<event_fd> <control_fd> <args>" to cgroup.event_control.
- Interpretation of args is defined by control file implementation;
-
-eventfd will be woken up by control file implementation or when the
-cgroup is removed.
-
-To unregister a notification handler just close eventfd.
-
-NOTE: Support of notifications should be implemented for the control
-file. See documentation for the subsystem.
3. Kernel API
=============
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e988bf1..240ae72 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -242,7 +242,7 @@ struct mem_cgroup_eventfd_list {
/*
* cgroup_event represents events which userspace want to receive.
*/
-struct cgroup_event {
+struct mem_cgroup_event {
/*
* css which the event belongs to.
*/
@@ -5977,14 +5977,27 @@ static void kmem_cgroup_css_offline(struct mem_cgroup *memcg)
#endif
/*
+ * DO NOT USE IN NEW FILES.
+ *
+ * "cgroup.event_control" implementation.
+ *
+ * This is way over-engineered. It tries to support fully configureable
+ * events for each user. Such level of flexibility is completely
+ * unnecessary especially in the light of the planned unified hierarchy.
+ *
+ * Please deprecate this and replace with something simpler if at all
+ * possible.
+ */
+
+/*
* Unregister event and free resources.
*
* Gets called from workqueue.
*/
-static void cgroup_event_remove(struct work_struct *work)
+static void memcg_event_remove(struct work_struct *work)
{
- struct cgroup_event *event = container_of(work, struct cgroup_event,
- remove);
+ struct mem_cgroup_event *event = container_of(work,
+ struct mem_cgroup_event, remove);
struct cgroup_subsys_state *css = event->css;
struct cgroup *cgrp = css->cgroup;
@@ -6005,11 +6018,11 @@ static void cgroup_event_remove(struct work_struct *work)
*
* Called with wqh->lock held and interrupts disabled.
*/
-static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
- int sync, void *key)
+static int memcg_event_wake(wait_queue_t *wait, unsigned mode,
+ int sync, void *key)
{
- struct cgroup_event *event = container_of(wait,
- struct cgroup_event, wait);
+ struct mem_cgroup_event *event =
+ container_of(wait, struct mem_cgroup_event, wait);
struct mem_cgroup *memcg = mem_cgroup_from_css(event->css);
unsigned long flags = (unsigned long)key;
@@ -6038,28 +6051,30 @@ static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
return 0;
}
-static void cgroup_event_ptable_queue_proc(struct file *file,
+static void memcg_event_ptable_queue_proc(struct file *file,
wait_queue_head_t *wqh, poll_table *pt)
{
- struct cgroup_event *event = container_of(pt,
- struct cgroup_event, pt);
+ struct mem_cgroup_event *event =
+ container_of(pt, struct mem_cgroup_event, pt);
event->wqh = wqh;
add_wait_queue(wqh, &event->wait);
}
/*
+ * DO NOT USE IN NEW FILES.
+ *
* Parse input and register new memcg event handler.
*
* Input must be in format '<event_fd> <control_fd> <args>'.
* Interpretation of args is defined by control file implementation.
*/
-static int cgroup_write_event_control(struct cgroup_subsys_state *css,
- struct cftype *cft, const char *buffer)
+static int memcg_write_event_control(struct cgroup_subsys_state *css,
+ struct cftype *cft, const char *buffer)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
struct cgroup *cgrp = css->cgroup;
- struct cgroup_event *event;
+ struct mem_cgroup_event *event;
struct cgroup *cgrp_cfile;
unsigned int efd, cfd;
struct file *efile;
@@ -6082,9 +6097,9 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
return -ENOMEM;
event->css = css;
INIT_LIST_HEAD(&event->list);
- init_poll_funcptr(&event->pt, cgroup_event_ptable_queue_proc);
- init_waitqueue_func_entry(&event->wait, cgroup_event_wake);
- INIT_WORK(&event->remove, cgroup_event_remove);
+ init_poll_funcptr(&event->pt, memcg_event_ptable_queue_proc);
+ init_waitqueue_func_entry(&event->wait, memcg_event_wake);
+ INIT_WORK(&event->remove, memcg_event_remove);
efile = eventfd_fget(efd);
if (IS_ERR(efile)) {
@@ -6130,6 +6145,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
* to be done via struct cftype but cgroup core no longer knows
* about these events. The following is crude but the whole thing
* is for compatibility anyway.
+ *
+ * DO NOT ADD NEW FILES.
*/
if (!strcmp(event->cft->name, "usage_in_bytes")) {
event->register_event = mem_cgroup_usage_register_event;
@@ -6227,8 +6244,8 @@ static struct cftype mem_cgroup_files[] = {
.read_u64 = mem_cgroup_hierarchy_read,
},
{
- .name = "cgroup.event_control",
- .write_string = cgroup_write_event_control,
+ .name = "cgroup.event_control", /* XXX: for compat */
+ .write_string = memcg_write_event_control,
.flags = CFTYPE_NO_PREFIX,
.mode = S_IWUGO,
},
@@ -6561,7 +6578,7 @@ static void mem_cgroup_invalidate_reclaim_iterators(struct mem_cgroup *memcg)
static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
- struct cgroup_event *event, *tmp;
+ struct mem_cgroup_event *event, *tmp;
/*
* Unregister events and notify userspace.
--
1.8.3.1
next prev parent reply other threads:[~2013-08-04 16:07 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-04 16:07 [PATCHSET cgroup/for-3.12] cgroup: make cgroup_event specific to memcg Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-04 16:07 ` [PATCH 1/5] cgroup: implement CFTYPE_NO_PREFIX Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-04 16:07 ` [PATCH 2/5] cgroup: export __cgroup_from_dentry() and __cgroup_dput() Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-05 2:58 ` Li Zefan
2013-08-05 2:58 ` Li Zefan
[not found] ` <51FF14C5.4040003-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-05 15:40 ` Tejun Heo
2013-08-05 15:40 ` Tejun Heo
2013-08-05 15:40 ` Tejun Heo
[not found] ` <1375632446-2581-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-05 17:08 ` [PATCH v2 2/5] cgroup: make __cgroup_from_dentry() and __cgroup_dput() global Tejun Heo
2013-08-05 17:08 ` Tejun Heo
2013-08-05 17:08 ` Tejun Heo
2013-08-04 16:07 ` [PATCH 3/5] cgroup, memcg: move cgroup_event implementation to memcg Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-05 3:14 ` Li Zefan
2013-08-05 3:14 ` Li Zefan
2013-08-05 3:14 ` Li Zefan
[not found] ` <1375632446-2581-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-05 17:09 ` [PATCH v2 " Tejun Heo
2013-08-05 17:09 ` Tejun Heo
2013-08-05 17:09 ` Tejun Heo
2013-08-06 2:02 ` Li Zefan
2013-08-06 2:02 ` Li Zefan
2013-08-06 2:21 ` Li Zefan
2013-08-06 2:21 ` Li Zefan
2013-08-06 3:26 ` [PATCH " Balbir Singh
2013-08-06 3:26 ` Balbir Singh
2013-08-06 14:09 ` Tejun Heo
2013-08-06 14:09 ` Tejun Heo
2013-08-06 16:03 ` Balbir Singh
2013-08-06 16:03 ` Balbir Singh
2013-08-04 16:07 ` [PATCH 4/5] cgroup, memcg: move cgroup->event_list[_lock] and event callbacks into memcg Tejun Heo
2013-08-04 16:07 ` Tejun Heo
2013-08-04 16:07 ` Tejun Heo [this message]
2013-08-04 16:07 ` [PATCH 5/5] memcg: rename cgroup_event to mem_cgroup_event Tejun Heo
2013-08-05 3:26 ` Li Zefan
2013-08-05 3:26 ` Li Zefan
[not found] ` <1375632446-2581-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-05 17:10 ` [PATCH v2 " Tejun Heo
2013-08-05 17:10 ` Tejun Heo
2013-08-05 17:10 ` Tejun Heo
[not found] ` <1375632446-2581-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-05 16:01 ` [PATCHSET cgroup/for-3.12] cgroup: make cgroup_event specific to memcg Michal Hocko
2013-08-05 16:01 ` Michal Hocko
2013-08-05 16:01 ` Michal Hocko
2013-08-05 16:29 ` Tejun Heo
2013-08-05 16:29 ` Tejun Heo
2013-08-05 19:16 ` Michal Hocko
2013-08-05 19:16 ` Michal Hocko
2013-08-05 19:44 ` Tejun Heo
2013-08-05 19:44 ` Tejun Heo
[not found] ` <20130805194431.GD23751-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-08-06 15:58 ` Michal Hocko
2013-08-06 15:58 ` Michal Hocko
2013-08-06 15:58 ` Michal Hocko
2013-08-06 16:15 ` Tejun Heo
2013-08-06 16:15 ` Tejun Heo
2013-08-07 12:18 ` Michal Hocko
2013-08-07 12:18 ` Michal Hocko
2013-08-07 12:43 ` Tejun Heo
2013-08-07 12:43 ` Tejun Heo
[not found] ` <20130807124321.GA27006-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-07 13:26 ` Michal Hocko
2013-08-07 13:26 ` Michal Hocko
2013-08-07 13:26 ` Michal Hocko
2013-08-07 13:36 ` Tejun Heo
2013-08-07 13:36 ` Tejun Heo
2013-08-08 2:53 ` Li Zefan
2013-08-08 2:53 ` Li Zefan
2013-08-09 1:00 ` Tejun Heo
2013-08-09 1:00 ` Tejun Heo
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=1375632446-2581-6-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=bsingharora@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan@huawei.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.