Index: linux/fs/read_write.c =================================================================== --- linux.orig/fs/read_write.c 2004-10-18 14:54:37.000000000 -0700 +++ linux/fs/read_write.c 2004-11-03 16:38:10.270235494 -0800 @@ -216,8 +216,11 @@ ssize_t vfs_read(struct file *file, char ret = file->f_op->read(file, buf, count, pos); else ret = do_sync_read(file, buf, count, pos); - if (ret > 0) + if (ret > 0) { dnotify_parent(file->f_dentry, DN_ACCESS); + current->rchar += ret; + } + current->syscr++; } } @@ -260,8 +263,11 @@ ssize_t vfs_write(struct file *file, con ret = file->f_op->write(file, buf, count, pos); else ret = do_sync_write(file, buf, count, pos); - if (ret > 0) + if (ret > 0) { dnotify_parent(file->f_dentry, DN_MODIFY); + current->wchar += ret; + } + current->syscw++; } } @@ -540,6 +546,9 @@ sys_readv(unsigned long fd, const struct fput_light(file, fput_needed); } + if (ret > 0) + current->rchar += ret; + current->syscr++; return ret; } @@ -558,6 +567,9 @@ sys_writev(unsigned long fd, const struc fput_light(file, fput_needed); } + if (ret > 0) + current->wchar += ret; + current->syscw++; return ret; } @@ -636,6 +648,13 @@ static ssize_t do_sendfile(int out_fd, i retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file); + if (retval > 0) { + current->rchar += retval; + current->wchar += retval; + } + current->syscr++; + current->syscw++; + if (*ppos > max) retval = -EOVERFLOW; Index: linux/include/linux/sched.h =================================================================== --- linux.orig/include/linux/sched.h 2004-10-18 14:53:13.000000000 -0700 +++ linux/include/linux/sched.h 2004-11-03 15:52:01.803397172 -0800 @@ -580,6 +580,8 @@ struct task_struct { * to a stack based synchronous wait) if its doing sync IO. */ wait_queue_t *io_wait; +/* i/o counters(bytes read/written, #syscalls */ + u64 rchar, wchar, syscr, syscw; #ifdef CONFIG_NUMA struct mempolicy *mempolicy; short il_next; /* could be shared with used_math */ Index: linux/kernel/fork.c =================================================================== --- linux.orig/kernel/fork.c 2004-10-18 14:53:13.000000000 -0700 +++ linux/kernel/fork.c 2004-11-03 16:44:23.266042599 -0800 @@ -985,12 +985,21 @@ static task_t *copy_process(unsigned lon clear_tsk_thread_flag(p, TIF_SIGPENDING); init_sigpending(&p->pending); - p->it_real_value = p->it_virt_value = p->it_prof_value = 0; - p->it_real_incr = p->it_virt_incr = p->it_prof_incr = 0; + p->it_real_value = 0; + p->it_virt_value = 0; + p->it_prof_value = 0; + p->it_real_incr = 0; + p->it_virt_incr = 0; + p->it_prof_incr = 0; init_timer(&p->real_timer); p->real_timer.data = (unsigned long) p; - p->utime = p->stime = 0; + p->utime = 0; + p->stime = 0; + p->rchar = 0; /* I/O counter: bytes read */ + p->wchar = 0; /* I/O counter: bytes written */ + p->syscr = 0; /* I/O counter: read syscalls */ + p->syscw = 0; /* I/O counter: write syscalls */ p->lock_depth = -1; /* -1 = no lock */ do_posix_clock_monotonic_gettime(&p->start_time); p->security = NULL;