Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement timed stap script in ext4

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report