From: sekharan@us.ibm.com
To: linux-kernel@vger.kernel.org, ckrm-tech@lists.sourceforge.net
Cc: sekharan@us.ibm.com
Subject: [RFC] [PATCH 09/12] Add stats file support to RCFS
Date: Thu, 20 Apr 2006 19:25:01 -0700 [thread overview]
Message-ID: <20060421022501.6145.18395.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060421022411.6145.83939.sendpatchset@localhost.localdomain>
09/12 - ckrm_configfs_rcfs_stats
Adds attr_store and attr_show support for stats 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 | 114 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 112 insertions(+), 2 deletions(-)
Index: linux2617-rc2/kernel/ckrm/ckrm_rcfs.c
===================================================================
--- linux2617-rc2.orig/kernel/ckrm/ckrm_rcfs.c
+++ linux2617-rc2/kernel/ckrm/ckrm_rcfs.c
@@ -20,8 +20,104 @@
#include <linux/parser.h>
#include "ckrm_local.h"
-static struct configfs_subsystem rcfs_subsys;
-static struct config_item_type rcfs_class_type;
+#define CKRM_NAME_LEN 20
+
+#define RES_STRING "res"
+
+static ssize_t show_stats(struct ckrm_class *class, char *buf)
+{
+ int i, j = 0, rc = 0;
+ size_t buf_size = PAGE_SIZE-1; /* allow only PAGE_SIZE # of bytes */
+ struct ckrm_controller *ctlr;
+ struct ckrm_shares *shares;
+
+ for (i = 0; i < CKRM_MAX_RES_CTLRS; i++, j = 0) {
+ if (buf_size <= 0)
+ break;
+ ctlr = ckrm_get_controller_by_id(i);
+ if (!ctlr)
+ continue;
+ shares = ckrm_get_controller_shares(class, ctlr);
+ if (shares && ctlr->show_stats)
+ j = ctlr->show_stats(shares, buf, buf_size);
+ ckrm_put_controller(ctlr);
+ rc += j;
+ buf += j;
+ buf_size -= j;
+ }
+ if (i < CKRM_MAX_RES_CTLRS)
+ rc = -ENOSPC;
+ return rc;
+}
+
+enum parse_token_t {
+ parse_res_type, parse_err
+};
+
+static match_table_t parse_tokens = {
+ {parse_res_type, RES_STRING"=%s"},
+ {parse_err, NULL}
+};
+
+static int ckrm_stats_parse(const char *options,
+ char **resname, char **remaining_line)
+{
+ char *p, *str;
+ int rc = -EINVAL;
+
+ if (!options)
+ return -EINVAL;
+
+ while ((p = strsep((char **)&options, ",")) != NULL) {
+ substring_t args[MAX_OPT_ARGS];
+ int token;
+
+ if (!*p)
+ continue;
+ token = match_token(p, parse_tokens, args);
+ if (token == parse_res_type) {
+ *resname = match_strdup(args);
+ str = p + strlen(p) + 1;
+ *remaining_line = kmalloc(strlen(str) + 1, GFP_KERNEL);
+ if (*remaining_line == NULL) {
+ kfree(*resname);
+ *resname = NULL;
+ rc = -ENOMEM;
+ } else {
+ strcpy(*remaining_line, str);
+ rc = 0;
+ }
+ break;
+ }
+ }
+ return rc;
+}
+
+static int reset_stats(struct ckrm_class *class, const char *str)
+{
+ int rc;
+ char *resname = NULL, *statstr = NULL;
+ struct ckrm_controller *ctlr;
+ struct ckrm_shares *shares;
+
+ rc = ckrm_stats_parse(str, &resname, &statstr);
+ if (rc)
+ return rc;
+
+ ctlr = ckrm_get_controller_by_name(resname);
+ if (!ctlr) {
+ rc = -EINVAL;
+ goto done;
+ }
+ shares = ckrm_get_controller_shares(class, ctlr);
+ if (shares && ctlr->reset_stats)
+ rc = ctlr->reset_stats(shares, statstr);
+ ckrm_put_controller(ctlr);
+done:
+ kfree(resname);
+ kfree(statstr);
+ return rc;
+}
struct class_attribute {
struct configfs_attribute configfs_attr;
@@ -29,6 +125,19 @@ struct class_attribute {
int (*store)(struct ckrm_class *, const char *);
};
+struct class_attribute stats_attr = {
+ .configfs_attr = {
+ .ca_name = "stats",
+ .ca_owner = THIS_MODULE,
+ .ca_mode = S_IRUGO | S_IWUSR
+ },
+ .show = show_stats,
+ .store = reset_stats
+};
+
+static struct configfs_subsystem rcfs_subsys;
+static struct config_item_type rcfs_class_type;
+
struct rcfs_class {
char *name;
struct ckrm_class *core;
@@ -169,6 +278,7 @@ static struct configfs_group_operations
};
static struct configfs_attribute *class_attrs[] = {
+ &stats_attr.configfs_attr,
NULL
};
--
----------------------------------------------------------------------
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:32 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 ` sekharan [this message]
2006-04-21 2:25 ` [RFC] [PATCH 10/12] Add shares file " 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=20060421022501.6145.18395.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