Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631433

[PATCH 6/7] perf config: Finally write changed configs on config file at a time

From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 6/7] perf config: Finally write changed configs on config file at a time
Date 2017-04-26 14:30 +0200
Message-ID <tAuf0-2dU-25@gated-at.bofh.it> (permalink)
References <tAueZ-2dU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 finally write changed configs at a time.

Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 tools/perf/builtin-config.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index c76aacf..793a729 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -33,8 +33,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;
@@ -48,7 +47,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 */
@@ -160,6 +158,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);
@@ -225,7 +224,11 @@ int cmd_config(int argc, const char **argv)
 			}
 
 			if (value) {
-				ret = set_config(set, config_filename, var, value);
+				ret = perf_config_set__collect(set, config_filename,
+							       var, value);
+				if (ret < 0)
+					break;
+				changed = true;
 				continue;
 			}
 			ret = show_spec_config(set, var);
@@ -234,6 +237,9 @@ int cmd_config(int argc, const char **argv)
 
 			free(arg);
 		}
+
+		if (changed)
+			ret = set_config(set, config_filename);
 	}
 
 none_err:
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] perf config: Bugfixes & Refactoring Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 3/7] perf config: Use none_err for all cases that nothing configured Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 4/7] perf config: Invert if statements to reduce nesting in cmd_config() Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
    Re: [PATCH 2/7] perf config: Check list empty before showing configs Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-05-02 17:20 +0200
      Re: [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song <treeze.taeung@gmail.com> - 2017-05-03 06:10 +0200
  [PATCH 6/7] perf config: Finally write changed configs on config file at a time Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 5/7] perf config: Correctly check whether it is from system config Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
    [tip:perf/urgent] perf config: Refactor a duplicated code for  obtaining config file name tip-bot for Taeung Song <tipbot@zytor.com> - 2017-05-03 19:50 +0200

csiph-web