diff options
author | Andrea Righi <righi.andrea@gmail.com> | 2008-07-27 11:29:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-27 12:58:20 -0400 |
commit | 5995477ab7f3522c497c9c4a1c55373e9d655574 (patch) | |
tree | a147fb61642a7ac5441855964eb97a2ff1e37202 /include/linux/sched.h | |
parent | 605ccb73f6a1c891a16268b3a2923208fc637958 (diff) |
task IO accounting: improve code readability
Put all i/o statistics in struct proc_io_accounting and use inline functions to
initialize and increment statistics, removing a lot of single variable
assignments.
This also reduces the kernel size as following (with CONFIG_TASK_XACCT=y and
CONFIG_TASK_IO_ACCOUNTING=y).
text data bss dec hex filename
11651 0 0 11651 2d83 kernel/exit.o.before
11619 0 0 11619 2d63 kernel/exit.o.after
10886 132 136 11154 2b92 kernel/fork.o.before
10758 132 136 11026 2b12 kernel/fork.o.after
3082029 807968 4818600 8708597 84e1f5 vmlinux.o.before
3081869 807968 4818600 8708437 84e155 vmlinux.o.after
Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Acked-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index f59318a0099b..034c1ca6b332 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -505,10 +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 | #ifdef CONFIG_TASK_XACCT | 508 | struct proc_io_accounting ioac; |
509 | u64 rchar, wchar, syscr, syscw; | ||
510 | #endif | ||
511 | struct task_io_accounting ioac; | ||
512 | 509 | ||
513 | /* | 510 | /* |
514 | * Cumulative ns of scheduled CPU time for dead threads in the | 511 | * Cumulative ns of scheduled CPU time for dead threads in the |
@@ -1256,11 +1253,7 @@ struct task_struct { | |||
1256 | 1253 | ||
1257 | unsigned long ptrace_message; | 1254 | unsigned long ptrace_message; |
1258 | siginfo_t *last_siginfo; /* For ptrace use. */ | 1255 | siginfo_t *last_siginfo; /* For ptrace use. */ |
1259 | #ifdef CONFIG_TASK_XACCT | 1256 | struct proc_io_accounting ioac; |
1260 | /* i/o counters(bytes read/written, #syscalls */ | ||
1261 | u64 rchar, wchar, syscr, syscw; | ||
1262 | #endif | ||
1263 | struct task_io_accounting ioac; | ||
1264 | #if defined(CONFIG_TASK_XACCT) | 1257 | #if defined(CONFIG_TASK_XACCT) |
1265 | u64 acct_rss_mem1; /* accumulated rss usage */ | 1258 | u64 acct_rss_mem1; /* accumulated rss usage */ |
1266 | u64 acct_vm_mem1; /* accumulated virtual memory usage */ | 1259 | u64 acct_vm_mem1; /* accumulated virtual memory usage */ |
@@ -2190,22 +2183,22 @@ extern long sched_group_rt_period(struct task_group *tg); | |||
2190 | #ifdef CONFIG_TASK_XACCT | 2183 | #ifdef CONFIG_TASK_XACCT |
2191 | 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) |
2192 | { | 2185 | { |
2193 | tsk->rchar += amt; | 2186 | tsk->ioac.chr.rchar += amt; |
2194 | } | 2187 | } |
2195 | 2188 | ||
2196 | 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) |
2197 | { | 2190 | { |
2198 | tsk->wchar += amt; | 2191 | tsk->ioac.chr.wchar += amt; |
2199 | } | 2192 | } |
2200 | 2193 | ||
2201 | static inline void inc_syscr(struct task_struct *tsk) | 2194 | static inline void inc_syscr(struct task_struct *tsk) |
2202 | { | 2195 | { |
2203 | tsk->syscr++; | 2196 | tsk->ioac.chr.syscr++; |
2204 | } | 2197 | } |
2205 | 2198 | ||
2206 | static inline void inc_syscw(struct task_struct *tsk) | 2199 | static inline void inc_syscw(struct task_struct *tsk) |
2207 | { | 2200 | { |
2208 | tsk->syscw++; | 2201 | tsk->ioac.chr.syscw++; |
2209 | } | 2202 | } |
2210 | #else | 2203 | #else |
2211 | 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) |