3
12
2014
23

blktrace 使用

1.安装

sudo apt-get install blktrace

若显示已经挂在则不必再挂载。否则执行如下指令进行挂载:

sudo mount -t debugfs debugfs /sys/kernel/debug

2.测试参数

安装好以后就是测试了。测试语法如下:

blktrace -d dev [-r debugfs_path] [-o output] [-k] [-w time] [-a action] [-A action_mask] ..

blktrace选项如下:

-r trace文件默认挂载地址为/sys/kernel/debug。-r参数能重新指定挂载地址

-a mask 缺省的为所有的事件都要trace,加入-a参数可以添加过滤器,即只观察想观察的事件

-b size 指定收集trace缓存的大小,收集debugfs files的大小,并非文件系统读写时的缓存

-n num 指定收集trace的缓存个数,同上-b 。

-o output 指定输出文件名字,假设你的名字为name 输出文件为name.blktrce.cpu。若你有两个cpu,则生成两个文件。-o的缺省名字为设备名。见下:

-w time 指令运行秒数。-w 5 运行5秒

-k kill 杀掉正在运行的进程,-k后不需要加参数

其中-a 滤镜后跟的参数如下

以下是别人的解释:
 
-A hex-mask			#设置过滤信息mask成十六进制mask
 -a mask			#添加mask到当前的过滤器
 -b size			#指定缓存大小for提取的结果,默认为512KB
 -d dev			#添加一个设备追踪
 -I file			#Adds the devices found in file as devices to trace
 -k			#杀掉正在运行的追踪
 -n num-sub			#指定缓冲池大小,默认为4个子缓冲区 
 -o file			#指定输出文件的名字
 -r rel-path			#指定的debugfs挂载点
 -V			#版本号 
 -w seconds			#设置运行的时间
 
3.测试实例
 
Usage: blktrace 2.0.0 -d <dev> [ -r debugfs path ] [ -o <output> ] [-k ] [ -w time ]
[ -a action ] [ -A action mask ] [ -I  <devs file> ] [ -v ]
 
实例1:

由上面这个例子,得出:

1.结束测试ctrl+c

2.生成blktrace文件的缺省名字是由"设备名字+blktrace+cpu号"组成

 

实例2:

blktrace -d /dev/sda -k

故若要kill掉sda的blktrace则命令为

 

实例3:

 blktrace -d /dev/sdb -w 10 -o blkt1

运行完毕后有两个输出文件分别是blkt1.blktrace.0和blkt1.blktrace.1。之所以有两个输出文件,这与运行系统cpu个数有关。这两个输出文件时二进制的,不能直接打开,需要如下指令转化为可读取文件

blkparse -i blkt1.blktrace.0 -o blkt1.txt 

该指令含义就是解析blkt1.blktrace.0,生成可读取blkt1.txt文件

若将两条指令合并,则为如下形式、

blktrace -d /dev/sda -o - |blkparse -i - -o blkparse.out

 

 

实例4:

blktrace -d /dev/sda -o - |blkparse -i - 

 

若检测结果希望直接显示在终端屏幕上,即以live形式检测。用上述指令

 

 

4 测试结果

通过blkparse解析文件如下:各个列的含义在第1,2,3行给出

倒数第三列为action,该列不同字母的具体含义如下:

C – complete A previously issued request has been completed. The output will detail the sector and size of that request, as well as the success or failure of it.
D – issued A request that previously resided on the block layer queue or in the io scheduler has been sent to the driver.
I – inserted A request is being sent to the io scheduler for addition to the internal queue and later service by the driver. The request is fully formed at this time.
Q – queued This notes intent to queue io at the given location. No real requests exists yet.
B – bounced The data pages attached to this bio are not reachable by the hardware and must be bounced to a lower memory location. This causes a big slowdown in io performance, since the data must be copied to/from kernel buffers. Usually this can be fixed with using better hardware -either a better io controller, or a platform with an IOMMU.
m – message Text message generated via kernel call to blk add trace msg.
M – back merge A previously inserted request exists that ends on the boundary of where this io begins, so the io scheduler can merge them together.
F – front merge Same as the back merge, except this io ends where a previously inserted requests starts.
G – get request To send any type of request to a block device, a struct request container must be allocated first.
S – sleep No available request structures were available, so the issuer has to wait for one to be freed.
P – plug When io is queued to a previously empty block device queue, Linux will plug the queue in anticipation of future ios being added before this data is needed.
U – unplug Some request data already queued in the device, start sending requests to the driver. This may happen automatically if a timeout period has passed (see next entry) or if a number of requests have been added to the queue.
T – unplug due to timer If nobody requests the io that was queued after plugging the queue, Linux will automatically unplug it after a defined period has passed.
X – split On raid or device mapper setups, an incoming io may straddle a device or internal zone and needs to be chopped up into smaller pieces for service. This may indicate a performance problem due to a bad setup of that raid/dm device, but may also just be part of normal boundary conditions. dm is notably bad at this and will clone lots of io.
A – remap For stacked devices, incoming io is remapped to device below it in the io stack. The remap action details what exactly is being remapped to what.
 
倒数第二列含义如下:
This is a small string containing at least one character (’R’ for read, ’W’ for write, or ’D’ for block discard operation), and optionally either a ’B’ (for barrier operations) or ’S’ (for synchronous operations).
即倒数第二列可以判断读、写or删除
另外B barrier operations
    S 同步操作

 

 

 
 
 
5.blktrace附录:
1.对应官方文档3.1.2 节
blktrace区分两种形式的块层的请求。file system和scsi commands。前者是文件系统的请求,后者使pc请求。file system的请求为读写请求,比如说在一个指定磁盘的指定位置读取一定大小的内容。这些请求一般由用户程序产生,但有时也会由vm把脏数据写到磁盘或者文件系统同步超级快或者日志块到disk而产生。pc请求为SCSI命令。blktrace 将命令数据块作为负载,这样blkparse可以解析它。
 
2.对应官方文档4.1节

 

blkparse还有其他参数可供选择,如下,我对此没做深入研究,故没给出解释:

以上参数部分解释:

-b 一次性处理的大小,即解析成结果时一次性解析的大小,缺省值为512

 

3.今天运行时碰到了一下问题

问题的原因是,我运行的目录错了。我在虚拟机上通过v-box,挂在了一个与windows共享的文件夹,即 mount -t vboxsf V-box /home/share 。在home/share路径下运行时,blktrace会出错。

Category: blktrace | Tags: | Read Count: 3347
Avatar_small
لی ویوسوہ ہو یار 说:
2021年8月09日 16:51

This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. soap2day.com

Avatar_small
Digital Ali 说:
2021年9月05日 15:14

I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google. m4ufree

Avatar_small
Digital Ali 说:
2021年9月11日 16:57

Excellent post. I was always checking this blog, and I’m impressed! Extremely useful info specially the last part, I care for such information a lot. I was exploring this particular info for a long time. Thanks to this blog my exploration has ended. https://docs.google.com/spreadsheets/d/1ntiogcbDulo3Vl9Htd7Jl9Xy-2kUp7-F33vbQ4q67Uc/edit#gid=409280497

Avatar_small
Digital Ali 说:
2021年9月12日 20:14

Yes, I am entirely agreed with this article, and I just want say that this article is very helpful and enlightening. I also have some precious piece of concerned info !!!!!!Thanks. worm drive circular saw

Avatar_small
Gullam Mohiyoddin 说:
2021年9月27日 19:59

Dazzling data! I genuinely ran over your blog and have been taking a gander at along. I figured I would leave my first comment. I don't have even the remotest bit of data what to say close to that I have. เสือมังกร ออนไลน์

Avatar_small
Gullam Mohiyoddin 说:
2021年9月29日 03:34

Sees for paper an especially strong composi แทงไฮโล

Avatar_small
William 说:
2021年9月29日 19:49

Dazzling data! I genuinely ran over your blog and have been taking a gander at along. I figured I would leave my first comment. I don't have even the remotest bit of data what to say close to that I have. starvegus

Avatar_small
William 说:
2021年9月30日 17:22

I use as demonstrated by an overall perspective striking surfaces : you will discover these things by: บาคาร่า ทดลอง เล่น"

Avatar_small
William 说:
2021年9月30日 22:45

So part to occur over your faltering on the web diary. Your blog gets me a muddling trade of impacting.. Salubrious pack close to the scene. sagaming

Avatar_small
William Johnson 说:
2021年10月02日 16:34

Cool you structure, the information is genuinely salubrious further deck, I'll give you a party with my scene. metamorphosis literary agency

Avatar_small
William Johnson 说:
2021年10月02日 22:17

I like to propose OK paying unessential defect to fit information and stood up concerning parts, fittingly notice it: แทงหวย

Avatar_small
Dave 说:
2021年10月05日 18:48

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. PGSLOT

Avatar_small
link 说:
2021年10月05日 21:12

Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. สล็อตออนไลน์

Avatar_small
link 说:
2021年10月07日 20:36

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. soap2day

Avatar_small
link 说:
2021年10月10日 16:06

Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. North American Bancard ISO Program

Avatar_small
William Johnson 说:
2021年10月22日 12:10

I invite you to the page where you can keep with amazing information on close region. 카지노사이트

Avatar_small
Dave 说:
2021年10月31日 14:25

I am thankful to you for sharing this plethora of useful information. I found this resource utmost beneficial for me. Thanks a lot for hard work. Football news and prediction

Avatar_small
Dave 说:
2021年11月21日 19:02

Merely a smiling visitant here to share the love (:, btw outstanding style. On page SEO

Avatar_small
Dave 说:
2021年12月14日 13:08

this is really nice to read..informative post is very good to read..thanks a lot! Adobe Illustrator Crack

Avatar_small
seo 说:
2021年12月26日 00:02

Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! <a href="https://www.alrafayglobal.com">https://www.alrafayglobal.com</a>

Avatar_small
William Johnson 说:
2022年1月20日 00:45

Benefit as shown by an overall perspective premium substances - you will see that individual for: https://twitchviral.com/blog/how-to-earn-money-on-twitch/

Avatar_small
jams 说:
2022年7月19日 22:01

This is great knowledgeable content <a href="https://utahhelicalpiers.com/">foundation repair Utah</a>

Avatar_small
NCERT Term 2 Sample 说:
2022年9月16日 23:04

Session 2 of the Course is called Term 2, and the Class 2nd Standard students who prepared for their examination tests can download the NCERT 2nd Term Question Paper 2023 Pdf with Answers for all Languages and Subjects of the Course. Every Central Board and other Schools have conducted their examination tests as per the revised syllabus and curriculum designed and published by NCERT.NCERT Term 2 Sample Paper Class 2 Every year the NCERT has published the study and learning material for every 2nd class student studying at all locations of the country for both SA-2, FA3, FA-4 and Assignment exams to Hindi mediu.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com