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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30088583/viewspace-2136830/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30088583/viewspace-2136830/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值