diff options
-rw-r--r-- | fs/proc/base.c | 10 | ||||
-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 | ||||
-rw-r--r-- | kernel/tsacct.c | 14 |
5 files changed, 44 insertions, 57 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 3d94906c7aa8..01ed610f9b87 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2403,7 +2403,7 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, | |||
2403 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 2403 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
2404 | static int do_io_accounting(struct task_struct *task, char *buffer, int whole) | 2404 | static int do_io_accounting(struct task_struct *task, char *buffer, int whole) |
2405 | { | 2405 | { |
2406 | struct proc_io_accounting acct = task->ioac; | 2406 | struct task_io_accounting acct = task->ioac; |
2407 | unsigned long flags; | 2407 | unsigned long flags; |
2408 | 2408 | ||
2409 | if (whole && lock_task_sighand(task, &flags)) { | 2409 | if (whole && lock_task_sighand(task, &flags)) { |
@@ -2423,10 +2423,10 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole) | |||
2423 | "read_bytes: %llu\n" | 2423 | "read_bytes: %llu\n" |
2424 | "write_bytes: %llu\n" | 2424 | "write_bytes: %llu\n" |
2425 | "cancelled_write_bytes: %llu\n", | 2425 | "cancelled_write_bytes: %llu\n", |
2426 | acct.chr.rchar, acct.chr.wchar, | 2426 | acct.rchar, acct.wchar, |
2427 | acct.chr.syscr, acct.chr.syscw, | 2427 | acct.syscr, acct.syscw, |
2428 | acct.blk.read_bytes, acct.blk.write_bytes, | 2428 | acct.read_bytes, acct.write_bytes, |
2429 | acct.blk.cancelled_write_bytes); | 2429 | acct.cancelled_write_bytes); |
2430 | } | 2430 | } |
2431 | 2431 | ||
2432 | static int proc_tid_io_accounting(struct task_struct *task, char *buffer) | 2432 | static int proc_tid_io_accounting(struct task_struct *task, char *buffer) |
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); |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index f9cd2561689c..8ebcd8532dfb 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -94,14 +94,14 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |||
94 | stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB; | 94 | stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB; |
95 | mmput(mm); | 95 | mmput(mm); |
96 | } | 96 | } |
97 | stats->read_char = p->ioac.chr.rchar; | 97 | stats->read_char = p->ioac.rchar; |
98 | stats->write_char = p->ioac.chr.wchar; | 98 | stats->write_char = p->ioac.wchar; |
99 | stats->read_syscalls = p->ioac.chr.syscr; | 99 | stats->read_syscalls = p->ioac.syscr; |
100 | stats->write_syscalls = p->ioac.chr.syscw; | 100 | stats->write_syscalls = p->ioac.syscw; |
101 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 101 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
102 | stats->read_bytes = p->ioac.blk.read_bytes; | 102 | stats->read_bytes = p->ioac.read_bytes; |
103 | stats->write_bytes = p->ioac.blk.write_bytes; | 103 | stats->write_bytes = p->ioac.write_bytes; |
104 | stats->cancelled_write_bytes = p->ioac.blk.cancelled_write_bytes; | 104 | stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes; |
105 | #else | 105 | #else |
106 | stats->read_bytes = 0; | 106 | stats->read_bytes = 0; |
107 | stats->write_bytes = 0; | 107 | stats->write_bytes = 0; |