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


    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 202,0 0 1 0.000000000 225 A WS 17046352 + 8 <- (202,1) 17044304 202,1 0 2 0.000002288 225 Q WS 17046352 + 8 [jbd2/xvda1-8] 202,1 0 3 0.000008167 225 G WS 17046352 + 8 [jbd2/xvda1-8] 202,1 0 4 0.000010829 225 I WS 17046352 + 8 [jbd2/xvda1-8] ^C202,1 0 0 0.000015747 0 m N cfq225S / insert_request 202,1 0 0 0.000016552 0 m N cfq225S / add_to_rr 202,1 0 0 0.000020871 0 m N cfq workload slice:100 202,1 0 0 0.000021950 0 m N cfq225S / set_active wl_prio:0 wl_type:1 202,1 0 0 0.000023149 0 m N cfq225S / fifo=(null) 202,1 0 0 0.000023724 0 m N cfq225S / dispatch_insert 202,1 0 0 0.000025445 0 m N cfq225S / dispatched a request 202,1 0 0 0.000026338 0 m N cfq225S / activate rq, drv=1 202,1 0 5 0.000026463 225 D WS 17046352 + 8 [jbd2/xvda1-8] 202,0 0 6 0.000034989 225 A WS 17046360 + 8 <- (202,1) 17044312 202,1 0 7 0.000035222 225 Q WS 17046360 + 8 [jbd2/xvda1-8] 202,1 0 8 0.000035927 225 G WS 17046360 + 8 [jbd2/xvda1-8] 202,1 0 9 0.000036342 225 I WS 17046360 + 8 [jbd2/xvda1-8] 202,1 0 0 0.000036929 0 m N cfq225S / insert_request 202,1 0 0 0.000037721 0 m N cfq225S / dispatch_insert 202,1 0 0 0.000038336 0 m N cfq225S / dispatched a request 202,1 0 0 0.000038829 0 m N cfq225S / activate rq, drv=2 202,1 0 10 0.000039058 225 D WS 17046360 + 8 [jbd2/xvda1-8] 202,0 0 11 0.000040827 225 A WS 17046368 + 8 <- (202,1) 17044320 202,1 0 12 0.000041061 225 Q WS 17046368 + 8 [jbd2/xvda1-8] 202,1 0 13 0.000041647 225 G WS 17046368 + 8 [jbd2/xvda1-8] 202,1 0 14 0.000041825 225 I WS 17046368 + 8 [jbd2/xvda1-8] 202,1 0 0 0.000042266 0 m N cfq225S / insert_request 202,1 0 0 0.000042776 0 m N cfq225S / dispatch_insert 202,1 0 0 0.000043250 0 m N cfq225S / dispatched a request 202,1 0 0 0.000043626 0 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. [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

    2. ----------------

    CFQ 调度

    [root@server1 ~]# debugfs -R 'stats' /dev/xvda1
    debugfs 1.41.12 (17-May-2010)
    Filesystem volume name:   <none>
    Last mounted on:          /
    Filesystem UUID:          94e4e384-0ace-437f-bc96-057dd64f42ee
    Filesystem magic number:  0xEF53
    Filesystem revision #:    1 (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:              2621440
    Block count:              10485248
    Reserved block count:     524262
    Free blocks:              9190446
    Free inodes:              2555389
    First block:              0
    Block size:               4096
    Fragment size:            4096
    Reserved GDT blocks:      1021
    Blocks per group:         32768
    Fragments per group:      32768
    Inodes per group:         8192
    Inode blocks per group:   512
    RAID stride:              32639
    Flex block group size:    16
    Filesystem created:       Thu Aug 14 21:16:07 2014
    Last mount time:          Tue Jun  7 17:32:09 2016
    Last write time:          Sun Apr 10 21:24:50 2016
    Mount count:              19
    Maximum mount count:      -1
    Last checked:             Wed Jan 20 16:20:12 2016
    Check interval:           0 (<none>)
    Lifetime writes:          12 GB
    Reserved blocks uid:      0 (user root)
    Reserved blocks gid:      0 (group root)
    First inode:              11
    Inode size:               256
    Required extra isize:     28
    Desired extra isize:      28
    Journal inode:            8
    Default directory hash:   half_md4
    Directory Hash Seed:      d5c54a86-d535-4c9b-9dea-e1b8e8088761
    Journal backup:           inode blocks
    Directories:              10660
     Group  0: block bitmap at 1025, inode bitmap at 1041, inode table at 1057
               20899 free blocks, 68 free inodes, 1255 used directories, 0 unused inodes
  • 相关阅读:
    SynchronousQueue、LinkedBlockingQueue、ArrayBlockingQueue性能测试
    JDK源码分析—— ArrayBlockingQueue 和 LinkedBlockingQueue
    ArrayBlockingQueue和LinkedBlockingQueue的区别
    Net处理html页面元素工具类(HtmlAgilityPack.dll)的使用
    WebView混合开发
    对付"反盗链"
    通过代码来操作SQLite的示例
    System.Data.SQLite未能加载文件或程序集
    Using SQLXML Bulk Load in the .NET Environment
    Asynchronous Programming Using Delegates使用委托进行异步编程
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5567553.html
Copyright © 2020-2023  润新知