From: sekharan@us.ibm.com
To: linux-kernel@vger.kernel.org, ckrm-tech@lists.sourceforge.net
Cc: sekharan@us.ibm.com
Subject: [RFC] [PATCH 07/12] Configfs based filesystem user interface - RCFS
Date: Thu, 20 Apr 2006 19:24:50 -0700 [thread overview]
Message-ID: <20060421022450.6145.58259.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060421022411.6145.83939.sendpatchset@localhost.localdomain>
07/12 - ckrm_configfs_rcfs
Create the filesystem(RCFS) for managing CKRM. Hooks up with configfs.
Provides functions for creating and deleting classes.
--
Signed-Off-By: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-Off-By: Shailabh Nagar <nagar@watson.ibm.com>
Signed-Off-By: Matt Helsley <matthltc@us.ibm.com>
init/Kconfig | 12 +++
kernel/ckrm/Makefile | 1
kernel/ckrm/ckrm_rcfs.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 173 insertions(+)
Index: linux2617-rc2/init/Kconfig
===================================================================
--- linux2617-rc2.orig/init/Kconfig
+++ linux2617-rc2/init/Kconfig
@@ -163,6 +163,18 @@ config CKRM
If you say Y here, enable the Resource Class File System and at least
one of the resource controllers below. Say N if you are unsure.
+config CKRM_RCFS
+ tristate "Resource Control File System (User API for CKRM)"
+ depends on CKRM
+ select CONFIGFS_FS
+ default m
+ help
+ RCFS is the filesystem API for CKRM. Compiling it as a module permits
+ users to only load RCFS if they intend to use CKRM.
+
+ Say M if unsure, Y to save on module loading. N doesn't make sense
+ when CKRM has been configured.
+
endmenu
config SYSCTL
bool "Sysctl support"
Index: linux2617-rc2/kernel/ckrm/ckrm_rcfs.c
===================================================================
--- /dev/null
+++ linux2617-rc2/kernel/ckrm/ckrm_rcfs.c
@@ -0,0 +1,160 @@
+/*
+ * kernel/ckrm/ckrm_rcfs.c
+ *
+ * Copyright (C) Shailabh Nagar, IBM Corp. 2005
+ * Chandra Seetharaman, IBM Corp. 2005, 2006
+ *
+ * Configfs based Resource class filesystem (rcfs) serving the
+ * user interface to Class-based Kernel Resource Management (CKRM).
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ */
+#include <linux/module.h>
+#include <linux/configfs.h>
+#include "ckrm_local.h"
+
+static struct configfs_subsystem rcfs_subsys;
+static struct config_item_type rcfs_class_type;
+
+struct rcfs_class {
+ char *name;
+ struct ckrm_class *core;
+ struct config_group group;
+};
+
+static inline struct rcfs_class *group_to_rcfs_class(struct config_group *grp)
+{
+ return container_of(grp, struct rcfs_class, group);
+}
+
+static inline struct rcfs_class *item_to_rcfs_class(struct config_item *item)
+{
+ return group_to_rcfs_class(to_config_group(item));
+}
+
+static inline struct ckrm_class *group_to_ckrm_class(struct config_group *grp)
+{
+ struct rcfs_class *rclass;
+ /*
+ * A configfs wrinkle forces us to treat the root group as a special
+ * case instead of wrapping the group in a struct rcfs_class like all
+ * other groups.
+ */
+ if (grp == &rcfs_subsys.su_group)
+ return &ckrm_default_class;
+ rclass = group_to_rcfs_class(grp);
+ return rclass->core;
+}
+
+static inline struct ckrm_class *item_to_ckrm_class(struct config_item *item)
+{
+ return group_to_ckrm_class(to_config_group(item));
+}
+
+/*
+ * This is the function that is called when a 'mkdir' command
+ * is issued under our filesystem
+ */
+static struct config_group *make_rcfs_class(struct config_group *group,
+ const char *name)
+{
+ struct rcfs_class *rclass, *rc_par;
+ struct ckrm_class *core, *parent;
+ char *new_name = NULL, *par_name = NULL;
+ int par_sz = 0;
+
+ rclass = kzalloc(sizeof(struct rcfs_class), GFP_KERNEL);
+ if (!rclass)
+ return NULL;
+
+ parent = group_to_ckrm_class(group);
+
+ if (parent != &ckrm_default_class) {
+ rc_par = group_to_rcfs_class(group);
+ par_name = rc_par->name;
+ par_sz = strlen(par_name);
+ }
+ new_name = kmalloc(par_sz + strlen(name) + 2, GFP_KERNEL);
+ if (!new_name)
+ goto noname;
+ if (par_name)
+ sprintf(new_name, "%s/%s", par_name, name);
+ else
+ sprintf(new_name, "%s", name);
+
+ core = ckrm_alloc_class(parent, new_name);
+ if (!core)
+ goto nocore;
+ rclass->core = core;
+ rclass->name = new_name;
+
+ config_group_init_type_name(&rclass->group, name, &rcfs_class_type);
+ return &rclass->group;
+
+nocore:
+ kfree(new_name);
+noname:
+ kfree(rclass);
+ return NULL;
+}
+
+/*
+ * This is the function that is called when a 'rmdir' command
+ * is issued under our filesystem
+ */
+static void rcfs_class_release_item(struct config_item *item)
+{
+ struct rcfs_class *rclass = item_to_rcfs_class(item);
+
+ ckrm_free_class(rclass->core);
+ kfree(rclass->name);
+ kfree(rclass);
+}
+
+static struct configfs_item_operations rcfs_class_item_ops = {
+ .release = rcfs_class_release_item,
+};
+
+static struct configfs_group_operations rcfs_class_group_ops = {
+ .make_group = make_rcfs_class,
+};
+
+static struct config_item_type rcfs_class_type = {
+ .ct_owner = THIS_MODULE,
+ .ct_item_ops = &rcfs_class_item_ops,
+ .ct_group_ops = &rcfs_class_group_ops,
+};
+
+static struct configfs_subsystem rcfs_subsys = {
+ .su_group = {
+ .cg_item = {
+ .ci_namebuf = "ckrm",
+ .ci_type = &rcfs_class_type,
+ }
+ }
+};
+
+static int __init rcfs_init(void)
+{
+ config_group_init(&rcfs_subsys.su_group);
+ init_MUTEX(&rcfs_subsys.su_sem);
+ return configfs_register_subsystem(&rcfs_subsys);
+}
+
+static void __exit rcfs_exit(void)
+{
+ configfs_unregister_subsystem(&rcfs_subsys);
+ ckrm_teardown();
+}
+
+late_initcall(rcfs_init);
+module_exit(rcfs_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RCFS - Provides an interface to classes and allows control "
+ "of their resource usage");
Index: linux2617-rc2/kernel/ckrm/Makefile
===================================================================
--- linux2617-rc2.orig/kernel/ckrm/Makefile
+++ linux2617-rc2/kernel/ckrm/Makefile
@@ -1 +1,2 @@
obj-y = ckrm.o ckrm_shares.o ckrm_task.o
+obj-$(CONFIG_CKRM_RCFS) += ckrm_rcfs.o
--
----------------------------------------------------------------------
Chandra Seetharaman | Be careful what you choose....
- sekharan@us.ibm.com | .......you may get it.
----------------------------------------------------------------------
next prev parent reply other threads:[~2006-04-21 2:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-21 2:24 [RFC] [PATCH 00/12] CKRM after a major overhaul sekharan
2006-04-21 2:24 ` [RFC] [PATCH 01/12] Register/Unregister interface for Controllers sekharan
2006-04-21 2:24 ` [RFC] [PATCH 02/12] Class creation/deletion sekharan
2006-04-21 2:24 ` [RFC] [PATCH 03/12] Share Handling sekharan
2006-04-21 2:24 ` [RFC] [PATCH 04/12] Add task logic to class sekharan
2006-04-21 2:24 ` [RFC] [PATCH 05/12] Init and clear class info in task sekharan
2006-04-21 2:24 ` [RFC] [PATCH 06/12] Add proc interface to get class info of task sekharan
2006-04-21 2:24 ` sekharan [this message]
2006-04-21 2:24 ` [RFC] [PATCH 08/12] Add attribute support to RCFS sekharan
2006-04-21 2:25 ` [RFC] [PATCH 09/12] Add stats file " sekharan
2006-04-21 2:25 ` [RFC] [PATCH 10/12] Add shares " sekharan
2006-04-21 2:25 ` [RFC] [PATCH 11/12] Add members " sekharan
2006-04-21 2:25 ` [RFC] [PATCH 12/12] Documentation for CKRM sekharan
2006-04-21 14:49 ` [ckrm-tech] [RFC] [PATCH 00/12] CKRM after a major overhaul Dave Hansen
2006-04-21 16:58 ` Chandra Seetharaman
2006-04-21 22:57 ` Andrew Morton
2006-04-22 1:48 ` Chandra Seetharaman
2006-04-22 2:13 ` Andrew Morton
2006-04-22 2:20 ` Matt Helsley
2006-04-22 2:33 ` Andrew Morton
2006-04-22 5:28 ` Chandra Seetharaman
2006-04-24 1:10 ` KUROSAWA Takahiro
2006-04-24 4:39 ` Kirill Korotaev
2006-04-24 5:41 ` KUROSAWA Takahiro
2006-04-24 6:45 ` Kirill Korotaev
2006-04-24 7:12 ` KUROSAWA Takahiro
2006-04-24 5:18 ` Hirokazu Takahashi
2006-04-25 1:42 ` Chandra Seetharaman
2006-04-23 6:52 ` Paul Jackson
2006-04-23 9:31 ` Matt Helsley
2006-04-28 1:58 ` Chandra Seetharaman
2006-04-28 6:07 ` Kirill Korotaev
2006-04-28 17:57 ` Chandra Seetharaman
2006-04-24 1:47 ` Hirokazu Takahashi
2006-04-24 20:42 ` Shailabh Nagar
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=20060421022450.6145.58259.sendpatchset@localhost.localdomain \
--to=sekharan@us.ibm.com \
--cc=ckrm-tech@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox