• Arnaldo Carvalho de Melo's avatar
    perf trace: Support syscall name globbing · 27702bcf
    Arnaldo Carvalho de Melo authored
    So now we can use:
    
      # perf trace -e pkey_*
       532.784 ( 0.006 ms): pkey/16018 pkey_alloc(init_val: DISABLE_WRITE) = -1 EINVAL Invalid argument
       532.795 ( 0.004 ms): pkey/16018 pkey_mprotect(start: 0x7f380d0a6000, len: 4096, prot: READ|WRITE, pkey: -1) = 0
       532.801 ( 0.002 ms): pkey/16018 pkey_free(pkey: -1                ) = -1 EINVAL Invalid argument
      ^C[root@jouet ~]#
    
    Or '-e epoll*', '-e *msg*', etc.
    
    Combining syscall names with perf events, tracepoints, etc, continues to
    be valid, i.e. this is possible:
    
      # perf probe -L sys_nanosleep
      <SyS_nanosleep@/home/acme/git/linux/kernel/time/hrtimer.c:0>
          0  SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
                            struct timespec __user *, rmtp)
             {
                    struct timespec64 tu;
    
          5         if (get_timespec64(&tu, rqtp))
          6                 return -EFAULT;
    
                    if (!timespec64_valid(&tu))
          9                 return -EINVAL;
    
         11         current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
         12         current->restart_block.nanosleep.rmtp = rmtp;
         13         return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
             }
    
      # perf probe my_probe="sys_nanosleep:12 rmtp"
      Added new event:
        probe:my_probe       (on sys_nanosleep:12 with rmtp)
    
      You can now use it in all perf tools, such as:
    
    	perf record -e probe:my_probe -aR sleep 1
    
      #
      # perf trace -e probe:my_probe/max-stack=5/,*sleep sleep 1
         0.427 ( 0.003 ms): sleep/16690 nanosleep(rqtp: 0x7ffefc245090) ...
         0.430 (         ): probe:my_probe:(ffffffffbd112923) rmtp=0)
                                           sys_nanosleep ([kernel.kallsyms])
                                           do_syscall_64 ([kernel.kallsyms])
                                           return_from_SYSCALL_64 ([kernel.kallsyms])
                                           __nanosleep_nocancel (/usr/lib64/libc-2.25.so)
         0.427 (1000.208 ms): sleep/16690  ... [continued]: nanosleep()) = 0
      #
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-elycoi8wy6y0w9dkj7ox1mzz@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    27702bcf
builtin-trace.c 86.2 KB