public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, namhyung@kernel.org, acme@redhat.com,
	wangnan0@huawei.com, dsahern@gmail.com,
	linux-kernel@vger.kernel.org, jolsa@kernel.org,
	a.p.zijlstra@chello.nl, tglx@linutronix.de, hpa@zytor.com
Subject: [tip:perf/core] perf record: Change switch-output option to take optional argument
Date: Thu, 12 Jan 2017 00:32:34 -0800	[thread overview]
Message-ID: <tip-cb4e1ebb6a398ff5b0067034b0d16566af4d78e8@git.kernel.org> (raw)
In-Reply-To: <1483955520-29063-4-git-send-email-jolsa@kernel.org>

Commit-ID:  cb4e1ebb6a398ff5b0067034b0d16566af4d78e8
Gitweb:     http://git.kernel.org/tip/cb4e1ebb6a398ff5b0067034b0d16566af4d78e8
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 9 Jan 2017 10:51:57 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 11 Jan 2017 16:48:01 -0300

perf record: Change switch-output option to take optional argument

Next patches will add --switch-output option arguments, changing the
option to allow that and adding its default value to 'signal'.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1483955520-29063-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f7e805b..2bf811a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -48,6 +48,8 @@
 
 struct switch_output {
 	bool		 signal;
+	const char	*str;
+	bool		 set;
 };
 
 struct record {
@@ -1356,6 +1358,22 @@ out_free:
 	return ret;
 }
 
+static int switch_output_setup(struct record *rec)
+{
+	struct switch_output *s = &rec->switch_output;
+
+	if (!s->set)
+		return 0;
+
+	if (!strcmp(s->str, "signal")) {
+		s->signal = true;
+		pr_debug("switch-output with SIGUSR2 signal\n");
+		return 0;
+	}
+
+	return -1;
+}
+
 static const char * const __record_usage[] = {
 	"perf record [<options>] [<command>]",
 	"perf record [<options>] -- <command> [<options>]",
@@ -1523,8 +1541,9 @@ static struct option __record_options[] = {
 		    "Record build-id of all DSOs regardless of hits"),
 	OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
 		    "append timestamp to output filename"),
-	OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal,
-		    "Switch output when receive SIGUSR2"),
+	OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str,
+			  &record.switch_output.set, "signal",
+			  "Switch output when receive SIGUSR2", "signal"),
 	OPT_BOOLEAN(0, "dry-run", &dry_run,
 		    "Parse options then exit"),
 	OPT_END()
@@ -1582,6 +1601,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
 		return -EINVAL;
 	}
 
+	if (switch_output_setup(rec)) {
+		parse_options_usage(record_usage, record_options, "switch-output", 0);
+		return -EINVAL;
+	}
+
 	if (rec->switch_output.signal)
 		rec->timestamp_filename = true;
 

  reply	other threads:[~2017-01-12  8:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09  9:51 [PATCHv2 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa
2017-01-09  9:51 ` [PATCH 1/6] perf tools: Add unit_number__scnprint function Jiri Olsa
2017-01-10 13:22   ` Arnaldo Carvalho de Melo
2017-01-12  8:31   ` [tip:perf/core] perf tools: Add unit_number__scnprintf function tip-bot for Jiri Olsa
2017-01-09  9:51 ` [PATCH 2/6] perf record: Add struct switch_output Jiri Olsa
2017-01-12  8:32   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-01-09  9:51 ` [PATCH 3/6] perf record: Change switch-output option to take optional argument Jiri Olsa
2017-01-12  8:32   ` tip-bot for Jiri Olsa [this message]
2017-01-09  9:51 ` [PATCH 4/6] perf record: Add switch-output size option argument Jiri Olsa
2017-01-12  8:33   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-01-09  9:51 ` [PATCH 5/6] perf record: Add switch-output size warning Jiri Olsa
2017-01-12  8:33   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-01-09  9:52 ` [PATCH 6/6] perf record: Add switch-output time option argument Jiri Olsa
2017-01-12  8:34   ` [tip:perf/core] " tip-bot for Jiri Olsa

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=tip-cb4e1ebb6a398ff5b0067034b0d16566af4d78e8@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /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