aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/read_write.c24
-rw-r--r--include/linux/sched.h40
-rw-r--r--kernel/fork.c2
4 files changed, 58 insertions, 12 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1a979ea3b379..7fb37d6f2864 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1810,17 +1810,21 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, filldir_t filld
1810static int proc_pid_io_accounting(struct task_struct *task, char *buffer) 1810static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
1811{ 1811{
1812 return sprintf(buffer, 1812 return sprintf(buffer,
1813#ifdef CONFIG_TASK_XACCT
1813 "rchar: %llu\n" 1814 "rchar: %llu\n"
1814 "wchar: %llu\n" 1815 "wchar: %llu\n"
1815 "syscr: %llu\n" 1816 "syscr: %llu\n"
1816 "syscw: %llu\n" 1817 "syscw: %llu\n"
1818#endif
1817 "read_bytes: %llu\n" 1819 "read_bytes: %llu\n"
1818 "write_bytes: %llu\n" 1820 "write_bytes: %llu\n"
1819 "cancelled_write_bytes: %llu\n", 1821 "cancelled_write_bytes: %llu\n",
1822#ifdef CONFIG_TASK_XACCT
1820 (unsigned long long)task->rchar, 1823 (unsigned long long)task->rchar,
1821 (unsigned long long)task->wchar, 1824 (unsigned long long)task->wchar,
1822 (unsigned long long)task->syscr, 1825 (unsigned long long)task->syscr,
1823 (unsigned long long)task->syscw, 1826 (unsigned long long)task->syscw,
1827#endif
1824 (unsigned long long)task->ioac.read_bytes, 1828 (unsigned long long)task->ioac.read_bytes,
1825 (unsigned long long)task->ioac.write_bytes, 1829 (unsigned long long)task->ioac.write_bytes,
1826 (unsigned long long)task->ioac.cancelled_write_bytes); 1830 (unsigned long long)task->ioac.cancelled_write_bytes);
diff --git a/fs/read_write.c b/fs/read_write.c
index 707ac21700d3..bcb0ef2aae3d 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -274,9 +274,9 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
274 ret = do_sync_read(file, buf, count, pos); 274 ret = do_sync_read(file, buf, count, pos);
275 if (ret > 0) { 275 if (ret > 0) {
276 fsnotify_access(file->f_path.dentry); 276 fsnotify_access(file->f_path.dentry);
277 current->rchar += ret; 277 add_rchar(current, ret);
278 } 278 }
279 current->syscr++; 279 inc_syscr(current);
280 } 280 }
281 } 281 }
282 282
@@ -332,9 +332,9 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
332 ret = do_sync_write(file, buf, count, pos); 332 ret = do_sync_write(file, buf, count, pos);
333 if (ret > 0) { 333 if (ret > 0) {
334 fsnotify_modify(file->f_path.dentry); 334 fsnotify_modify(file->f_path.dentry);
335 current->wchar += ret; 335 add_wchar(current, ret);
336 } 336 }
337 current->syscw++; 337 inc_syscw(current);
338 } 338 }
339 } 339 }
340 340
@@ -675,8 +675,8 @@ sys_readv(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
675 } 675 }
676 676
677 if (ret > 0) 677 if (ret > 0)
678 current->rchar += ret; 678 add_rchar(current, ret);
679 current->syscr++; 679 inc_syscr(current);
680 return ret; 680 return ret;
681} 681}
682 682
@@ -696,8 +696,8 @@ sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
696 } 696 }
697 697
698 if (ret > 0) 698 if (ret > 0)
699 current->wchar += ret; 699 add_wchar(current, ret);
700 current->syscw++; 700 inc_syscw(current);
701 return ret; 701 return ret;
702} 702}
703 703
@@ -779,12 +779,12 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
779 retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file); 779 retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file);
780 780
781 if (retval > 0) { 781 if (retval > 0) {
782 current->rchar += retval; 782 add_rchar(current, retval);
783 current->wchar += retval; 783 add_wchar(current, retval);
784 } 784 }
785 current->syscr++;
786 current->syscw++;
787 785
786 inc_syscr(current);
787 inc_syscw(current);
788 if (*ppos > max) 788 if (*ppos > max)
789 retval = -EOVERFLOW; 789 retval = -EOVERFLOW;
790 790
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 446373535190..76c8e2dc48dd 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1013,8 +1013,10 @@ struct task_struct {
1013 * to a stack based synchronous wait) if its doing sync IO. 1013 * to a stack based synchronous wait) if its doing sync IO.
1014 */ 1014 */
1015 wait_queue_t *io_wait; 1015 wait_queue_t *io_wait;
1016#ifdef CONFIG_TASK_XACCT
1016/* i/o counters(bytes read/written, #syscalls */ 1017/* i/o counters(bytes read/written, #syscalls */
1017 u64 rchar, wchar, syscr, syscw; 1018 u64 rchar, wchar, syscr, syscw;
1019#endif
1018 struct task_io_accounting ioac; 1020 struct task_io_accounting ioac;
1019#if defined(CONFIG_TASK_XACCT) 1021#if defined(CONFIG_TASK_XACCT)
1020 u64 acct_rss_mem1; /* accumulated rss usage */ 1022 u64 acct_rss_mem1; /* accumulated rss usage */
@@ -1649,6 +1651,44 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
1649 1651
1650extern void normalize_rt_tasks(void); 1652extern void normalize_rt_tasks(void);
1651 1653
1654#ifdef CONFIG_TASK_XACCT
1655static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
1656{
1657 tsk->rchar += amt;
1658}
1659
1660static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
1661{
1662 tsk->wchar += amt;
1663}
1664
1665static inline void inc_syscr(struct task_struct *tsk)
1666{
1667 tsk->syscr++;
1668}
1669
1670static inline void inc_syscw(struct task_struct *tsk)
1671{
1672 tsk->syscw++;
1673}
1674#else
1675static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
1676{
1677}
1678
1679static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
1680{
1681}
1682
1683static inline void inc_syscr(struct task_struct *tsk)
1684{
1685}
1686
1687static inline void inc_syscw(struct task_struct *tsk)
1688{
1689}
1690#endif
1691
1652#endif /* __KERNEL__ */ 1692#endif /* __KERNEL__ */
1653 1693
1654#endif 1694#endif
diff --git a/kernel/fork.c b/kernel/fork.c
index d57118da73ff..80284eb488ce 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1038,10 +1038,12 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1038 p->utime = cputime_zero; 1038 p->utime = cputime_zero;
1039 p->stime = cputime_zero; 1039 p->stime = cputime_zero;
1040 p->sched_time = 0; 1040 p->sched_time = 0;
1041#ifdef CONFIG_TASK_XACCT
1041 p->rchar = 0; /* I/O counter: bytes read */ 1042 p->rchar = 0; /* I/O counter: bytes read */
1042 p->wchar = 0; /* I/O counter: bytes written */ 1043 p->wchar = 0; /* I/O counter: bytes written */
1043 p->syscr = 0; /* I/O counter: read syscalls */ 1044 p->syscr = 0; /* I/O counter: read syscalls */
1044 p->syscw = 0; /* I/O counter: write syscalls */ 1045 p->syscw = 0; /* I/O counter: write syscalls */
1046#endif
1045 task_io_accounting_init(p); 1047 task_io_accounting_init(p);
1046 acct_clear_integrals(p); 1048 acct_clear_integrals(p);
1047 1049