Messages in this thread Patch in this message | | | From | Chandra Seetharaman <> | Date | Thu, 27 Apr 2006 18:35:11 -0700 | Subject | [PATCH 11/12] Add members file support to RGCS |
| |
11/12 - user_interface_members
Adds attr_store and attr_show support for members file. --
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>
rgcs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+)
Index: linux-2617-rc3/kernel/res_group/rgcs.c =================================================================== --- linux-2617-rc3.orig/kernel/res_group/rgcs.c 2006-04-27 10:18:47.000000000 -0700 +++ linux-2617-rc3/kernel/res_group/rgcs.c 2006-04-27 10:18:47.000000000 -0700 @@ -242,6 +242,43 @@ static ssize_t show_shares(struct resour return rc; } +/* + * Given a buffer with a pid in it, add the task with that pid to the + * resource group. Ignores entire buffer after the first pid is parsed. + */ +static int add_member(struct resource_group *rgroup, const char *str) +{ + pid_t pid; + + pid = (pid_t) simple_strtol(str, NULL, 0); + if (pid <= 0) + return -EINVAL; /* Not a valid pid */ + return set_res_group(pid, rgroup); +} + +/* + * Lists pids of tasks that belong to the given rgroup. + */ +static ssize_t show_members(struct resource_group *rgroup, char *buf) +{ + ssize_t i, rc = 0, bufsize = PAGE_SIZE; + struct task_struct *tsk; + + spin_lock(&rgroup->group_lock); + list_for_each_entry(tsk, &rgroup->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(&rgroup->group_lock); + return rc; +} + struct rgroup_attribute { struct configfs_attribute configfs_attr; ssize_t (*show)(struct resource_group *, char *); @@ -268,6 +305,17 @@ struct rgroup_attribute shares_attr = { .store = set_shares }; +struct rgroup_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 rgcs_subsys; static struct config_item_type rgcs_item_type; @@ -417,6 +465,7 @@ static struct configfs_group_operations static struct configfs_attribute *rgroup_attrs[] = { &stats_attr.configfs_attr, &shares_attr.configfs_attr, + &members_attr.configfs_attr, NULL }; --
---------------------------------------------------------------------- Chandra Seetharaman | Be careful what you choose.... - sekharan@us.ibm.com | .......you may get it. ---------------------------------------------------------------------- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |