Skip to content

Commit

Permalink
perf daemon: Add config file support
Browse files Browse the repository at this point in the history
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: 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-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Feb 11, 2021
1 parent 90b0aad commit c066626
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tools/perf/Documentation/perf-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,20 @@ auxtrace.*::
If the directory does not exist or has the wrong file type,
the current directory is used.

daemon.*::

daemon.base::
Base path for daemon data. All sessions data are stored under
this path.

session-<NAME>.*::

session-<NAME>.run::

Defines new record session for daemon. The value is record's
command line without the 'record' keyword.


SEE ALSO
--------
linkperf:perf[1]
30 changes: 30 additions & 0 deletions tools/perf/Documentation/perf-daemon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ DESCRIPTION
This command allows to run simple daemon process that starts and
monitors configured record sessions.

You can imagine 'perf daemon' of background process with several
'perf record' child tasks, like:

# ps axjf
...
1 916507 ... perf daemon start
916507 916508 ... \_ perf record --control=fifo:control,ack -m 10M -e cycles --overwrite --switch-output -a
916507 916509 ... \_ perf record --control=fifo:control,ack -m 20M -e sched:* --overwrite --switch-output -a

Not every 'perf record' session is suitable for running under daemon.
User need perf session that either produces data on query, like the
flight recorder sessions in above example or session that is configured
to produce data periodically, like with --switch-output configuration
for time and size.

OPTIONS
-------
Expand All @@ -43,6 +57,22 @@ START COMMAND
The start command creates the daemon process.


CONFIG FILE
-----------
The daemon is configured within standard perf config file by
following new variables:

daemon.base:
Base path for daemon data. All sessions data are
stored under this path.

session-<NAME>.run:
Defines new record session. The value is record's command
line without the 'record' keyword.

Each perf record session is run in daemon.base/<NAME> directory.


SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-config[1]
Loading

0 comments on commit c066626

Please sign in to comment.