• 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
builtin-daemon.c 16.8 KB