3

I was going through iostat man page. According to it,

 %iowait
 Show the percentage of time that the CPU or CPUs were idle during which the system    
 had an outstanding disk I/O request.   

 %idle
 Show the percentage of time that the CPU or CPUs were idle during which the system    
 did not have an outstanding disk I/O request.                  

I didnt understand how iostat figures out that whether the I/O request are outstanding or not.

2 Answers 2

3

iowait is basically The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.

Measured on a per io basis from the front of the io scheduler until io is done. It covers the time that is taken through scheduler, driver, controller, transport (for san), and storage needed to complete each io. It is the average time, in milliseconds, for I/O requests completed by storage and includes the time spent by the requests in the scheduler queue and time spent by storage servicing them.

There are multiple phases of an IO while it is being transferred. After application sends an IO, a request is allocated for it, when the request is granted kernel sees whether it can merge the io to any existing request queue. Time spent in the request queue adds to the total service time. Then after merging is done, the io is submitted to storage. If the storage is under pressure or can't cope with the IO numbers, then our IO has to wait to be serviced by the storage also. So, there are essentially two waiting phases which iostat measure up.

The proc file /proc/diskstats is the one that it refers for the purpose.

4
  • Can you tell me whether i can get all these waiting times from proc. I looked into /proc/diskstats/ and /sys/block/<devicename>/stat` also. Both are containing same metrics but none is having the waiting times. Oct 25, 2012 at 18:47
  • Hey, I will check it but no time now. Gimme few hours and I will get back. Oct 25, 2012 at 18:51
  • @pradeepchhetri /proc/diskstats/ only shows disk activity, I already told you where you get the time spent waiting for I/O.
    – scai
    Oct 26, 2012 at 6:53
  • @scai: Sorry for that, I didnt notice. Thanks a lot. Oct 26, 2012 at 7:02
0

By asking the kernel. This information is directly contained in the first line of /proc/stat, see the proc documentation.

2
  • I know that it is getting from proc filesystem, but i want to know how it decide whether this time disk I/O is outstanding. Oct 25, 2012 at 10:02
  • 1
    Please see the linked documentation. The 4th number (5th column) is the idle value reported by iostat and the 5th number (6th column) of the first line is the iowait value reported by iostat. It doesn't have to decide anything, the kernel already does.
    – scai
    Oct 25, 2012 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .