public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat
@ 2017-09-07  3:18 Taeung Song
  2017-09-08 14:33 ` Arnaldo Carvalho de Melo
  2017-09-22 16:35 ` [tip:perf/core] perf config: Write a config file just once tip-bot for Taeung Song
  0 siblings, 2 replies; 3+ messages in thread
From: Taeung Song @ 2017-09-07  3:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, taeung, Jiri Olsa, Namhyung Kim

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

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 | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e3..b89417d 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.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat
  2017-09-07  3:18 [PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat Taeung Song
@ 2017-09-08 14:33 ` Arnaldo Carvalho de Melo
  2017-09-22 16:35 ` [tip:perf/core] perf config: Write a config file just once tip-bot for Taeung Song
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-09-08 14:33 UTC (permalink / raw)
  To: Taeung Song; +Cc: linux-kernel, taeung, Jiri Olsa, Namhyung Kim

Em Thu, Sep 07, 2017 at 12:18:51PM +0900, Taeung Song escreveu:
> 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

Thanks, applied.

- Arnaldo
 
> 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 | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
> index a1d82e3..b89417d 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.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf config: Write a config file just once
  2017-09-07  3:18 [PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat Taeung Song
  2017-09-08 14:33 ` Arnaldo Carvalho de Melo
@ 2017-09-22 16:35 ` tip-bot for Taeung Song
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Taeung Song @ 2017-09-22 16:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, treeze.taeung, namhyung, tglx, linux-kernel, mingo, hpa,
	jolsa

Commit-ID:  5c2615556d4410baebc9b336f14befe0bb32cde4
Gitweb:     http://git.kernel.org/tip/5c2615556d4410baebc9b336f14befe0bb32cde4
Author:     Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Thu, 7 Sep 2017 12:18:51 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Sep 2017 09:49:15 -0300

perf config: Write a config file just once

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 a1d82e3..b89417d 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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-22 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-07  3:18 [PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat Taeung Song
2017-09-08 14:33 ` Arnaldo Carvalho de Melo
2017-09-22 16:35 ` [tip:perf/core] perf config: Write a config file just once tip-bot for Taeung Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox