From: Jiri Olsa Date: Sat, 26 Dec 2020 23:20:38 +0000 (+0100) Subject: perf tools: Add 'ping' control command X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=47fddcb479e73c341fb414e40a89572dacadd360;p=linux.git perf tools: Add 'ping' control command Add a control 'ping' command to detect if perf is up and its control interface is operational. It will be used in following daemon patches to synchronize with record session - when control interface is up and running, we know that perf record is monitoring and ready to receive signals. Example session: terminal 1: # mkfifo control ack # perf record --control=fifo:control,ack terminal 2: # echo ping > control # cat ack ack Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: Alexei Budankov Cc: Ian Rogers Cc: Mark Rutland Cc: Michael Petlan Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20201226232038.390883-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index c0ee766bca050..f3161c9673e93 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -652,6 +652,7 @@ Available commands: 'disable name' : disable event 'name' 'snapshot' : AUX area tracing snapshot). 'stop' : stop perf record + 'ping' : ping 'evlist [-v|-g|-F] : display all events -F Show just the sample frequency used for each event. diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 36fc71097822c..8a0127d4fb521 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1950,6 +1950,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) case EVLIST_CTL_CMD_ENABLE: case EVLIST_CTL_CMD_DISABLE: case EVLIST_CTL_CMD_EVLIST: + case EVLIST_CTL_CMD_PING: default: break; } diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 46a3f4ab13715..a380e38ca937a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -623,6 +623,7 @@ static void process_evlist(struct evlist *evlist, unsigned int interval) case EVLIST_CTL_CMD_UNSUPPORTED: case EVLIST_CTL_CMD_EVLIST: case EVLIST_CTL_CMD_STOP: + case EVLIST_CTL_CMD_PING: default: break; } diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c6de70cefbaee..61b2408821e57 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1943,6 +1943,9 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd, } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_STOP_TAG, (sizeof(EVLIST_CTL_CMD_STOP_TAG)-1))) { *cmd = EVLIST_CTL_CMD_STOP; + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_PING_TAG, + (sizeof(EVLIST_CTL_CMD_PING_TAG)-1))) { + *cmd = EVLIST_CTL_CMD_PING; } } @@ -2081,6 +2084,7 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) break; case EVLIST_CTL_CMD_SNAPSHOT: case EVLIST_CTL_CMD_STOP: + case EVLIST_CTL_CMD_PING: break; case EVLIST_CTL_CMD_ACK: case EVLIST_CTL_CMD_UNSUPPORTED: diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 6f45c3630355b..7c2521cb6b095 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -332,6 +332,7 @@ struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evse #define EVLIST_CTL_CMD_SNAPSHOT_TAG "snapshot" #define EVLIST_CTL_CMD_EVLIST_TAG "evlist" #define EVLIST_CTL_CMD_STOP_TAG "stop" +#define EVLIST_CTL_CMD_PING_TAG "ping" #define EVLIST_CTL_CMD_MAX_LEN 64 @@ -343,6 +344,7 @@ enum evlist_ctl_cmd { EVLIST_CTL_CMD_SNAPSHOT, EVLIST_CTL_CMD_EVLIST, EVLIST_CTL_CMD_STOP, + EVLIST_CTL_CMD_PING, }; int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close);