All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace
@ 2010-02-22 15:43 Kirill A. Shutemov
  2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers, linux-mm
  Cc: Paul Menage, Li Zefan, Andrew Morton, KAMEZAWA Hiroyuki,
	Balbir Singh, Pavel Emelyanov, Dan Malek, Daisuke Nishimura,
	Kirill A. Shutemov

eventfd are used to notify about two types of event:
 - control file-specific, like crossing memory threshold;
 - cgroup removing.

To understand what really happen, userspace can check if the cgroup
still exists. To avoid race beetween userspace and kernelspace we have
to notify userspace about cgroup removing only after rmdir of cgroup
directory.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 kernel/cgroup.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index ce9008f..46903cb 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -780,28 +780,15 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb)
 static int cgroup_call_pre_destroy(struct cgroup *cgrp)
 {
 	struct cgroup_subsys *ss;
-	struct cgroup_event *event, *tmp;
 	int ret = 0;
 
 	for_each_subsys(cgrp->root, ss)
 		if (ss->pre_destroy) {
 			ret = ss->pre_destroy(ss, cgrp);
 			if (ret)
-				goto out;
+				break;
 		}
 
-	/*
-	 * Unregister events and notify userspace.
-	 */
-	spin_lock(&cgrp->event_list_lock);
-	list_for_each_entry_safe(event, tmp, &cgrp->event_list, list) {
-		list_del(&event->list);
-		eventfd_signal(event->eventfd, 1);
-		schedule_work(&event->remove);
-	}
-	spin_unlock(&cgrp->event_list_lock);
-
-out:
 	return ret;
 }
 
@@ -2991,7 +2978,6 @@ static void cgroup_event_remove(struct work_struct *work)
 	event->cft->unregister_event(cgrp, event->cft, event->eventfd);
 
 	eventfd_ctx_put(event->eventfd);
-	remove_wait_queue(event->wqh, &event->wait);
 	kfree(event);
 }
 
@@ -3009,6 +2995,7 @@ static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
 	unsigned long flags = (unsigned long)key;
 
 	if (flags & POLLHUP) {
+		remove_wait_queue_locked(event->wqh, &event->wait);
 		spin_lock(&cgrp->event_list_lock);
 		list_del(&event->list);
 		spin_unlock(&cgrp->event_list_lock);
@@ -3457,6 +3444,7 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
 	struct dentry *d;
 	struct cgroup *parent;
 	DEFINE_WAIT(wait);
+	struct cgroup_event *event, *tmp;
 	int ret;
 
 	/* the vfs holds both inode->i_mutex already */
@@ -3540,6 +3528,20 @@ again:
 	set_bit(CGRP_RELEASABLE, &parent->flags);
 	check_for_release(parent);
 
+	/*
+	 * Unregister events and notify userspace.
+	 * Notify userspace about cgroup removing only after rmdir of cgroup
+	 * directory to avoid race between userspace and kernelspace
+	 */
+	spin_lock(&cgrp->event_list_lock);
+	list_for_each_entry_safe(event, tmp, &cgrp->event_list, list) {
+		list_del(&event->list);
+		remove_wait_queue(event->wqh, &event->wait);
+		eventfd_signal(event->eventfd, 1);
+		schedule_work(&event->remove);
+	}
+	spin_unlock(&cgrp->event_list_lock);
+
 	mutex_unlock(&cgroup_mutex);
 	return 0;
 }
-- 
1.6.6.2

--
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>

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
       [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-22 15:43   ` Kirill A. Shutemov
  2010-02-23  3:17   ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Li Zefan
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: Daisuke Nishimura, Dan Malek, Paul Menage, Balbir Singh,
	Andrew Morton, Pavel Emelyanov

Events should be removed after rmdir of cgroup directory, but before
destroying subsystem state objects. Let's take reference to cgroup
directory dentry to do that.

Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
 include/linux/cgroup.h |    3 ---
 kernel/cgroup.c        |    8 ++++++++
 mm/memcontrol.c        |    9 ---------
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 64cebfe..1719c75 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -395,9 +395,6 @@ struct cftype {
 	 * closes the eventfd or on cgroup removing.
 	 * This callback must be implemented, if you want provide
 	 * notification functionality.
-	 *
-	 * Be careful. It can be called after destroy(), so you have
-	 * to keep all nesessary data, until all events are removed.
 	 */
 	int (*unregister_event)(struct cgroup *cgrp, struct cftype *cft,
 			struct eventfd_ctx *eventfd);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 46903cb..d142524 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2979,6 +2979,7 @@ static void cgroup_event_remove(struct work_struct *work)
 
 	eventfd_ctx_put(event->eventfd);
 	kfree(event);
+	dput(cgrp->dentry);
 }
 
 /*
@@ -3099,6 +3100,13 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft,
 		goto fail;
 	}
 
+	/*
+	 * Events should be removed after rmdir of cgroup directory, but before
+	 * destroying subsystem state objects. Let's take reference to cgroup
+	 * directory dentry to do that.
+	 */
+	dget(cgrp->dentry);
+
 	spin_lock(&cgrp->event_list_lock);
 	list_add(&event->list, &cgrp->event_list);
 	spin_unlock(&cgrp->event_list_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a443c30..8fe6e7f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3358,12 +3358,6 @@ static int mem_cgroup_register_event(struct cgroup *cgrp, struct cftype *cft,
 		}
 	}
 
-	/*
-	 * We need to increment refcnt to be sure that all thresholds
-	 * will be unregistered before calling __mem_cgroup_free()
-	 */
-	mem_cgroup_get(memcg);
-
 	if (type == _MEM)
 		rcu_assign_pointer(memcg->thresholds, thresholds_new);
 	else
@@ -3457,9 +3451,6 @@ assign:
 	/* To be sure that nobody uses thresholds before freeing it */
 	synchronize_rcu();
 
-	for (i = 0; i < thresholds->size - size; i++)
-		mem_cgroup_put(memcg);
-
 	kfree(thresholds);
 unlock:
 	mutex_unlock(&memcg->thresholds_lock);
-- 
1.6.6.2

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
  2010-02-22 15:43 [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Kirill A. Shutemov
@ 2010-02-22 15:43 ` Kirill A. Shutemov
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
                     ` (2 more replies)
  2010-02-23  3:17 ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Li Zefan
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers, linux-mm
  Cc: Paul Menage, Li Zefan, Andrew Morton, KAMEZAWA Hiroyuki,
	Balbir Singh, Pavel Emelyanov, Dan Malek, Daisuke Nishimura,
	Kirill A. Shutemov

Events should be removed after rmdir of cgroup directory, but before
destroying subsystem state objects. Let's take reference to cgroup
directory dentry to do that.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>
---
 include/linux/cgroup.h |    3 ---
 kernel/cgroup.c        |    8 ++++++++
 mm/memcontrol.c        |    9 ---------
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 64cebfe..1719c75 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -395,9 +395,6 @@ struct cftype {
 	 * closes the eventfd or on cgroup removing.
 	 * This callback must be implemented, if you want provide
 	 * notification functionality.
-	 *
-	 * Be careful. It can be called after destroy(), so you have
-	 * to keep all nesessary data, until all events are removed.
 	 */
 	int (*unregister_event)(struct cgroup *cgrp, struct cftype *cft,
 			struct eventfd_ctx *eventfd);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 46903cb..d142524 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2979,6 +2979,7 @@ static void cgroup_event_remove(struct work_struct *work)
 
 	eventfd_ctx_put(event->eventfd);
 	kfree(event);
+	dput(cgrp->dentry);
 }
 
 /*
@@ -3099,6 +3100,13 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft,
 		goto fail;
 	}
 
+	/*
+	 * Events should be removed after rmdir of cgroup directory, but before
+	 * destroying subsystem state objects. Let's take reference to cgroup
+	 * directory dentry to do that.
+	 */
+	dget(cgrp->dentry);
+
 	spin_lock(&cgrp->event_list_lock);
 	list_add(&event->list, &cgrp->event_list);
 	spin_unlock(&cgrp->event_list_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a443c30..8fe6e7f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3358,12 +3358,6 @@ static int mem_cgroup_register_event(struct cgroup *cgrp, struct cftype *cft,
 		}
 	}
 
-	/*
-	 * We need to increment refcnt to be sure that all thresholds
-	 * will be unregistered before calling __mem_cgroup_free()
-	 */
-	mem_cgroup_get(memcg);
-
 	if (type == _MEM)
 		rcu_assign_pointer(memcg->thresholds, thresholds_new);
 	else
@@ -3457,9 +3451,6 @@ assign:
 	/* To be sure that nobody uses thresholds before freeing it */
 	synchronize_rcu();
 
-	for (i = 0; i < thresholds->size - size; i++)
-		mem_cgroup_put(memcg);
-
 	kfree(thresholds);
 unlock:
 	mutex_unlock(&memcg->thresholds_lock);
-- 
1.6.6.2

--
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>

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
       [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-22 15:43     ` Kirill A. Shutemov
  2010-02-23  3:18     ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Li Zefan
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: Daisuke Nishimura, Dan Malek, Paul Menage, Balbir Singh,
	Andrew Morton, Pavel Emelyanov

An example of cgroup notification API usage.

Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
 Documentation/cgroups/cgroup_event_listener.c |  103 +++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/cgroups/cgroup_event_listener.c

diff --git a/Documentation/cgroups/cgroup_event_listener.c b/Documentation/cgroups/cgroup_event_listener.c
new file mode 100644
index 0000000..8c2d7aa
--- /dev/null
+++ b/Documentation/cgroups/cgroup_event_listener.c
@@ -0,0 +1,103 @@
+/*
+ * cgroup_event_listener.c - Simple listener of cgroup events
+ *
+ * Copyright (C) Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/eventfd.h>
+
+#define USAGE_STR "Usage: cgroup_event_listener <path-to-control-file> <args>\n"
+
+int main(int argc, char **argv)
+{
+	int efd = -1;
+	int cfd = -1;
+	int event_control = -1;
+	char event_control_path[PATH_MAX];
+	int ret;
+
+	if (argc != 3) {
+		fputs(USAGE_STR, stderr);
+		return 1;
+	}
+
+	cfd = open(argv[1], O_RDONLY);
+	if (cfd == -1) {
+		fprintf(stderr, "Cannot open %s: %s\n", argv[1],
+				strerror(errno));
+		goto out;
+	}
+
+	ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
+			dirname(argv[1]));
+	if (ret > PATH_MAX) {
+		fputs("Path to cgroup.event_control is too long\n", stderr);
+		goto out;
+	}
+
+	event_control = open(event_control_path, O_WRONLY);
+	if (event_control == -1) {
+		fprintf(stderr, "Cannot open %s: %s\n", event_control_path,
+				strerror(errno));
+		goto out;
+	}
+
+	efd = eventfd(0, 0);
+	if (efd == -1) {
+		perror("eventfd() failed");
+		goto out;
+	}
+
+	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
+	if (ret == -1) {
+		perror("Cannot write to cgroup.event_control");
+		goto out;
+	}
+
+	while (1) {
+		uint64_t result;
+
+		ret = read(efd, &result, sizeof(result));
+		if (ret == -1) {
+			if (errno == EINTR)
+				continue;
+			perror("Cannot read from eventfd");
+			break;
+		}
+		assert(ret == sizeof(result));
+
+		ret = access(event_control_path, W_OK);
+		if ((ret == -1) && (errno == ENOENT)) {
+				puts("The cgroup seems to have removed.");
+				ret = 0;
+				break;
+		}
+
+		if (ret == -1) {
+			perror("cgroup.event_control "
+					"is not accessable any more");
+			break;
+		}
+
+		printf("%s %s: crossed\n", argv[1], argv[2]);
+	}
+
+out:
+	if (efd >= 0)
+		close(efd);
+	if (event_control >= 0)
+		close(event_control);
+	if (cfd >= 0)
+		close(cfd);
+
+	return (ret != 0);
+}
-- 
1.6.6.2

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
  2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
@ 2010-02-22 15:43   ` Kirill A. Shutemov
  2010-02-22 15:43     ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
                       ` (2 more replies)
  2010-02-23  3:18   ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Li Zefan
  2010-02-24  8:40   ` Balbir Singh
  2 siblings, 3 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers, linux-mm
  Cc: Paul Menage, Li Zefan, Andrew Morton, KAMEZAWA Hiroyuki,
	Balbir Singh, Pavel Emelyanov, Dan Malek, Daisuke Nishimura,
	Kirill A. Shutemov

An example of cgroup notification API usage.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 Documentation/cgroups/cgroup_event_listener.c |  103 +++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/cgroups/cgroup_event_listener.c

diff --git a/Documentation/cgroups/cgroup_event_listener.c b/Documentation/cgroups/cgroup_event_listener.c
new file mode 100644
index 0000000..8c2d7aa
--- /dev/null
+++ b/Documentation/cgroups/cgroup_event_listener.c
@@ -0,0 +1,103 @@
+/*
+ * cgroup_event_listener.c - Simple listener of cgroup events
+ *
+ * Copyright (C) Kirill A. Shutemov <kirill@shutemov.name>
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/eventfd.h>
+
+#define USAGE_STR "Usage: cgroup_event_listener <path-to-control-file> <args>\n"
+
+int main(int argc, char **argv)
+{
+	int efd = -1;
+	int cfd = -1;
+	int event_control = -1;
+	char event_control_path[PATH_MAX];
+	int ret;
+
+	if (argc != 3) {
+		fputs(USAGE_STR, stderr);
+		return 1;
+	}
+
+	cfd = open(argv[1], O_RDONLY);
+	if (cfd == -1) {
+		fprintf(stderr, "Cannot open %s: %s\n", argv[1],
+				strerror(errno));
+		goto out;
+	}
+
+	ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
+			dirname(argv[1]));
+	if (ret > PATH_MAX) {
+		fputs("Path to cgroup.event_control is too long\n", stderr);
+		goto out;
+	}
+
+	event_control = open(event_control_path, O_WRONLY);
+	if (event_control == -1) {
+		fprintf(stderr, "Cannot open %s: %s\n", event_control_path,
+				strerror(errno));
+		goto out;
+	}
+
+	efd = eventfd(0, 0);
+	if (efd == -1) {
+		perror("eventfd() failed");
+		goto out;
+	}
+
+	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
+	if (ret == -1) {
+		perror("Cannot write to cgroup.event_control");
+		goto out;
+	}
+
+	while (1) {
+		uint64_t result;
+
+		ret = read(efd, &result, sizeof(result));
+		if (ret == -1) {
+			if (errno == EINTR)
+				continue;
+			perror("Cannot read from eventfd");
+			break;
+		}
+		assert(ret == sizeof(result));
+
+		ret = access(event_control_path, W_OK);
+		if ((ret == -1) && (errno == ENOENT)) {
+				puts("The cgroup seems to have removed.");
+				ret = 0;
+				break;
+		}
+
+		if (ret == -1) {
+			perror("cgroup.event_control "
+					"is not accessable any more");
+			break;
+		}
+
+		printf("%s %s: crossed\n", argv[1], argv[2]);
+	}
+
+out:
+	if (efd >= 0)
+		close(efd);
+	if (event_control >= 0)
+		close(event_control);
+	if (cfd >= 0)
+		close(cfd);
+
+	return (ret != 0);
+}
-- 
1.6.6.2

--
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>

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds
       [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-22 15:43       ` Kirill A. Shutemov
  2010-02-23  3:19       ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
  2010-02-24  3:30       ` Li Zefan
  2 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: Daisuke Nishimura, Dan Malek, Paul Menage, Balbir Singh,
	Andrew Morton, Pavel Emelyanov

Decription of sanity check for memory thresholds.

Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
 Documentation/cgroups/memcg_test.txt |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Documentation/cgroups/memcg_test.txt b/Documentation/cgroups/memcg_test.txt
index e011488..4d32e0e 100644
--- a/Documentation/cgroups/memcg_test.txt
+++ b/Documentation/cgroups/memcg_test.txt
@@ -396,3 +396,24 @@ Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y.
 	memory.stat of both A and B.
 	See 8.2 of Documentation/cgroups/memory.txt to see what value should be
 	written to move_charge_at_immigrate.
+
+ 9.10 Memory thresholds
+	Memory controler implements memory thresholds using cgroups notification
+	API. You can use Documentation/cgroups/cgroup_event_listener.c to test
+	it.
+
+	(Shell-A) Create cgroup and run event listener
+	# mkdir /cgroup/A
+	# ./cgroup_event_listener /cgroup/A/memory.usage_in_bytes 5M
+
+	(Shell-B) Add task to cgroup and try to allocate and free memory
+	# echo $$ >/cgroup/A/tasks
+	# a="$(dd if=/dev/zero bs=1M count=10)"
+	# a=
+
+	You will see message from cgroup_event_listener every time you cross
+	the thresholds.
+
+	Use /cgroup/A/memory.memsw.usage_in_bytes to test memsw thresholds.
+
+	It's good idea to test root cgroup as well.
-- 
1.6.6.2

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
@ 2010-02-22 15:43     ` Kirill A. Shutemov
  2010-02-23  3:19     ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
  2010-02-24  3:30     ` Li Zefan
  2 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-22 15:43 UTC (permalink / raw)
  To: containers, linux-mm
  Cc: Paul Menage, Li Zefan, Andrew Morton, KAMEZAWA Hiroyuki,
	Balbir Singh, Pavel Emelyanov, Dan Malek, Daisuke Nishimura,
	Kirill A. Shutemov

Decription of sanity check for memory thresholds.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 Documentation/cgroups/memcg_test.txt |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Documentation/cgroups/memcg_test.txt b/Documentation/cgroups/memcg_test.txt
index e011488..4d32e0e 100644
--- a/Documentation/cgroups/memcg_test.txt
+++ b/Documentation/cgroups/memcg_test.txt
@@ -396,3 +396,24 @@ Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y.
 	memory.stat of both A and B.
 	See 8.2 of Documentation/cgroups/memory.txt to see what value should be
 	written to move_charge_at_immigrate.
+
+ 9.10 Memory thresholds
+	Memory controler implements memory thresholds using cgroups notification
+	API. You can use Documentation/cgroups/cgroup_event_listener.c to test
+	it.
+
+	(Shell-A) Create cgroup and run event listener
+	# mkdir /cgroup/A
+	# ./cgroup_event_listener /cgroup/A/memory.usage_in_bytes 5M
+
+	(Shell-B) Add task to cgroup and try to allocate and free memory
+	# echo $$ >/cgroup/A/tasks
+	# a="$(dd if=/dev/zero bs=1M count=10)"
+	# a=
+
+	You will see message from cgroup_event_listener every time you cross
+	the thresholds.
+
+	Use /cgroup/A/memory.memsw.usage_in_bytes to test memsw thresholds.
+
+	It's good idea to test root cgroup as well.
-- 
1.6.6.2

--
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>

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace
       [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-22 15:43   ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
@ 2010-02-23  3:17   ` Li Zefan
       [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-24  7:12   ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:17 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek,
	Paul Menage, Pavel Emelyanov, Andrew Morton, Balbir Singh

(Late reply for I just came back from a long vacation)

Kirill A. Shutemov wrote:
> eventfd are used to notify about two types of event:
>  - control file-specific, like crossing memory threshold;
>  - cgroup removing.
> 
> To understand what really happen, userspace can check if the cgroup
> still exists. To avoid race beetween userspace and kernelspace we have
> to notify userspace about cgroup removing only after rmdir of cgroup
> directory.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

Acked-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace
  2010-02-22 15:43 [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Kirill A. Shutemov
  2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
@ 2010-02-23  3:17 ` Li Zefan
       [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-24  7:12 ` Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:17 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Andrew Morton,
	KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelyanov, Dan Malek,
	Daisuke Nishimura

(Late reply for I just came back from a long vacation)

Kirill A. Shutemov wrote:
> eventfd are used to notify about two types of event:
>  - control file-specific, like crossing memory threshold;
>  - cgroup removing.
> 
> To understand what really happen, userspace can check if the cgroup
> still exists. To avoid race beetween userspace and kernelspace we have
> to notify userspace about cgroup removing only after rmdir of cgroup
> directory.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Acked-by: Li Zefan <lizf@cn.fujitsu.com>

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
       [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-22 15:43     ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
@ 2010-02-23  3:18     ` Li Zefan
       [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-24  8:40     ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:18 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek,
	Paul Menage, Pavel Emelyanov, Andrew Morton, Balbir Singh

Kirill A. Shutemov wrote:
> Events should be removed after rmdir of cgroup directory, but before
> destroying subsystem state objects. Let's take reference to cgroup
> directory dentry to do that.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

Looks good.

Acked-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
  2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
@ 2010-02-23  3:18   ` Li Zefan
  2010-02-24  8:40   ` Balbir Singh
  2 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:18 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Andrew Morton,
	KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelyanov, Dan Malek,
	Daisuke Nishimura

Kirill A. Shutemov wrote:
> Events should be removed after rmdir of cgroup directory, but before
> destroying subsystem state objects. Let's take reference to cgroup
> directory dentry to do that.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>

Looks good.

Acked-by: Li Zefan <lizf@cn.fujitsu.com>

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
       [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-22 15:43       ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
@ 2010-02-23  3:19       ` Li Zefan
  2010-02-24  3:30       ` Li Zefan
  2 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:19 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek,
	Paul Menage, Pavel Emelyanov, Andrew Morton, Balbir Singh

Kirill A. Shutemov wrote:
> An example of cgroup notification API usage.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

Acked-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
  2010-02-22 15:43     ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
@ 2010-02-23  3:19     ` Li Zefan
  2010-02-24  3:30     ` Li Zefan
  2 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-23  3:19 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Andrew Morton,
	KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelyanov, Dan Malek,
	Daisuke Nishimura

Kirill A. Shutemov wrote:
> An example of cgroup notification API usage.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Acked-by: Li Zefan <lizf@cn.fujitsu.com>

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
       [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  2010-02-22 15:43       ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
  2010-02-23  3:19       ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
@ 2010-02-24  3:30       ` Li Zefan
  2 siblings, 0 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-24  3:30 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek,
	Paul Menage, Pavel Emelyanov, Andrew Morton, Balbir Singh

> +	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);

I found it won't return negative value for invalid input, though
errno is set properly.

try:
# ./cgroup_event_listner /cgroup/cgroup.procs abc

while strace shows write() does return -1:

# strace ./cgroup_event_listner /cgroup/cgroup.procs abc
...
write(6, "7 5 abc"..., 7)               = -1 EINVAL (Invalid argument)

> +	if (ret == -1) {
> +		perror("Cannot write to cgroup.event_control");
> +		goto out;
> +	}

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
  2010-02-22 15:43     ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
  2010-02-23  3:19     ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
@ 2010-02-24  3:30     ` Li Zefan
  2010-02-24 11:36       ` Kirill A. Shutemov
       [not found]       ` <4B849D4C.2090800-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  2 siblings, 2 replies; 25+ messages in thread
From: Li Zefan @ 2010-02-24  3:30 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Andrew Morton,
	KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelyanov, Dan Malek,
	Daisuke Nishimura

> +	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);

I found it won't return negative value for invalid input, though
errno is set properly.

try:
# ./cgroup_event_listner /cgroup/cgroup.procs abc

while strace shows write() does return -1:

# strace ./cgroup_event_listner /cgroup/cgroup.procs abc
...
write(6, "7 5 abc"..., 7)               = -1 EINVAL (Invalid argument)

> +	if (ret == -1) {
> +		perror("Cannot write to cgroup.event_control");
> +		goto out;
> +	}

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace
       [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
                     ` (2 preceding siblings ...)
       [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-24  7:12   ` Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24  7:12 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Daisuke Nishimura,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek, Paul Menage,
	Andrew Morton, Pavel Emelyanov

* Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org> [2010-02-22 17:43:39]:

> eventfd are used to notify about two types of event:
>  - control file-specific, like crossing memory threshold;
>  - cgroup removing.
> 
> To understand what really happen, userspace can check if the cgroup
> still exists. To avoid race beetween userspace and kernelspace we have
> to notify userspace about cgroup removing only after rmdir of cgroup
> directory.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

That does make sense, looks good to me. You've already got the
necessary acks.

-- 
	Three Cheers,
	Balbir

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace
  2010-02-22 15:43 [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Kirill A. Shutemov
                   ` (2 preceding siblings ...)
       [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-24  7:12 ` Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24  7:12 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Li Zefan, Andrew Morton,
	KAMEZAWA Hiroyuki, Pavel Emelyanov, Dan Malek, Daisuke Nishimura

* Kirill A. Shutemov <kirill@shutemov.name> [2010-02-22 17:43:39]:

> eventfd are used to notify about two types of event:
>  - control file-specific, like crossing memory threshold;
>  - cgroup removing.
> 
> To understand what really happen, userspace can check if the cgroup
> still exists. To avoid race beetween userspace and kernelspace we have
> to notify userspace about cgroup removing only after rmdir of cgroup
> directory.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

That does make sense, looks good to me. You've already got the
necessary acks.

-- 
	Three Cheers,
	Balbir

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
       [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
                       ` (2 preceding siblings ...)
       [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-24  8:40     ` Balbir Singh
  3 siblings, 0 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24  8:40 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Daisuke Nishimura,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek, Paul Menage,
	Andrew Morton, Pavel Emelyanov

* Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org> [2010-02-22 17:43:40]:

> Events should be removed after rmdir of cgroup directory, but before
> destroying subsystem state objects. Let's take reference to cgroup
> directory dentry to do that.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

Looks good, but remember the mem_cgroup data structure will can
disappear after the rmdir

-- 
	Three Cheers,
	Balbir

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
  2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
  2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
  2010-02-23  3:18   ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Li Zefan
@ 2010-02-24  8:40   ` Balbir Singh
  2010-02-24 11:42     ` Kirill A. Shutemov
       [not found]     ` <20100224084005.GC2310-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
  2 siblings, 2 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24  8:40 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Li Zefan, Andrew Morton,
	KAMEZAWA Hiroyuki, Pavel Emelyanov, Dan Malek, Daisuke Nishimura

* Kirill A. Shutemov <kirill@shutemov.name> [2010-02-22 17:43:40]:

> Events should be removed after rmdir of cgroup directory, but before
> destroying subsystem state objects. Let's take reference to cgroup
> directory dentry to do that.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>

Looks good, but remember the mem_cgroup data structure will can
disappear after the rmdir

-- 
	Three Cheers,
	Balbir

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
       [not found]       ` <4B849D4C.2090800-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2010-02-24 11:36         ` Kirill A. Shutemov
  0 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-24 11:36 UTC (permalink / raw)
  To: Li Zefan
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek,
	Paul Menage, Pavel Emelyanov, Andrew Morton, Balbir Singh

On Wed, Feb 24, 2010 at 5:30 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>> +     ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
>
> I found it won't return negative value for invalid input, though
> errno is set properly.

It looks like a glibc bug. I've file bug to glibc bugzilla:

http://sourceware.org/bugzilla/show_bug.cgi?id=11319

I'll fix cgroup_event_listener.c. Thanks!

> try:
> # ./cgroup_event_listner /cgroup/cgroup.procs abc
>
> while strace shows write() does return -1:
>
> # strace ./cgroup_event_listner /cgroup/cgroup.procs abc
> ...
> write(6, "7 5 abc"..., 7)               = -1 EINVAL (Invalid argument)
>
>> +     if (ret == -1) {
>> +             perror("Cannot write to cgroup.event_control");
>> +             goto out;
>> +     }
>
> --
> 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>
>
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation
  2010-02-24  3:30     ` Li Zefan
@ 2010-02-24 11:36       ` Kirill A. Shutemov
       [not found]       ` <4B849D4C.2090800-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  1 sibling, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-24 11:36 UTC (permalink / raw)
  To: Li Zefan
  Cc: containers, linux-mm, Paul Menage, Andrew Morton,
	KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelyanov, Dan Malek,
	Daisuke Nishimura

On Wed, Feb 24, 2010 at 5:30 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>> +     ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
>
> I found it won't return negative value for invalid input, though
> errno is set properly.

It looks like a glibc bug. I've file bug to glibc bugzilla:

http://sourceware.org/bugzilla/show_bug.cgi?id=11319

I'll fix cgroup_event_listener.c. Thanks!

> try:
> # ./cgroup_event_listner /cgroup/cgroup.procs abc
>
> while strace shows write() does return -1:
>
> # strace ./cgroup_event_listner /cgroup/cgroup.procs abc
> ...
> write(6, "7 5 abc"..., 7)               = -1 EINVAL (Invalid argument)
>
>> +     if (ret == -1) {
>> +             perror("Cannot write to cgroup.event_control");
>> +             goto out;
>> +     }
>
> --
> 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>
>

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
       [not found]     ` <20100224084005.GC2310-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
@ 2010-02-24 11:42       ` Kirill A. Shutemov
  0 siblings, 0 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-24 11:42 UTC (permalink / raw)
  To: balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
  Cc: Daisuke Nishimura,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek, Paul Menage,
	Andrew Morton, Pavel Emelyanov

On Wed, Feb 24, 2010 at 10:40 AM, Balbir Singh
<balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> wrote:
> * Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org> [2010-02-22 17:43:40]:
>
>> Events should be removed after rmdir of cgroup directory, but before
>> destroying subsystem state objects. Let's take reference to cgroup
>> directory dentry to do that.
>>
>> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
>> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
>
> Looks good, but remember the mem_cgroup data structure will can
> disappear after the rmdir

IIUC, struct mem_cgroup can be freed only after ->destroy(), which can
be called only if there is no references to cgroup directory dentry.

Have I missed something?

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
  2010-02-24  8:40   ` Balbir Singh
@ 2010-02-24 11:42     ` Kirill A. Shutemov
  2010-02-24 12:17       ` Balbir Singh
       [not found]       ` <cc557aab1002240342u1b0223a4td8269d727b004621-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
       [not found]     ` <20100224084005.GC2310-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
  1 sibling, 2 replies; 25+ messages in thread
From: Kirill A. Shutemov @ 2010-02-24 11:42 UTC (permalink / raw)
  To: balbir
  Cc: containers, linux-mm, Paul Menage, Li Zefan, Andrew Morton,
	KAMEZAWA Hiroyuki, Pavel Emelyanov, Dan Malek, Daisuke Nishimura

On Wed, Feb 24, 2010 at 10:40 AM, Balbir Singh
<balbir@linux.vnet.ibm.com> wrote:
> * Kirill A. Shutemov <kirill@shutemov.name> [2010-02-22 17:43:40]:
>
>> Events should be removed after rmdir of cgroup directory, but before
>> destroying subsystem state objects. Let's take reference to cgroup
>> directory dentry to do that.
>>
>> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>
>
> Looks good, but remember the mem_cgroup data structure will can
> disappear after the rmdir

IIUC, struct mem_cgroup can be freed only after ->destroy(), which can
be called only if there is no references to cgroup directory dentry.

Have I missed something?

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
       [not found]       ` <cc557aab1002240342u1b0223a4td8269d727b004621-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-02-24 12:17         ` Balbir Singh
  0 siblings, 0 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24 12:17 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Daisuke Nishimura,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Dan Malek, Paul Menage,
	Andrew Morton, Pavel Emelyanov

* Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org> [2010-02-24 13:42:15]:

> On Wed, Feb 24, 2010 at 10:40 AM, Balbir Singh
> <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> wrote:
> > * Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org> [2010-02-22 17:43:40]:
> >
> >> Events should be removed after rmdir of cgroup directory, but before
> >> destroying subsystem state objects. Let's take reference to cgroup
> >> directory dentry to do that.
> >>
> >> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
> >> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
> >
> > Looks good, but remember the mem_cgroup data structure will can
> > disappear after the rmdir
> 
> IIUC, struct mem_cgroup can be freed only after ->destroy(), which can
> be called only if there is no references to cgroup directory dentry.
>

No.. You've got it right, it disappears after the last dput(). 

-- 
	Three Cheers,
	Balbir

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects
  2010-02-24 11:42     ` Kirill A. Shutemov
@ 2010-02-24 12:17       ` Balbir Singh
       [not found]       ` <cc557aab1002240342u1b0223a4td8269d727b004621-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 0 replies; 25+ messages in thread
From: Balbir Singh @ 2010-02-24 12:17 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, linux-mm, Paul Menage, Li Zefan, Andrew Morton,
	KAMEZAWA Hiroyuki, Pavel Emelyanov, Dan Malek, Daisuke Nishimura

* Kirill A. Shutemov <kirill@shutemov.name> [2010-02-24 13:42:15]:

> On Wed, Feb 24, 2010 at 10:40 AM, Balbir Singh
> <balbir@linux.vnet.ibm.com> wrote:
> > * Kirill A. Shutemov <kirill@shutemov.name> [2010-02-22 17:43:40]:
> >
> >> Events should be removed after rmdir of cgroup directory, but before
> >> destroying subsystem state objects. Let's take reference to cgroup
> >> directory dentry to do that.
> >>
> >> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> >> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hioryu@jp.fujitsu.com>
> >
> > Looks good, but remember the mem_cgroup data structure will can
> > disappear after the rmdir
> 
> IIUC, struct mem_cgroup can be freed only after ->destroy(), which can
> be called only if there is no references to cgroup directory dentry.
>

No.. You've got it right, it disappears after the last dput(). 

-- 
	Three Cheers,
	Balbir

--
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>

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-02-24 12:17 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-22 15:43 [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Kirill A. Shutemov
2010-02-22 15:43 ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
2010-02-22 15:43   ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
2010-02-22 15:43     ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
2010-02-23  3:19     ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
2010-02-24  3:30     ` Li Zefan
2010-02-24 11:36       ` Kirill A. Shutemov
     [not found]       ` <4B849D4C.2090800-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2010-02-24 11:36         ` Kirill A. Shutemov
2010-02-23  3:18   ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Li Zefan
2010-02-24  8:40   ` Balbir Singh
2010-02-24 11:42     ` Kirill A. Shutemov
2010-02-24 12:17       ` Balbir Singh
     [not found]       ` <cc557aab1002240342u1b0223a4td8269d727b004621-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-24 12:17         ` Balbir Singh
     [not found]     ` <20100224084005.GC2310-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
2010-02-24 11:42       ` Kirill A. Shutemov
2010-02-23  3:17 ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Li Zefan
     [not found] ` <1f8bd63acb6485c88f8539e009459a28fb6ad55b.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2010-02-22 15:43   ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Kirill A. Shutemov
2010-02-23  3:17   ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Li Zefan
     [not found]   ` <690745ebd257c74a1c47d552fec7fbb0b5efb7d0.1266853233.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2010-02-22 15:43     ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Kirill A. Shutemov
2010-02-23  3:18     ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Li Zefan
     [not found]     ` <458c3169608cb333f390b2cb732565fec9fec67e.1266853234.git.kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2010-02-22 15:43       ` [PATCH v2 -mmotm 4/4] memcg: Update memcg_test.txt to describe memory thresholds Kirill A. Shutemov
2010-02-23  3:19       ` [PATCH v2 -mmotm 3/4] cgroups: Add simple listener of cgroup events to documentation Li Zefan
2010-02-24  3:30       ` Li Zefan
2010-02-24  8:40     ` [PATCH v2 -mmotm 2/4] cgroups: remove events before destroying subsystem state objects Balbir Singh
2010-02-24  7:12   ` [PATCH v2 -mmotm 1/4] cgroups: Fix race between userspace and kernelspace Balbir Singh
2010-02-24  7:12 ` Balbir Singh

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.