aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/base.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d82d800389f6..e74308bdabd3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2405,35 +2405,18 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2405 u64 rchar, wchar, syscr, syscw; 2405 u64 rchar, wchar, syscr, syscw;
2406 struct task_io_accounting ioac; 2406 struct task_io_accounting ioac;
2407 2407
2408 if (!whole) { 2408 rchar = task->rchar;
2409 rchar = task->rchar; 2409 wchar = task->wchar;
2410 wchar = task->wchar; 2410 syscr = task->syscr;
2411 syscr = task->syscr; 2411 syscw = task->syscw;
2412 syscw = task->syscw; 2412 memcpy(&ioac, &task->ioac, sizeof(ioac));
2413 memcpy(&ioac, &task->ioac, sizeof(ioac));
2414 } else {
2415 unsigned long flags;
2416 struct task_struct *t = task;
2417 rchar = wchar = syscr = syscw = 0;
2418 memset(&ioac, 0, sizeof(ioac));
2419 2413
2420 rcu_read_lock(); 2414 if (whole) {
2421 do { 2415 unsigned long flags;
2422 rchar += t->rchar;
2423 wchar += t->wchar;
2424 syscr += t->syscr;
2425 syscw += t->syscw;
2426
2427 ioac.read_bytes += t->ioac.read_bytes;
2428 ioac.write_bytes += t->ioac.write_bytes;
2429 ioac.cancelled_write_bytes +=
2430 t->ioac.cancelled_write_bytes;
2431 t = next_thread(t);
2432 } while (t != task);
2433 rcu_read_unlock();
2434 2416
2435 if (lock_task_sighand(task, &flags)) { 2417 if (lock_task_sighand(task, &flags)) {
2436 struct signal_struct *sig = task->signal; 2418 struct signal_struct *sig = task->signal;
2419 struct task_struct *t = task;
2437 2420
2438 rchar += sig->rchar; 2421 rchar += sig->rchar;
2439 wchar += sig->wchar; 2422 wchar += sig->wchar;
@@ -2444,11 +2427,20 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2444 ioac.write_bytes += sig->ioac.write_bytes; 2427 ioac.write_bytes += sig->ioac.write_bytes;
2445 ioac.cancelled_write_bytes += 2428 ioac.cancelled_write_bytes +=
2446 sig->ioac.cancelled_write_bytes; 2429 sig->ioac.cancelled_write_bytes;
2447 2430 while_each_thread(task, t) {
2431 rchar += t->rchar;
2432 wchar += t->wchar;
2433 syscr += t->syscr;
2434 syscw += t->syscw;
2435
2436 ioac.read_bytes += t->ioac.read_bytes;
2437 ioac.write_bytes += t->ioac.write_bytes;
2438 ioac.cancelled_write_bytes +=
2439 t->ioac.cancelled_write_bytes;
2440 }
2448 unlock_task_sighand(task, &flags); 2441 unlock_task_sighand(task, &flags);
2449 } 2442 }
2450 } 2443 }
2451
2452 return sprintf(buffer, 2444 return sprintf(buffer,
2453 "rchar: %llu\n" 2445 "rchar: %llu\n"
2454 "wchar: %llu\n" 2446 "wchar: %llu\n"
@@ -2457,13 +2449,9 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2457 "read_bytes: %llu\n" 2449 "read_bytes: %llu\n"
2458 "write_bytes: %llu\n" 2450 "write_bytes: %llu\n"
2459 "cancelled_write_bytes: %llu\n", 2451 "cancelled_write_bytes: %llu\n",
2460 (unsigned long long)rchar, 2452 rchar, wchar, syscr, syscw,
2461 (unsigned long long)wchar, 2453 ioac.read_bytes, ioac.write_bytes,
2462 (unsigned long long)syscr, 2454 ioac.cancelled_write_bytes);
2463 (unsigned long long)syscw,
2464 (unsigned long long)ioac.read_bytes,
2465 (unsigned long long)ioac.write_bytes,
2466 (unsigned long long)ioac.cancelled_write_bytes);
2467} 2455}
2468 2456
2469static int proc_tid_io_accounting(struct task_struct *task, char *buffer) 2457static int proc_tid_io_accounting(struct task_struct *task, char *buffer)