Skip to contentSkip to conversation

BSD accounting IO stats

PATCH Andi Kleen 4 participants 4 messages Aug 2, 2004 – Aug 3, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw

drivers/block/ll_rw_blk.c void drive_stat_acct(struct request *rq, · line 1952

Quoted 8 lines · Guillaume Thouvenin

diff -uprN -X dontdiff linux-2.6.8-rc2/drivers/block/ll_rw_blk.c linux-2.6.8-rc2+BSDacct_IO/drivers/block/ll_rw_blk.c

drivers/block/ll_rw_blk.c +1 -0
@@ -1949,10 +1949,12 @@ void drive_stat_acct(struct request *rq,
 
 	if (rw == READ) {
 		disk_stat_add(rq->rq_disk, read_sectors, nr_sectors);
+		current->rblk += nr_sectors;

This doesn't look very useful, because most writes which are flushed delayed would get accounted to pdflushd. Using such inaccurate data for accounting sounds quite dangerous to me.

If you really wanted to do this i guess you would need to track the pid of the process and account it there. But the process may be already gone, so it would better fit into some other longer lived data structure (like the uid)

Overall I don't think this accounting is worth it because doing it right would be quite some overhead and doing it in a simple way like this patch is too inaccurate.

-Andi

#2 lore raw
Quoted 5 lines · Andi Kleen

This doesn't look very useful, because most writes which are flushed delayed would get accounted to pdflushd.

If you really wanted to do this i guess you would need to track the pid of the process and account it there.

It may be easier to do this at write(2) time, making the assumption that most IO done there will eventually hit the filesystem.

Not sure what to do at read time, the current code may well be good enough.

Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
#3 lore raw
Quoted 3 lines · Rik van Riel

It may be easier to do this at write(2) time, making the assumption that most IO done there will eventually hit the filesystem.

but for lots of loads that's not true, consider the case of temporary files which usually never hit the disk before being unlinked

--cw

#4 lore raw
In reply to Andi Kleen
Quoted 5 lines · Andi Kleen
Quoted 5 lines

diff -uprN -X dontdiff linux-2.6.8-rc2/drivers/block/ll_rw_blk.c linux-2.6.8-rc2+BSDacct_IO/drivers/block/ll_rw_blk.c

drivers/block/ll_rw_blk.c +0 -0
@@ -1949,10 +1949,12 @@ void drive_stat_acct(struct request *rq,
 
Quoted 12 lines

drivers/block/ll_rw_blk.c void drive_stat_acct(struct request *rq, · line 1954

Quoted 5 lines
drivers/block/ll_rw_blk.c +1 -0
 	if (rw == READ) {
 		disk_stat_add(rq->rq_disk, read_sectors, nr_sectors);
+		current->rblk += nr_sectors;
 
 

This doesn't look very useful, because most writes which are flushed delayed would get accounted to pdflushd. Using such inaccurate data for accounting sounds quite dangerous to me.

I agree with that. Like you and Andrew said, this metric (write block) is just an estimate (quite wrong indeed) of what really occurred in the system because some writings are accounted elsewhere (pdflush or journaling file system).

I also agree that a rough estimation is not very interesting, therefore I'm working on another patch to provide accurate values.

Best,
Guillaume