Messages in this thread Patch in this message | | | From | Jiri Olsa <> | Subject | [PATCH 3/4] perf tools: Add stop control command | Date | Sun, 27 Dec 2020 00:20:37 +0100 |
| |
Adding control 'stop' command to stop perf record. When it is received, perf will set done = 1.
Example session:
terminal 1: # mkfifo control ack # perf record --control=fifo:control,ack
terminal 2: # echo stop > control
terminal 1: [ perf record: Woken up 7 times to write data ] [ perf record: Captured and wrote 3.214 MB perf.data (38280 samples) ] #
Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- tools/perf/Documentation/perf-record.txt | 1 + tools/perf/builtin-record.c | 3 +++ tools/perf/builtin-stat.c | 1 + tools/perf/util/evlist.c | 4 ++++ tools/perf/util/evlist.h | 2 ++ 5 files changed, 11 insertions(+)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 5cf103f28eb0..539230955dbc 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -645,6 +645,7 @@ Available commands: 'enable name' : enable event 'name' 'disable name' : disable event 'name' 'snapshot' : AUX area tracing snapshot). + 'stop' : stop perf record '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 389be92c5a65..9aa051c3c722 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1941,6 +1941,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) hit_auxtrace_snapshot_trigger(rec); evlist__ctlfd_ack(rec->evlist); break; + case EVLIST_CTL_CMD_STOP: + done = 1; + break; case EVLIST_CTL_CMD_ACK: case EVLIST_CTL_CMD_UNSUPPORTED: case EVLIST_CTL_CMD_ENABLE: diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 02fbf0dc8119..5681cbabbec5 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -589,6 +589,7 @@ static void process_evlist(struct evlist *evlist, unsigned int interval) case EVLIST_CTL_CMD_ACK: case EVLIST_CTL_CMD_UNSUPPORTED: case EVLIST_CTL_CMD_EVLIST: + case EVLIST_CTL_CMD_STOP: default: break; } diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 9e890b482220..c6de70cefbae 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1940,6 +1940,9 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd, } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_EVLIST_TAG, (sizeof(EVLIST_CTL_CMD_EVLIST_TAG)-1))) { *cmd = EVLIST_CTL_CMD_EVLIST; + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_STOP_TAG, + (sizeof(EVLIST_CTL_CMD_STOP_TAG)-1))) { + *cmd = EVLIST_CTL_CMD_STOP; } } @@ -2077,6 +2080,7 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) err = evlist__ctlfd_list(evlist, cmd_data); break; case EVLIST_CTL_CMD_SNAPSHOT: + case EVLIST_CTL_CMD_STOP: 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 e79c64d81d21..6f45c3630355 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -331,6 +331,7 @@ struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evse #define EVLIST_CTL_CMD_ACK_TAG "ack\n" #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_MAX_LEN 64 @@ -341,6 +342,7 @@ enum evlist_ctl_cmd { EVLIST_CTL_CMD_ACK, EVLIST_CTL_CMD_SNAPSHOT, EVLIST_CTL_CMD_EVLIST, + EVLIST_CTL_CMD_STOP, }; int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close); -- 2.26.2
| |