小编给大家分享一下ext4如何实现时延stap脚本,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
#!/bin/sh STAP_FILE_PATH="/tmp/moderate-ext4.stp" MODERATE_EXT4_FUNCTIONS=( #ext4 direct io function "ext4_direct_IO" #ext4 page related functions #"ext4_readpages" #"ext4_writepage" #ext4 aio related functions "generic_file_aio_read" "ext4_file_write" #ext4 sync function "ext4_sync_file" ) function error() { echo $@ exit 1 } function probe_functions() { local delay=${1:-"1"} rm $STAP_FILE_PATH &>/dev/null # header cat <> $STAP_FILE_PATH #!/usr/bin/stap -DSTP_NO_OVERLOAD # Delay reads by 250 ms # stap -v -g nfsd_delay_op.stp nfsd_read 250 %{ #undef STP_OVERLOAD #include %} function udelay(ms:long) %{ /* guru */ udelay(THIS->ms); %} EOF for func_name in ${MODERATE_EXT4_FUNCTIONS[@]}; do if [[ $func_name =~ "ext4" ]]; then # ext4 module probe body cat <> $STAP_FILE_PATH probe module("ext4").function("$func_name").return { udelay($delay); } EOF else # kernel probe body cat <> $STAP_FILE_PATH probe kernel.function("$func_name").return { udelay($delay); } EOF fi done } function usage() { local program=`basename $0` echo "Usage: $program is a tool to moderate ext4's io based on systemtap" echo "the only option is time, and the unit is milliseconds" exit 1 } function main() { if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage fi which stap &>/dev/null || yum -b current intall -y systemtap probe_functions $1 stap -v -g $STAP_FILE_PATH } main $1 |
以上是“ext4如何实现时延stap脚本”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。