1. 16 Feb, 2021 2 commits
    • Leo Yan's avatar
      perf arm-spe: Synthesize memory event · e55ed342
      Leo Yan authored
      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: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarJames 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: default avatarJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e55ed342
    • Leo Yan's avatar
      perf arm-spe: Fill address info for samples · 54f7815e
      Leo Yan authored
      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: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarJames 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: default avatarJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20210211133856.2137-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54f7815e
  2. 12 Feb, 2021 5 commits
  3. 11 Feb, 2021 21 commits
    • Kees Cook's avatar
      perf tools: Replace lkml.org links with lore · 6edfd0eb
      Kees Cook authored
      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: default avatarKees Kook <keescook@chromium.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarPeter 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6edfd0eb
    • Jiri Olsa's avatar
      perf tests: Add daemon 'lock' test · dec34515
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dec34515
    • Jiri Olsa's avatar
      perf tests: Add daemon 'ping' command test · 63551dc7
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      63551dc7
    • Jiri Olsa's avatar
      perf tests: Add daemon 'signal' command test · f32102aa
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f32102aa
    • Jiri Olsa's avatar
      perf tests: Add daemon 'stop' command test · f624f6d0
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f624f6d0
    • Jiri Olsa's avatar
      perf tests: Add daemon reconfig test · 91a17d6f
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      91a17d6f
    • Jiri Olsa's avatar
      perf tests: Add daemon 'list' command test · 2291bb91
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2291bb91
    • Jiri Olsa's avatar
      perf daemon: Add examples to man page · 13fb3b9f
      Jiri Olsa authored
      Add usage examples to the man page.
      Signed-off-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      13fb3b9f
    • Jiri Olsa's avatar
      perf daemon: Add up time for daemon/session list · 5bdee4f0
      Jiri Olsa authored
      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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5bdee4f0
    • Jiri Olsa's avatar
      perf daemon: Use control to stop session · 6d6162d5
      Jiri Olsa authored
      Use the 'stop' control command to stop perf record session.  If that
      fails, fall back to current SIGTERM/SIGKILL pair.
      Signed-off-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6d6162d5
    • Jiri Olsa's avatar
      perf daemon: Add 'ping' command · edcaa479
      Jiri Olsa authored
      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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edcaa479
    • Jiri Olsa's avatar
      perf daemon: Set control fifo for session · 6a6d1804
      Jiri Olsa authored
      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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a6d1804
    • Jiri Olsa's avatar
      perf daemon: Allow only one daemon over base directory · 8c98be6c
      Jiri Olsa authored
      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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c98be6c
    • Jiri Olsa's avatar
      perf daemon: Add 'stop' command · 23c5831e
      Jiri Olsa authored
      Add 'perf daemon stop' command to stop daemon process and all running
      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
      
      Start the daemon:
      
        # perf daemon start
      
      Stop the daemon
      
        # perf daemon stop
      
      Daemon is not running, nothing to connect to:
      
        # perf daemon
        connect error: Connection refused
      Signed-off-by: default avatarJiri 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-13-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      23c5831e
    • Jiri Olsa's avatar
      perf daemon: Add 'signal' command · 2d6914cd
      Jiri Olsa authored
      Allow the 'perf daemon' to send SIGUSR2 to all running sessions or just
      to a specific session.
      
      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
      
      Send signal to all running sessions:
      
        # perf daemon signal
        signal 12 sent to session 'cycles [773738]'
        signal 12 sent to session 'sched [773739]'
      
      Or to specific one:
      
        # perf daemon signal --session sched
        signal 12 sent to session 'sched [773739]'
      
      And verify signals were delivered and perf.data dumped:
      
        # cat /opt/perfdata/session-cycles/output
        rounding mmap pages size to 32M (8192 pages)
        [ perf record: dump data: Woken up 1 times ]
        [ perf record: Dump perf.data.2021010220382490 ]
      
        # car /opt/perfdata/session-sched/output
        rounding mmap pages size to 32M (8192 pages)
        [ perf record: dump data: Woken up 1 times ]
        [ perf record: Dump perf.data.2021010220382489 ]
        [ perf record: dump data: Woken up 1 times ]
        [ perf record: Dump perf.data.2021010220393745 ]
      Signed-off-by: default avatarJiri 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-12-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2d6914cd
    • Jiri Olsa's avatar
      perf daemon: Add 'list' command · b325f7be
      Jiri Olsa authored
      Add a 'list' command to display all running sessions.  It's the default
      command if no other command is specified.
      
      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
      
      List sessions:
      
        # perf daemon
        [771394:daemon] base: /opt/perfdata
        [771395:cycles] perf record -m 10M -e cycles --overwrite --switch-output -a
        [771396:sched] perf record -m 20M -e sched:* --overwrite --switch-output -a
      
      List sessions with more info:
      
        # perf daemon -v
        [771394:daemon] base: /opt/perfdata
          output:  /opt/perfdata/output
        [771395:cycles] perf record -m 10M -e cycles --overwrite --switch-output -a
          base:    /opt/perfdata/session-cycles
          output:  /opt/perfdata/session-cycles/output
        [771396:sched] perf record -m 20M -e sched:* --overwrite --switch-output -a
          base:    /opt/perfdata/session-sched
          output:  /opt/perfdata/session-sched/output
      
      The 'output' file is perf record output for specific session.
      
      Note you have to stop all running perf processes manually at this point,
      stop command is coming in following patches.
      
      Committer notes:
      
      Fixup union initialization to overcome this in multiple older systems:
      
        22    15.74 debian:8                      : FAIL gcc version 4.9.2 (Debian 4.9.2-10+deb8u2)
      
          builtin-daemon.c: In function 'send_cmd_list':
          builtin-daemon.c:1386:2: error: missing initializer for field 'csv_sep' of 'struct <anonymous>' [-Werror=missing-field-initializers]
            };
            ^
          builtin-daemon.c:641:8: note: 'csv_sep' declared here
             char csv_sep;
                  ^
          cc1: all warnings being treated as errors
      Signed-off-by: default avatarJiri 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-11-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b325f7be
    • Jiri Olsa's avatar
      perf daemon: Add signalfd support · 12c1a415
      Jiri Olsa authored
      Use a signalfd fd to track SIGCHLD signals as notifications for perf
      session termination.
      
      This way we don't need to actively check for child status, being
      notified if there's change.
      Suggested-by: default avatarAlexei Budankov <abudankov@huawei.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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-10-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      12c1a415
    • Jiri Olsa's avatar
      perf daemon: Add background support · 88adb119
      Jiri Olsa authored
      Add support to put the daemon process in the background.
      
      It's now enabled by default and -f option is added to keep the daemon
      process on the console for debugging.
      Signed-off-by: default avatarJiri 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-9-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      88adb119
    • Jiri Olsa's avatar
      perf daemon: Add config file change check · 3cda0625
      Jiri Olsa authored
      Add support to detect changes to the daemon's config file triggering a
      re-read of the configuration when that happens.
      
      Use a inotify file descriptor plugged into the main fdarray object for
      polling.
      
      Example:
      
        # cat ~/.perfconfig
        [daemon]
        base=/opt/perfdata
      
        [session-cycles]
        run = -m 10M -e cycles --overwrite --switch-output -a
      
      Starting the daemon:
      
        # perf daemon start
      
      Check sessions:
      
        # perf daemon
        [772262:daemon] base: /opt/perfdata
        [772263:cycles] perf record -m 10M -e cycles --overwrite --switch-output -a
      
      Change '-m 10M' to '-m 20M', and check daemon log:
      
        # tail -f /opt/perfdata/output
        [2021-01-02 20:31:41.234045] daemon started (pid 772262)
        [2021-01-02 20:31:41.235072] reconfig: ruining session [cycles:772263]: -m 10M -e cycles --overwrite --switch-output -a
        [2021-01-02 20:32:08.310137] reconfig: session 'cycles' killed
        [2021-01-02 20:32:08.310847] reconfig: ruining session [cycles:772338]: -m 20M -e cycles --overwrite --switch-output -a
      
      And the session list:
      
        # perf daemon
        [772262:daemon] base: /opt/perfdata
        [772338:cycles] perf record -m 20M -e cycles --overwrite --switch-output -a
      
      Note the changed '-m 20M' option is in place.
      Signed-off-by: default avatarJiri 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-8-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3cda0625
    • Jiri Olsa's avatar
      perf daemon: Add config file support · c0666261
      Jiri Olsa authored
      Adding support to configure daemon with config file.
      
      Each client or server invocation of perf daemon needs to know the
      base directory, where all sessions data is stored.
      
      The base is defined with:
      
        daemon.base
          Base path for daemon data. All sessions data are stored under
          this path.
      
      The daemon allows to create record sessions. Each session is a
      record command spawned and monitored by perf daemon.
      
      The session is defined with:
      
        session-<NAME>.run
          Defines new record session for daemon. The value is record's
          command line without the 'record' keyword.
      
      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
      
      The example above defines '/opt/perfdata' as the base directory and 2
      record sessions.
      
        # perf daemon start
        [2021-01-28 19:47:33.454413] daemon started (pid 16015)
        [2021-01-28 19:47:33.455910] reconfig: ruining session [cycles:16016]: -m 10M -e cycles --overwrite --switch-output -a
        [2021-01-28 19:47:33.456599] reconfig: ruining session [sched:16017]: -m 20M -e sched:* --overwrite --switch-output -a
      
        # ps -ef | grep perf
        ... perf daemon start
        ... /home/jolsa/.../perf record -m 20M -e cycles --overwrite --switch-output -a
        ... /home/jolsa/.../perf record -m 20M -e sched:* --overwrite --switch-output -a
      
      The base directory is populated with:
      
        # find /opt/perfdata/
        /opt/perfdata/
        /opt/perfdata/control                    <- control socket
        /opt/perfdata/session-cycles             <- data for session 'cycles':
        /opt/perfdata/session-cycles/output      <-   perf record output
        /opt/perfdata/session-cycles/perf.data   <-   perf data
        /opt/perfdata/session-sched              <- ditto for session 'sched'
        /opt/perfdata/session-sched/output
        /opt/perfdata/session-sched/perf.data
      Signed-off-by: default avatarJiri 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-7-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c0666261
    • Jiri Olsa's avatar
      perf daemon: Add client socket support · 90b0aad8
      Jiri Olsa authored
      Add support for client socket side that will be used to send commands to
      the daemon server socket.
      
      This patch adds only the core support, all commands using this
      functionality are coming in the following patches.
      
      Committer notes:
      
      Hat to patch patch it to deal with this in some systems:
      
        cc1: warnings being treated as errors
        builtin-daemon.c: In function 'send_cmd':  MKDIR    /tmp/build/perf/bench/
      
        builtin-daemon.c:1368: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
          MKDIR    /tmp/build/perf/tests/
        make[3]: *** [/tmp/build/perf/builtin-daemon.o] Error 1
      
      And also to not leak the 'line' buffer allocated by getline(), since you
      initialized line to NULL and len to zero, man page says:
      
        If *lineptr is set to NULL and *n is set 0 before the call,
        then getline() will allocate a buffer for storing the line.
        This buffer should be freed by the user program even if
        getline() failed.
      Signed-off-by: default avatarJiri 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-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      90b0aad8
  4. 09 Feb, 2021 7 commits
    • Jiri Olsa's avatar
      perf daemon: Add server socket support · ed36b704
      Jiri Olsa authored
      Add support to create a server socket that listens for client commands
      and processes them.
      
      This patch adds only the core support, all commands using this
      functionality are coming in the following patches.
      Signed-off-by: default avatarJiri 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-5-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ed36b704
    • Jiri Olsa's avatar
      perf daemon: Add base option · 5631d100
      Jiri Olsa authored
      Add a base option allowing the user to specify a base directory.  It
      will have precedence over config file base definition coming in the
      following patches.
      Signed-off-by: default avatarJiri 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-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5631d100
    • Jiri Olsa's avatar
      perf daemon: Add config option · fc1dcb1e
      Jiri Olsa authored
      Add a config option and base functionality that takes the option
      argument (if specified) and other system config locations and produces
      an 'acting' config file path.
      
      The actual config file processing is coming in following patches.
      Signed-off-by: default avatarJiri 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-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc1dcb1e
    • Jiri Olsa's avatar
      perf daemon: Add daemon command · d450bc50
      Jiri Olsa authored
      Add a daemon skeleton with a minimal base (non) functionality, covering
      various setup in start command.
      
      Add an initial perf-daemon.txt with basic info.
      
      This is in response to pople asking for the possibility to be able run
      record long running sessions on the background.
      
      The patchset that starts with this adds support to configure and run
      record sessions on background via new 'perf daemon' command.
      
      This is useful for being able to use perf as a flight recorder that one
      can interact with asking for events to be enabled or disabled, added or
      removed, etc.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      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-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d450bc50
    • Yang Li's avatar
      perf script: Simplify bool conversion · 8524711d
      Yang Li authored
        Fix the following coccicheck warning:
        ./tools/perf/builtin-script.c:2789:36-41: WARNING: conversion to bool
        not needed here
        ./tools/perf/builtin-script.c:3237:48-53: WARNING: conversion to bool
        not needed here
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/1612773936-98691-1-git-send-email-yang.lee@linux.alibaba.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8524711d
    • Arnaldo Carvalho de Melo's avatar
      perf arm64/s390: Fix printf conversion specifier for IP addresses · 6db59d35
      Arnaldo Carvalho de Melo authored
      We need to use "%#" PRIx64 for u64 values, not "%lx". In arm64's and
      s390x cases the compiler doesn't complain, but lets fix this in case
      this code gets copied to a 32-bit arch, like with powerpc 32-bit that
      got fixed in the previous patch.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hewenliang <hewenliang4@huawei.com>
      Cc: Hu Shiyuan <hushiyuan@huawei.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: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6db59d35
    • Arnaldo Carvalho de Melo's avatar
      perf powerpc: Fix printf conversion specifier for IP addresses · 0f000f9c
      Arnaldo Carvalho de Melo authored
      We need to use "%#" PRIx64 for u64 values, not "%lx", fixing this build
      problem on powerpc 32-bit:
      
        72    13.69 ubuntu:18.04-x-powerpc        : FAIL powerpc-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
          arch/powerpc/util/machine.c: In function 'arch__symbols__fixup_end':
          arch/powerpc/util/machine.c:23:12: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'u64 {aka long long unsigned int}' [-Werror=format=]
            pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
                      ^
          /git/linux/tools/perf/util/debug.h:18:21: note: in definition of macro 'pr_fmt'
           #define pr_fmt(fmt) fmt
                               ^~~
          /git/linux/tools/perf/util/debug.h:33:29: note: in expansion of macro 'pr_debugN'
           #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
                                       ^~~~~~~~~
          /git/linux/tools/perf/util/debug.h:33:42: note: in expansion of macro 'pr_fmt'
           #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
                                                    ^~~~~~
          arch/powerpc/util/machine.c:23:2: note: in expansion of macro 'pr_debug4'
            pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
            ^~~~~~~~~
          cc1: all warnings being treated as errors
          /git/linux/tools/build/Makefile.build:139: recipe for target 'util' failed
          make[5]: *** [util] Error 2
          /git/linux/tools/build/Makefile.build:139: recipe for target 'powerpc' failed
          make[4]: *** [powerpc] Error 2
          /git/linux/tools/build/Makefile.build:139: recipe for target 'arch' failed
          make[3]: *** [arch] Error 2
        73    30.47 ubuntu:18.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
      
      Fixes: 557c3ead ("perf powerpc: Fix gap between kernel end and module start")
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f000f9c
  5. 08 Feb, 2021 5 commits
    • Jin Yao's avatar
      perf script: Support filtering by hex address · 61d9fc44
      Jin Yao authored
      'perf script' supports '-S' or '--symbol' options to only list the
      records for these symbols. A symbol is typically a name or hex address.
      If it's hex address, it is the start address of one symbol.
      
      While it would be useful if we can filter trace records by any hex
      address (not only the start address of symbol). So now we support
      filtering trace records by more conditions, such as:
      
      - symbol name
      - start address of symbol
      - any hexadecimal address
      - address range
      
      The comparison order is defined as:
      
      1. symbol name comparison
      2. symbol start address comparison.
      3. any hexadecimal address comparison.
      4. address range comparison.
      
      The idea is if we can get a valid address from -S list, we add the
      address to addr_list for address comparison otherwise we still leave
      it to sym_list for symbol comparison.
      
      Some examples:
      
        root@kbl-ppc:~# ./perf script -S ffffffff9a477308
                  perf  8562 [000] 347303.578858:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [000] 347303.578860:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [000] 347303.578861:         11   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [001] 347303.578903:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [001] 347303.578905:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [001] 347303.578906:         15   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [002] 347303.578952:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
                  perf  8562 [002] 347303.578953:          1   cycles:  ffffffff9a477308 native_write_msr+0x8 ([kernel.kallsyms])
      
      Filter the traced records by hex address ffffffff9a477308.
      
        root@kbl-ppc:~# ./perf script -S ffffffff9a4dd4ce,ffffffff9a4d2de9,ffffffff9a6bf9f4
                  perf  8562 [001] 347303.578911:     311706   cycles:  ffffffff9a6bf9f4 __kmalloc_node+0x204 ([kernel.kallsyms])
                  perf  8562 [002] 347303.578960:     354477   cycles:  ffffffff9a4d2de9 sched_setaffinity+0x49 ([kernel.kallsyms])
                  perf  8562 [003] 347303.579015:     450958   cycles:  ffffffff9a4dd4ce dequeue_task_fair+0x1ae ([kernel.kallsyms])
      
      Filter the traced records by hex address ffffffff9a4dd4ce, ffffffff9a4d2de9, ffffffff9a6bf9f4.
      
        root@kbl-ppc:~# ./perf script -S ffffffff9a477309 --addr-range 16
                  perf  8562 [000] 347303.578863:        291   cycles:  ffffffff9a47730a native_write_msr+0xa ([kernel.kallsyms])
                  perf  8562 [001] 347303.578907:        411   cycles:  ffffffff9a47730a native_write_msr+0xa ([kernel.kallsyms])
                  perf  8562 [002] 347303.578956:        462   cycles:  ffffffff9a47730f native_write_msr+0xf ([kernel.kallsyms])
                  perf  8562 [003] 347303.579010:        497   cycles:  ffffffff9a47730f native_write_msr+0xf ([kernel.kallsyms])
                  perf  8562 [004] 347303.579059:        429   cycles:  ffffffff9a47730f native_write_msr+0xf ([kernel.kallsyms])
                  perf  8562 [005] 347303.579109:        408   cycles:  ffffffff9a47730a native_write_msr+0xa ([kernel.kallsyms])
                  perf  8562 [006] 347303.579159:        460   cycles:  ffffffff9a47730f native_write_msr+0xf ([kernel.kallsyms])
                  perf  8562 [007] 347303.579213:        436   cycles:  ffffffff9a47730f native_write_msr+0xf ([kernel.kallsyms])
      
      Filter the traced records from address range [ffffffff9a477309, ffffffff9a477309 + 15].
      
        root@kbl-ppc:~# ./perf script -S "ffffffff9b163046,rcu_nmi_exit"
                  perf  8562 [004] 347303.579060:      12013   cycles:  ffffffff9b163046 exc_nmi+0x166 ([kernel.kallsyms])
                  perf  8562 [007] 347303.579214:      12138   cycles:  ffffffff9b165944 rcu_nmi_exit+0x34 ([kernel.kallsyms])
      
      Filter by address + symbol
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210207080935.31784-2-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      61d9fc44
    • Jin Yao's avatar
      perf intlist: Change 'struct intlist' int member to 'unsigned long' · 94253393
      Jin Yao authored
      This is to let intlist support addresses as its payload.
      
      One potential problem is it can't support negative number. But so far,
      there is no such kind of use case.
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210207080935.31784-1-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      94253393
    • Paul Cercueil's avatar
      perf stat: Use nftw() instead of ftw() · a81fbb87
      Paul Cercueil authored
      ftw() has been obsolete for about 12 years now.
      
      Committer notes:
      
      Further notes provided by the patch author:
      
          "NOTE: Not runtime-tested, I have no idea what I need to do in perf
           to test this. But at least it compiles now with my uClibc-based
           toolchain."
      
      I looked at the nftw()/ftw() man page and for the use made with cgroups
      in 'perf stat' the end result is equivalent.
      
      Fixes: bb1c15b6 ("perf stat: Support regex pattern in --for-each-cgroup")
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: od@zcrc.me
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20210208181157.1324550-1-paul@crapouillou.netSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a81fbb87
    • Kan Liang's avatar
      perf tools: Update topdown documentation for Sapphire Rapids · 7d91e818
      Kan Liang authored
      Update Topdown extension on Sapphire Rapids and how to collect the L2
      events.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.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/1612296553-21962-10-git-send-email-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7d91e818
    • Kan Liang's avatar
      perf stat: Support L2 Topdown events · 63e39aa6
      Kan Liang authored
      The TMA method level 2 metrics is supported from the Intel Sapphire
      Rapids server, which expose four L2 Topdown metrics events to user
      space. There are eight L2 events in total. The other four L2 Topdown
      metrics events are calculated from the corresponding L1 and the exposed
      L2 events.
      
      Now, the --topdown prints the complete top-down metrics that supported
      by the CPU. For the Intel Sapphire Rapids server, there are 4 L1 events
      and 8 L2 events displyed in one line.
      
      Add a new option, --td-level, to display the top-down statistics that
      equal to or lower than the input level.
      
      The L2 event is marked only when both its L1 parent event and itself
      crosse the threshold.
      
      Here is an example:
      
        $ perf stat --topdown --td-level=2 --no-metric-only sleep 1
        Topdown accuracy may decrease when measuring long periods.
        Please print the result regularly, e.g. -I1000
      
        Performance counter stats for 'sleep 1':
      
           16,734,390   slots
            2,100,001   topdown-retiring       # 12.6% retiring
            2,034,376   topdown-bad-spec       # 12.3% bad speculation
            4,003,128   topdown-fe-bound       # 24.1% frontend bound
              328,125   topdown-heavy-ops      #  2.0% heavy operations    #  10.6% light operations
            1,968,751   topdown-br-mispredict  # 11.9% branch mispredict   #  0.4% machine clears
            2,953,127   topdown-fetch-lat      # 17.8% fetch latency       #  6.3% fetch bandwidth
            5,906,255   topdown-mem-bound      # 35.6% memory bound        #  15.4% core bound
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.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/1612296553-21962-9-git-send-email-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      63e39aa6