Messages in this thread Patch in this message | | | Date | Thu, 21 Oct 2004 18:32:52 -0700 | From | Jay Lan <> | Subject | [Lse-tech] [PATCH 2.6.9 1/2] enhanced accounting data collection |
| |
1/2: acct_io
Enahanced I/O accounting data collection.
Signed-off-by: Jay Lan <jlan@sgi.com>
Index: linux/fs/read_write.c =================================================================== --- linux.orig/fs/read_write.c 2004-09-29 20:05:18.000000000 -0700 +++ linux/fs/read_write.c 2004-10-01 17:09:42.711763439 -0700 @@ -216,8 +216,11 @@ 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 @@ 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,10 @@ fput_light(file, fput_needed); } + if (ret > 0) { + current->rchar += ret; + } + current->syscr++; return ret; } @@ -558,6 +568,10 @@ fput_light(file, fput_needed); } + if (ret > 0) { + current->wchar += ret; + } + current->syscw++; return ret; } @@ -636,6 +650,13 @@ 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-01 17:01:21.412848229 -0700 +++ linux/include/linux/sched.h 2004-10-01 17:09:42.723482260 -0700 @@ -591,6 +591,9 @@ struct rw_semaphore pagg_sem; #endif +/* i/o counters(bytes read/written, #syscalls */ + unsigned long rchar, wchar, syscr, syscw; + }; static inline pid_t process_group(struct task_struct *tsk) Index: linux/kernel/fork.c =================================================================== --- linux.orig/kernel/fork.c 2004-10-01 17:01:21.432379595 -0700 +++ linux/kernel/fork.c 2004-10-01 17:09:42.732271376 -0700 @@ -995,6 +995,7 @@ p->real_timer.data = (unsigned long) p; p->utime = p->stime = 0; + p->rchar = p->wchar = p->syscr = p->syscw = 0; p->lock_depth = -1; /* -1 = no lock */ p->start_time = get_jiffies_64(); p->security = NULL; | |