linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 00/22] perf tools: Add daemon command
@ 2021-01-02 22:04 Jiri Olsa
  2021-01-02 22:04 ` [PATCH 01/22] perf tools: Make perf_config_from_file static Jiri Olsa
                   ` (22 more replies)
  0 siblings, 23 replies; 44+ messages in thread
From: Jiri Olsa @ 2021-01-02 22:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Peter Zijlstra, Ingo Molnar, Mark Rutland, Namhyung Kim,
	Alexander Shishkin, Michael Petlan, Ian Rogers, Stephane Eranian,
	Alexei Budankov

hi,
we were asked for possibility to be able run record
sessions on background.

This patchset adds support to configure and run record
sessions on background via new 'perf daemon' command.

Please check below the example on usage.

The patchset is based on following control changes:
  https://lore.kernel.org/lkml/20201226232038.390883-1-jolsa@kernel.org/

Available also here:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/daemon

v2 changes:
  - switch options to sub-commands [Namhyung]
  - use signalfd to track on sessions [Alexei]
  - use stop command to stop sessions [Alexei]
  - couple minor fixes [Alexei]
  - more detailed changelogs [Arnaldo]
  - added tests

thanks,
jirka


---
Jiri Olsa (22):
      perf tools: Make perf_config_from_file static
      perf tools: Add config set interface
      perf tools: Add debug_set_display_time function
      perf tools: Add perf_home_perfconfig function
      perf tools: Make perf_config_system global
      perf tools: Make perf_config_global gobal
      perf daemon: Add daemon command
      perf daemon: Add config file change check
      perf daemon: Add signalfd support
      perf daemon: Add signal command
      perf daemon: Add stop command
      perf daemon: Allow only one daemon over base directory
      perf daemon: Set control fifo for session
      perf daemon: Add ping command
      perf daemon: Use control to stop session
      perf daemon: Add up time for daemon/session list
      perf daemon: Add man page for perf-daemon
      perf test: Add daemon list command test
      perf test: Add daemon reconfig test
      perf test: Add daemon stop command test
      perf test: Add daemon signal command test
      perf test: Add daemon ping command test

 tools/perf/Build                         |    1 +
 tools/perf/Documentation/perf-config.txt |   14 ++
 tools/perf/Documentation/perf-daemon.txt |  187 ++++++++++++++++
 tools/perf/builtin-daemon.c              | 1327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h                     |    1 +
 tools/perf/command-list.txt              |    1 +
 tools/perf/perf.c                        |    1 +
 tools/perf/tests/shell/daemon.sh         |  388 ++++++++++++++++++++++++++++++++
 tools/perf/util/config.c                 |  123 +++++++----
 tools/perf/util/config.h                 |    7 +-
 tools/perf/util/debug.c                  |   34 ++-
 tools/perf/util/debug.h                  |    1 +
 12 files changed, 2037 insertions(+), 48 deletions(-)
 create mode 100644 tools/perf/Documentation/perf-daemon.txt
 create mode 100644 tools/perf/builtin-daemon.c
 create mode 100755 tools/perf/tests/shell/daemon.sh


---
Example with 2 record sessions:

  # 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


Check sessions:

  # perf daemon
  [603349:daemon] base: /opt/perfdata
  [603350:cycles] perf record -m 10M -e cycles --overwrite --switch-output -a
  [603351:sched] perf record -m 20M -e sched:* --overwrite --switch-output -a

First line is daemon process info with configured daemon base.


Check sessions with more info:

  # perf daemon -v
  [603349:daemon] base: /opt/perfdata
    output:  /opt/perfdata/output
    lock:    /opt/perfdata/lock
    up:      1 minutes
  [603350:cycles] perf record -m 10M -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:      1 minutes
  [603351: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:      1 minutes

The 'base' path is daemon/session base.
The 'lock' file is daemon's lock file guarding that no other
daemon is running on top of the base.
The 'output' file is perf record output for specific session.
The 'control' and 'ack' files are perf control files.
The 'up' number shows minutes daemon/session is running.


Make sure control session is online:

  # perf daemon ping
  OK   cycles
  OK   sched


Send USR2 signal to session 'cycles' to generate perf.data file:

  # perf daemon signal --session cycles
  signal 12 sent to session 'cycles [603452]'

  # tail -2  /opt/perfdata/session-cycles/output
  [ perf record: dump data: Woken up 1 times ]
  [ perf record: Dump perf.data.2020123017013149 ]


Send USR2 signal to all sessions:

  # perf daemon signal
  signal 12 sent to session 'cycles [603452]'
  signal 12 sent to session 'sched [603453]'

  # tail -2  /opt/perfdata/session-cycles/output
  [ perf record: dump data: Woken up 1 times ]
  [ perf record: Dump perf.data.2020123017024689 ]
  # tail -2  /opt/perfdata/session-sched/output
  [ perf record: dump data: Woken up 1 times ]
  [ perf record: Dump perf.data.2020123017024713 ]


Stop daemon:

  # perf daemon stop


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2021-01-27 22:05 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02 22:04 [PATCHv2 00/22] perf tools: Add daemon command Jiri Olsa
2021-01-02 22:04 ` [PATCH 01/22] perf tools: Make perf_config_from_file static Jiri Olsa
2021-01-18 15:51   ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 02/22] perf tools: Add config set interface Jiri Olsa
2021-01-18 15:53   ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 03/22] perf tools: Add debug_set_display_time function Jiri Olsa
2021-01-18 16:02   ` Arnaldo Carvalho de Melo
2021-01-19 14:59   ` Arnaldo Carvalho de Melo
2021-01-19 17:39     ` Jiri Olsa
2021-01-19 19:42       ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 04/22] perf tools: Add perf_home_perfconfig function Jiri Olsa
2021-01-18 16:05   ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 05/22] perf tools: Make perf_config_system global Jiri Olsa
2021-01-18 16:03   ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 06/22] perf tools: Make perf_config_global gobal Jiri Olsa
2021-01-18 16:05   ` Arnaldo Carvalho de Melo
2021-01-02 22:04 ` [PATCH 07/22] perf daemon: Add daemon command Jiri Olsa
2021-01-19  4:08   ` Namhyung Kim
2021-01-19 18:31     ` Jiri Olsa
2021-01-21  4:53       ` Namhyung Kim
2021-01-27  7:09   ` Namhyung Kim
2021-01-27 22:01     ` Jiri Olsa
2021-01-02 22:04 ` [PATCH 08/22] perf daemon: Add config file change check Jiri Olsa
2021-01-19  5:31   ` Namhyung Kim
2021-01-19 17:49     ` Jiri Olsa
2021-01-21  4:54       ` Namhyung Kim
2021-01-02 22:04 ` [PATCH 09/22] perf daemon: Add signalfd support Jiri Olsa
2021-01-02 22:04 ` [PATCH 10/22] perf daemon: Add signal command Jiri Olsa
2021-01-02 22:04 ` [PATCH 11/22] perf daemon: Add stop command Jiri Olsa
2021-01-19  5:35   ` Namhyung Kim
2021-01-02 22:04 ` [PATCH 12/22] perf daemon: Allow only one daemon over base directory Jiri Olsa
2021-01-19  5:37   ` Namhyung Kim
2021-01-19 17:44     ` Jiri Olsa
2021-01-02 22:04 ` [PATCH 13/22] perf daemon: Set control fifo for session Jiri Olsa
2021-01-02 22:04 ` [PATCH 14/22] perf daemon: Add ping command Jiri Olsa
2021-01-02 22:04 ` [PATCH 15/22] perf daemon: Use control to stop session Jiri Olsa
2021-01-02 22:04 ` [PATCH 16/22] perf daemon: Add up time for daemon/session list Jiri Olsa
2021-01-02 22:04 ` [PATCH 17/22] perf daemon: Add man page for perf-daemon Jiri Olsa
2021-01-02 22:04 ` [PATCH 18/22] perf test: Add daemon list command test Jiri Olsa
2021-01-02 22:04 ` [PATCH 19/22] perf test: Add daemon reconfig test Jiri Olsa
2021-01-02 22:04 ` [PATCH 20/22] perf test: Add daemon stop command test Jiri Olsa
2021-01-02 22:04 ` [PATCH 21/22] perf test: Add daemon signal " Jiri Olsa
2021-01-02 22:04 ` [PATCH 22/22] perf test: Add daemon ping " Jiri Olsa
2021-01-18 12:55 ` [PATCHv2 00/22] perf tools: Add daemon command Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).