How to implement timed stap script in ext4
Editor to share with you ext4 how to achieve delay stap script, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
#! / 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=$ {1VR-"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
The above is all the content of the article "how to implement the timed stap script in ext4". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!