All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@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: Re: [PATCH 8/8] perf daemon: Set control fifo for session
Date: Tue, 15 Dec 2020 12:47:08 -0300	[thread overview]
Message-ID: <20201215154708.GI258566@kernel.org> (raw)
In-Reply-To: <20201212104358.412065-9-jolsa@kernel.org>

Em Sat, Dec 12, 2020 at 11:43:58AM +0100, Jiri Olsa escreveu:
> Setup control fifos for session and add --control
> option to session arguments.

You're stating what this does, not why this is useful, can you add a
paragraph to that effect?

- Arnaldo
 
> Use can list control fifos with:
> 
>    # perf daemon -v
>    [1:92187] perf record -m 11M -e cycles -o /opt/perfdata/1/perf.data --overwrite --switch-output -a
>      output:  /opt/perfdata/1/output
>      control: /opt/perfdata/1/control
>      ack:     /opt/perfdata/1/ack
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/Documentation/perf-daemon.txt |  8 +++++++-
>  tools/perf/builtin-daemon.c              | 24 +++++++++++++++++++++++-
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-daemon.txt b/tools/perf/Documentation/perf-daemon.txt
> index 87de2c77e4c7..c507ba7c85cc 100644
> --- a/tools/perf/Documentation/perf-daemon.txt
> +++ b/tools/perf/Documentation/perf-daemon.txt
> @@ -16,7 +16,8 @@ DESCRIPTION
>  This command allows to run simple daemon process that starts and
>  monitors configured record sessions.
>  
> -Each session represents one perf record process.
> +Each session represents one perf record process started with
> +control setup (with perf record --control.. options).
>  
>  These sessions are configured through config file, see CONFIG FILE
>  section with EXAMPLES.
> @@ -94,10 +95,15 @@ Check sessions with more info:
>    # perf daemon -v
>    [1:92187] perf record -m 11M -e cycles -o /opt/perfdata/1/perf.data --overwrite --switch-output -a
>      output:  /opt/perfdata/1/output
> +    control: /opt/perfdata/1/control
> +    ack:     /opt/perfdata/1/ack
>    [2:92188] perf record -m 20M -e sched:* -o /opt/perfdata/2/perf.data --overwrite --switch-output -a
>      output:  /opt/perfdata/2/output
> +    control: /opt/perfdata/2/control
> +    ack:     /opt/perfdata/2/ack
>  
>  The 'output' file is perf record output for specific session.
> +The 'control' and 'ack' files are perf control files.
>  
>  
>  Send SIGUSR2 signal to all sessions:
> diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> index 1bd5432a57a3..765369a30414 100644
> --- a/tools/perf/builtin-daemon.c
> +++ b/tools/perf/builtin-daemon.c
> @@ -33,6 +33,8 @@
>  #include <api/fs/fs.h>
>  
>  #define SESSION_OUTPUT  "output"
> +#define SESSION_CONTROL "control"
> +#define SESSION_ACK     "ack"
>  
>  enum session_state {
>  	SESSION_STATE__OK,
> @@ -43,6 +45,7 @@ enum session_state {
>  struct session {
>  	char			*name;
>  	char			*run;
> +	char			*control;
>  	int			 pid;
>  	struct list_head	 list;
>  	enum session_state	 state;
> @@ -254,6 +257,8 @@ static void session__kill(struct session *session, struct daemon *daemon)
>  
>  static int session__run(struct session *session, struct daemon *daemon)
>  {
> +	char control[PATH_MAX];
> +	char ack[PATH_MAX];
>  	char base[PATH_MAX];
>  	char buf[PATH_MAX];
>  	char **argv;
> @@ -266,6 +271,18 @@ static int session__run(struct session *session, struct daemon *daemon)
>  		return -1;
>  	}
>  
> +	scnprintf(control, sizeof(control), "%s/" SESSION_CONTROL, base);
> +	if (mkfifo(control, O_RDWR) && errno != EEXIST) {
> +		perror("failed to create control fifo");
> +		return -1;
> +	}
> +
> +	scnprintf(ack, sizeof(ack), "%s/" SESSION_ACK, base);
> +	if (mkfifo(ack, O_RDWR) && errno != EEXIST) {
> +		perror("failed to create ack fifo");
> +		return -1;
> +	}
> +
>  	session->pid = fork();
>  	if (session->pid < 0)
>  		return -1;
> @@ -291,7 +308,8 @@ static int session__run(struct session *session, struct daemon *daemon)
>  	dup2(fd, 2);
>  	close(fd);
>  
> -	scnprintf(buf, sizeof(buf), "%s record %s", PERF, session->run);
> +	scnprintf(buf, sizeof(buf), "%s record --control=fifo:%s,%s %s",
> +		  PERF, control, ack, session->run);
>  
>  	argv = argv_split(buf, &argc);
>  	if (!argv)
> @@ -472,6 +490,10 @@ static int cmd_session_list(struct daemon *daemon, FILE *out, bool simple)
>  			continue;
>  		fprintf(out, "  output:  %s/%s/" SESSION_OUTPUT "\n",
>  			daemon->base, session->name);
> +		fprintf(out, "  control: %s/%s/" SESSION_CONTROL "\n",
> +			daemon->base, session->name);
> +		fprintf(out, "  ack:     %s/%s/" SESSION_ACK "\n",
> +			daemon->base, session->name);
>  	}
>  
>  	return 0;
> -- 
> 2.26.2
> 

-- 

- Arnaldo

      reply	other threads:[~2020-12-15 15:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 10:43 [RFC 0/8] perf tools: Add daemon command Jiri Olsa
2020-12-12 10:43 ` [PATCH 1/8] perf tools: Add debug_set_file function Jiri Olsa
2020-12-15 15:37   ` Arnaldo Carvalho de Melo
2020-12-12 10:43 ` [PATCH 2/8] perf tools: Add debug_set_display_time function Jiri Olsa
2020-12-15 15:37   ` Arnaldo Carvalho de Melo
2020-12-12 10:43 ` [PATCH 3/8] perf tools: Add config set interface Jiri Olsa
2020-12-15 15:41   ` Arnaldo Carvalho de Melo
2020-12-15 19:11     ` Jiri Olsa
2020-12-12 10:43 ` [PATCH 4/8] perf daemon: Add daemon command Jiri Olsa
2020-12-15 15:40   ` Alexei Budankov
2020-12-15 19:43     ` Jiri Olsa
2020-12-16  7:54       ` Alexei Budankov
2020-12-16  8:14         ` Jiri Olsa
2020-12-18 13:25       ` Namhyung Kim
2020-12-18 19:30         ` Jiri Olsa
2020-12-15 15:44   ` Arnaldo Carvalho de Melo
2020-12-15 19:20     ` Jiri Olsa
2020-12-12 10:43 ` [PATCH 5/8] perf daemon: Add signal command Jiri Olsa
2020-12-15 15:45   ` Arnaldo Carvalho de Melo
2020-12-15 19:14     ` Jiri Olsa
2020-12-12 10:43 ` [PATCH 6/8] perf daemon: Add stop command Jiri Olsa
2020-12-15 15:45   ` Arnaldo Carvalho de Melo
2020-12-12 10:43 ` [PATCH 7/8] perf daemon: Allow only one daemon over base directory Jiri Olsa
2020-12-15 15:46   ` Arnaldo Carvalho de Melo
2020-12-15 19:16     ` Jiri Olsa
2020-12-12 10:43 ` [PATCH 8/8] perf daemon: Set control fifo for session Jiri Olsa
2020-12-15 15:47   ` Arnaldo Carvalho de Melo [this message]

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=20201215154708.GI258566@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=abudankov@huawei.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.