public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Michael Petlan <mpetlan@redhat.com>,
	Ian Rogers <irogers@google.com>,
	Stephane Eranian <eranian@google.com>,
	Alexei Budankov <abudankov@huawei.com>
Subject: [PATCH 4/4] perf tools: Add ping control command
Date: Sun, 27 Dec 2020 00:20:38 +0100	[thread overview]
Message-ID: <20201226232038.390883-5-jolsa@kernel.org> (raw)
In-Reply-To: <20201226232038.390883-1-jolsa@kernel.org>

Adding control 'ping' command to detect if perf is up and
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 <jolsa@kernel.org>
---
 tools/perf/Documentation/perf-record.txt | 1 +
 tools/perf/builtin-record.c              | 1 +
 tools/perf/builtin-stat.c                | 1 +
 tools/perf/util/evlist.c                 | 4 ++++
 tools/perf/util/evlist.h                 | 2 ++
 5 files changed, 9 insertions(+)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 539230955dbc..aa2da60ff12b 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -646,6 +646,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 9aa051c3c722..3de81453ff8a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1949,6 +1949,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 5681cbabbec5..d5d08ffae31b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -590,6 +590,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 c6de70cefbae..61b2408821e5 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 6f45c3630355..7c2521cb6b09 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);
-- 
2.26.2


  parent reply	other threads:[~2020-12-26 23:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-26 23:20 [PATCHv4 0/4] perf tools: Allow to enable/disable events via control pipe Jiri Olsa
2020-12-26 23:20 ` [PATCH 1/4] perf tools: Allow to enable/disable events via control file Jiri Olsa
2021-01-19 14:16   ` Arnaldo Carvalho de Melo
2021-01-19 17:34     ` Jiri Olsa
2020-12-26 23:20 ` [PATCH 2/4] perf tools: Add evlist control command Jiri Olsa
2020-12-26 23:20 ` [PATCH 3/4] perf tools: Add stop " Jiri Olsa
2020-12-26 23:20 ` Jiri Olsa [this message]
2021-01-07 12:12 ` [PATCHv4 0/4] perf tools: Allow to enable/disable events via control pipe Jiri Olsa
2021-01-08  6:10   ` Namhyung Kim
2021-01-19 14:30 ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201226232038.390883-5-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=abudankov@huawei.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox