• 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
perf-daemon.txt 2.49 KB