使用blktrace统计磁盘块I/O访问频率 + IO调度CFQ

时间:2022-02-18 09:14:43

http://blog.chinaunix.net/uid-24774106-id-4096470.html

http://blog.csdn.net/wyzxg/article/details/7449821

了解IO协议栈

[root@localhost ~]# stap -l 'ioscheduler.*'
ioscheduler.elv_add_request
ioscheduler.elv_completed_request
ioscheduler.elv_next_request [root@localhost ~]# stap -l 'ioblock.*'
ioblock.end
ioblock.request

mount -t debugfs debugfs /sys/kernel/debug

btrace /dev/xvda1


[root@server1 ~]# btrace /dev/xvda1
, 0.000000000 A WS + <- (,)
, 0.000002288 Q WS + [jbd2/xvda1-]
, 0.000008167 G WS + [jbd2/xvda1-]
, 0.000010829 I WS + [jbd2/xvda1-]
^C202, 0.000015747 m N cfq225S / insert_request
, 0.000016552 m N cfq225S / add_to_rr
, 0.000020871 m N cfq workload slice:
, 0.000021950 m N cfq225S / set_active wl_prio: wl_type:
, 0.000023149 m N cfq225S / fifo=(null)
, 0.000023724 m N cfq225S / dispatch_insert
, 0.000025445 m N cfq225S / dispatched a request
, 0.000026338 m N cfq225S / activate rq, drv=
, 0.000026463 D WS + [jbd2/xvda1-]
, 0.000034989 A WS + <- (,)
, 0.000035222 Q WS + [jbd2/xvda1-]
, 0.000035927 G WS + [jbd2/xvda1-]
, 0.000036342 I WS + [jbd2/xvda1-]
, 0.000036929 m N cfq225S / insert_request
, 0.000037721 m N cfq225S / dispatch_insert
, 0.000038336 m N cfq225S / dispatched a request
, 0.000038829 m N cfq225S / activate rq, drv=
, 0.000039058 D WS + [jbd2/xvda1-]
, 0.000040827 A WS + <- (,)
, 0.000041061 Q WS + [jbd2/xvda1-]
, 0.000041647 G WS + [jbd2/xvda1-]
, 0.000041825 I WS + [jbd2/xvda1-]
, 0.000042266 m N cfq225S / insert_request
, 0.000042776 m N cfq225S / dispatch_insert
, 0.000043250 m N cfq225S / dispatched a request
, 0.000043626 m N cfq225S / activate rq, drv=3
...
blktrace is a block layer IO tracing mechanism which provides detailed informa-tion about request queue operations up to user space.

      mount -t debugfs debugfs /sys/kernel/debug
blktrace -d /dev/sda -o - |blkparse -i - -o blkparse.out
  1. 使用blktrace统计磁盘块I/O访问频率 + IO调度CFQ
  2. [root@server1 ~]# cat blkparse.out |grep cfq
    202,1 0 0 0.000015618 0 m N cfq225S / insert_request
    202,1 0 0 0.000020115 0 m N cfq225S / slice expired t=0
    202,1 0 0 0.000022817 0 m N cfq225S / sl_used=120 disp=7 charge=7 iops=1 sect=56
    202,1 0 0 0.000024892 0 m N cfq workload slice:100
    202,1 0 0 0.000025825 0 m N cfq225S / set_active wl_prio:0 wl_type:1
    202,1 0 0 0.000027072 0 m N cfq225S / fifo=(null)
    202,1 0 0 0.000027564 0 m N cfq225S / dispatch_insert
    202,1 0 0 0.000029452 0 m N cfq225S / dispatched a request
    202,1 0 0 0.000030065 0 m N cfq225S / activate rq, drv=1
    202,1 0 0 0.000041729 0 m N cfq225S / insert_request
    202,1 0 0 0.000042400 0 m N cfq225S / dispatch_insert
    202,1 0 0 0.000043012 0 m N cfq225S / dispatched a request
    202,1 0 0 0.000043463 0 m N cfq225S / activate rq, drv=2
    202,1 0 0 0.005256969 0 m N cfq225S / complete rqnoidle 1
    202,1 0 0 0.005258751 0 m N cfq225S / set_slice=120
    202,1 0 0 0.005263485 0 m N cfq225S / complete rqnoidle

  3. ----------------

CFQ 调度

使用blktrace统计磁盘块I/O访问频率 + IO调度CFQ

[root@server1 ~]# debugfs -R 'stats' /dev/xvda1
debugfs 1.41. (-May-)
Filesystem volume name: <none>
Last mounted on: /
Filesystem UUID: 94e4e384-0ace-437f-bc96-057dd64f42ee
Filesystem magic number: 0xEF53
Filesystem revision #: (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_
file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count:
Block count:
Reserved block count:
Free blocks:
Free inodes:
First block:
Block size:
Fragment size:
Reserved GDT blocks:
Blocks per group:
Fragments per group:
Inodes per group:
Inode blocks per group:
RAID stride:
Flex block group size:
Filesystem created: Thu Aug ::
Last mount time: Tue Jun ::
Last write time: Sun Apr ::
Mount count:
Maximum mount count: -
Last checked: Wed Jan ::
Check interval: (<none>)
Lifetime writes: GB
Reserved blocks uid: (user root)
Reserved blocks gid: (group root)
First inode:
Inode size:
Required extra isize:
Desired extra isize:
Journal inode:
Default directory hash: half_md4
Directory Hash Seed: d5c54a86-d535-4c9b-9dea-e1b8e8088761
Journal backup: inode blocks
Directories:
Group : block bitmap at , inode bitmap at , inode table at
free blocks, free inodes, used directories, unused inodes