1. 20 4月, 2017 1 次提交
  2. 04 3月, 2017 1 次提交
  3. 12 1月, 2017 1 次提交
  4. 16 7月, 2016 5 次提交
  5. 13 7月, 2016 1 次提交
  6. 23 6月, 2016 1 次提交
  7. 30 5月, 2016 1 次提交
  8. 24 5月, 2016 2 次提交
  9. 21 5月, 2016 1 次提交
  10. 10 5月, 2016 1 次提交
  11. 16 4月, 2016 1 次提交
  12. 12 4月, 2016 2 次提交
  13. 22 2月, 2016 1 次提交
    • W
      perf tools: Enable passing event to BPF object · 7630b3e2
      Wang Nan 提交于
      A new syntax is added to the parser so that the user can access
      predefined perf events in BPF objects.
      
      After this patch, BPF programs for perf are finally able to utilize
      bpf_perf_event_read() introduced in commit 35578d79 ("bpf: Implement
      function bpf_perf_event_read() that get the selected hardware PMU
      counter").
      
      Test result:
      
        # cat test_bpf_map_2.c
        /************************ BEGIN **************************/
        #include <uapi/linux/bpf.h>
        #define SEC(NAME) __attribute__((section(NAME), used))
        struct bpf_map_def {
            unsigned int type;
            unsigned int key_size;
            unsigned int value_size;
            unsigned int max_entries;
        };
        static int (*trace_printk)(const char *fmt, int fmt_size, ...) =
            (void *)BPF_FUNC_trace_printk;
        static int (*get_smp_processor_id)(void) =
            (void *)BPF_FUNC_get_smp_processor_id;
        static int (*perf_event_read)(struct bpf_map_def *, int) =
            (void *)BPF_FUNC_perf_event_read;
      
        struct bpf_map_def SEC("maps") pmu_map = {
            .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
            .key_size = sizeof(int),
            .value_size = sizeof(int),
            .max_entries = __NR_CPUS__,
        };
        SEC("func_write=sys_write")
        int func_write(void *ctx)
        {
            unsigned long long val;
            char fmt[] = "sys_write:        pmu=%llu\n";
            val = perf_event_read(&pmu_map, get_smp_processor_id());
            trace_printk(fmt, sizeof(fmt), val);
            return 0;
        }
      
        SEC("func_write_return=sys_write%return")
        int func_write_return(void *ctx)
        {
            unsigned long long val = 0;
            char fmt[] = "sys_write_return: pmu=%llu\n";
            val = perf_event_read(&pmu_map, get_smp_processor_id());
            trace_printk(fmt, sizeof(fmt), val);
            return 0;
        }
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        /************************* END ***************************/
      
      Normal case:
      
        # echo "" > /sys/kernel/debug/tracing/trace
        # perf record -i -e cycles -e './test_bpf_map_2.c/map:pmu_map.event=cycles/' ls /
        [SNIP]
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.013 MB perf.data (7 samples) ]
        # cat /sys/kernel/debug/tracing/trace | grep ls
                      ls-17066 [000] d... 938449.863301: : sys_write:        pmu=1157327
                      ls-17066 [000] dN.. 938449.863342: : sys_write_return: pmu=1225218
                      ls-17066 [000] d... 938449.863349: : sys_write:        pmu=1241922
                      ls-17066 [000] dN.. 938449.863369: : sys_write_return: pmu=1267445
      
      Normal case (system wide):
      
        # echo "" > /sys/kernel/debug/tracing/trace
        # perf record -i -e cycles -e './test_bpf_map_2.c/map:pmu_map.event=cycles/' -a
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.811 MB perf.data (120 samples) ]
      
        # cat /sys/kernel/debug/tracing/trace | grep -v '18446744073709551594' | grep -v perf | head -n 20
        [SNIP]
        #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
        #              | |       |   ||||       |         |
                   gmain-30828 [002] d... 2740551.068992: : sys_write:        pmu=84373
                   gmain-30828 [002] d... 2740551.068992: : sys_write_return: pmu=87696
                   gmain-30828 [002] d... 2740551.068996: : sys_write:        pmu=100658
                   gmain-30828 [002] d... 2740551.068997: : sys_write_return: pmu=102572
      
      Error case 1:
      
        # perf record -e './test_bpf_map_2.c' ls /
        [SNIP]
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.014 MB perf.data ]
        # cat /sys/kernel/debug/tracing/trace | grep ls
                      ls-17115 [007] d... 2724279.665625: : sys_write:        pmu=18446744073709551614
                      ls-17115 [007] dN.. 2724279.665651: : sys_write_return: pmu=18446744073709551614
                      ls-17115 [007] d... 2724279.665658: : sys_write:        pmu=18446744073709551614
                      ls-17115 [007] dN.. 2724279.665677: : sys_write_return: pmu=18446744073709551614
      
        (18446744073709551614 is 0xfffffffffffffffe (-2))
      
      Error case 2:
      
        # perf record -e cycles -e './test_bpf_map_2.c/map:pmu_map.event=evt/' -a
        event syntax error: '..ps:pmu_map.event=evt/'
                                          \___ Event not found for map setting
      
        Hint:	Valid config terms:
             	map:[<arraymap>].value=[value]
             	map:[<eventmap>].event=[event]
        [SNIP]
      
      Error case 3:
        # ls /proc/2348/task/
        2348  2505  2506  2507  2508
        # perf record -i -e cycles -e './test_bpf_map_2.c/map:pmu_map.event=cycles/' -p 2348
        ERROR: Apply config to BPF failed: Cannot set event to BPF map in multi-thread tracing
      
      Error case 4:
        # perf record -e cycles -e './test_bpf_map_2.c/map:pmu_map.event=cycles/' ls /
        ERROR: Apply config to BPF failed: Doesn't support inherit event (Hint: use -i to turn off inherit)
      
      Error case 5:
        # perf record -i -e raw_syscalls:sys_enter -e './test_bpf_map_2.c/map:pmu_map.event=raw_syscalls:sys_enter/' ls
        ERROR: Apply config to BPF failed: Can only put raw, hardware and BPF output event into a BPF map
      
      Error case 6:
        # perf record -i -e './test_bpf_map_2.c/map:pmu_map.event=123/' ls /
        event syntax error: '.._map.event=123/'
                                          \___ Incorrect value type for map
        [SNIP]
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo 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: 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-7-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7630b3e2
  14. 09 1月, 2016 1 次提交
  15. 08 1月, 2016 1 次提交
  16. 18 12月, 2015 1 次提交
  17. 06 10月, 2015 1 次提交
  18. 29 9月, 2015 2 次提交
  19. 15 9月, 2015 3 次提交
  20. 29 8月, 2015 1 次提交
  21. 17 8月, 2015 1 次提交
  22. 07 8月, 2015 1 次提交
  23. 24 7月, 2015 1 次提交
  24. 22 7月, 2015 1 次提交
  25. 26 6月, 2015 1 次提交
  26. 18 6月, 2015 1 次提交
  27. 18 5月, 2015 1 次提交
    • A
      perf tools: Elliminate alignment holes · 86066064
      Arnaldo Carvalho de Melo 提交于
      perf_evsel:
      
      Before:
      
      	/* size: 320, cachelines: 5, members: 35 */
      	/* sum members: 304, holes: 3, sum holes: 16 */
      
      After:
      
      	/* size: 304, cachelines: 5, members: 35 */
      	/* last cacheline: 48 bytes */
      
      perf_evlist:
      
      Before:
      
      	/* size: 2544, cachelines: 40, members: 17 */
      	/* sum members: 2533, holes: 2, sum holes: 11 */
      	/* last cacheline: 48 bytes */
      
      After:
      
      	/* size: 2536, cachelines: 40, members: 17 */
      	/* sum members: 2533, holes: 1, sum holes: 3 */
      	/* last cacheline: 40 bytes */
      
      timechart:
      
      Before:
      
      	/* size: 288, cachelines: 5, members: 21 */
      	/* sum members: 271, holes: 2, sum holes: 10 */
      	/* padding: 7 */
      	/* last cacheline: 32 bytes */
      
      After:
      
      	/* size: 272, cachelines: 5, members: 21 */
      	/* sum members: 271, holes: 1, sum holes: 1 */
      	/* last cacheline: 16 bytes */
      
      thread:
      
      Before:
      
      	/* size: 112, cachelines: 2, members: 15 */
      	/* sum members: 101, holes: 2, sum holes: 11 */
      	/* last cacheline: 48 bytes */
      
      After:
      
      	/* size: 104, cachelines: 2, members: 15 */
      	/* sum members: 101, holes: 1, sum holes: 3 */
      	/* last cacheline: 40 bytes */
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-a543w7zjl9yyrg9nkf1teukp@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      86066064
  28. 16 5月, 2015 1 次提交
  29. 29 4月, 2015 2 次提交
  30. 10 4月, 2015 1 次提交