惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
L
Lohrmann on Cybersecurity
S
Securelist
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
T
Troy Hunt's Blog
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
Latest news
Latest news
Hacker News - Newest:
Hacker News - Newest: "LLM"
NISL@THU
NISL@THU
The Hacker News
The Hacker News
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
O
OpenAI News
P
Proofpoint News Feed
Know Your Adversary
Know Your Adversary
G
GRAHAM CLULEY
博客园_首页
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题
博客园 - 叶小钗
L
LINUX DO - 最新话题
Martin Fowler
Martin Fowler
N
News | PayPal Newsroom
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
PCI Perspectives
PCI Perspectives
月光博客
月光博客
IT之家
IT之家
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

hwchiu learning note Blog

Kubernetes 怎麼計算 imageFS | hwchiu learning note Nginx Proxy_Pass 不會重新查詢 DNS | hwchiu learning note Multus 下如何透過 network policy 設定 | hwchiu learning note Linux Bridge MTU | hwchiu learning note Kubevirt 初體驗 | hwchiu learning note [MacOS ]隨手筆記 Sed 與 Rename 的使用 | hwchiu learning note Docusaurus 使用 blog mode 後連結一直反白的問題 | hwchiu learning note gcloud 切換帳號 | hwchiu learning note k8s 內安裝 redis-cluster | hwchiu learning note Helm Chart 中如何根據條件來動態安裝 Template 內的物件 | hwchiu learning note GCS 操作上注意事項 | hwchiu learning note istio 操作記錄 | hwchiu learning note terraform | hwchiu learning note Kubernetes GKE 維運上小筆記 | hwchiu learning note Git 修改 author/committer | hwchiu learning note GCP NAT 相關筆記 | hwchiu learning note gcloud ssh 到 GCP VM | hwchiu learning note CloudSQL 收費注意事項 | hwchiu learning note Loki 安裝上的參數調整以及 Ring 的問題除錯 | hwchiu learning note kustomize + helm | hwchiu learning note 觀測 K8s 內 OOM 事件 | hwchiu learning note GKE 上的 RBAC 筆記 | hwchiu learning note 本地產生 jwt token | hwchiu learning note ArgoCD 安裝筆記 | hwchiu learning note CircleCI Context 的使用 | hwchiu learning note 透過 GCP IAP Gateway 來保護 GKE 內的網站 | hwchiu learning note 閱讀筆記: 「SRE 的工作介绍」 | hwchiu learning note 閱讀筆記: 「DevOps is a failure」 | hwchiu learning note 閱讀筆記: 「面試人生 - 設計一個簡易的分散式 Job Scheduler」 | hwchiu learning note 閱讀筆記: 「Cloudflare 06/21 災後報告」 | hwchiu learning note 閱讀筆記: 「啟動 container 直接 kernel panic 的 bug」 | hwchiu learning note 閱讀筆記: 「分散式系統上的常見網路謬誤」 | hwchiu learning note 閱讀筆記: 「為什麼有些工程師不相信 Best Practices 」 | hwchiu learning note 閱讀筆記: 「使用 StressChaos 的經驗來學習 Pod Memory 使用情況」 | hwchiu learning note 閱讀筆記: 「/proc/meminfo 與 free 指令的內容比較」 | hwchiu learning note 閱讀筆記: 「goss, 一個簡易且迅速的 server 驗證工具」 | hwchiu learning note 閱讀筆記: 「如何寫出有意義的討論訊息 」 | hwchiu learning note 閱讀筆記: 「如何提供專業 Code Review 意見」 | hwchiu learning note 閱讀筆記: 「Mizu, 一套用來檢視 Kubernetes Traffic 的視覺化工具」 | hwchiu learning note 閱讀筆記: 「Tetragon, 基於 eBPF 的 Kubernetes 資安管理工具」 | hwchiu learning note 閱讀筆記: 「Datree, Kubernetes Configuration 檢查工具」 | hwchiu learning note 閱讀筆記: 「基於 eBPF 的 ServiceMesh」 | hwchiu learning note 閱讀筆記: 「提升 DevOps 技術的免費書籍」 | hwchiu learning note 閱讀筆記: 「新手閱讀,我踩過的 Terraform 各種雷」 | hwchiu learning note 閱讀筆記: 「容器的除錯之路,遇到 Permission Denied 該怎麼辦」 | hwchiu learning note 閱讀筆記: 「成為軟體架構師的閱讀之路」 | hwchiu learning note 閱讀筆記: 「使用 serverless 5年後的心酸經驗談」 | hwchiu learning note 閱讀筆記: 「istio 下因為YAML 與 Go template 結合產生的 CVE」 | hwchiu learning note 閱讀筆記: 「三座獨立 k8s cluster 還是一個跨三個地區的 k8s cluster ?」 | hwchiu learning note 閱讀筆記: 「DevOps 的 2022 學習之路」 | hwchiu learning note 閱讀筆記: 「強化 Kubernetes 叢集的必備工具」 | hwchiu learning note 閱讀筆記: 「你真的有正確使用 SSH 嗎?」 | hwchiu learning note 閱讀筆記: 「透過 Kubernetes Event-Driver Autoscaler(KEDA) 來根據各種指標動態擴充容器」 | hwchiu learning note 閱讀筆記: 「升級 Kubernetes 1.22 的注意事項」 | hwchiu learning note 閱讀筆記: 「kubectl delete 的行為跟 docker delete 完全不同」 | hwchiu learning note 閱讀筆記: 「Dockerfile 中透過 COPY --chomd 比透過 RUN chomd 可以省下更多空間」 | hwchiu learning note 閱讀筆記: 「軟體工程師你真的工作的很開心嗎??」 | hwchiu learning note 閱讀筆記: 「如何於 Docker 環境中運行 rootless 模式」 | hwchiu learning note 閱讀筆記: 「一個用來管理 Kubernetes 開源工具的開源工具」 | hwchiu learning note 閱讀筆記: 「為什麼 3A 大作的遊戲室都不愛喜歡使用 STL」 | hwchiu learning note 閱讀筆記: 「Terraform 生態下的五個相關輔助工具」 | hwchiu learning note 閱讀筆記: 「Facebook 內的文化特別之處」 | hwchiu learning note 閱讀筆記: 「Package Maintainers 應該要具備的資安概念」 | hwchiu learning note 閱讀筆記: 「如何判別到底要不要使用 Service Mesh」 | hwchiu learning note 閱讀筆記: 「透過 Helm 與 Terraform 來自動 Re-new Cloudflare origin CA」 | hwchiu learning note 閱讀筆記: 「20年工程師生涯教會我的 20 件事情」 | hwchiu learning note 閱讀筆記: 「Kubernetes 紀錄片 」 | hwchiu learning note 閱讀筆記: 「Golang 原始碼的的版本控制歷史」 | hwchiu learning note 閱讀筆記: 「大家總是喜歡誇大自己的工作時數」 | hwchiu learning note 閱讀筆記: 「ClickHouse 與 Elasticsearch 的比較」 | hwchiu learning note 閱讀筆記: 「Paypal 如何調整 Kubernetes 讓其規模達到四千節點,20萬個 Pod」 | hwchiu learning note 閱讀筆記: 「macOS 的 fsync 實作其實跟大家想像的完全不同 」 | hwchiu learning note 閱讀筆記: 「 取代 Docker Desktop 的高效率開發環境」 | hwchiu learning note 閱讀筆記: 「 Kubernetes 四種不同開發環境的比較」 | hwchiu learning note 閱讀筆記: 「 談談遷移應用程式到 Kubernetes 內的失敗經驗談」 | hwchiu learning note 閱讀筆記: 「GitHub 上常常看到的奇妙 commit 到底是什麼?」 | hwchiu learning note 閱讀筆記: 「透過一點小技巧讓你的 Makefile 有一個更好的 Help說明」 | hwchiu learning note 閱讀筆記: 「視覺化系統內 iptables 規則」 | hwchiu learning note hwchiu learning note 閱讀筆記: 「如何使用 jq 讓你的 kubectl更為強大」 | hwchiu learning note 閱讀筆記: 「PwnKit, 長達 12 年可以讓一般使用者輕鬆變成 Root 的 CVE」 | hwchiu learning note 閱讀筆記: 「Linux 5.17 將使用 BLAKE2s 來替代 SAH1 來達到更安全更快速的隨機亂數產生器」 | hwchiu learning note 閱讀筆記: 「Kubernetes 內透過 DNS-01 處理 wildcard TLS 的兩三事」 | hwchiu learning note 閱讀筆記: 「透過 Crossplane 與 ArgoCD 來達成應用程式與基礎建設的 GitOps 部署方式」 | hwchiu learning note 閱讀筆記: 「The pains of GitOps 1.0」 | hwchiu learning note 閱讀筆記: 「NPM 的 colors modules 打亂一堆人...」 | hwchiu learning note 閱讀筆記: 「2021年回顧,因為 DB 的效能的爭論所以我女友跟我分手了....」 | hwchiu learning note 閱讀筆記: 「使用 OpenKruise v1.0 提供更進階的 workload 部署與升級」 | hwchiu learning note 閱讀筆記: 「透過 Kubefarm 來自動化幫實體機器打造基於 Kubernetes in Kubernetes 的 Kubernetes 環境」 | hwchiu learning note 閱讀筆記: 「Meta 如何打造一個供多團隊使用的 SLI/SLO 設定與觀測平台」 | hwchiu learning note 閱讀筆記: 「多年工作經驗總是搞砸電話面試, why ?」 | hwchiu learning note 系統設計文,探討交友app背後的設計理念 | hwchiu learning note 2021-年度回顧 | hwchiu learning note [Cloud Design Pattern] - Ambassador 模式 | hwchiu learning note 是時候停止使用 python 3.6 | hwchiu learning note 工作20 餘年的軟體架構經驗談 | hwchiu learning note Dockerfile 內 Shell/Exec 的用法差異 | hwchiu learning note Bash 下要如何處理 Signal | hwchiu learning note Infrastructure 各種踩雷經驗 | hwchiu learning note 建置 Container Image 中的 Anti-Patterns | hwchiu learning note
Blktrace, Blkparse and Fio example | hwchiu learning note
HungWei ChiuBlogger · 2017-06-02 · via hwchiu learning note Blog

blktrace is a block layer IO tracing mechanism which provide detailed information about request queue operations up to user space.

blkparse will combine streams of events for various devices on various CPUs, and produce a formatted output the the event information. It take the output of above tool blktrace and convert those information into fency readable form.

In the following, We will use those tools blktrace and blkparse to help us to observe sector numbers which has been written by fio requests. We will use the fil to generate two diffenrt IO pattern requests, sequence write and random write.

Environment

OS: Ubuntu 14.04 Storage: NVME FIO: fio-2.19-12-gb94d blktrace: 2.0.0 blkparse: 1.1.0

you can use following commands to install blktrace and blkparse

apt-get install -y blktrace

Experiment

Step1

In order to make the output of blkparse more easily to read, we set the numjobs to 1. Following is my fio config

[global]
iodepth=256
numjobs=1
direct=1

time_based
runtime=120
group_reporting
size=5G
ioengine=libaio

filename=/dev/nvme1n1
[rw]
bs=4k
rw=randwrite

[sw]
bs=64k
rw=write

After we setup the fio config, use the fio to generate the IO request. In this example, we ask the fio to generate the IO via sequence write pattern.

fio ${path_of_config} section=sw

During the experiment, you can use the tool iostat to monitor the I/O information about the device we want to observe.

Step2

Open other terminal and use blktrace to collection the data, there are two parameter we need to use, First one is -d, which indicate what target device blktrace will monitor to. Second, is -w, we use it to limit the time (seconds) how long blktrace will run. So, our final command looks like below.

blktrace -d /dev/nvme1n1 -w 60

In the end of blktrace, you can discover some new files has created by blktrace and its prefix name is nvme1n1.blktrac.xx The number of files is depends how may CPUs in your system.

-rw-r--r--  1 root     root         821152 Jun  2 10:39 nvme1n1.blktrace.0
-rw-r--r-- 1 root root 21044368 Jun 2 10:39 nvme1n1.blktrace.1
-rw-r--r-- 1 root root 462864 Jun 2 10:39 nvme1n1.blktrace.10
-rw-r--r-- 1 root root 737960 Jun 2 10:39 nvme1n1.blktrace.11
-rw-r--r-- 1 root root 865872 Jun 2 10:39 nvme1n1.blktrace.12
-rw-r--r-- 1 root root 755248 Jun 2 10:39 nvme1n1.blktrace.13
-rw-r--r-- 1 root root 4675176 Jun 2 10:39 nvme1n1.blktrace.14
-rw-r--r-- 1 root root 4471480 Jun 2 10:39 nvme1n1.blktrace.15
-rw-r--r-- 1 root root 5070264 Jun 2 10:39 nvme1n1.blktrace.16
-rw-r--r-- 1 root root 5075040 Jun 2 10:39 nvme1n1.blktrace.17
-rw-r--r-- 1 root root 5062104 Jun 2 10:39 nvme1n1.blktrace.18
-rw-r--r-- 1 root root 5586936 Jun 2 10:39 nvme1n1.blktrace.19
-rw-r--r-- 1 root root 3718848 Jun 2 10:39 nvme1n1.blktrace.2

Step3

Now, we can use the blkparse to regenerate human-readable output form the output we get via blktrace before.

We need to indicate source files, you can just use the device name without .blktrace.xx, for example, nvmen1, it will search all files which match the pattern nvmen1.blktrace.xx and put together to analyze. Then, the -f option used to foramt the output data, you can find more about it via man blkparse

OUTPUT DESCRIPTION AND FORMATTING
The output from blkparse can be tailored for specific use -- in particular, to ease parsing of output, and/or limit output fields to those the user wants to see. The data for fields which can be output include:

a Action, a (small) string (1 or 2 characters) -- see table below for more details

c CPU id

C Command

d RWBS field, a (small) string (1-3 characters) -- see section below for more details

D 7-character string containing the major and minor numbers of the event's device (separated by a comma).

e Error value

m Minor number of event's device.

M Major number of event's device.

n Number of blocks

N Number of bytes

p Process ID

P Display packet data -- series of hexadecimal values

s Sequence numbers

S Sector number

t Time stamp (nanoseconds)

T Time stamp (seconds)

u Elapsed value in microseconds (-t command line option)

U Payload unsigned integer

For our observation, we use %5T.%9t, %p, %C, %a, %S\n to format our result containing timestamp, command, process ID, action and sequence number.

Since the data I/O contains many action, such as complete, queued, inserted..ect. we can use option -a to filter actions, you can find more info via man blktrace. In this case, we use the write to filter the actions.

In the end, use the -o options to indicate the output file name.

barrier: barrier attribute
complete: completed by driver
fs: requests
issue: issued to driver
pc: packet command events
queue: queue operations
read: read traces
requeue: requeue operations
sync: synchronous attribute
write: write traces
notify: trace messages
drv_data: additional driver specific trace

The command will look like below and it will output the result to file output.txt.

blkparse nvme1n1 -f "%5T.%9t, %p, %C, %a, %S\n"  -a write -o output.txt

open the file, the result looks like

    0.000000000, 22890, fio, Q, 1720960
0.000001857, 22890, fio, G, 1720960
0.000005803, 22890, fio, I, 1720960
0.000009234, 22890, fio, D, 1720960
0.000036821, 0, swapper/0, C, 1996928
0.000067519, 22890, fio, Q, 1721088
0.000068538, 22890, fio, G, 1721088
0.000071531, 22890, fio, I, 1721088
0.000073102, 22890, fio, D, 1721088
0.000093464, 0, swapper/0, C, 1994624
0.000123806, 0, swapper/0, C, 1785472
0.000147436, 22892, fio, C, 1784576
0.000159977, 22891, fio, C, 1997312
0.000166653, 22891, fio, Q, 2006912
0.000167632, 22891, fio, G, 2006912
0.000169422, 22891, fio, I, 2006912
0.000171178, 22891, fio, D, 2006912
0.000188830, 22892, fio, Q, 1817728
0.000189783, 22892, fio, G, 1817728
0.000191405, 22892, fio, I, 1817728
0.000192830, 22892, fio, D, 1817728
0.000202367, 22891, fio, Q, 2007040
0.000203160, 22891, fio, G, 2007040
0.000205969, 22891, fio, I, 2007040
0.000207524, 22891, fio, D, 2007040
0.000227655, 22892, fio, Q, 1817856
0.000228457, 22892, fio, G, 1817856
0.000231936, 22892, fio, I, 1817856
....

Since the fio will fork to two process to handle the process, we use the grep to focus on one specific process (pid=22892).

grep "22892, fio" output.txt | more

Now, the result seems good, we can discover the sequence number (fifth column) is increasing. One thing we need to care about is the row which action is "C", which means the completed, since we don't know how NVME handle those request and reply to upper layer. we only need to focus on other action. such as "Q (queued This notes intent to queue i/o at the given location. No real requests exists yet.)" or "I (inserted A request is being sent to the i/o scheduler for addition to the internal queue and later service by the driver. The request is fully formed at this time)".

    0.000147436, 22892, fio, C, 1784576
0.000188830, 22892, fio, Q, 1817728
0.000189783, 22892, fio, G, 1817728
0.000191405, 22892, fio, I, 1817728
0.000192830, 22892, fio, D, 1817728
0.000227655, 22892, fio, Q, 1817856
0.000228457, 22892, fio, G, 1817856
0.000231936, 22892, fio, I, 1817856
0.000233530, 22892, fio, D, 1817856
0.000360361, 22892, fio, Q, 1817984
0.000361310, 22892, fio, G, 1817984
0.000364163, 22892, fio, I, 1817984
0.000366696, 22892, fio, D, 1817984
0.000536731, 22892, fio, Q, 1818112
0.000537758, 22892, fio, G, 1818112
0.000539371, 22892, fio, I, 1818112
0.000541407, 22892, fio, D, 1818112
0.000670209, 22892, fio, Q, 1818240
0.000671345, 22892, fio, G, 1818240
0.000673383, 22892, fio, I, 1818240
0.000676260, 22892, fio, D, 1818240
0.001885543, 22892, fio, Q, 1818368
0.001887444, 22892, fio, G, 1818368
0.001891353, 22892, fio, I, 1818368
0.001895917, 22892, fio, D, 1818368
0.001934546, 22892, fio, Q, 1818496
0.001935468, 22892, fio, G, 1818496
0.001936891, 22892, fio, I, 1818496
0.001938742, 22892, fio, D, 1818496
0.001965818, 22892, fio, Q, 1818624

Now, we can do all above command again and change the section to rw for fio using the randon write pattern. The blkparse result will show the random sequence number.

Summary

In this article, we try to use tools blktrace and blkparse to analysiz the block level I/O for fio request. We observe the filed sequence number to make sure thhat the fio can generate the sequence or random according to its config.

Reference