All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	mhocko-AlSwsSmVLrQ@public.gmane.org,
	hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH 11/12] memcg: rename cgroup_event to mem_cgroup_event
Date: Thu, 15 Aug 2013 12:02:29 -0400	[thread overview]
Message-ID: <1376582550-12548-12-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1376582550-12548-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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.

v2: Index in cgroups.txt updated accordingly as suggested by Li Zefan.

Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 Documentation/cgroups/cgroups.txt | 20 --------------
 mm/memcontrol.c                   | 57 +++++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index 638bf17..821de56 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -24,7 +24,6 @@ CONTENTS:
   2.1 Basic Usage
   2.2 Attaching processes
   2.3 Mounting hierarchies by name
-  2.4 Notification API
 3. Kernel API
   3.1 Overview
   3.2 Synchronization
@@ -472,25 +471,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 8663d6c..2f0a8e1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -243,7 +243,7 @@ struct mem_cgroup_eventfd_list {
 /*
  * cgroup_event represents events which userspace want to receive.
  */
-struct cgroup_event {
+struct mem_cgroup_event {
 	/*
 	 * memcg which the event belongs to.
 	 */
@@ -5973,14 +5973,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 mem_cgroup *memcg = event->memcg;
 
 	remove_wait_queue(event->wqh, &event->wait);
@@ -6000,11 +6013,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 = event->memcg;
 	unsigned long flags = (unsigned long)key;
 
@@ -6033,27 +6046,29 @@ 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 cgroup 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_event *event;
+	struct mem_cgroup_event *event;
 	struct cgroup_subsys_state *cfile_css;
 	unsigned int efd, cfd;
 	struct file *efile;
@@ -6078,9 +6093,9 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
 
 	event->memcg = memcg;
 	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)) {
@@ -6111,6 +6126,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.
 	 */
 	name = cfile->f_dentry->d_name.name;
 
@@ -6221,8 +6238,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,
 	},
@@ -6555,7 +6572,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

  parent reply	other threads:[~2013-08-15 16:02 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15 16:02 [PATCHSET v2 cgroup/for-3.12] cgroup: make cgroup_event specific to memcg Tejun Heo
     [not found] ` <1376582550-12548-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-15 16:02   ` [PATCH 01/12] cgroup: rename cgroup_css_from_dir() to css_from_dir() and update its syntax Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 02/12] cgroup: make cgroup_css() take cgroup_subsys * instead and allow NULL subsys Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 03/12] cgroup: implement CFTYPE_NO_PREFIX Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 04/12] cgroup: make cgroup_event hold onto cgroup_subsys_state instead of cgroup Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 05/12] cgroup: make cgroup_write_event_control() use css_from_dir() instead of __d_cgrp() Tejun Heo
     [not found]     ` <1376582550-12548-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-26 22:38       ` Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 06/12] cgroup, memcg: move cgroup_event implementation to memcg Tejun Heo
     [not found]     ` <1376582550-12548-7-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-27 14:20       ` Michal Hocko
     [not found]         ` <20130827142002.GC13302-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-08-27 20:00           ` Tejun Heo
2013-08-27 20:00           ` Tejun Heo
     [not found]             ` <20130827200002.GD12212-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-08-28 14:29               ` Michal Hocko
2013-08-28 14:29               ` Michal Hocko
2013-08-29 18:19       ` [PATCH v3 " Tejun Heo
2013-08-29 18:19       ` Tejun Heo
     [not found]         ` <20130829181911.GA8517-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-08-30 10:47           ` Michal Hocko
2013-08-30 10:47           ` Michal Hocko
     [not found]             ` <20130830104755.GC28658-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-08-30 10:52               ` Tejun Heo
     [not found]                 ` <20130830105210.GA30910-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-30 11:05                   ` Michal Hocko
2013-08-30 11:05                   ` Michal Hocko
2013-08-30 10:52               ` Tejun Heo
2013-08-15 16:02   ` [PATCH " Tejun Heo
2013-08-15 16:02   ` [PATCH 07/12] memcg: cgroup_write_event_control() now knows @css is for memcg Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 08/12] cgroup, memcg: move cgroup->event_list[_lock] and event callbacks into memcg Tejun Heo
     [not found]     ` <1376582550-12548-9-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-30 11:08       ` Michal Hocko
     [not found]         ` <20130830110846.GB31605-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-09-03 21:56           ` Tejun Heo
     [not found]             ` <20130903215646.GA31091-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-09-04  7:11               ` Michal Hocko
2013-09-03 21:56           ` Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 09/12] memcg: remove cgroup_event->cft Tejun Heo
     [not found]     ` <1376582550-12548-10-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-30 11:13       ` Michal Hocko
2013-08-15 16:02   ` Tejun Heo
2013-08-15 16:02   ` [PATCH 10/12] memcg: make cgroup_event deal with mem_cgroup instead of cgroup_subsys_state Tejun Heo
2013-08-15 16:02   ` Tejun Heo
     [not found]     ` <1376582550-12548-11-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-30 11:15       ` Michal Hocko
2013-08-30 11:15       ` Michal Hocko
2013-08-15 16:02   ` [PATCH 11/12] memcg: rename cgroup_event to mem_cgroup_event Tejun Heo
2013-08-15 16:02   ` Tejun Heo [this message]
     [not found]     ` <1376582550-12548-12-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-08-23  3:42       ` Li Zefan
     [not found]         ` <5216DA08.8040406-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-23 16:40           ` Tejun Heo
2013-08-23  3:42       ` Li Zefan
2013-08-30 11:19       ` Michal Hocko
2013-08-30 11:19       ` Michal Hocko
2013-08-15 16:02   ` [PATCH 12/12] cgroup: unexport cgroup_css() and remove __file_cft() Tejun Heo
2013-08-15 16:02   ` Tejun Heo
2013-08-21 20:12   ` [PATCHSET v2 cgroup/for-3.12] cgroup: make cgroup_event specific to memcg Tejun Heo
     [not found]     ` <20130821201239.GB2436-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-23  3:43       ` Li Zefan
     [not found]         ` <5216DA6F.3080508-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-23 12:31           ` Tejun Heo
2013-08-23  3:43       ` Li Zefan
2013-08-24 18:20       ` Michal Hocko
2013-08-24 18:20       ` Michal Hocko
     [not found]         ` <20130824182005.GA15897-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-08-24 18:25           ` Tejun Heo
2013-08-21 20:12   ` Tejun Heo
2013-08-26 14:15   ` Kirill A. Shutemov
2013-08-26 14:15   ` Kirill A. Shutemov
     [not found]     ` <20130826141536.GA14985-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2013-08-26 15:17       ` Tejun Heo
     [not found]         ` <20130826151747.GD25171-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-26 14:29           ` Kirill A. Shutemov
     [not found]             ` <20130826142918.GB14985-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2013-08-26 15:30               ` Tejun Heo
2013-08-26 15:30               ` Tejun Heo
     [not found]                 ` <20130826153028.GE25171-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-26 14:35                   ` Kirill A. Shutemov
2013-11-10  4:48   ` Tejun Heo
     [not found]     ` <20131110044811.GA25112-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-11-11 14:10       ` Michal Hocko
     [not found]         ` <20131111141010.GB14497-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-11-22 23:39           ` Tejun Heo
     [not found]             ` <20131122233947.GH8981-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-11-25 10:33               ` Michal Hocko
2013-11-25 10:33               ` Michal Hocko
2013-11-22 23:39           ` Tejun Heo
2013-11-10  4:48   ` 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=1376582550-12548-12-git-send-email-tj@kernel.org \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=mhocko-AlSwsSmVLrQ@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 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.