simple (dumb) script to track sizes of IOs

Badari Pulavarty pbadari@us.ibm.com
Thu Oct 6 16:48:00 GMT 2005


Hi,

Here is a simple systemtap script to track the sizes of IOs 
that are getting generated (to the driver).

Is this useful for anyone ? Earlier (before systemtap), I did 
this in the kernel to figure out the IO pattern thats getting
generated from a database run (to check the IO merging and 
optimize). Since I was doing it in the kernel, I had better
places to add counters to avoid all the error handling and 
retry cases.

BTW, feel free to enhance it to complete TODO list.

Is there a way, I can print in the order of IO sizes easily ?

Thanks,
Badari

Here is the output:

[root@elm3b23 systemtap.samples]# stap -g iosizes.stp
io sizes tracking, start time=1128617047
iosize  = 124k   iocount = 1
iosize  = 92k    iocount = 1
iosize  = 4k     iocount = 11
iosize  = 8k     iocount = 2
iosize  = 32k    iocount = 2
iosize  = 48k    iocount = 1
iosize  = 172k   iocount = 1
iosize  = 12k    iocount = 1
iosize  = 364k   iocount = 1
iosize  = 2k     iocount = 1
iosize  = 1k     iocount = 1
iosize  = 512k   iocount = 3371
iosize  = 256k   iocount = 5505
iosize  = 72k    iocount = 1
iosize  = 128k   iocount = 6830
iosize  = 44k    iocount = 1
io sizes tracking, end time=1128617074



-------------- next part --------------
#! stap
# Simple (dumb) script to figure out the sizes of IOs getting
# generated.
#
# TODO: 
#	- sort the output by iosizes for easy read
#	- add per device counters
#	- hook it up in right places (to handle failures correctly)
#

global iosizes

probe kernel.function("blk_rq_map_sg") {
   iosizes [$rq->nr_sectors] ++
}

function _(n) { return string(n) } 

function report () {
  foreach (io in iosizes) {
	if (iosizes[io])
		print("iosize  = " . _(io/2) .
		      "k\t iocount = " . _(iosizes[io]) .
		      "\n")
  }
  delete iosizes
}


probe begin {
  print ("io sizes tracking, start time=" . _(gettimeofday_s()) . "\n")
}
probe end {
  report()
  print ("io sizes tracking, end time=" . _(gettimeofday_s()) . "\n")
}


More information about the Systemtap mailing list