From: Nikanth Karthikesan <knikanth@suse.de>
To: balbir@linux.vnet.ibm.com
Cc: Paul Menage <menage@google.com>,
lizf@cn.fujitsu.com, linux-kernel@vger.kernel.org
Subject: [PATCH] taskstats: Unify cgroupstats.h with taskstats.h and use a single nla_policy
Date: Mon, 13 Jul 2009 22:23:12 +0530 [thread overview]
Message-ID: <200907132223.12627.knikanth@suse.de> (raw)
In-Reply-To: <20090713155439.GF5051@balbir.in.ibm.com>
Currently we never get message from kernel to userspace of type
TASKSTATS_TYPE_PID. Having the values in the same range would restrict one not
to use the same netlink socket for a command that would return response of
type TASKSTATS_TYPE_PID and the CGROUPSTATS_CMD_GET command.
Change it by using the same set of types and attributes for both
TASKSTATS_CMD_NEW/GET and CGROUPSTATS_CMD_GET/NEW by using the same
nla_policy.
Unify linux/cgroupstats.h with linux/taskstat.h
Bump the taskstat version while doing so.
Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
---
diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index aa73e72..ffac484 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -25,7 +25,6 @@
#include <linux/genetlink.h>
#include <linux/taskstats.h>
-#include <linux/cgroupstats.h>
/*
* Generic macros for dealing with netlink sockets. Might be duplicated
@@ -133,7 +132,7 @@ int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
msg.n.nlmsg_seq = 0;
msg.n.nlmsg_pid = nlmsg_pid;
msg.g.cmd = genl_cmd;
- msg.g.version = 0x1;
+ msg.g.version = 0x2;
na = (struct nlattr *) GENLMSG_DATA(&msg);
na->nla_type = nla_type;
na->nla_len = nla_len + 1 + NLA_HDRLEN;
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 665fa70..dd7c675 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -12,7 +12,7 @@
#include <linux/cpumask.h>
#include <linux/nodemask.h>
#include <linux/rcupdate.h>
-#include <linux/cgroupstats.h>
+#include <linux/taskstats.h>
#include <linux/prio_heap.h>
#include <linux/rwsem.h>
#include <linux/idr.h>
diff --git a/include/linux/cgroupstats.h b/include/linux/cgroupstats.h
deleted file mode 100644
index 3753c33..0000000
--- a/include/linux/cgroupstats.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* cgroupstats.h - exporting per-cgroup statistics
- *
- * Copyright IBM Corporation, 2007
- * Author Balbir Singh <balbir@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _LINUX_CGROUPSTATS_H
-#define _LINUX_CGROUPSTATS_H
-
-#include <linux/types.h>
-#include <linux/taskstats.h>
-
-/*
- * Data shared between user space and kernel space on a per cgroup
- * basis. This data is shared using taskstats.
- *
- * Most of these states are derived by looking at the task->state value
- * For the nr_io_wait state, a flag in the delay accounting structure
- * indicates that the task is waiting on IO
- *
- * Each member is aligned to a 8 byte boundary.
- */
-struct cgroupstats {
- __u64 nr_sleeping; /* Number of tasks sleeping */
- __u64 nr_running; /* Number of tasks running */
- __u64 nr_stopped; /* Number of tasks in stopped state */
- __u64 nr_uninterruptible; /* Number of tasks in uninterruptible */
- /* state */
- __u64 nr_io_wait; /* Number of tasks waiting on IO */
-};
-
-/*
- * Commands sent from userspace
- * Not versioned. New commands should only be inserted at the enum's end
- * prior to __CGROUPSTATS_CMD_MAX
- */
-
-enum {
- CGROUPSTATS_CMD_UNSPEC = __TASKSTATS_CMD_MAX, /* Reserved */
- CGROUPSTATS_CMD_GET, /* user->kernel request/get-response */
- CGROUPSTATS_CMD_NEW, /* kernel->user event */
- __CGROUPSTATS_CMD_MAX,
-};
-
-#define CGROUPSTATS_CMD_MAX (__CGROUPSTATS_CMD_MAX - 1)
-
-enum {
- CGROUPSTATS_TYPE_UNSPEC = 0, /* Reserved */
- CGROUPSTATS_TYPE_CGROUP_STATS, /* contains name + stats */
- __CGROUPSTATS_TYPE_MAX,
-};
-
-#define CGROUPSTATS_TYPE_MAX (__CGROUPSTATS_TYPE_MAX - 1)
-
-enum {
- CGROUPSTATS_CMD_ATTR_UNSPEC = 0,
- CGROUPSTATS_CMD_ATTR_FD,
- __CGROUPSTATS_CMD_ATTR_MAX,
-};
-
-#define CGROUPSTATS_CMD_ATTR_MAX (__CGROUPSTATS_CMD_ATTR_MAX - 1)
-
-#endif /* _LINUX_CGROUPSTATS_H */
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 341dddb..cba4594 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -165,6 +165,24 @@ struct taskstats {
__u64 freepages_delay_total;
};
+/*
+ * Data shared between user space and kernel space on a per cgroup
+ * basis. This data is shared using taskstats.
+ *
+ * Most of these states are derived by looking at the task->state value
+ * For the nr_io_wait state, a flag in the delay accounting structure
+ * indicates that the task is waiting on IO
+ *
+ * Each member is aligned to a 8 byte boundary.
+ */
+struct cgroupstats {
+ __u64 nr_sleeping; /* Number of tasks sleeping */
+ __u64 nr_running; /* Number of tasks running */
+ __u64 nr_stopped; /* Number of tasks in stopped state */
+ __u64 nr_uninterruptible; /* Number of tasks in uninterruptible */
+ /* state */
+ __u64 nr_io_wait; /* Number of tasks waiting on IO */
+};
/*
* Commands sent from userspace
@@ -176,6 +194,9 @@ enum {
TASKSTATS_CMD_UNSPEC = 0, /* Reserved */
TASKSTATS_CMD_GET, /* user->kernel request/get-response */
TASKSTATS_CMD_NEW, /* kernel->user event */
+ CGROUPSTATS_CMD_GET, /* user->kernel request/get-response */
+ /* for cgroup statistics */
+ CGROUPSTATS_CMD_NEW, /* kernel->user event for cgroups */
__TASKSTATS_CMD_MAX,
};
@@ -188,6 +209,7 @@ enum {
TASKSTATS_TYPE_STATS, /* taskstats structure */
TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */
TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */
+ CGROUPSTATS_TYPE_CGROUP_STATS, /* contains cgroup name + stats */
__TASKSTATS_TYPE_MAX,
};
@@ -199,6 +221,7 @@ enum {
TASKSTATS_CMD_ATTR_TGID,
TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,
TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK,
+ CGROUPSTATS_CMD_ATTR_FD,
__TASKSTATS_CMD_ATTR_MAX,
};
@@ -207,6 +230,6 @@ enum {
/* NETLINK_GENERIC related info */
#define TASKSTATS_GENL_NAME "TASKSTATS"
-#define TASKSTATS_GENL_VERSION 0x1
+#define TASKSTATS_GENL_VERSION 0x2
#endif /* _LINUX_TASKSTATS_H */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 3737a68..94bee03 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -43,7 +43,7 @@
#include <linux/sort.h>
#include <linux/kmod.h>
#include <linux/delayacct.h>
-#include <linux/cgroupstats.h>
+#include <linux/taskstats.h>
#include <linux/hash.h>
#include <linux/namei.h>
#include <linux/smp_lock.h>
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 888adbc..448caba 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -22,7 +22,6 @@
#include <linux/delayacct.h>
#include <linux/cpumask.h>
#include <linux/percpu.h>
-#include <linux/cgroupstats.h>
#include <linux/cgroup.h>
#include <linux/fs.h>
#include <linux/file.h>
@@ -46,15 +45,12 @@ static struct genl_family family = {
.maxattr = TASKSTATS_CMD_ATTR_MAX,
};
-static struct nla_policy taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1]
+static struct nla_policy policy[TASKSTATS_CMD_ATTR_MAX+1]
__read_mostly = {
[TASKSTATS_CMD_ATTR_PID] = { .type = NLA_U32 },
[TASKSTATS_CMD_ATTR_TGID] = { .type = NLA_U32 },
[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK] = { .type = NLA_STRING },
- [TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK] = { .type = NLA_STRING },};
-
-static struct nla_policy
-cgroupstats_cmd_get_policy[CGROUPSTATS_CMD_ATTR_MAX+1] __read_mostly = {
+ [TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK] = { .type = NLA_STRING },
[CGROUPSTATS_CMD_ATTR_FD] = { .type = NLA_U32 },
};
@@ -582,13 +578,13 @@ err:
static struct genl_ops taskstats_ops = {
.cmd = TASKSTATS_CMD_GET,
.doit = taskstats_user_cmd,
- .policy = taskstats_cmd_get_policy,
+ .policy = policy,
};
static struct genl_ops cgroupstats_ops = {
.cmd = CGROUPSTATS_CMD_GET,
.doit = cgroupstats_user_cmd,
- .policy = cgroupstats_cmd_get_policy,
+ .policy = policy,
};
/* Needed early in initialization */
prev parent reply other threads:[~2009-07-13 16:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-13 13:01 [RFC][PATCH] taskstats: Fix CGROUPSTATS_TYPE_CGROUP_STATS having same value as TASKSTATS_TYPE_PID Nikanth Karthikesan
2009-07-13 13:41 ` Balbir Singh
2009-07-13 15:37 ` Nikanth Karthikesan
2009-07-13 15:53 ` Balbir Singh
2009-07-14 10:57 ` Nikanth Karthikesan
2009-07-13 15:46 ` Nikanth Karthikesan
2009-07-13 15:54 ` Balbir Singh
2009-07-13 16:53 ` Nikanth Karthikesan [this message]
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=200907132223.12627.knikanth@suse.de \
--to=knikanth@suse.de \
--cc=balbir@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.