linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Taeung Song <treeze.taeung@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 19/44] perf config: Write a config file just once
Date: Fri, 22 Sep 2017 11:41:55 -0300	[thread overview]
Message-ID: <20170922144220.9411-20-acme@kernel.org> (raw)
In-Reply-To: <20170922144220.9411-1-acme@kernel.org>

From: Taeung Song <treeze.taeung@gmail.com>

Currently set_config() can be repeatedly called for each input config on
the below case:

  $ perf config kmem.default=slab report.children=false ...

But it's a waste, so only once write a config file gathering all given
config key=value pairs.

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1504754331-9776-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-config.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e33282c..b89417d9305e 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -34,8 +34,7 @@ static struct option config_options[] = {
 	OPT_END()
 };
 
-static int set_config(struct perf_config_set *set, const char *file_name,
-		      const char *var, const char *value)
+static int set_config(struct perf_config_set *set, const char *file_name)
 {
 	struct perf_config_section *section = NULL;
 	struct perf_config_item *item = NULL;
@@ -49,7 +48,6 @@ static int set_config(struct perf_config_set *set, const char *file_name,
 	if (!fp)
 		return -1;
 
-	perf_config_set__collect(set, file_name, var, value);
 	fprintf(fp, "%s\n", first_line);
 
 	/* overwrite configvariables */
@@ -161,6 +159,7 @@ int cmd_config(int argc, const char **argv)
 	struct perf_config_set *set;
 	char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
 	const char *config_filename;
+	bool changed = false;
 
 	argc = parse_options(argc, argv, config_options, config_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
@@ -231,15 +230,26 @@ int cmd_config(int argc, const char **argv)
 					goto out_err;
 				}
 			} else {
-				if (set_config(set, config_filename, var, value) < 0) {
-					pr_err("Failed to set '%s=%s' on %s\n",
-					       var, value, config_filename);
+				if (perf_config_set__collect(set, config_filename,
+							     var, value) < 0) {
+					pr_err("Failed to add '%s=%s'\n",
+					       var, value);
 					free(arg);
 					goto out_err;
 				}
+				changed = true;
 			}
 			free(arg);
 		}
+
+		if (!changed)
+			break;
+
+		if (set_config(set, config_filename) < 0) {
+			pr_err("Failed to set the configs on %s\n",
+			       config_filename);
+			goto out_err;
+		}
 	}
 
 	ret = 0;
-- 
2.13.5

  parent reply	other threads:[~2017-09-22 14:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 14:41 [GIT PULL 00/44] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 01/44] perf sched timehist: Add pid and tid options Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 02/44] perf tools: Support weak groups in 'perf stat' Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 03/44] perf vendor events: Support metric_group and no event name in JSON parser Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 04/44] perf stat: Factor out generic metric printing Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 05/44] perf stat: Print generic metric header even for failed expressions Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 06/44] perf pmu: Extract function to get JSON alias map Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 07/44] perf stat: Support JSON metrics in perf stat Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 08/44] perf list: Add metric groups to perf list Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 09/44] perf stat: Don't use ctx for saved values lookup Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 10/44] perf stat: Support duration_time for metrics Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 11/44] perf stat: Hide internal duration_time counter Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 12/44] perf stat: Update walltime_nsecs_stats in interval mode Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 13/44] perf record: Support direct --user-regs arguments Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 14/44] perf script: Support user regs Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 15/44] perf tools: Add python-clean target Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 16/44] perf ui progress: Add ui specific init function Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 17/44] perf ui progress: Add size info into progress bar Arnaldo Carvalho de Melo
2017-09-22 14:41 ` [PATCH 18/44] perf tools: Use scandir() to replace readdir() Arnaldo Carvalho de Melo
2017-09-22 14:41 ` Arnaldo Carvalho de Melo [this message]
2017-09-22 14:41 ` [PATCH 20/44] perf config: Allow creating empty config set for config file autogeneration Arnaldo Carvalho de Melo
2017-09-22 16:26 ` [GIT PULL 00/44] perf/core improvements and fixes Ingo Molnar

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=20170922144220.9411-20-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=treeze.taeung@gmail.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;
as well as URLs for NNTP newsgroup(s).