Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fs/cachestat compatible with kernel 5.15+ #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions fs/cachestat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# mark_page_accessed() for measuring cache accesses
# mark_buffer_dirty() for measuring cache writes
# add_to_page_cache_lru() for measuring page additions
# account_page_dirtied() for measuring page dirties
# (account_page|folio_account)_dirtied() for measuring page dirties
#
# It is possible that these functions have been renamed (or are different
# logically) for your kernel version, and this script will not work as-is.
Expand Down Expand Up @@ -108,9 +108,14 @@ cd $tracing || die "ERROR: accessing tracing. Root user? Kernel has FTRACE?

### enable tracing
sysctl -q kernel.ftrace_enabled=1 # doesn't set exit status
printf "mark_page_accessed\nmark_buffer_dirty\nadd_to_page_cache_lru\naccount_page_dirtied\n" > set_ftrace_filter || \
page_dirtied_fn=`uname -r | awk -F. '{\
if (\$1 >= 5 && \$2 >= 15) {print "folio_account_dirtied"} \
else {print "account_page_dirtied"}\
}'`

printf "mark_page_accessed\nmark_buffer_dirty\nadd_to_page_cache_lru\n${page_dirtied_fn}\n" > set_ftrace_filter || \
die "ERROR: tracing these four kernel functions: mark_page_accessed,"\
"mark_buffer_dirty, add_to_page_cache_lru and account_page_dirtied (unknown kernel version?). Exiting."
"mark_buffer_dirty, add_to_page_cache_lru and ${page_dirtied_fn} (unknown kernel version?). Exiting."
warn "echo nop > current_tracer"
if ! echo 1 > function_profile_enabled; then
echo > set_ftrace_filter
Expand Down Expand Up @@ -143,7 +148,7 @@ while (( !quit && (!opt_duration || secs < duration) )); do
mpa = a["mark_page_accessed"]
mbd = a["mark_buffer_dirty"]
apcl = a["add_to_page_cache_lru"]
apd = a["account_page_dirtied"]
apd = a[$page_dirtied_fn]

total = mpa - mbd
misses = apcl - apd
Expand Down
2 changes: 1 addition & 1 deletion man/man8/cachestat.8
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mark_buffer_dirty() for measuring cache writes
.IP
add_to_page_cache_lru() for measuring page additions
.IP
account_page_dirtied() for measuring page dirties
(account_page|folio_account)_dirtied() for measuring page dirties
.PP
It is possible that these functions have been renamed (or are different
logically) for your kernel version, and this script will not work as-is.
Expand Down