Ahoy,

On 2003/02/12 23:13, I posted here a question about tracing physical disk I/O on a Linux system:

How does one go about tracing *physical* disk I/O on Linux?
Level 1: trace physical I/O requests:
   "wrote 4 sectors at offset 533624 on /dev/hda1"
Level 2: report/filter-by PID:
   "PID 256 (/bin/foo) wrote 4 sectors at offset 533624 on /dev/hda1"
Level 3: map physical locations back to files:
   "PID 256 (/bin/foo) wrote 2048 bytes to inode 535 (/tmp/foo)"
To goal is to understand and reduce disk usage on a loaded system.
It would suffice to get totals per file/process over several seconds
instead of per-event notification.

It turns out that "Level 2" functionality is available as part of laptop_mode patch, present in stock kernel 2.4.23+ (an equivalent for 2.6.x is in the works: see http://lwn.net/Articles/64883/).


Quoth Documentation/laptop-mode.txt:
"It can happen that the disk still keeps spinning up and you don't quite know why or what causes it. The laptop mode patch has a little helper for that as well, /proc/sys/vm/block_dump. When set to 1, it will dump info to the kernel message buffer about what process caused the io."


The printout includes PID, device, offset and block count.

As for "Level 3" functionality (i.e., getting the filename), I think this can be done invoking d_path() on the dentry(s) pointed to by the inode associated with the disk i/o request; the inode can be retrieved as bh->b_page->mapping->host in 2.4.24's submit_bh(), or bio->bi_io_vec[i].bv_page->mapping->host (in 2.6.1's submit_bio()).


Eran


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Reply via email to