Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH] Add an option "cgroup_nodelete" to not delete cgroups  after job completion
@ 2010-03-31 20:46 Vivek Goyal
  2010-03-31 20:54 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Vivek Goyal @ 2010-03-31 20:46 UTC (permalink / raw)
  To: fio

o Add an option cgroup_nodelete to not remove cgroups created by fio after
  the job completion. This can help a user in inspecting various cgroup
  files after fio job completion.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
 HOWTO     |    6 ++++++
 cgroup.c  |   12 ++++++++----
 fio.1     |    6 ++++++
 fio.h     |    1 +
 options.c |    7 +++++++
 5 files changed, 28 insertions(+), 4 deletions(-)

Index: fio/HOWTO
===================================================================
--- fio.orig/HOWTO	2010-03-31 14:40:27.000000000 -0400
+++ fio/HOWTO	2010-03-31 14:42:12.415002796 -0400
@@ -1036,6 +1036,12 @@ cgroup_weight=int	Set the weight of the 
 		the documentation that comes with the kernel, allowed values
 		are in the range of 100..1000.
 
+cgroup_nodelete=bool Normally fio will delete the cgroups it has created after
+		the job completion. To override this behavior and to leave
+		cgroups around after the job completion, set cgroup_nodelete=1.
+		This can be useful if one wants to inspect various cgroup
+		files after job completion. Default: false
+
 uid=int		Instead of running as the invoking user, set the user ID to
 		this value before the thread/process does any work.
 
Index: fio/options.c
===================================================================
--- fio.orig/options.c	2010-03-31 14:40:27.000000000 -0400
+++ fio/options.c	2010-03-31 14:42:12.416002791 -0400
@@ -1818,6 +1818,13 @@ static struct fio_option options[FIO_MAX
 		.maxval	= 1000,
 	},
 	{
+		.name	= "cgroup_nodelete",
+		.type	= FIO_OPT_BOOL,
+		.off1	= td_var_offset(cgroup_nodelete),
+		.help	= "Do not delete cgroups after job completion",
+		.def	= "0",
+	},
+	{
 		.name	= "uid",
 		.type	= FIO_OPT_INT,
 		.off1	= td_var_offset(uid),
Index: fio/fio.h
===================================================================
--- fio.orig/fio.h	2010-03-31 14:40:27.000000000 -0400
+++ fio/fio.h	2010-03-31 14:42:12.416002791 -0400
@@ -281,6 +281,7 @@ struct thread_options {
 	 */
 	char *cgroup;
 	unsigned int cgroup_weight;
+	unsigned int cgroup_nodelete;
 
 	unsigned int uid;
 	unsigned int gid;
Index: fio/cgroup.c
===================================================================
--- fio.orig/cgroup.c	2010-03-31 14:42:04.000000000 -0400
+++ fio/cgroup.c	2010-03-31 14:44:53.060002430 -0400
@@ -14,6 +14,7 @@ static struct fio_mutex *lock;
 struct cgroup_member {
 	struct flist_head list;
 	char *root;
+	unsigned int cgroup_nodelete;
 };
 
 static char *find_cgroup_mnt(struct thread_data *td)
@@ -43,14 +44,16 @@ static char *find_cgroup_mnt(struct thre
 	return mntpoint;
 }
 
-static void add_cgroup(const char *name, struct flist_head *clist)
+static void add_cgroup(struct thread_data *td, const char *name,
+			struct flist_head *clist)
 {
 	struct cgroup_member *cm;
 
 	cm = smalloc(sizeof(*cm));
 	INIT_FLIST_HEAD(&cm->list);
 	cm->root = smalloc_strdup(name);
-
+	if (td->o.cgroup_nodelete)
+		cm->cgroup_nodelete = 1;
 	fio_mutex_down(lock);
 	flist_add_tail(&cm->list, clist);
 	fio_mutex_up(lock);
@@ -65,7 +68,8 @@ void cgroup_kill(struct flist_head *clis
 
 	flist_for_each_safe(n, tmp, clist) {
 		cm = flist_entry(n, struct cgroup_member, list);
-		rmdir(cm->root);
+		if (!cm->cgroup_nodelete)
+			rmdir(cm->root);
 		flist_del(&cm->list);
 		sfree(cm->root);
 		sfree(cm);
@@ -144,7 +148,7 @@ int cgroup_setup(struct thread_data *td,
 			goto err;
 		}
 	} else
-		add_cgroup(root, clist);
+		add_cgroup(td, root, clist);
 
 	if (td->o.cgroup_weight) {
 		if (write_int_to_file(td, root, "blkio.weight",
Index: fio/fio.1
===================================================================
--- fio.orig/fio.1	2010-03-31 13:30:12.000000000 -0400
+++ fio/fio.1	2010-03-31 17:02:44.940001605 -0400
@@ -762,6 +762,12 @@ your system doesn't have it mounted, you
 Set the weight of the cgroup to this value. See the documentation that comes
 with the kernel, allowed values are in the range of 100..1000.
 .TP
+.BI cgroup_nodelete \fR=\fPbool
+Normally fio will delete the cgroups it has created after the job completion.
+To override this behavior and to leave cgroups around after the job completion,
+set cgroup_nodelete=1. This can be useful if one wants to inspect various
+cgroup files after job completion. Default: false
+.TP
 .BI uid \fR=\fPint
 Instead of running as the invoking user, set the user ID to this value before
 the thread/process does any work.

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

* Re: [PATCH] Add an option "cgroup_nodelete" to not delete cgroups  after job completion
  2010-03-31 20:46 [PATCH] Add an option "cgroup_nodelete" to not delete cgroups after job completion Vivek Goyal
@ 2010-03-31 20:54 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2010-03-31 20:54 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: fio

On Wed, Mar 31 2010, Vivek Goyal wrote:
> o Add an option cgroup_nodelete to not remove cgroups created by fio after
>   the job completion. This can help a user in inspecting various cgroup
>   files after fio job completion.

Thanks Vivek, added. And thanks for updating both the HOWTO and man
page.

-- 
Jens Axboe


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

end of thread, other threads:[~2010-03-31 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-31 20:46 [PATCH] Add an option "cgroup_nodelete" to not delete cgroups after job completion Vivek Goyal
2010-03-31 20:54 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox