Wandering Thoughts archives


What per-partition disk IO stats you get from the Linux kernel

A while back I wrote about what disk IO stats you get from the Linux kernel. At the time I talked only about full devices, not partitions, but recently I've become interested in the subject of what IO stats are maintained for partitions (because sometimes you're interested in per-partition information).

The answer depends on what 2.6 kernel version you have. In kernels before 2.6.25, you only have counts of read and write IOs issued and sectors read and written (what I called rio, rsect, wio, and wsect in my original entry). From 2.6.25 onwards, all stats are accurately maintained for partitions as well as whole disks, including time-based statistics and in-flight counts; this goes by the term 'extended partition statistics'.

(At this point I throw brickbats at the kernel's Documentation/iostats.txt, which claims to have been last updated in 2003 and spends a bunch of time talking about the pre-2.6.25 situation, but then has a little note at the end to the effect that all of this is now inapplicable since 2.6.25.)

These days disk stats also show up in sysfs, which is more convenient if you only want stats for a single entity; the format is the same as /proc/diskstats with the first three fields dropped. Since about 2.6.32, sysfs (but not /proc/diskstats) will also give you separate stats for how many read and write IOs are in flight, as well as the merged numbers. This shows up in the inflight sysfs entry, which has two numbers; the first number is reads and the second is writes.

Where all of this is done in the source code has changed since my previous entry. Data is displayed in block/genhd.c (and also fs/partitions/check.c for per-partition sysfs stuff) and is now maintained in block/blk-core.c and block/blk-merge.c, using various bits that are found in include/linux/genhd.h.

I have not checked the kernel code to see how much you can trust these stats for LVM or software RAID devices (or how this has changed over time).

linux/DiskIOStatsII written at 02:45:58; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.