Commit 47fddcb4 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20201226232038.390883-5-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f186cd61
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -652,6 +652,7 @@ Available commands:
  'disable name'     : disable event 'name'
  'disable name'     : disable event 'name'
  'snapshot'         : AUX area tracing snapshot).
  'snapshot'         : AUX area tracing snapshot).
  'stop'             : stop perf record
  'stop'             : stop perf record
  'ping'             : ping


  'evlist [-v|-g|-F] : display all events
  'evlist [-v|-g|-F] : display all events
                       -F  Show just the sample frequency used for each event.
                       -F  Show just the sample frequency used for each event.
+1 −0
Original line number Original line Diff line number Diff line
@@ -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_ENABLE:
			case EVLIST_CTL_CMD_DISABLE:
			case EVLIST_CTL_CMD_DISABLE:
			case EVLIST_CTL_CMD_EVLIST:
			case EVLIST_CTL_CMD_EVLIST:
			case EVLIST_CTL_CMD_PING:
			default:
			default:
				break;
				break;
			}
			}
+1 −0
Original line number Original line Diff line number Diff line
@@ -623,6 +623,7 @@ static void process_evlist(struct evlist *evlist, unsigned int interval)
		case EVLIST_CTL_CMD_UNSUPPORTED:
		case EVLIST_CTL_CMD_UNSUPPORTED:
		case EVLIST_CTL_CMD_EVLIST:
		case EVLIST_CTL_CMD_EVLIST:
		case EVLIST_CTL_CMD_STOP:
		case EVLIST_CTL_CMD_STOP:
		case EVLIST_CTL_CMD_PING:
		default:
		default:
			break;
			break;
		}
		}
+4 −0
Original line number Original line Diff line number Diff line
@@ -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,
		} else if (!strncmp(cmd_data, EVLIST_CTL_CMD_STOP_TAG,
				    (sizeof(EVLIST_CTL_CMD_STOP_TAG)-1))) {
				    (sizeof(EVLIST_CTL_CMD_STOP_TAG)-1))) {
			*cmd = EVLIST_CTL_CMD_STOP;
			*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;
				break;
			case EVLIST_CTL_CMD_SNAPSHOT:
			case EVLIST_CTL_CMD_SNAPSHOT:
			case EVLIST_CTL_CMD_STOP:
			case EVLIST_CTL_CMD_STOP:
			case EVLIST_CTL_CMD_PING:
				break;
				break;
			case EVLIST_CTL_CMD_ACK:
			case EVLIST_CTL_CMD_ACK:
			case EVLIST_CTL_CMD_UNSUPPORTED:
			case EVLIST_CTL_CMD_UNSUPPORTED:
+2 −0
Original line number Original line Diff line number Diff line
@@ -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_SNAPSHOT_TAG "snapshot"
#define EVLIST_CTL_CMD_EVLIST_TAG "evlist"
#define EVLIST_CTL_CMD_EVLIST_TAG "evlist"
#define EVLIST_CTL_CMD_STOP_TAG "stop"
#define EVLIST_CTL_CMD_STOP_TAG "stop"
#define EVLIST_CTL_CMD_PING_TAG "ping"


#define EVLIST_CTL_CMD_MAX_LEN 64
#define EVLIST_CTL_CMD_MAX_LEN 64


@@ -343,6 +344,7 @@ enum evlist_ctl_cmd {
	EVLIST_CTL_CMD_SNAPSHOT,
	EVLIST_CTL_CMD_SNAPSHOT,
	EVLIST_CTL_CMD_EVLIST,
	EVLIST_CTL_CMD_EVLIST,
	EVLIST_CTL_CMD_STOP,
	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);
int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close);