1. 19 2月, 2021 5 次提交
  2. 18 2月, 2021 8 次提交
  3. 17 2月, 2021 1 次提交
    • J
      perf symbols: Resolve symbols against debug file first · 6833e0b8
      Jiri Slaby 提交于
      With LTO, there are symbols like these:
      
      /usr/lib/debug/usr/lib64/libantlr4-runtime.so.4.8-4.8-1.4.x86_64.debug
       10305: 0000000000955fa4     0 NOTYPE  LOCAL  DEFAULT   29 Predicate.cpp.2bc410e7
      
      This comes from a runtime/debug split done by the standard way:
      
        objcopy --only-keep-debug $runtime $debug
        objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line --strip-all $runtime
      
      perf currently cannot resolve such symbols (relicts of LTO), as section
      29 exists only in the debug file (29 is .debug_info). And perf resolves
      symbols only against runtime file. This results in all symbols from such
      a library being unresolved:
      
           0.38%  main2    libantlr4-runtime.so.4.8  [.] 0x00000000000671e0
      
      So try resolving against the debug file first. And only if it fails (the
      section has NOBITS set), try runtime file. We can do this, as "objcopy
      --only-keep-debug" per documentation preserves all sections, but clears
      data of some of them (the runtime ones) and marks them as NOBITS.
      
      The correct result is now:
           0.38%  main2    libantlr4-runtime.so.4.8  [.] antlr4::IntStream::~IntStream
      
      Note that these LTO symbols are properly skipped anyway as they belong
      neither to *text* nor to *data* (is_label && !elf_sec__filter(&shdr,
      secstrs) is true).
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210217122125.26416-1-jslaby@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6833e0b8
  4. 16 2月, 2021 3 次提交
    • L
      perf arm-spe: Set sample's data source field · a89dbc9b
      Leo Yan 提交于
      The sample structure contains the field 'data_src' which is used to
      tell the data operation attributions, e.g. operation type is loading or
      storing, cache level, it's snooping or remote accessing, etc.  At the
      end, the 'data_src' will be parsed by perf mem/c2c tools to display
      human readable strings.
      
      This patch is to fill the 'data_src' field in the synthesized samples
      base on different types.  Currently perf tool can display statistics for
      L1/L2/L3 caches but it doesn't support the 'last level cache'.  To fit
      to current implementation, 'data_src' field uses L3 cache for last level
      cache.
      
      Before this commit, perf mem report looks like this:
        # Samples: 75K of event 'l1d-miss'
        # Total weight : 75951
        # Sort order   : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked
        #
        # Overhead  Samples  Local Weight  Memory access  Symbol                  Shared Object  Data Symbol             Data Object  Snoop  TLB access
        # ........  .......  ............  .............  ......................  .............  ......................  ...........  .....  ..........
        #
            81.56%    61945  0             N/A            [.] 0x00000000000009d8  serial_c       [.] 0000000000000000    [unknown]    N/A    N/A
            18.44%    14003  0             N/A            [.] 0x0000000000000828  serial_c       [.] 0000000000000000    [unknown]    N/A    N/A
      
      Now on a system with Arm SPE, addresses and access types are displayed:
      
        # Samples: 75K of event 'l1d-miss'
        # Total weight : 75951
        # Sort order   : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked
        #
        # Overhead  Samples  Local Weight  Memory access  Symbol                  Shared Object  Data Symbol             Data Object  Snoop  TLB access
        # ........  .......  ............  .............  ......................  .............  ......................  ...........  .....  ..........
        #
             0.43%      324  0             L1 miss        [.] 0x00000000000009d8  serial_c       [.] 0x0000ffff80794e00  anon         N/A    Walker hit
             0.42%      322  0             L1 miss        [.] 0x00000000000009d8  serial_c       [.] 0x0000ffff80794580  anon         N/A    Walker hit
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: NJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-6-james.clark@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a89dbc9b
    • L
      perf arm-spe: Synthesize memory event · e55ed342
      Leo Yan 提交于
      The memory event can deliver two benefits:
      
      - The first benefit is the memory event can give out global view for
        memory accessing, rather than organizing events with scatter mode
        (e.g. uses separate event for L1 cache, last level cache, etc) which
        which can only display a event for single memory type, memory events
        include all memory accessing so it can display the data accessing
        cross memory levels in the same view;
      
      - The second benefit is the sample generation might introduce a big
        overhead and need to wait for long time for Perf reporting, we can
        specify itrace option '--itrace=M' to filter out other events and only
        output memory events, this can significantly reduce the overhead
        caused by generating samples.
      
      This patch is to enable memory event for Arm SPE.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: NJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-5-james.clark@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e55ed342
    • L
      perf arm-spe: Fill address info for samples · 54f7815e
      Leo Yan 提交于
      To properly handle memory and branch samples, this patch divides into
      two functions for generating samples: arm_spe__synth_mem_sample() is for
      synthesizing memory and TLB samples; arm_spe__synth_branch_sample() is
      to synthesize branch samples.
      
      Arm SPE backend decoder has passed virtual and physical address through
      packets, the address info is stored into the synthesize samples in the
      function arm_spe__synth_mem_sample().
      
      Committer notes:
      
      Fixed this:
      
        36    46.77 fedora:27                     : FAIL clang version 5.0.2 (tags/RELEASE_502/final)
      
          util/arm-spe.c:269:34: error: missing field 'pid' initializer [-Werror,-Wmissing-field-initializers]
                  struct perf_sample sample = { 0 };
                                                  ^
          util/arm-spe.c:288:34: error: missing field 'pid' initializer [-Werror,-Wmissing-field-initializers]
                  struct perf_sample sample = { 0 };
      
      By using = { .ip = 0, };
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: NJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-4-james.clark@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      54f7815e
  5. 13 2月, 2021 8 次提交
    • J
      perf probe: Fix kretprobe issue caused by GCC bug · 105f75eb
      Jianlin Lv 提交于
      Perf failed to add a kretprobe event with debuginfo of vmlinux which is
      compiled by gcc with -fpatchable-function-entry option enabled.  The
      same issue with kernel module.
      
      Issue:
      
        # perf probe  -v 'kernel_clone%return $retval'
        ......
        Writing event: r:probe/kernel_clone__return _text+599624 $retval
        Failed to write event: Invalid argument
          Error: Failed to add events. Reason: Invalid argument (Code: -22)
      
        # cat /sys/kernel/debug/tracing/error_log
        [156.75] trace_kprobe: error: Retprobe address must be an function entry
        Command: r:probe/kernel_clone__return _text+599624 $retval
                                              ^
      
        # llvm-dwarfdump  vmlinux |grep  -A 10  -w 0x00df2c2b
        0x00df2c2b:   DW_TAG_subprogram
                      DW_AT_external  (true)
                      DW_AT_name      ("kernel_clone")
                      DW_AT_decl_file ("/home/code/linux-next/kernel/fork.c")
                      DW_AT_decl_line (2423)
                      DW_AT_decl_column       (0x07)
                      DW_AT_prototyped        (true)
                      DW_AT_type      (0x00dcd492 "pid_t")
                      DW_AT_low_pc    (0xffff800010092648)
                      DW_AT_high_pc   (0xffff800010092b9c)
                      DW_AT_frame_base        (DW_OP_call_frame_cfa)
      
        # cat /proc/kallsyms |grep kernel_clone
        ffff800010092640 T kernel_clone
        # readelf -s vmlinux |grep -i kernel_clone
        183173: ffff800010092640  1372 FUNC    GLOBAL DEFAULT    2 kernel_clone
      
        # objdump -d vmlinux |grep -A 10  -w \<kernel_clone\>:
        ffff800010092640 <kernel_clone>:
        ffff800010092640:       d503201f        nop
        ffff800010092644:       d503201f        nop
        ffff800010092648:       d503233f        paciasp
        ffff80001009264c:       a9b87bfd        stp     x29, x30, [sp, #-128]!
        ffff800010092650:       910003fd        mov     x29, sp
        ffff800010092654:       a90153f3        stp     x19, x20, [sp, #16]
      
      The entry address of kernel_clone converted by debuginfo is _text+599624
      (0x92648), which is consistent with the value of DW_AT_low_pc attribute.
      But the symbolic address of kernel_clone from /proc/kallsyms is
      ffff800010092640.
      
      This issue is found on arm64, -fpatchable-function-entry=2 is enabled when
      CONFIG_DYNAMIC_FTRACE_WITH_REGS=y;
      Just as objdump displayed the assembler contents of kernel_clone,
      GCC generate 2 NOPs  at the beginning of each function.
      
      kprobe_on_func_entry detects that (_text+599624) is not the entry address
      of the function, which leads to the failure of adding kretprobe event.
      
        kprobe_on_func_entry
        ->_kprobe_addr
        ->kallsyms_lookup_size_offset
        ->arch_kprobe_on_func_entry		// FALSE
      
      The cause of the issue is that the first instruction in the compile unit
      indicated by DW_AT_low_pc does not include NOPs.
      This issue exists in all gcc versions that support
      -fpatchable-function-entry option.
      
      I have reported it to the GCC community:
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776
      
      Currently arm64 and PA-RISC may enable fpatchable-function-entry option.
      The kernel compiled with clang does not have this issue.
      
      FIX:
      
      This GCC issue only cause the registration failure of the kretprobe event
      which doesn't need debuginfo. So, stop using debuginfo for retprobe.
      map will be used to query the probe function address.
      Signed-off-by: NJianlin Lv <Jianlin.Lv@arm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: clang-built-linux@googlegroups.com
      Cc: Frank Ch. Eigler <fche@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20210210062646.2377995-1-Jianlin.Lv@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      105f75eb
    • N
      perf symbols: Fix return value when loading PE DSO · 77771a97
      Nicholas Fraser 提交于
      The first time dso__load() was called on a PE file it always returned -1
      error. This caused the first call to map__find_symbol() to always fail
      on a PE file so the first sample from each PE file always had symbol
      <unknown>. Subsequent samples succeed however because the DSO is already
      loaded.
      
      This fixes dso__load() to return 0 when successfully loading a DSO with
      libbfd.
      
      Fixes: eac9a434 ("perf symbols: Try reading the symbol table with libbfd")
      Signed-off-by: NNicholas Fraser <nfraser@codeweavers.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Frank Ch. Eigler <fche@redhat.com>
      Cc: Huw Davies <huw@codeweavers.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Tommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Ulrich Czekalla <uczekalla@codeweavers.com>
      Link: http://lore.kernel.org/lkml/1671b43b-09c3-1911-dbf8-7f030242fbf7@codeweavers.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      77771a97
    • N
      perf symbols: Make dso__load_bfd_symbols() load PE files from debug cache only · 00a34234
      Nicholas Fraser 提交于
      dso__load_bfd_symbols() attempts to load a DSO at its original path,
      then closes it and loads the file in the debug cache. This is incorrect.
      It should ignore the original file and work with only the debug cache.
      
      The original file may have changed or may not even exist, for example if
      the debug cache has been transferred to another machine via "perf
      archive".
      
      This fix makes it only load the file in the debug cache.
      
      Further notes from Nicholas:
      
      dso__load_bfd_symbols() is called in a loop from dso__load() for a variety
      of paths. These are generated by the various DSO_BINARY_TYPEs in the
      binary_type_symtab list at the top of util/symbol.c. In each case the
      debugfile passed to dso__load_bfd_symbols() is the path to try.
      
      One of those iterations (the first one I believe) passes the original path
      as the debugfile. If the file still exists at the original path, this is
      the one that ends up being used in case the debugcache was deleted or the
      PE file doesn't have a build-id.
      
      A later iteration (BUILD_ID_CACHE) passes debugfile as the file in the
      debugcache if it has a build-id. Even if the file was previously loaded at
      its original path, (if I understand correctly) this load will override it
      so the debugcache file ends up being used.
      
      Committer notes:
      
      So if it fails to find in the cache, it will eventually hope for the
      best and look at the path in the local filesystem, which in many cases
      is enough.
      
      At some point we need to switch from this "hope for the best" approach
      to one that warns the user that there is no guarantee, if no buildid is
      present, that just by looking at the pathname the symbolisation will
      work.
      Signed-off-by: NNicholas Fraser <nfraser@codeweavers.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Frank Ch. Eigler <fche@redhat.com>
      Cc: Huw Davies <huw@codeweavers.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Tommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Ulrich Czekalla <uczekalla@codeweavers.com>
      Link: http://lore.kernel.org/lkml/e58e1237-94ab-e1c9-a7b9-473531906954@codeweavers.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      00a34234
    • L
      perf arm-spe: Store operation type in packet · 97ae666a
      Leo Yan 提交于
      This patch is to store operation type in packet structure.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: NJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-3-james.clark@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      97ae666a
    • L
      perf arm-spe: Store memory address in packet · 265cfb95
      Leo Yan 提交于
      This patch is to store virtual and physical memory addresses in packet,
      which will be used for memory samples.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210211133856.2137-2-james.clark@arm.comSigned-off-by: NJames Clark <james.clark@arm.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      265cfb95
    • L
      perf arm-spe: Enable sample type PERF_SAMPLE_DATA_SRC · 845d3a65
      Leo Yan 提交于
      This patch is to enable sample type PERF_SAMPLE_DATA_SRC for Arm SPE in
      the perf data, when output the tracing data, it tells tools that it
      contains data source in the memory event.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NJames Clark <james.clark@arm.com>
      Tested-by: NJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Andre Przywara <andre.przywara@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210211133856.2137-1-james.clark@arm.comSigned-off-by: NJames Clark <james.clark@arm.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      845d3a65
    • I
      perf env: Remove unneeded internal/cpumap inclusions · e73b0d58
      Ian Rogers 提交于
      Minor cleanup.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210211183914.4093187-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e73b0d58
    • I
      perf tools: Remove unused xyarray.c as it was moved to tools/lib/perf · b1cdc7d3
      Ian Rogers 提交于
      Migrated to libperf in:
      
        4b247fa7 ("libperf: Adopt xyarray class from perf")
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210212043803.365993-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b1cdc7d3
  6. 12 2月, 2021 2 次提交
    • D
      perf symbols: Use (long) for iterator for bfd symbols · 96de68ff
      Dmitry Safonov 提交于
      GCC (GCC) 8.4.0 20200304 fails to build perf with:
      : util/symbol.c: In function 'dso__load_bfd_symbols':
      : util/symbol.c:1626:16: error: comparison of integer expressions of different signednes
      :   for (i = 0; i < symbols_count; ++i) {
      :                 ^
      : util/symbol.c:1632:16: error: comparison of integer expressions of different signednes
      :    while (i + 1 < symbols_count &&
      :                 ^
      : util/symbol.c:1637:13: error: comparison of integer expressions of different signednes
      :    if (i + 1 < symbols_count &&
      :              ^
      : cc1: all warnings being treated as errors
      
      It's unlikely that the symtable will be that big, but the fix is an
      oneliner and as perf has CORE_CFLAGS += -Wextra, which makes build to
      fail together with CORE_CFLAGS += -Werror
      
      Fixes: eac9a434 ("perf symbols: Try reading the symbol table with libbfd")
      Signed-off-by: NDmitry Safonov <dima@arista.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Dmitry Safonov <0x7f454c46@gmail.com>
      Cc: Jacek Caban <jacek@codeweavers.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Link: http://lore.kernel.org/lkml/20210209145148.178702-1-dima@arista.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      96de68ff
    • M
      perf annotate: Fix jump parsing for C++ code. · 1f0e6edc
      Martin Liška 提交于
      Considering the following testcase:
      
        int
        foo(int a, int b)
        {
           for (unsigned i = 0; i < 1000000000; i++)
             a += b;
           return a;
        }
      
        int main()
        {
           foo (3, 4);
           return 0;
        }
      
      'perf annotate' displays:
      
        86.52 │40055e: → ja   40056c <foo(int, int)+0x26>
        13.37 │400560:   mov  -0x18(%rbp),%eax
              │400563:   add  %eax,-0x14(%rbp)
              │400566:   addl $0x1,-0x4(%rbp)
         0.11 │40056a: → jmp  400557 <foo(int, int)+0x11>
              │40056c:   mov  -0x14(%rbp),%eax
              │40056f:   pop  %rbp
      
      and the 'ja 40056c' does not link to the location in the function.  It's
      caused by fact that comma is wrongly parsed, it's part of function
      signature.
      
      With my patch I see:
      
        86.52 │   ┌──ja   26
        13.37 │   │  mov  -0x18(%rbp),%eax
              │   │  add  %eax,-0x14(%rbp)
              │   │  addl $0x1,-0x4(%rbp)
         0.11 │   │↑ jmp  11
              │26:└─→mov  -0x14(%rbp),%eax
      
      and 'o' output prints:
      
        86.52 │4005┌── ↓ ja   40056c <foo(int, int)+0x26>
        13.37 │4005│0:   mov  -0x18(%rbp),%eax
              │4005│3:   add  %eax,-0x14(%rbp)
              │4005│6:   addl $0x1,-0x4(%rbp)
         0.11 │4005│a: ↑ jmp  400557 <foo(int, int)+0x11>
              │4005└─→   mov  -0x14(%rbp),%eax
      
      On the contrary, compiling the very same file with gcc -x c, the parsing
      is fine because function arguments are not displayed:
      
        jmp  400543 <foo+0x1d>
      
      Committer testing:
      
      Before:
      
        $ cat cpp_args_annotate.c
        int
        foo(int a, int b)
        {
           for (unsigned i = 0; i < 1000000000; i++)
             a += b;
           return a;
        }
      
        int main()
        {
           foo (3, 4);
           return 0;
        }
        $ gcc --version |& head -1
        gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
        $ gcc -g cpp_args_annotate.c -o cpp_args_annotate
        $ perf record ./cpp_args_annotate
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 0.275 MB perf.data (7188 samples) ]
        $ perf annotate --stdio2 foo
        Samples: 7K of event 'cycles:u', 4000 Hz, Event count (approx.): 7468429289, [percent: local period]
        foo() /home/acme/c/cpp_args_annotate
        Percent
                    0000000000401106 <foo>:
                    foo():
                    int
                    foo(int a, int b)
                    {
                      push %rbp
                      mov  %rsp,%rbp
                      mov  %edi,-0x14(%rbp)
                      mov  %esi,-0x18(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      movl $0x0,-0x4(%rbp)
                    ↓ jmp  1d
                    a += b;
         13.45  13:   mov  -0x18(%rbp),%eax
                      add  %eax,-0x14(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      addl $0x1,-0x4(%rbp)
          0.09  1d:   cmpl $0x3b9ac9ff,-0x4(%rbp)
         86.46      ↑ jbe  13
                    return a;
                      mov  -0x14(%rbp),%eax
                    }
                      pop  %rbp
                    ← retq
        $
      
      I.e. works for C, now lets switch to C++:
      
        $ g++ -g cpp_args_annotate.c -o cpp_args_annotate
        $ perf record ./cpp_args_annotate
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.268 MB perf.data (6976 samples) ]
        $ perf annotate --stdio2 foo
        Samples: 6K of event 'cycles:u', 4000 Hz, Event count (approx.): 7380681761, [percent: local period]
        foo() /home/acme/c/cpp_args_annotate
        Percent
                    0000000000401106 <foo(int, int)>:
                    foo(int, int):
                    int
                    foo(int a, int b)
                    {
                      push %rbp
                      mov  %rsp,%rbp
                      mov  %edi,-0x14(%rbp)
                      mov  %esi,-0x18(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      movl $0x0,-0x4(%rbp)
                      cmpl $0x3b9ac9ff,-0x4(%rbp)
         86.53      → ja   40112c <foo(int, int)+0x26>
                    a += b;
         13.32        mov  -0x18(%rbp),%eax
          0.00        add  %eax,-0x14(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      addl $0x1,-0x4(%rbp)
          0.15      → jmp  401117 <foo(int, int)+0x11>
                    return a;
                      mov  -0x14(%rbp),%eax
                    }
                      pop  %rbp
                    ← retq
        $
      
      Reproduced.
      
      Now with this patch:
      
      Reusing the C++ built binary, as we can see here:
      
        $ readelf -wi cpp_args_annotate | grep producer
          <c>   DW_AT_producer    : (indirect string, offset: 0x2e): GNU C++14 10.2.1 20201125 (Red Hat 10.2.1-9) -mtune=generic -march=x86-64 -g
        $
      
      And furthermore:
      
        $ file cpp_args_annotate
        cpp_args_annotate: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=4fe3cab260204765605ec630d0dc7a7e93c361a9, for GNU/Linux 3.2.0, with debug_info, not stripped
        $ perf buildid-list -i cpp_args_annotate
        4fe3cab260204765605ec630d0dc7a7e93c361a9
        $ perf buildid-list | grep cpp_args_annotate
        4fe3cab260204765605ec630d0dc7a7e93c361a9 /home/acme/c/cpp_args_annotate
        $
      
      It now works:
      
        $ perf annotate --stdio2 foo
        Samples: 6K of event 'cycles:u', 4000 Hz, Event count (approx.): 7380681761, [percent: local period]
        foo() /home/acme/c/cpp_args_annotate
        Percent
                    0000000000401106 <foo(int, int)>:
                    foo(int, int):
                    int
                    foo(int a, int b)
                    {
                      push %rbp
                      mov  %rsp,%rbp
                      mov  %edi,-0x14(%rbp)
                      mov  %esi,-0x18(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      movl $0x0,-0x4(%rbp)
                11:   cmpl $0x3b9ac9ff,-0x4(%rbp)
         86.53      ↓ ja   26
                    a += b;
         13.32        mov  -0x18(%rbp),%eax
          0.00        add  %eax,-0x14(%rbp)
                    for (unsigned i = 0; i < 1000000000; i++)
                      addl $0x1,-0x4(%rbp)
          0.15      ↑ jmp  11
                    return a;
                26:   mov  -0x14(%rbp),%eax
                    }
                      pop  %rbp
                    ← retq
        $
      Signed-off-by: NMartin Liška <mliska@suse.cz>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Link: http://lore.kernel.org/lkml/13e1a405-edf9-e4c2-4327-a9b454353730@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f0e6edc
  7. 11 2月, 2021 13 次提交
    • K
      perf tools: Replace lkml.org links with lore · 6edfd0eb
      Kees Cook 提交于
      As started by commit 05a5f51c ("Documentation: Replace lkml.org
      links with lore"), replace lkml.org links with lore to better use a
      single source that's more likely to stay available long-term.
      Signed-off-by: NKees Kook <keescook@chromium.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Link: http://lore.kernel.org/lkml/20210210234220.2401035-1-keescook@chromium.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6edfd0eb
    • J
      perf tests: Add daemon 'lock' test · dec34515
      Jiri Olsa 提交于
      Add a test for the perf daemon 'lock' command ensuring only one instance
      of daemon can run over one base directory.
      
      Committer testing:
      
        [root@five ~]# perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 793255
        test daemon list
        test daemon reconfig
        test daemon stop
        test daemon signal
        signal 12 sent to session 'test [793506]'
        signal 12 sent to session 'test [793506]'
        test daemon ping
        test daemon lock
        test child finished with 0
        ---- end ----
        daemon operations: Ok
        [root@five ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-25-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dec34515
    • J
      perf tests: Add daemon 'ping' command test · 63551dc7
      Jiri Olsa 提交于
      Add a test for the perf daemon 'ping' command. The tests verifies the
      ping command gets proper answer from sessions.
      
      Committer testing:
      
        [root@five ~]# perf test daemon
        76: daemon operations                                               : Ok
        [root@five ~]# perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 792143
        test daemon list
        test daemon reconfig
        test daemon stop
        test daemon signal
        signal 12 sent to session 'test [792415]'
        signal 12 sent to session 'test [792415]'
        test daemon ping
        test child finished with 0
        ---- end ----
        daemon operations: Ok
        [root@five ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-24-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      63551dc7
    • J
      perf tests: Add daemon 'signal' command test · f32102aa
      Jiri Olsa 提交于
      Add a test for the perf daemon 'signal' command. The test sends a signal
      to configured sessions and verifies the perf data files were generated
      accordingly.
      
        Committer testing:
      
        [root@five ~]# perf test daemon
        76: daemon operations                                               : Ok
        [root@five ~]# perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 790017
        test daemon list
        test daemon reconfig
        test daemon stop
        test daemon signal
        signal 12 sent to session 'test [790268]'
        signal 12 sent to session 'test [790268]'
        test child finished with 0
        ---- end ----
        daemon operations: Ok
        [root@five ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-23-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f32102aa
    • J
      perf tests: Add daemon 'stop' command test · f624f6d0
      Jiri Olsa 提交于
      Add a test for the perf daemon 'stop' command. The test stops the daemon
      and verifies all the configured sessions are properly terminated.
      
      Committer testing:
      
        [root@five ~]# time perf test daemon
        76: daemon operations                                               : Ok
        [root@five ~]# time perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 788560
        test daemon list
        test daemon reconfig
        test daemon stop
        test child finished with 0
        ---- end ----
        daemon operations: Ok
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-22-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f624f6d0
    • J
      perf tests: Add daemon reconfig test · 91a17d6f
      Jiri Olsa 提交于
      Add a test for daemon reconfiguration. The test changes the
      configuration file and checks that the session is changed properly.
      
      Committer testing:
      
        [root@five ~]# perf test daemon
        76: daemon operations                                               : Ok
        [root@five ~]# time perf test daemon
        76: daemon operations                                               : Ok
      
        real	0m6.055s
        user	0m0.174s
        sys	0m0.147s
        [root@five ~]# time perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 786863
        test daemon list
        test daemon reconfig
        test child finished with 0
        ---- end ----
        daemon operations: Ok
      
        real	0m6.127s
        user	0m0.222s
        sys	0m0.165s
        [root@five ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-21-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      91a17d6f
    • J
      perf tests: Add daemon 'list' command test · 2291bb91
      Jiri Olsa 提交于
      Add test for basic perf daemon listing via the CSV output mode (-x
      option).
      
      Check that the configured sessions display expected values.
      
      Committer testing:
      
        [root@five ~]# perf test daemon
        76: daemon operations                                               : Ok
        [root@five ~]#
        [root@five ~]# perf test -v daemon
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 785037
        test daemon list
        test child finished with 0
        ---- end ----
        daemon operations: Ok
        [root@five ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-20-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2291bb91
    • J
      perf daemon: Add examples to man page · 13fb3b9f
      Jiri Olsa 提交于
      Add usage examples to the man page.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-19-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      13fb3b9f
    • J
      perf daemon: Add up time for daemon/session list · 5bdee4f0
      Jiri Olsa 提交于
      Display up time for both daemon and sessions.
      
      Example:
      
        # cat ~/.perfconfig
        [daemon]
        base=/opt/perfdata
      
        [session-cycles]
        run = -m 10M -e cycles --overwrite --switch-output -a
      
        [session-sched]
        run = -m 20M -e sched:* --overwrite --switch-output -a
      
      Starting the daemon:
      
        # perf daemon start
      
      Get the details with up time:
      
        # perf daemon -v
        [778315:daemon] base: /opt/perfdata
          output:  /opt/perfdata/output
          lock:    /opt/perfdata/lock
          up:      15 minutes
        [778316:cycles] perf record -m 20M -e cycles --overwrite --switch-output -a
          base:    /opt/perfdata/session-cycles
          output:  /opt/perfdata/session-cycles/output
          control: /opt/perfdata/session-cycles/control
          ack:     /opt/perfdata/session-cycles/ack
          up:      10 minutes
        [778317:sched] perf record -m 20M -e sched:* --overwrite --switch-output -a
          base:    /opt/perfdata/session-sched
          output:  /opt/perfdata/session-sched/output
          control: /opt/perfdata/session-sched/control
          ack:     /opt/perfdata/session-sched/ack
          up:      2 minutes
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-18-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5bdee4f0
    • J
      perf daemon: Use control to stop session · 6d6162d5
      Jiri Olsa 提交于
      Use the 'stop' control command to stop perf record session.  If that
      fails, fall back to current SIGTERM/SIGKILL pair.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-17-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6d6162d5
    • J
      perf daemon: Add 'ping' command · edcaa479
      Jiri Olsa 提交于
      Add a 'ping' command to verify that the 'perf record' session is up and
      operational.
      
      It's used in the following patches via test code to make sure 'perf
      record' is ready to receive signals.
      
      Example:
      
        # cat ~/.perfconfig
        [daemon]
        base=/opt/perfdata
      
        [session-cycles]
        run = -m 10M -e cycles --overwrite --switch-output -a
      
        [session-sched]
        run = -m 20M -e sched:* --overwrite --switch-output -a
      
      Start the daemon:
      
        # perf daemon start
      
      Ping all sessions:
      
        # perf daemon ping
        OK   cycles
        OK   sched
      
      Ping specific session:
      
        # perf daemon ping --session sched
        OK   sched
      
      Committer notes:
      
      Fixed up bug pointed by clang:
      
      Buggy:
      
        if (!pollfd.revents & POLLIN)
      
      Correct code:
      
        if (!(pollfd.revents & POLLIN))
      
      clang warning:
      
        builtin-daemon.c:560:6: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
                if (!pollfd.revents & POLLIN) {
                    ^               ~
        builtin-daemon.c:560:6: note: add parentheses after the '!' to evaluate the bitwise operator first
      
      Also use designated initialized with pollfd, i.e.:
      
        struct pollfd pollfd = { .events = POLLIN, };
      
      Instead of:
      
        struct pollfd pollfd = { 0, };
      
      To get past:
      
          builtin-daemon.c:510:30: error: missing field 'events' initializer [-Werror,-Wmissing-field-initializers]
                  struct pollfd pollfd = { 0, };
                                              ^
          1 error generated.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-16-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      edcaa479
    • J
      perf daemon: Set control fifo for session · 6a6d1804
      Jiri Olsa 提交于
      Setup control fifos for session and add --control option to session
      arguments.
      
      Example:
      
        # cat ~/.perfconfig
        [daemon]
        base=/opt/perfdata
      
        [session-cycles]
        run = -m 10M -e cycles --overwrite --switch-output -a
      
        [session-sched]
        run = -m 20M -e sched:* --overwrite --switch-output -a
      
      Starting the daemon:
      
        # perf daemon start
      
      Use can list control fifos with (control and ack files):
      
        # perf daemon -v
        [776459:daemon] base: /opt/perfdata
          output:  /opt/perfdata/output
          lock:    /opt/perfdata/lock
        [776460:cycles] perf record -m 20M -e cycles --overwrite --switch-output -a
          base:    /opt/perfdata/session-cycles
          output:  /opt/perfdata/session-cycles/output
          control: /opt/perfdata/session-cycles/control
          ack:     /opt/perfdata/session-cycles/ack
        [776461:sched] perf record -m 20M -e sched:* --overwrite --switch-output -a
          base:    /opt/perfdata/session-sched
          output:  /opt/perfdata/session-sched/output
          control: /opt/perfdata/session-sched/control
          ack:     /opt/perfdata/session-sched/ack
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-15-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6a6d1804
    • J
      perf daemon: Allow only one daemon over base directory · 8c98be6c
      Jiri Olsa 提交于
      Add 'lock' file under daemon base and flock it, so only one perf daemon
      can run on top of it.
      
      Each daemon tries to create and lock BASE/lock file, if it's successful
      we are sure we're the only daemon running over the BASE.
      
      Once daemon is finished, file descriptor to lock file is closed and lock
      is released.
      
      Example:
      
        # cat ~/.perfconfig
        [daemon]
        base=/opt/perfdata
      
        [session-cycles]
        run = -m 10M -e cycles --overwrite --switch-output -a
      
        [session-sched]
        run = -m 20M -e sched:* --overwrite --switch-output -a
      
      Starting the daemon:
      
        # perf daemon start
      
      And try once more:
      
        # perf daemon start
        failed: another perf daemon (pid 775594) owns /opt/perfdata
      
      will end up with an error, because there's already one running
      on top of /opt/perfdata.
      
      Committer notes:
      
      Provide lockf(F_TLOCK) when not available, i.e. transform:
      
        lockf(fd, F_TLOCK, 0);
      
      into:
      
        flock(fd, LOCK_EX | LOCK_NB);
      
      Which should be equivalent.
      
      Noticed when cross building to some odd Android NDK.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: https://lore.kernel.org/r/20210208200908.1019149-14-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8c98be6c