Commit 25890454 authored by Shailabh Nagar's avatar Shailabh Nagar Committed by Linus Torvalds

[PATCH] per-task-delay-accounting: /proc export of aggregated block I/O delays

Export I/O delays seen by a task through /proc/<tgid>/stats for use in top
etc.

Note that delays for I/O done for swapping in pages (swapin I/O) is clubbed
together with all other I/O here (this is not the case in the netlink
interface where the swapin I/O is kept distinct)

[akpm@osdl.org: printk warning fix]
Signed-off-by: default avatarShailabh Nagar <nagar@watson.ibm.com>
Signed-off-by: default avatarBalbir Singh <balbir@in.ibm.com>
Cc: Jes Sorensen <jes@sgi.com>
Cc: Peter Chubb <peterc@gelato.unsw.edu.au>
Cc: Erich Focht <efocht@ess.nec.de>
Cc: Levent Serinol <lserinol@gmail.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a3baf649
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include <linux/times.h> #include <linux/times.h>
#include <linux/cpuset.h> #include <linux/cpuset.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <linux/delayacct.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -411,7 +412,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) ...@@ -411,7 +412,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n",
task->pid, task->pid,
tcomm, tcomm,
state, state,
...@@ -455,7 +456,8 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) ...@@ -455,7 +456,8 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
task->exit_signal, task->exit_signal,
task_cpu(task), task_cpu(task),
task->rt_priority, task->rt_priority,
task->policy); task->policy,
(unsigned long long)delayacct_blkio_ticks(task));
if(mm) if(mm)
mmput(mm); mmput(mm);
return res; return res;
......
...@@ -37,6 +37,7 @@ extern void __delayacct_tsk_exit(struct task_struct *); ...@@ -37,6 +37,7 @@ extern void __delayacct_tsk_exit(struct task_struct *);
extern void __delayacct_blkio_start(void); extern void __delayacct_blkio_start(void);
extern void __delayacct_blkio_end(void); extern void __delayacct_blkio_end(void);
extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *); extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
extern __u64 __delayacct_blkio_ticks(struct task_struct *);
static inline void delayacct_set_flag(int flag) static inline void delayacct_set_flag(int flag)
{ {
...@@ -86,6 +87,13 @@ static inline int delayacct_add_tsk(struct taskstats *d, ...@@ -86,6 +87,13 @@ static inline int delayacct_add_tsk(struct taskstats *d,
return __delayacct_add_tsk(d, tsk); return __delayacct_add_tsk(d, tsk);
} }
static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
{
if (tsk->delays)
return __delayacct_blkio_ticks(tsk);
return 0;
}
#else #else
static inline void delayacct_set_flag(int flag) static inline void delayacct_set_flag(int flag)
{} {}
...@@ -104,6 +112,8 @@ static inline void delayacct_blkio_end(void) ...@@ -104,6 +112,8 @@ static inline void delayacct_blkio_end(void)
static inline int delayacct_add_tsk(struct taskstats *d, static inline int delayacct_add_tsk(struct taskstats *d,
struct task_struct *tsk) struct task_struct *tsk)
{ return 0; } { return 0; }
static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
{ return 0; }
#endif /* CONFIG_TASK_DELAY_ACCT */ #endif /* CONFIG_TASK_DELAY_ACCT */
#endif #endif
...@@ -164,3 +164,15 @@ done: ...@@ -164,3 +164,15 @@ done:
spin_unlock(&tsk->delays_lock); spin_unlock(&tsk->delays_lock);
return 0; return 0;
} }
__u64 __delayacct_blkio_ticks(struct task_struct *tsk)
{
__u64 ret;
spin_lock(&tsk->delays->lock);
ret = nsec_to_clock_t(tsk->delays->blkio_delay +
tsk->delays->swapin_delay);
spin_unlock(&tsk->delays->lock);
return ret;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment