public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: sekharan@us.ibm.com
To: linux-kernel@vger.kernel.org, ckrm-tech@lists.sourceforge.net
Cc: sekharan@us.ibm.com
Subject: [RFC] [PATCH 11/12] Add members file support to RCFS
Date: Thu, 20 Apr 2006 19:25:13 -0700	[thread overview]
Message-ID: <20060421022513.6145.20550.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060421022411.6145.83939.sendpatchset@localhost.localdomain>

11/12 - ckrm_configfs_rcfs_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>

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

Index: linux2617-rc2/kernel/ckrm/ckrm_rcfs.c
===================================================================
--- linux2617-rc2.orig/kernel/ckrm/ckrm_rcfs.c
+++ linux2617-rc2/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....
              - sekharan@us.ibm.com   |      .......you may get it.
----------------------------------------------------------------------

  parent reply	other threads:[~2006-04-21  2:27 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 ` [RFC] [PATCH 07/12] Configfs based filesystem user interface - RCFS sekharan
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 ` sekharan [this message]
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=20060421022513.6145.20550.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