11/12 - ckrm_configfs_rcfs_members

Adds attr_store and attr_show support for members file.
--

Signed-Off-By: Chandra Seetharaman <[EMAIL PROTECTED]>
Signed-Off-By: Shailabh Nagar <[EMAIL PROTECTED]>
Signed-Off-By: Matt Helsley <[EMAIL PROTECTED]>

 kernel/ckrm/ckrm_rcfs.c |   49 
+++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+)

Index: linux-2.6.16/kernel/ckrm/ckrm_rcfs.c
===================================================================
--- linux-2.6.16.orig/kernel/ckrm/ckrm_rcfs.c
+++ linux-2.6.16/kernel/ckrm/ckrm_rcfs.c
@@ -244,6 +244,43 @@ static ssize_t show_shares(struct ckrm_c
        return rc;
 }
 
+/*
+ * Given a buffer with a pid in it, add the task with that pid to the class.
+ * Ignores entire buffer after the first pid is parsed.
+ */
+static int add_member(struct ckrm_class *class, const char *str)
+{
+       pid_t pid;
+
+       pid = (pid_t) simple_strtol(str, NULL, 0);
+       if (pid <= 0)
+               return -EINVAL; /* Not a valid pid */
+       return ckrm_setclass(pid, class);
+}
+
+/*
+ * Lists pids of tasks that belong to the given class.
+ */
+static ssize_t show_members(struct ckrm_class *class, char *buf)
+{
+       ssize_t i, rc = 0, bufsize = PAGE_SIZE;
+       struct task_struct *tsk;
+
+       spin_lock(&class->class_lock);
+       list_for_each_entry(tsk, &class->task_list, member_list) {
+               if (bufsize <= 0) {
+                       rc = -ENOSPC;
+                       break;
+               }
+               if (!tsk->pid)  /* Ignore swappers */
+                       continue;
+               i = snprintf(buf, bufsize, "%ld\n", (long)tsk->pid);
+               buf += i; rc += i; bufsize -= i;
+       }
+       spin_unlock(&class->class_lock);
+       return rc;
+}
+
 struct class_attribute {
        struct configfs_attribute configfs_attr;
        ssize_t (*show)(struct ckrm_class *, char *);
@@ -270,6 +307,17 @@ struct class_attribute shares_attr = {
        .store = set_shares
 };
 
+struct class_attribute members_attr = {
+       .configfs_attr = {
+               .ca_name = "members",
+               .ca_owner = THIS_MODULE,
+               .ca_mode = S_IRUGO | S_IWUSR
+       },
+       .show = show_members,
+       .store = add_member
+};
+
+
 static struct configfs_subsystem rcfs_subsys;
 static struct config_item_type rcfs_class_type;
 
@@ -415,6 +463,7 @@ static struct configfs_group_operations 
 static struct configfs_attribute *class_attrs[] = {
        &stats_attr.configfs_attr,
        &shares_attr.configfs_attr,
+       &members_attr.configfs_attr,
        NULL
 };
 

-- 

----------------------------------------------------------------------
    Chandra Seetharaman               | Be careful what you choose....
              - [EMAIL PROTECTED]   |      .......you may get it.
----------------------------------------------------------------------


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech

Reply via email to