diff options
| author | Andrea Righi <righi.andrea@gmail.com> | 2008-07-27 18:48:12 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-27 19:12:28 -0400 |
| commit | 940389b8afad6495211614c13eb91ef7001773ec (patch) | |
| tree | 92c581cc9dc7a067899a6a28e382e4099dfe8ead /include | |
| parent | 837b41b5de356aa67abb2cadb5eef3efc7776f91 (diff) | |
task IO accounting: move all IO statistics in struct task_io_accounting
Simplify the code of include/linux/task_io_accounting.h.
It is also more reasonable to have all the task i/o-related statistics in a
single struct (task_io_accounting).
Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/sched.h | 12 | ||||
| -rw-r--r-- | include/linux/task_io_accounting.h | 17 | ||||
| -rw-r--r-- | include/linux/task_io_accounting_ops.h | 48 |
3 files changed, 32 insertions, 45 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 034c1ca6b332..5270d449ff9d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -505,7 +505,7 @@ struct signal_struct { | |||
| 505 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; | 505 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; |
| 506 | unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; | 506 | unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; |
| 507 | unsigned long inblock, oublock, cinblock, coublock; | 507 | unsigned long inblock, oublock, cinblock, coublock; |
| 508 | struct proc_io_accounting ioac; | 508 | struct task_io_accounting ioac; |
| 509 | 509 | ||
| 510 | /* | 510 | /* |
| 511 | * Cumulative ns of scheduled CPU time for dead threads in the | 511 | * Cumulative ns of scheduled CPU time for dead threads in the |
| @@ -1253,7 +1253,7 @@ struct task_struct { | |||
| 1253 | 1253 | ||
| 1254 | unsigned long ptrace_message; | 1254 | unsigned long ptrace_message; |
| 1255 | siginfo_t *last_siginfo; /* For ptrace use. */ | 1255 | siginfo_t *last_siginfo; /* For ptrace use. */ |
| 1256 | struct proc_io_accounting ioac; | 1256 | struct task_io_accounting ioac; |
| 1257 | #if defined(CONFIG_TASK_XACCT) | 1257 | #if defined(CONFIG_TASK_XACCT) |
| 1258 | u64 acct_rss_mem1; /* accumulated rss usage */ | 1258 | u64 acct_rss_mem1; /* accumulated rss usage */ |
| 1259 | u64 acct_vm_mem1; /* accumulated virtual memory usage */ | 1259 | u64 acct_vm_mem1; /* accumulated virtual memory usage */ |
| @@ -2183,22 +2183,22 @@ extern long sched_group_rt_period(struct task_group *tg); | |||
| 2183 | #ifdef CONFIG_TASK_XACCT | 2183 | #ifdef CONFIG_TASK_XACCT |
| 2184 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) | 2184 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) |
| 2185 | { | 2185 | { |
| 2186 | tsk->ioac.chr.rchar += amt; | 2186 | tsk->ioac.rchar += amt; |
| 2187 | } | 2187 | } |
| 2188 | 2188 | ||
| 2189 | static inline void add_wchar(struct task_struct *tsk, ssize_t amt) | 2189 | static inline void add_wchar(struct task_struct *tsk, ssize_t amt) |
| 2190 | { | 2190 | { |
| 2191 | tsk->ioac.chr.wchar += amt; | 2191 | tsk->ioac.wchar += amt; |
| 2192 | } | 2192 | } |
| 2193 | 2193 | ||
| 2194 | static inline void inc_syscr(struct task_struct *tsk) | 2194 | static inline void inc_syscr(struct task_struct *tsk) |
| 2195 | { | 2195 | { |
| 2196 | tsk->ioac.chr.syscr++; | 2196 | tsk->ioac.syscr++; |
| 2197 | } | 2197 | } |
| 2198 | 2198 | ||
| 2199 | static inline void inc_syscw(struct task_struct *tsk) | 2199 | static inline void inc_syscw(struct task_struct *tsk) |
| 2200 | { | 2200 | { |
| 2201 | tsk->ioac.chr.syscw++; | 2201 | tsk->ioac.syscw++; |
| 2202 | } | 2202 | } |
| 2203 | #else | 2203 | #else |
| 2204 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) | 2204 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) |
diff --git a/include/linux/task_io_accounting.h b/include/linux/task_io_accounting.h index 165390f8b936..5e88afc9a2fb 100644 --- a/include/linux/task_io_accounting.h +++ b/include/linux/task_io_accounting.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * proc_io_accounting: a structure which is used for recording a single task's | 2 | * task_io_accounting: a structure which is used for recording a single task's |
| 3 | * IO statistics. | 3 | * IO statistics. |
| 4 | * | 4 | * |
| 5 | * Don't include this header file directly - it is designed to be dragged in via | 5 | * Don't include this header file directly - it is designed to be dragged in via |
| @@ -8,8 +8,8 @@ | |||
| 8 | * Blame akpm@osdl.org for all this. | 8 | * Blame akpm@osdl.org for all this. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | struct task_io_accounting { | ||
| 11 | #ifdef CONFIG_TASK_XACCT | 12 | #ifdef CONFIG_TASK_XACCT |
| 12 | struct task_chr_io_accounting { | ||
| 13 | /* bytes read */ | 13 | /* bytes read */ |
| 14 | u64 rchar; | 14 | u64 rchar; |
| 15 | /* bytes written */ | 15 | /* bytes written */ |
| @@ -18,14 +18,9 @@ struct task_chr_io_accounting { | |||
| 18 | u64 syscr; | 18 | u64 syscr; |
| 19 | /* # of write syscalls */ | 19 | /* # of write syscalls */ |
| 20 | u64 syscw; | 20 | u64 syscw; |
| 21 | }; | ||
| 22 | #else /* CONFIG_TASK_XACCT */ | ||
| 23 | struct task_chr_io_accounting { | ||
| 24 | }; | ||
| 25 | #endif /* CONFIG_TASK_XACCT */ | 21 | #endif /* CONFIG_TASK_XACCT */ |
| 26 | 22 | ||
| 27 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 23 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
| 28 | struct task_io_accounting { | ||
| 29 | /* | 24 | /* |
| 30 | * The number of bytes which this task has caused to be read from | 25 | * The number of bytes which this task has caused to be read from |
| 31 | * storage. | 26 | * storage. |
| @@ -46,13 +41,5 @@ struct task_io_accounting { | |||
| 46 | * information loss in doing that. | 41 | * information loss in doing that. |
| 47 | */ | 42 | */ |
| 48 | u64 cancelled_write_bytes; | 43 | u64 cancelled_write_bytes; |
| 49 | }; | ||
| 50 | #else /* CONFIG_TASK_IO_ACCOUNTING */ | ||
| 51 | struct task_io_accounting { | ||
| 52 | }; | ||
| 53 | #endif /* CONFIG_TASK_IO_ACCOUNTING */ | 44 | #endif /* CONFIG_TASK_IO_ACCOUNTING */ |
| 54 | |||
| 55 | struct proc_io_accounting { | ||
| 56 | struct task_chr_io_accounting chr; | ||
| 57 | struct task_io_accounting blk; | ||
| 58 | }; | 45 | }; |
diff --git a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h index e6f958ebe97f..4d090f9ee608 100644 --- a/include/linux/task_io_accounting_ops.h +++ b/include/linux/task_io_accounting_ops.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 9 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
| 10 | static inline void task_io_account_read(size_t bytes) | 10 | static inline void task_io_account_read(size_t bytes) |
| 11 | { | 11 | { |
| 12 | current->ioac.blk.read_bytes += bytes; | 12 | current->ioac.read_bytes += bytes; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | /* | 15 | /* |
| @@ -18,12 +18,12 @@ static inline void task_io_account_read(size_t bytes) | |||
| 18 | */ | 18 | */ |
| 19 | static inline unsigned long task_io_get_inblock(const struct task_struct *p) | 19 | static inline unsigned long task_io_get_inblock(const struct task_struct *p) |
| 20 | { | 20 | { |
| 21 | return p->ioac.blk.read_bytes >> 9; | 21 | return p->ioac.read_bytes >> 9; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | static inline void task_io_account_write(size_t bytes) | 24 | static inline void task_io_account_write(size_t bytes) |
| 25 | { | 25 | { |
| 26 | current->ioac.blk.write_bytes += bytes; | 26 | current->ioac.write_bytes += bytes; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | /* | 29 | /* |
| @@ -32,25 +32,25 @@ static inline void task_io_account_write(size_t bytes) | |||
| 32 | */ | 32 | */ |
| 33 | static inline unsigned long task_io_get_oublock(const struct task_struct *p) | 33 | static inline unsigned long task_io_get_oublock(const struct task_struct *p) |
| 34 | { | 34 | { |
| 35 | return p->ioac.blk.write_bytes >> 9; | 35 | return p->ioac.write_bytes >> 9; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static inline void task_io_account_cancelled_write(size_t bytes) | 38 | static inline void task_io_account_cancelled_write(size_t bytes) |
| 39 | { | 39 | { |
| 40 | current->ioac.blk.cancelled_write_bytes += bytes; | 40 | current->ioac.cancelled_write_bytes += bytes; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static inline void task_io_accounting_init(struct proc_io_accounting *ioac) | 43 | static inline void task_io_accounting_init(struct task_io_accounting *ioac) |
| 44 | { | 44 | { |
| 45 | memset(ioac, 0, sizeof(*ioac)); | 45 | memset(ioac, 0, sizeof(*ioac)); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst, | 48 | static inline void task_blk_io_accounting_add(struct task_io_accounting *dst, |
| 49 | struct proc_io_accounting *src) | 49 | struct task_io_accounting *src) |
| 50 | { | 50 | { |
| 51 | dst->blk.read_bytes += src->blk.read_bytes; | 51 | dst->read_bytes += src->read_bytes; |
| 52 | dst->blk.write_bytes += src->blk.write_bytes; | 52 | dst->write_bytes += src->write_bytes; |
| 53 | dst->blk.cancelled_write_bytes += src->blk.cancelled_write_bytes; | 53 | dst->cancelled_write_bytes += src->cancelled_write_bytes; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | #else | 56 | #else |
| @@ -77,35 +77,35 @@ static inline void task_io_account_cancelled_write(size_t bytes) | |||
| 77 | { | 77 | { |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static inline void task_io_accounting_init(struct proc_io_accounting *ioac) | 80 | static inline void task_io_accounting_init(struct task_io_accounting *ioac) |
| 81 | { | 81 | { |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst, | 84 | static inline void task_blk_io_accounting_add(struct task_io_accounting *dst, |
| 85 | struct proc_io_accounting *src) | 85 | struct task_io_accounting *src) |
| 86 | { | 86 | { |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | #endif /* CONFIG_TASK_IO_ACCOUNTING */ | 89 | #endif /* CONFIG_TASK_IO_ACCOUNTING */ |
| 90 | 90 | ||
| 91 | #ifdef CONFIG_TASK_XACCT | 91 | #ifdef CONFIG_TASK_XACCT |
| 92 | static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst, | 92 | static inline void task_chr_io_accounting_add(struct task_io_accounting *dst, |
| 93 | struct proc_io_accounting *src) | 93 | struct task_io_accounting *src) |
| 94 | { | 94 | { |
| 95 | dst->chr.rchar += src->chr.rchar; | 95 | dst->rchar += src->rchar; |
| 96 | dst->chr.wchar += src->chr.wchar; | 96 | dst->wchar += src->wchar; |
| 97 | dst->chr.syscr += src->chr.syscr; | 97 | dst->syscr += src->syscr; |
| 98 | dst->chr.syscw += src->chr.syscw; | 98 | dst->syscw += src->syscw; |
| 99 | } | 99 | } |
| 100 | #else | 100 | #else |
| 101 | static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst, | 101 | static inline void task_chr_io_accounting_add(struct task_io_accounting *dst, |
| 102 | struct proc_io_accounting *src) | 102 | struct task_io_accounting *src) |
| 103 | { | 103 | { |
| 104 | } | 104 | } |
| 105 | #endif /* CONFIG_TASK_XACCT */ | 105 | #endif /* CONFIG_TASK_XACCT */ |
| 106 | 106 | ||
| 107 | static inline void task_io_accounting_add(struct proc_io_accounting *dst, | 107 | static inline void task_io_accounting_add(struct task_io_accounting *dst, |
| 108 | struct proc_io_accounting *src) | 108 | struct task_io_accounting *src) |
| 109 | { | 109 | { |
| 110 | task_chr_io_accounting_add(dst, src); | 110 | task_chr_io_accounting_add(dst, src); |
| 111 | task_blk_io_accounting_add(dst, src); | 111 | task_blk_io_accounting_add(dst, src); |
