perf daemon: Add 'ping' command
authorJiri Olsa <jolsa@kernel.org>
Mon, 8 Feb 2021 20:08:59 +0000 (21:08 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 11 Feb 2021 13:19:52 +0000 (10:19 -0300)
commitedcaa47958c7438b56fc528d4e242f16a249003f
tree1b4a2191ea69ff8d77d4ad6af461c1e5066ad2e4
parent6a6d1804a190ef0d8ac35a5728cee2e19dd00777
perf daemon: Add 'ping' command

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: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-daemon.txt
tools/perf/builtin-daemon.c