diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2007-10-19 02:39:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:36 -0400 |
commit | 846c7bb055747989891f5cd2bb6e8d56243ba1e7 (patch) | |
tree | e044041366efa8298157c4ae86615d68d30dd6d2 /include/linux/cgroup.h | |
parent | c2e2c7fa1cb2cf2b114a6c9bc132b6601db5a7c8 (diff) |
Add cgroupstats
This patch is inspired by the discussion at
http://lkml.org/lkml/2007/4/11/187 and implements per cgroup statistics
as suggested by Andrew Morton in http://lkml.org/lkml/2007/4/11/263. The
patch is on top of 2.6.21-mm1 with Paul's cgroups v9 patches (forward
ported)
This patch implements per cgroup statistics infrastructure and re-uses
code from the taskstats interface. A new set of cgroup operations are
registered with commands and attributes. It should be very easy to
*extend* per cgroup statistics, by adding members to the cgroupstats
structure.
The current model for cgroupstats is a pull, a push model (to post
statistics on interesting events), should be very easy to add. Currently
user space requests for statistics by passing the cgroup file
descriptor. Statistics about the state of all the tasks in the cgroup
is returned to user space.
TODO's/NOTE:
This patch provides an infrastructure for implementing cgroup statistics.
Based on the needs of each controller, we can incrementally add more statistics,
event based support for notification of statistics, accumulation of taskstats
into cgroup statistics in the future.
Sample output
# ./cgroupstats -C /cgroup/a
sleeping 2, blocked 0, running 1, stopped 0, uninterruptible 0
# ./cgroupstats -C /cgroup/
sleeping 154, blocked 0, running 0, stopped 0, uninterruptible 0
If the approach looks good, I'll enhance and post the user space utility for
the same
Feedback, comments, test results are always welcome!
[akpm@linux-foundation.org: build fix]
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 9e9b7efa180b..87479328d46d 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/cpumask.h> | 13 | #include <linux/cpumask.h> |
14 | #include <linux/nodemask.h> | 14 | #include <linux/nodemask.h> |
15 | #include <linux/rcupdate.h> | 15 | #include <linux/rcupdate.h> |
16 | #include <linux/cgroupstats.h> | ||
16 | 17 | ||
17 | #ifdef CONFIG_CGROUPS | 18 | #ifdef CONFIG_CGROUPS |
18 | 19 | ||
@@ -29,6 +30,8 @@ extern void cgroup_fork(struct task_struct *p); | |||
29 | extern void cgroup_fork_callbacks(struct task_struct *p); | 30 | extern void cgroup_fork_callbacks(struct task_struct *p); |
30 | extern void cgroup_post_fork(struct task_struct *p); | 31 | extern void cgroup_post_fork(struct task_struct *p); |
31 | extern void cgroup_exit(struct task_struct *p, int run_callbacks); | 32 | extern void cgroup_exit(struct task_struct *p, int run_callbacks); |
33 | extern int cgroupstats_build(struct cgroupstats *stats, | ||
34 | struct dentry *dentry); | ||
32 | 35 | ||
33 | extern struct file_operations proc_cgroup_operations; | 36 | extern struct file_operations proc_cgroup_operations; |
34 | 37 | ||
@@ -313,6 +316,11 @@ static inline void cgroup_exit(struct task_struct *p, int callbacks) {} | |||
313 | 316 | ||
314 | static inline void cgroup_lock(void) {} | 317 | static inline void cgroup_lock(void) {} |
315 | static inline void cgroup_unlock(void) {} | 318 | static inline void cgroup_unlock(void) {} |
319 | static inline int cgroupstats_build(struct cgroupstats *stats, | ||
320 | struct dentry *dentry) | ||
321 | { | ||
322 | return -EINVAL; | ||
323 | } | ||
316 | 324 | ||
317 | #endif /* !CONFIG_CGROUPS */ | 325 | #endif /* !CONFIG_CGROUPS */ |
318 | 326 | ||