1. 25 9月, 2019 2 次提交
  2. 21 9月, 2019 1 次提交
  3. 20 9月, 2019 1 次提交
  4. 01 9月, 2019 2 次提交
  5. 30 8月, 2019 1 次提交
  6. 29 8月, 2019 2 次提交
  7. 26 8月, 2019 1 次提交
  8. 23 8月, 2019 1 次提交
  9. 15 8月, 2019 1 次提交
    • A
      perf trace: Add --switch-on/--switch-off events · 22ac4318
      Arnaldo Carvalho de Melo 提交于
      Just like with 'perf script':
      
        # perf trace -e sched:*,syscalls:*sleep* sleep 1
             0.000 :28345/28345 sched:sched_waking:comm=perf pid=28346 prio=120 target_cpu=005
             0.005 :28345/28345 sched:sched_wakeup:perf:28346 [120] success=1 CPU:005
             0.383 sleep/28346 sched:sched_process_exec:filename=/usr/bin/sleep pid=28346 old_pid=28346
             0.613 sleep/28346 sched:sched_stat_runtime:comm=sleep pid=28346 runtime=607375 [ns] vruntime=23289041218 [ns]
             0.689 sleep/28346 syscalls:sys_enter_nanosleep:rqtp: 0x7ffc491789b0
             0.693 sleep/28346 sched:sched_stat_runtime:comm=sleep pid=28346 runtime=72021 [ns] vruntime=23289113239 [ns]
             0.694 sleep/28346 sched:sched_switch:sleep:28346 [120] S ==> swapper/5:0 [120]
          1000.787 :0/0 sched:sched_waking:comm=sleep pid=28346 prio=120 target_cpu=005
          1000.824 :0/0 sched:sched_wakeup:sleep:28346 [120] success=1 CPU:005
          1000.908 sleep/28346 syscalls:sys_exit_nanosleep:0x0
          1001.218 sleep/28346 sched:sched_process_exit:comm=sleep pid=28346 prio=120
        # perf trace -e sched:*,syscalls:*sleep* --switch-on=syscalls:sys_enter_nanosleep sleep 1
             0.000 sleep/28349 sched:sched_stat_runtime:comm=sleep pid=28349 runtime=603036 [ns] vruntime=23873537697 [ns]
             0.001 sleep/28349 sched:sched_switch:sleep:28349 [120] S ==> swapper/4:0 [120]
          1000.392 :0/0 sched:sched_waking:comm=sleep pid=28349 prio=120 target_cpu=004
          1000.443 :0/0 sched:sched_wakeup:sleep:28349 [120] success=1 CPU:004
          1000.540 sleep/28349 syscalls:sys_exit_nanosleep:0x0
          1000.852 sleep/28349 sched:sched_process_exit:comm=sleep pid=28349 prio=120
        # perf trace -e sched:*,syscalls:*sleep* --switch-on=syscalls:sys_enter_nanosleep --switch-off=syscalls:sys_exit_nanosleep sleep 1
             0.000 sleep/28352 sched:sched_stat_runtime:comm=sleep pid=28352 runtime=610543 [ns] vruntime=24811686681 [ns]
             0.001 sleep/28352 sched:sched_switch:sleep:28352 [120] S ==> swapper/0:0 [120]
          1000.397 :0/0 sched:sched_waking:comm=sleep pid=28352 prio=120 target_cpu=000
          1000.440 :0/0 sched:sched_wakeup:sleep:28352 [120] success=1 CPU:000
        #
        # perf trace -e sched:*,syscalls:*sleep* --switch-on=syscalls:sys_enter_nanosleep --switch-off=syscalls:sys_exit_nanosleep --show-on-off sleep 1
             0.000 sleep/28367 syscalls:sys_enter_nanosleep:rqtp: 0x7fffd1a25fc0
             0.004 sleep/28367 sched:sched_stat_runtime:comm=sleep pid=28367 runtime=628760 [ns] vruntime=22170052672 [ns]
             0.005 sleep/28367 sched:sched_switch:sleep:28367 [120] S ==> swapper/2:0 [120]
          1000.367 :0/0 sched:sched_waking:comm=sleep pid=28367 prio=120 target_cpu=002
          1000.412 :0/0 sched:sched_wakeup:sleep:28367 [120] success=1 CPU:002
          1000.512 sleep/28367 syscalls:sys_exit_nanosleep:0x0
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: William Cohen <wcohen@redhat.com>
      Link: https://lkml.kernel.org/n/tip-t3ngpt1brcc1fm9gep9gxm4q@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      22ac4318
  10. 13 8月, 2019 1 次提交
    • L
      perf trace: Fix segmentation fault when access syscall info on arm64 · 3e70008a
      Leo Yan 提交于
      'perf trace' reports the segmentation fault as below on Arm64:
      
        # perf trace -e string -e augmented_raw_syscalls.c
        LLVM: dumping tools/perf/examples/bpf/augmented_raw_syscalls.o
        perf: Segmentation fault
        Obtained 12 stack frames.
        perf(sighandler_dump_stack+0x47) [0xaaaaac96ac87]
        linux-vdso.so.1(+0x5b7) [0xffffadbeb5b7]
        /lib/aarch64-linux-gnu/libc.so.6(strlen+0x10) [0xfffface7d5d0]
        /lib/aarch64-linux-gnu/libc.so.6(_IO_vfprintf+0x1ac7) [0xfffface49f97]
        /lib/aarch64-linux-gnu/libc.so.6(__vsnprintf_chk+0xc7) [0xffffacedfbe7]
        perf(scnprintf+0x97) [0xaaaaac9ca3ff]
        perf(+0x997bb) [0xaaaaac8e37bb]
        perf(cmd_trace+0x28e7) [0xaaaaac8ec09f]
        perf(+0xd4a13) [0xaaaaac91ea13]
        perf(main+0x62f) [0xaaaaac8a147f]
        /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0xe3) [0xfffface22d23]
        perf(+0x57723) [0xaaaaac8a1723]
        Segmentation fault
      
      This issue is introduced by commit 30a910d7 ("perf trace:
      Preallocate the syscall table"), it allocates trace->syscalls.table[]
      array and the element count is 'trace->sctbl->syscalls.nr_entries'; but
      on Arm64, the system call number is not continuously used; e.g. the
      syscall maximum id is 436 but the real entries is only 281.
      
      So the table is allocated with 'nr_entries' as the element count, but it
      accesses the table with the syscall id, which might be out of the bound
      of the array and cause the segmentation fault.
      
      This patch allocates trace->syscalls.table[] with the element count is
      'trace->sctbl->syscalls.max_id + 1', this allows any id to access the
      table without out of the bound.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Fixes: 30a910d7 ("perf trace: Preallocate the syscall table")
      Link: http://lkml.kernel.org/r/20190809104752.27338-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e70008a
  11. 30 7月, 2019 27 次提交
    • J
      libperf: Adopt simplified perf_evsel__close() function from tools/perf · 88761fa1
      Jiri Olsa 提交于
      Add perf_evsel__close() function to libperf while keeping a tools/perf
      specific evsel__close() to free ids.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-64-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      88761fa1
    • J
      libperf: Add threads to struct perf_evlist · 03617c22
      Jiri Olsa 提交于
      Move threads from tools/perf's evlist to libperf's perf_evlist struct.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-56-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      03617c22
    • J
      libperf: Move perf_event_attr field from perf's evsel to libperf's perf_evsel · 1fc632ce
      Jiri Olsa 提交于
      Move the perf_event_attr struct fron 'struct evsel' to 'struct perf_evsel'.
      
      Committer notes:
      
      Fixed up these:
      
       tools/perf/arch/arm/util/auxtrace.c
       tools/perf/arch/arm/util/cs-etm.c
       tools/perf/arch/arm64/util/arm-spe.c
       tools/perf/arch/s390/util/auxtrace.c
       tools/perf/util/cs-etm.c
      
      Also
      
        cc1: warnings being treated as errors
        tests/sample-parsing.c: In function 'do_test':
        tests/sample-parsing.c:162: error: missing initializer
        tests/sample-parsing.c:162: error: (near initialization for 'evsel.core.cpus')
      
         	struct evsel evsel = {
         		.needs_swap = false,
        -		.core.attr = {
        -			.sample_type = sample_type,
        -			.read_format = read_format,
        +		.core = {
        +			. attr = {
        +				.sample_type = sample_type,
        +				.read_format = read_format,
        +			},
      
        [perfbuilder@a70e4eeb5549 /]$ gcc --version |& head -1
        gcc (GCC) 4.4.7
      
      Also we don't need to include perf_event.h in
      tools/perf/lib/include/perf/evsel.h, forward declaring 'struct
      perf_event_attr' is enough. And this even fixes the build in some
      systems where things are used somewhere down the include path from
      perf_event.h without defining __always_inline.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-43-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1fc632ce
    • J
      libperf: Add nr_entries to struct perf_evlist · 6484d2f9
      Jiri Olsa 提交于
      Move nr_entries count from 'struct perf' to into perf_evlist struct.
      
      Committer notes:
      
      Fix tools/perf/arch/s390/util/auxtrace.c case. And also the comment in
      tools/perf/util/annotate.h.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-42-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6484d2f9
    • J
      libperf: Include perf_evlist in evlist object · ce9036a6
      Jiri Olsa 提交于
      Include perf_evlist in the evlist object, will continue to move other
      generic things into libperf's perf_evlist.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-37-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ce9036a6
    • J
      libperf: Include perf_evsel in evsel object · b27c4ece
      Jiri Olsa 提交于
      Including perf_evsel in evsel object, will continue to move other
      generic things into libperf's perf_evsel struct.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-36-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b27c4ece
    • J
      perf evlist: Rename perf_evlist__disable() to evlist__disable() · e74676de
      Jiri Olsa 提交于
      Rename perf_evlist__disable() to evlist__disable(), so we don't have a
      name clash when we add perf_evlist__disable() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-23-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e74676de
    • J
      perf evlist: Rename perf_evlist__enable() to evlist__enable() · 1c87f165
      Jiri Olsa 提交于
      Rename perf_evlist__enable() to evlist__enable(), so we don't have a
      name clash when we add perf_evlist__enable() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-22-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1c87f165
    • J
      perf evlist: Rename perf_evlist__open() to evlist__open() · 474ddc4c
      Jiri Olsa 提交于
      Rename perf_evlist__open() to evlist__open(), so we don't have a name
      clash when we add perf_evlist__open() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-20-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      474ddc4c
    • J
      perf evsel: Rename perf_evsel__disable() to evsel__disable() · 9a10bb22
      Jiri Olsa 提交于
      Renaming perf_evsel__disable() to evsel__disable(), so we don't have a
      name clash when we add perf_evsel__disable() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-17-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9a10bb22
    • J
      perf evlist: Rename perf_evlist__add() to evlist__add() · a1cf3a75
      Jiri Olsa 提交于
      Rename perf_evlist__add() to evlist__add(), so we don't have a name
      clash when we add perf_evlist__add() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-13-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a1cf3a75
    • J
      perf evsel: Rename perf_evsel__new() to evsel__new() · 365c3ae7
      Jiri Olsa 提交于
      Rename perf_evsel__new() to evsel__new(), so we don't have a name clash
      when we add perf_evsel__new() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-12-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      365c3ae7
    • J
      perf evsel: Rename perf_evsel__delete() to evsel__delete() · 5eb2dd2a
      Jiri Olsa 提交于
      Remame perf_evsel__delete() to evsel__delete(), so we don't have a name
      clash when we add perf_evsel__delete() in libperf.
      
      Also renaming perf_evsel__delete_priv() to evsel__delete_priv().
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-11-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5eb2dd2a
    • J
      perf evlist: Rename perf_evlist__delete() to evlist__delete() · c12995a5
      Jiri Olsa 提交于
      Rename perf_evlist__delete() to evlist__delete(), so we don't have a
      name clash when we add perf_evlist__delete() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-10-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c12995a5
    • J
      perf evlist: Rename perf_evlist__new() to evlist__new() · 0f98b11c
      Jiri Olsa 提交于
      Rename perf_evlist__new() to evlist__new(), so we don't have a name
      clash when we add perf_evlist__new() in libperf.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-9-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0f98b11c
    • J
      perf evlist: Rename struct perf_evlist to struct evlist · 63503dba
      Jiri Olsa 提交于
      Rename struct perf_evlist to struct evlist, so we don't have a name
      clash when we add struct perf_evlist in libperf.
      
      Committer notes:
      
      Added fixes to build on arm64, from Jiri and from me
      (tools/perf/util/cs-etm.c)
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-6-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      63503dba
    • J
      perf evsel: Rename struct perf_evsel to struct evsel · 32dcd021
      Jiri Olsa 提交于
      Rename struct perf_evsel to struct evsel, so we don't have a name clash
      when we add struct perf_evsel in libperf.
      
      Committer notes:
      
      Added fixes for arm64, provided by Jiri.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32dcd021
    • A
      perf trace: Add "sendfile64" alias to the "sendfile" syscall · e4b00e93
      Arnaldo Carvalho de Melo 提交于
      We were looking in tracefs for:
      
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile/format when
      
      what is there is just
      
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile/format
      
      Its the same id, 40 in x86_64, so just add an alias and let the existing
      logic take care of that.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-km2hmg7hru6u4pawi5fi903q@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e4b00e93
    • A
      perf trace: Reuse BPF augmenters from syscalls with similar args signature · ad4153f9
      Arnaldo Carvalho de Melo 提交于
      We have an augmenter for the "open" syscall, which has just one pointer,
      in the first argument, a "const char *", so any other syscall that has
      just one pointer and that is the first can reuse the "open" BPF
      augmenter program.
      
      Even more, syscalls that get two pointers with the first being a string
      can reuse "open"'s BPF augmenter till we have an augmenter that better
      matches that syscall with two pointers.
      
      With this the few augmenters we have, for open (first arg is a string),
      openat (2nd arg is a string), renameat (2nd and 4th are strings) can be
      reused by a lot of syscalls, ditto for "bind" reusing "connect" because
      both have the 2nd argument as a sockaddr and the 3rd as its len.
      
      Lets see how this makes the "bind" syscall reuse the "connect" BPF prog
      augmenter found in tools/perf/examples/bpf/augmented_raw_syscalls.c:
      
        # perf trace -e bind,connect systemctl restart sshd
        connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        #
      
      Oh, it just connects to some daemon, so we better do it system wide and then
      stop/start sshd:
      
        # perf trace -e bind,connect
        systemctl/10124 connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        sshd/10102 connect(7, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        systemctl/10126 connect(3, { .family: PF_LOCAL, path: /run/systemd/private }, 23) = 0
        systemd/10128  ... [continued]: connect())            = 0
        (sshd)/10128 connect(3, { .family: PF_LOCAL, path: /run/systemd/journal/stdout }, 30) ...
        sshd/10128 bind(3, { .family: PF_NETLINK }, 12)    = 0
        sshd/10128 connect(4, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(3, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        sshd/10128 connect(3, { .family: PF_UNSPEC }, 16)  = 0
        sshd/10128 connect(3, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/10128 connect(3, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(3, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        sshd/10128 bind(4, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/10128 connect(6, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        sshd/10128 bind(6, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        sshd/10128 connect(7, { .family: PF_LOCAL, path: /dev/log }, 110) = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-zfley2ghs4nim1uq4nu6ed3l@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ad4153f9
    • A
      perf trace: Preallocate the syscall table · 30a910d7
      Arnaldo Carvalho de Melo 提交于
      We'll continue reading its details from tracefs as we need it, but
      preallocate the whole thing otherwise we may realloc and end up with
      pointers to the previous buffer.
      
      I.e. in an upcoming algorithm we'll look for syscalls that have function
      signatures that are similar to a given syscall to see if we can reuse
      its BPF augmenter, so we may be at syscall 42, having a 'struct syscall'
      pointing to that slot in trace->syscalls.table[] and try to read the
      slot for an yet unread syscall, which would realloc that table to read
      the info for syscall 43, say, which would trigger a realoc of
      trace->syscalls.table[], and then the pointer we had for syscall 42
      would be pointing to the previous block of memory. b00m.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-m3cjzzifibs13imafhkk77a0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      30a910d7
    • A
      perf trace: Mark syscall ids that are not allocated to avoid unnecessary error messages · b8b1033f
      Arnaldo Carvalho de Melo 提交于
      There are holes in syscall tables with IDs not associated with any
      syscall, mark those when trying to read information for syscalls, which
      could happen when iterating thru all syscalls from 0 to the highest
      numbered syscall id.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-cku9mpcrcsqaiq0jepu86r68@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b8b1033f
    • A
      perf trace: Forward error codes when trying to read syscall info · 5d2bd889
      Arnaldo Carvalho de Melo 提交于
      We iterate thru the syscall table produced from the kernel syscall
      tables reading info, propagate the error and add to the debug message.
      
      This helps in fixing further bugs, such as failing to read the
      "sendfile" syscall info when it really should try the aliasm
      "sendfile64".
      
        Problems reading syscall 40: 2 (No such file or directory)(sendfile) information
      
        # grep sendfile /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c
      	[40] = "sendfile",
        #
      
      I.e. in the tracefs format file for the syscall tracepoints we have it
      as sendfile64:
      
        # find /sys -type f -name format | grep sendfile
        /sys/kernel/debug/tracing/events/syscalls/sys_enter_sendfile64/format
        /sys/kernel/debug/tracing/events/syscalls/sys_exit_sendfile64/format
        #
      
      But as "sendfile" in the file used to build the syscall table used in
      perf:
      
        $ grep sendfile arch/x86/entry/syscalls/syscall_64.tbl
        40	common	sendfile		__x64_sys_sendfile64
        $
      
      So we need to add, in followup patches, aliases in 'perf trace' syscall
      data structures to cope with thie.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-w3eluap63x9je0bb8o3t79tz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5d2bd889
    • A
      perf trace beauty: Beautify bind's sockaddr arg · 247dd65b
      Arnaldo Carvalho de Melo 提交于
      By reusing the "connect" BPF collector.
      
      Testing it system wide and stopping/starting sshd:
      
        # perf trace -e bind
        LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        DNS Res~er #18/15132 bind(243, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(247, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(238, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(243, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/10327 bind(258, { .family: PF_NETLINK }, 12)  = 0
        :6507/6507 bind(24, { .family: PF_NETLINK }, 12)   = 0
        DNS Res~er #19/4833 bind(238, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(242, { .family: PF_NETLINK }, 12)  = 0
        sshd/6514 bind(3, { .family: PF_NETLINK }, 12)    = 0
        sshd/6514 bind(5, { .family: PF_INET, port: 22, addr: 0.0.0.0 }, 16) = 0
        sshd/6514 bind(7, { .family: PF_INET6, port: 22, addr: :: }, 28) = 0
        DNS Res~er #18/10327 bind(229, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #18/15132 bind(231, { .family: PF_NETLINK }, 12)  = 0
        DNS Res~er #19/4833 bind(229, { .family: PF_NETLINK }, 12)  = 0
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-m2hmxqrckxxw2ciki0tu889u@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      247dd65b
    • A
      perf trace beauty: Do not try to use the fd->pathname beautifier for bind/connect fd arg · ef969ca6
      Arnaldo Carvalho de Melo 提交于
      Doesn't make sense and also we now beautify the sockaddr, which provides
      enough info:
      
        # trace -e close,socket,connec* ssh www.bla.com
        <SNIP>
        close(5)                                = 0
        socket(PF_INET, SOCK_DGRAM|CLOEXEC|NONBLOCK, IPPROTO_IP) = 5
        connect(5, { .family: PF_INET, port: 53, addr: 192.168.44.1 }, 16) = 0
        close(5)                                = 0
        socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-h9drpb7ail808d2mh4n7tla4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ef969ca6
    • A
      perf trace beauty: Disable fd->pathname when close() not enabled · 79d725cd
      Arnaldo Carvalho de Melo 提交于
      As we invalidate the fd->pathname table in the SCA_CLOSE_FD beautifier,
      if we don't have it we may end up keeping an fd->pathname association
      that then gets misprinted.
      
      The previous behaviour continues when the close() syscall is enabled,
      which may still be a a problem if we lose records (i.e. we may lose a
      'close' record and then get that fd reused by socket()) but then the
      tool will notify that records are being lost and the user will be warned
      that some of the heuristics will fall apart.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b7t6h8sq9lebemvfy2zh3qq1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      79d725cd
    • A
      perf trace beauty: Make connect's addrlen be printed as an int, not hex · 1d862752
      Arnaldo Carvalho de Melo 提交于
        # perf trace -e connec* ssh www.bla.com
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(3</var/lib/sss/mc/passwd>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(4<socket:[16610959]>, { .family: PF_LOCAL, path: /var/lib/sss/pipes/nss }, 110) = 0
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(7, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 53, addr: 192.168.44.1 }, 16) = 0
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 22, addr: 146.112.61.108 }, 16) = 0
        connect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET6, port: 22, addr: ::ffff:146.112.61.108 }, 28) = 0
        ^Cconnect(5</usr/lib64/libnss_mdns4_minimal.so.2>, { .family: PF_INET, port: 22, addr: 146.112.61.108 }, 16) = -1 (unknown) (INTERNAL ERROR: strerror_r(512, [buf], 128)=22)
        #
      
      Argh, the SCA_FD needs to invalidate its cache when close is done...
      
      It works if the 'close' syscall is not filtered out ;-\
      
        # perf trace -e close,connec* ssh www.bla.com
        close(3)                                = 0
        close(3</usr/lib64/libpcre2-8.so.0.8.0>) = 0
        close(3)                                = 0
        close(3</usr/lib64/libkrb5.so.3.3>)     = 0
        close(3</usr/lib64/libkrb5.so.3.3>)     = 0
        close(3)                                = 0
        close(3</usr/lib64/libk5crypto.so.3.1>) = 0
        close(3</usr/lib64/libk5crypto.so.3.1>) = 0
        close(3</usr/lib64/libcom_err.so.2.1>)  = 0
        close(3</usr/lib64/libcom_err.so.2.1>)  = 0
        close(3)                                = 0
        close(3</usr/lib64/libkrb5support.so.0.1>) = 0
        close(3</usr/lib64/libkrb5support.so.0.1>) = 0
        close(3</usr/lib64/libkeyutils.so.1.8>) = 0
        close(3</usr/lib64/libkeyutils.so.1.8>) = 0
        close(3)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        close(4)                                = 0
        close(3)                                = 0
        close(3)                                = 0
        connect(3</etc/nsswitch.conf>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        close(3</etc/nsswitch.conf>)            = 0
        connect(3</usr/lib64/libnss_sss.so.2>, { .family: PF_LOCAL, path: /var/run/nscd/socket }, 110) = -1 ENOENT (No such file or directory)
        close(3</usr/lib64/libnss_sss.so.2>)    = 0
        close(3</usr/lib64/libnss_sss.so.2>)    = 0
        close(3)                                = 0
        close(3)                                = 0
        connect(4<socket:[16616519]>, { .family: PF_LOCAL, path: /var/lib/sss/pipes/nss }, 110) = 0
        ^C
        #
      
      Will disable this beautifier when 'close' is filtered out...
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-ekuiciyx4znchvy95c8p1yyi@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1d862752
    • A
      perf trace: Look for default name for entries in the syscalls prog array · 8b8044e5
      Arnaldo Carvalho de Melo 提交于
      I.e. just look for "!syscalls:sys_enter_" or "exit_" plus the syscall
      name, that way we need just to add entries to the
      augmented_raw_syscalls.c BPF source to add handlers.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-6xavwddruokp6ohs7tf4qilb@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8b8044e5