• Wang Nan's avatar
    perf tools: Apply tracepoint event definition options to BPF script · 95088a59
    Wang Nan authored
    Users can pass options to tracepoints defined in the BPF script.  For
    example:
    
      # perf record -e ./test.c/no-inherit/ bash
      # dd if=/dev/zero of=/dev/null count=10000
      # exit
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.022 MB perf.data (139 samples) ]
    
      (no-inherit works, only the sys_read issued by bash are captured, at
       least 10000 sys_read issued by dd are skipped.)
    
    test.c:
    
      #define SEC(NAME) __attribute__((section(NAME), used))
      SEC("func=sys_read")
      int bpf_func__sys_read(void *ctx)
      {
          return 1;
      }
      char _license[] SEC("license") = "GPL";
      int _version SEC("version") = LINUX_VERSION_CODE;
    
    no-inherit is applied to the kprobe event defined in test.c.
    Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
    Cc: Cody P Schafer <dev@codyps.com>
    Cc: He Kuang <hekuang@huawei.com>
    Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kirill Smelkov <kirr@nexedi.com>
    Cc: Li Zefan <lizefan@huawei.com>
    Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Zefan Li <lizefan@huawei.com>
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1456132275-98875-10-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    95088a59
bpf.c 6.43 KB