trace+probe_vfs_getname.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Check open filename arg using perf trace + vfs_getname
  2. # Uses the 'perf test shell' library to add probe:vfs_getname to the system
  3. # then use it with 'perf trace' using 'touch' to write to a temp file, then
  4. # checks that that was captured by the vfs_getname was used by 'perf trace',
  5. # that already handles "probe:vfs_getname" if present, and used in the
  6. # "open" syscall "filename" argument beautifier.
  7. # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
  8. . $(dirname $0)/lib/probe.sh
  9. skip_if_no_perf_probe || exit 2
  10. . $(dirname $0)/lib/probe_vfs_getname.sh
  11. file=$(mktemp /tmp/temporary_file.XXXXX)
  12. trace_open_vfs_getname() {
  13. evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
  14. perf trace -e $evts touch $file 2>&1 | \
  15. egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
  16. }
  17. add_probe_vfs_getname || skip_if_no_debuginfo
  18. err=$?
  19. if [ $err -ne 0 ] ; then
  20. exit $err
  21. fi
  22. # Do not use whatever ~/.perfconfig file, it may change the output
  23. # via trace.{show_timestamp,show_prefix,etc}
  24. export PERF_CONFIG=/dev/null
  25. trace_open_vfs_getname
  26. err=$?
  27. rm -f ${file}
  28. cleanup_probe_vfs_getname
  29. exit $err