Skip to content

Commit 6a6d180

Browse files
olsajiriacmel
authored andcommitted
perf daemon: Set control fifo for session
Setup control fifos for session and add --control option to session arguments. 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 Starting the daemon: # perf daemon start Use can list control fifos with (control and ack files): # perf daemon -v [776459:daemon] base: /opt/perfdata output: /opt/perfdata/output lock: /opt/perfdata/lock [776460:cycles] perf record -m 20M -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 [776461: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 Signed-off-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexei Budankov <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8c98be6 commit 6a6d180

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

tools/perf/Documentation/perf-daemon.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ flight recorder sessions in above example or session that is configured
3737
to produce data periodically, like with --switch-output configuration
3838
for time and size.
3939

40+
Each session is started with control setup (with perf record --control
41+
options).
42+
4043
OPTIONS
4144
-------
4245
-v::

tools/perf/builtin-daemon.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "util.h"
3333

3434
#define SESSION_OUTPUT "output"
35+
#define SESSION_CONTROL "control"
36+
#define SESSION_ACK "ack"
3537

3638
/*
3739
* Session states:
@@ -74,6 +76,7 @@ struct daemon_session {
7476
char *base;
7577
char *name;
7678
char *run;
79+
char *control;
7780
int pid;
7881
struct list_head list;
7982
enum daemon_session_state state;
@@ -365,7 +368,18 @@ static int daemon_session__run(struct daemon_session *session,
365368
dup2(fd, 2);
366369
close(fd);
367370

368-
scnprintf(buf, sizeof(buf), "%s record %s", daemon->perf, session->run);
371+
if (mkfifo(SESSION_CONTROL, O_RDWR) && errno != EEXIST) {
372+
perror("failed: create control fifo");
373+
return -1;
374+
}
375+
376+
if (mkfifo(SESSION_ACK, O_RDWR) && errno != EEXIST) {
377+
perror("failed: create ack fifo");
378+
return -1;
379+
}
380+
381+
scnprintf(buf, sizeof(buf), "%s record --control=fifo:%s,%s %s",
382+
daemon->perf, SESSION_CONTROL, SESSION_ACK, session->run);
369383

370384
argv = argv_split(buf, &argc);
371385
if (!argv)
@@ -603,6 +617,12 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)
603617
/* session output */
604618
csv_sep, session->base, SESSION_OUTPUT);
605619

620+
fprintf(out, "%c%s/%s%c%s/%s",
621+
/* session control */
622+
csv_sep, session->base, SESSION_CONTROL,
623+
/* session ack */
624+
csv_sep, session->base, SESSION_ACK);
625+
606626
fprintf(out, "\n");
607627
} else {
608628
fprintf(out, "[%d:%s] perf record %s\n",
@@ -613,6 +633,10 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)
613633
session->base);
614634
fprintf(out, " output: %s/%s\n",
615635
session->base, SESSION_OUTPUT);
636+
fprintf(out, " control: %s/%s\n",
637+
session->base, SESSION_CONTROL);
638+
fprintf(out, " ack: %s/%s\n",
639+
session->base, SESSION_ACK);
616640
}
617641
}
618642

0 commit comments

Comments
 (0)