Add containerstats (v3)
Get series with b4
b4 am 20070608181346.15764.2467.sendpatchset@balbir-laptopVersions newest first
- v1 Latest1 patch 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | Update getdelays to become containerstats awareDocumentation/ | +42 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [0/1] [patch -mm] Add containerstats (v3)
Changelog (v3)
1. Use the container iterator (Paul Menage)
2. delayacct_set_flag() has now been moved to delayacct_blkio_start (Andrew Morton)
Changelog (v2)
1. Instead of parsing long container path's use the dentry to match the container for which stats are required. The user space application opens the container directory and passes the file descriptor, which is used to determine the container for which stats are required. This approach was suggested by Paul Menage
This patch is inspired by the discussion at http://lkml.org/lkml/2007/4/11/187
and implements per container 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 containers v9 patches (forward ported)
This patch implements per container statistics infrastructure and re-uses code from the taskstats interface. A new set of container operations are registered with commands and attributes. It should be very easy to *extend* per container statistics, by adding members to the containerstats structure.
The current model for containerstats 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 container file descriptor. Statistics about the state of all the tasks in the container is returned to user space.
TODO's/NOTE:
This patch provides an infrastructure for implementing container 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 container statistics in the future.
Sample output
# ./containerstats -C /container/a sleeping 2, blocked 0, running 1, stopped 0, uninterruptible 0
# ./containerstats -C /container/ 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!
---
Documentation/accounting/containerstats.txt | 27 ++++++++++ include/linux/Kbuild | 1 include/linux/container.h | 8 +++ include/linux/containerstats.h | 70 ++++++++++++++++++++++++++++ include/linux/delayacct.h | 13 +++++ kernel/container.c | 54 +++++++++++++++++++++ kernel/taskstats.c | 66 ++++++++++++++++++++++++++ 7 files changed, 239 insertions(+)
Documentation/accounting/containerstats.txt new file +27 -0
@@ -0,0 +1,27 @@ +Containerstats is inspired by the discussion at +http://lkml.org/lkml/2007/4/11/187 and implements per container statistics as +suggested by Andrew Morton in http://lkml.org/lkml/2007/4/11/263. + +Per container statistics infrastructure re-uses code from the taskstats +interface. A new set of container operations are registered with commands +and attributes specific to containers. It should be very easy to +extend per container statistics, by adding members to the containerstats +structure. + +The current model for containerstats 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 container path. +Statistics about the state of all the tasks in the container is returned to +user space. + +NOTE: We currently rely on delay accounting for extracting information +about tasks blocked on I/O. If CONFIG_TASK_DELAY_ACCT is disabled, this +information will not be available. + +To extract container statistics a utility very similar to getdelays.c +has been developed, the sample output of the utility is shown below + +~/balbir/containerstats # ./getdelays -C "/container/a" +sleeping 1, blocked 0, running 1, stopped 0, uninterruptible 0 +~/balbir/containerstats # ./getdelays -C "/container" +sleeping 155, blocked 0, running 1, stopped 0, uninterruptible 2
include/linux/container.h renamed from include/linux/container.h~containers-taskstats +8 -0
@@ -13,6 +13,7 @@#include <linux/cpumask.h> #include <linux/nodemask.h> #include <linux/rcupdate.h> +#include <linux/containerstats.h> #ifdef CONFIG_CONTAINERS
@@ -27,6 +28,8 @@ extern void container_unlock(void);extern void container_fork (struct task_struct *p);extern void container_fork_callbacks (struct task_struct *p);extern void container_exit (struct task_struct *p,int run_callbacks); +extern int containerstats_build (struct containerstats *stats, +struct dentry *dentry);extern struct file_operations proc_container_operations;
@@ -288,6 +291,11 @@ static inline void container_exit(structstatic inline void container_lock (void ) {}static inline void container_unlock (void ) {} +static inline int containerstats_build (struct containerstats *stats, +struct dentry *dentry) +{ +return -EINVAL ; +}#endif /* !CONFIG_CONTAINERS */
include/linux/containerstats.h new file +70 -0
70 lines not on this page · raw message
include/linux/delayacct.h renamed from include/linux/delayacct.h~containers-taskstats +13 -0
@@ -26,6 +26,7 @@* Used to set current->delays->flags */ #define DELAYACCT_PF_SWAPIN 0x00000001/* I am doing a swapin */ +#define DELAYACCT_PF_BLKIO 0x00000002/* I am waiting on IO */ #ifdef CONFIG_TASK_DELAY_ACCT
@@ -39,6 +40,14 @@ extern void __delayacct_blkio_end(void);extern int __delayacct_add_tsk (struct taskstats *,struct task_struct *);extern __u64 __delayacct_blkio_ticks (struct task_struct *); +static inline int delayacct_is_task_waiting_on_io (struct task_struct *p) +{ +if (p->delays) +return (p->delays->flags &DELAYACCT_PF_BLKIO ); +else +return 0 ; +} +static inline void delayacct_set_flag (int flag) {if (current->delays)
@@ -71,6 +80,7 @@ static inline void delayacct_tsk_free(ststatic inline void delayacct_blkio_start (void ) { +delayacct_set_flag (DELAYACCT_PF_BLKIO );if (current->delays)__delayacct_blkio_start (); }
@@ -79,6 +89,7 @@ static inline void delayacct_blkio_end(v {if (current->delays)__delayacct_blkio_end (); +delayacct_clear_flag (DELAYACCT_PF_BLKIO ); } static inline int delayacct_add_tsk(struct taskstats *d,
@@ -116,6 +127,8 @@ static inline int delayacct_add_tsk(stru {return 0 ; }static inline __u64 delayacct_blkio_ticks (struct task_struct *tsk) {return 0 ; } +static inline int delayacct_is_task_waiting_on_io (struct task_struct *p) +{return 0 ; }#endif /* CONFIG_TASK_DELAY_ACCT */ #endif
include/linux/Kbuild renamed from include/linux/Kbuild~containers-taskstats +1 -0
@@ -47,6 +47,7 @@ header-y += coff.h header-y += comstats.h header-y += consolemap.h header-y += const.h +header-y += containerstats.h header-y += cycx_cfm.h header-y += dlm_device.h header-y += dlm_netlink.h
kernel/container.c renamed from kernel/container.c~containers-taskstats +54 -0
66 lines not on this page · raw message
diff -puN kernel/sched.c~containers-taskstats kernel/sched.c
kernel/taskstats.c renamed from kernel/taskstats.c~containers-taskstats +66 -0
98 lines not on this page · raw message
diff -puN kernel/cpuset.c~containers-taskstats kernel/cpuset.c diff -puN kernel/delayacct.c~containers-taskstats kernel/delayacct.c _
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL