![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0 0002 /* 0003 Description: 0004 0005 . Disable strace like syscall tracing (--no-syscalls), or try tracing 0006 just some (-e *sleep). 0007 0008 . Attach a filter function to a kernel function, returning when it should 0009 be considered, i.e. appear on the output. 0010 0011 . Run it system wide, so that any sleep of >= 5 seconds and < than 6 0012 seconds gets caught. 0013 0014 . Ask for callgraphs using DWARF info, so that userspace can be unwound 0015 0016 . While this is running, run something like "sleep 5s". 0017 0018 . If we decide to add tv_nsec as well, then it becomes: 0019 0020 int probe(hrtimer_nanosleep, rqtp->tv_sec rqtp->tv_nsec)(void *ctx, int err, long sec, long nsec) 0021 0022 I.e. add where it comes from (rqtp->tv_nsec) and where it will be 0023 accessible in the function body (nsec) 0024 0025 # perf trace --no-syscalls -e tools/perf/examples/bpf/5sec.c/call-graph=dwarf/ 0026 0.000 perf_bpf_probe:func:(ffffffff9811b5f0) tv_sec=5 0027 hrtimer_nanosleep ([kernel.kallsyms]) 0028 __x64_sys_nanosleep ([kernel.kallsyms]) 0029 do_syscall_64 ([kernel.kallsyms]) 0030 entry_SYSCALL_64 ([kernel.kallsyms]) 0031 __GI___nanosleep (/usr/lib64/libc-2.26.so) 0032 rpl_nanosleep (/usr/bin/sleep) 0033 xnanosleep (/usr/bin/sleep) 0034 main (/usr/bin/sleep) 0035 __libc_start_main (/usr/lib64/libc-2.26.so) 0036 _start (/usr/bin/sleep) 0037 ^C# 0038 0039 Copyright (C) 2018 Red Hat, Inc., Arnaldo Carvalho de Melo <acme@redhat.com> 0040 */ 0041 0042 #include <bpf.h> 0043 0044 #define NSEC_PER_SEC 1000000000L 0045 0046 int probe(hrtimer_nanosleep, rqtp)(void *ctx, int err, long long sec) 0047 { 0048 return sec / NSEC_PER_SEC == 5ULL; 0049 } 0050 0051 license(GPL);
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |