All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] perf tools: Assorted fixes
@ 2019-02-20 12:27 Jiri Olsa
  2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

hi,
sending assorted general fixes that queued
up in my other branches.

Also available in here:
  https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/fixes

thanks,
jirka


---
Jiri Olsa (6):
      perf tools: Don't report zero period samples for slave events
      perf tools: Force sample_type for slave events
      perf script: Allow +- operator for type specific fields option
      perf tools: Add missing new line into pr_debug call
      perf tools: Increase debug leve for cpu_map__snprint verbose output
      perf tools: Make rm_rf to remove single file

 tools/perf/Documentation/perf-script.txt |  6 ++++++
 tools/perf/builtin-script.c              |  8 ++++++++
 tools/perf/util/bpf-event.c              |  2 +-
 tools/perf/util/cpumap.c                 |  2 +-
 tools/perf/util/evsel.c                  |  8 ++++++++
 tools/perf/util/session.c                |  7 +++++++
 tools/perf/util/util.c                   | 16 +++++++++++++---
 7 files changed, 44 insertions(+), 5 deletions(-)

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

* [PATCH 1/6] perf tools: Don't report zero period samples for slave events
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
@ 2019-02-20 12:27 ` Jiri Olsa
  2019-02-28  7:44   ` [tip:perf/core] perf session: " tip-bot for Jiri Olsa
  2019-02-20 12:27 ` [PATCH 2/6] perf tools: Force sample_type " Jiri Olsa
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

There's no reason to deliver sample for zero period.
It means there was no value for slave event since its
last group leader sample.

Link: http://lkml.kernel.org/n/tip-d5he0papol5dhwvfq33ess1p@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/session.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 18fb9c8cbf9c..c764bbc91009 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1202,6 +1202,13 @@ static int deliver_sample_value(struct perf_evlist *evlist,
 		return 0;
 	}
 
+	/*
+	 * There's no reason to deliver sample
+	 * for zero period, bail out.
+	 */
+	if (!sample->period)
+		return 0;
+
 	return tool->sample(tool, event, sample, sid->evsel, machine);
 }
 
-- 
2.17.2


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

* [PATCH 2/6] perf tools: Force sample_type for slave events
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
  2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
@ 2019-02-20 12:27 ` Jiri Olsa
  2019-02-28  7:45   ` [tip:perf/core] perf evsel: " tip-bot for Jiri Olsa
  2019-02-20 12:27 ` [PATCH 3/6] perf script: Allow +- operator for type specific fields option Jiri Olsa
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

Forcing sample_type setup for slave events in group
leader sessions.

We don't get sample for slave events, we make them
when delivering group leader sample. Set the slave
event to follow the master sample_type to ease up
report.

Link: http://lkml.kernel.org/n/tip-mqhyqhxm0p2jyzqjffwgbll0@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/evsel.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 684c893ca6bc..dfe2958e6287 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -956,6 +956,14 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		attr->sample_freq    = 0;
 		attr->sample_period  = 0;
 		attr->write_backward = 0;
+
+		/*
+		 * We don't get sample for slave events, we make them
+		 * when delivering group leader sample. Set the slave
+		 * event to follow the master sample_type to ease up
+		 * report.
+		 */
+		attr->sample_type = leader->attr.sample_type;
 	}
 
 	if (opts->no_samples)
-- 
2.17.2


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

* [PATCH 3/6] perf script: Allow +- operator for type specific fields option
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
  2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
  2019-02-20 12:27 ` [PATCH 2/6] perf tools: Force sample_type " Jiri Olsa
@ 2019-02-20 12:27 ` Jiri Olsa
  2019-02-28  7:45   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

Adding support to add/remove fields for specific event types
in -F option.  It's now possible to use '+-' after event type,
like:

  # cat > test.c
  #include <stdio.h>

  int main(void)
  {
     printf("Hello world\n");
     while(1) {}
  }
  ^D
  # gcc -g -o test test.c
  # perf probe -x test 'test.c:5'
  # perf record -e '{cpu/cpu-cycles,period=10000/,probe_test:main}:S' ./test
  ...

  # perf script -Ftrace:+period,-cpu
            test  3859 396291.117343:      10275 cpu/cpu-cycles,period=10000/:      7f..
            test  3859 396291.118234:      11041 cpu/cpu-cycles,period=10000/:  ffffff..
            test  3859 396291.118234:          1              probe_test:main:
            test  3859 396291.118248:       8668 cpu/cpu-cycles,period=10000/:  ffffff..
            test  3859 396291.118263:      10139 cpu/cpu-cycles,period=10000/:  ffffff..

Link: http://lkml.kernel.org/n/tip-gpd58vbcgsk4zx041zwl85e8@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Documentation/perf-script.txt | 6 ++++++
 tools/perf/builtin-script.c              | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 9e4def08d569..2e19fd7ffe35 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -159,6 +159,12 @@ OPTIONS
 	the override, and the result of the above is that only S/W and H/W
 	events are displayed with the given fields.
 
+	It's possible tp add/remove fields only for specific event type:
+
+		-Fsw:-cpu,-period
+
+	removes cpu and period from software events.
+
 	For the 'wildcard' option if a user selected field is invalid for an
 	event type, a message is displayed to the user that the option is
 	ignored for that type. For example:
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8d5fe092525c..373ea151dc60 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2560,6 +2560,10 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
 			pr_warning("Overriding previous field request for %s events.\n",
 				   event_type(type));
 
+		/* Don't override defaults for +- */
+		if (strchr(tok, '+') || strchr(tok, '-'))
+			goto parse;
+
 		output[type].fields = 0;
 		output[type].user_set = true;
 		output[type].wildcard_set = false;
@@ -2644,6 +2648,10 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
 				rc = -EINVAL;
 				goto out;
 			}
+			if (change == REMOVE)
+				output[type].fields &= ~all_output_options[i].field;
+			else
+				output[type].fields |= all_output_options[i].field;
 			output[type].user_set = true;
 			output[type].wildcard_set = true;
 		}
-- 
2.17.2


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

* [PATCH 4/6] perf tools: Add missing new line into pr_debug call
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
                   ` (2 preceding siblings ...)
  2019-02-20 12:27 ` [PATCH 3/6] perf script: Allow +- operator for type specific fields option Jiri Olsa
@ 2019-02-20 12:27 ` Jiri Olsa
  2019-02-20 19:23   ` Arnaldo Carvalho de Melo
  2019-02-28  7:46   ` [tip:perf/core] perf bpf-event: " tip-bot for Jiri Olsa
  2019-02-20 12:27 ` [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output Jiri Olsa
  2019-02-20 12:28 ` [PATCH 6/6] perf tools: Make rm_rf to remove single file Jiri Olsa
  5 siblings, 2 replies; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

Adding missing new line into pr_debug call in
perf_event__synthesize_bpf_events function,
so the error message does not screw the verbose
output.

Link: http://lkml.kernel.org/n/tip-z9h6x8v1mef0iqsfx6m28nf2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/bpf-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 62dda96b0096..028c8ec1f62a 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -233,7 +233,7 @@ int perf_event__synthesize_bpf_events(struct perf_tool *tool,
 				err = 0;
 				break;
 			}
-			pr_debug("%s: can't get next program: %s%s",
+			pr_debug("%s: can't get next program: %s%s\n",
 				 __func__, strerror(errno),
 				 errno == EINVAL ? " -- kernel too old?" : "");
 			/* don't report error on old kernel or EPERM  */
-- 
2.17.2


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

* [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
                   ` (3 preceding siblings ...)
  2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
@ 2019-02-20 12:27 ` Jiri Olsa
  2019-02-28  7:47   ` [tip:perf/core] perf cpumap: Increase debug level " tip-bot for Jiri Olsa
  2019-02-20 12:28 ` [PATCH 6/6] perf tools: Make rm_rf to remove single file Jiri Olsa
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen

So it does not screw up single -v verbose output.

Link: http://lkml.kernel.org/n/tip-4ucm1kfmy1xwp9w8xohdzirq@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 0bbc3feb0894..0b599229bc7e 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -681,7 +681,7 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 
 #undef COMMA
 
-	pr_debug("cpumask list: %s\n", buf);
+	pr_debug2("cpumask list: %s\n", buf);
 	return ret;
 }
 
-- 
2.17.2


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

* [PATCH 6/6] perf tools: Make rm_rf to remove single file
  2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
                   ` (4 preceding siblings ...)
  2019-02-20 12:27 ` [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output Jiri Olsa
@ 2019-02-20 12:28 ` Jiri Olsa
  2019-02-28  7:47   ` [tip:perf/core] perf tools: Make rm_rf() " tip-bot for Jiri Olsa
  5 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2019-02-20 12:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Alexey Budankov, lkml, Ingo Molnar, Namhyung Kim,
	Alexander Shishkin, Peter Zijlstra, Andi Kleen

Let rm_rf remove file if it's provided by path.

Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Link: http://lkml.kernel.org/n/tip-whhp3ej5795l9dc86xfyyp74@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/util.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 320b0fef249a..3ee410fc047a 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -120,16 +120,26 @@ int mkdir_p(char *path, mode_t mode)
 int rm_rf(const char *path)
 {
 	DIR *dir;
-	int ret = 0;
+	int ret;
 	struct dirent *d;
 	char namebuf[PATH_MAX];
+	struct stat statbuf;
 
+	/* Do not fail if there's no file. */
+	ret = lstat(path, &statbuf);
+	if (ret)
+		return 0;
+
+	/* Try to remove any file we get. */
+	if (!(statbuf.st_mode & S_IFDIR))
+		return unlink(path);
+
+	/* We have directory in path. */
 	dir = opendir(path);
 	if (dir == NULL)
-		return 0;
+		return -1;
 
 	while ((d = readdir(dir)) != NULL && !ret) {
-		struct stat statbuf;
 
 		if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
 			continue;
-- 
2.17.2


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

* Re: [PATCH 4/6] perf tools: Add missing new line into pr_debug call
  2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
@ 2019-02-20 19:23   ` Arnaldo Carvalho de Melo
  2019-02-28  7:46   ` [tip:perf/core] perf bpf-event: " tip-bot for Jiri Olsa
  1 sibling, 0 replies; 14+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-02-20 19:23 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen, Song Liu

Em Wed, Feb 20, 2019 at 01:27:58PM +0100, Jiri Olsa escreveu:
> Adding missing new line into pr_debug call in
> perf_event__synthesize_bpf_events function,
> so the error message does not screw the verbose
> output.

Adding Song Liu to the CC list,

- Arnaldo
 
> Link: http://lkml.kernel.org/n/tip-z9h6x8v1mef0iqsfx6m28nf2@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/bpf-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index 62dda96b0096..028c8ec1f62a 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -233,7 +233,7 @@ int perf_event__synthesize_bpf_events(struct perf_tool *tool,
>  				err = 0;
>  				break;
>  			}
> -			pr_debug("%s: can't get next program: %s%s",
> +			pr_debug("%s: can't get next program: %s%s\n",
>  				 __func__, strerror(errno),
>  				 errno == EINVAL ? " -- kernel too old?" : "");
>  			/* don't report error on old kernel or EPERM  */
> -- 
> 2.17.2

-- 

- Arnaldo

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

* [tip:perf/core] perf session: Don't report zero period samples for slave events
  2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
@ 2019-02-28  7:44   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, peterz, ak, jolsa, acme, mingo, linux-kernel, tglx,
	alexander.shishkin, namhyung

Commit-ID:  529c1a9e18c3b470d2eff7879923eda40b1431db
Gitweb:     https://git.kernel.org/tip/529c1a9e18c3b470d2eff7879923eda40b1431db
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:27:55 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 16:07:51 -0300

perf session: Don't report zero period samples for slave events

There's no reason to deliver a sample with zero period.  It means there
was no value for slave event since its last group leader sample.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 18fb9c8cbf9c..c764bbc91009 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1202,6 +1202,13 @@ static int deliver_sample_value(struct perf_evlist *evlist,
 		return 0;
 	}
 
+	/*
+	 * There's no reason to deliver sample
+	 * for zero period, bail out.
+	 */
+	if (!sample->period)
+		return 0;
+
 	return tool->sample(tool, event, sample, sid->evsel, machine);
 }
 

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

* [tip:perf/core] perf evsel: Force sample_type for slave events
  2019-02-20 12:27 ` [PATCH 2/6] perf tools: Force sample_type " Jiri Olsa
@ 2019-02-28  7:45   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, alexander.shishkin, mingo, hpa, namhyung, acme,
	tglx, peterz, jolsa, ak

Commit-ID:  6e7e8b9fec45f7bef11a5d9d2dd9febe439d4047
Gitweb:     https://git.kernel.org/tip/6e7e8b9fec45f7bef11a5d9d2dd9febe439d4047
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:27:56 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 16:08:59 -0300

perf evsel: Force sample_type for slave events

Force sample_type setup for slave events in group leader sessions.

We don't get sample for slave events, we make them when delivering group
leader sample. Set the slave event to follow the master sample_type to
ease up report.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 684c893ca6bc..dfe2958e6287 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -956,6 +956,14 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		attr->sample_freq    = 0;
 		attr->sample_period  = 0;
 		attr->write_backward = 0;
+
+		/*
+		 * We don't get sample for slave events, we make them
+		 * when delivering group leader sample. Set the slave
+		 * event to follow the master sample_type to ease up
+		 * report.
+		 */
+		attr->sample_type = leader->attr.sample_type;
 	}
 
 	if (opts->no_samples)

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

* [tip:perf/core] perf script: Allow +- operator for type specific fields option
  2019-02-20 12:27 ` [PATCH 3/6] perf script: Allow +- operator for type specific fields option Jiri Olsa
@ 2019-02-28  7:45   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, ak, peterz, linux-kernel, tglx, alexander.shishkin, jolsa,
	acme, hpa, namhyung

Commit-ID:  6ef362fd3cf3af5d8143a07b4ea20499bf2a9eec
Gitweb:     https://git.kernel.org/tip/6ef362fd3cf3af5d8143a07b4ea20499bf2a9eec
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:27:57 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 16:15:35 -0300

perf script: Allow +- operator for type specific fields option

Add support to add/remove fields for specific event types in -F option.
It's now possible to use '+-' after event type, like:

  # cat > test.c
  #include <stdio.h>

  int main(void)
  {
     printf("Hello world\n");
     while(1) {}
  }
  ^D
  # gcc -g -o test test.c
  # perf probe -x test 'test.c:5'
  # perf record -e '{cpu/cpu-cycles,period=10000/,probe_test:main}:S' ./test
  ...

  # perf script -Ftrace:+period,-cpu
            test  3859 396291.117343:      10275 cpu/cpu-cycles,period=10000/:      7f..
            test  3859 396291.118234:      11041 cpu/cpu-cycles,period=10000/:  ffffff..
            test  3859 396291.118234:          1              probe_test:main:
            test  3859 396291.118248:       8668 cpu/cpu-cycles,period=10000/:  ffffff..
            test  3859 396291.118263:      10139 cpu/cpu-cycles,period=10000/:  ffffff..

Committer testing:

Couldn't make the test above work, but tested it with:

  # perf probe -x hello main
  Added new event:
    probe_hello:main     (on main in /home/acme/c/hello)

  You can now use it in all perf tools, such as:

	  perf record -e probe_hello:main -aR sleep 1

  # perf record -e probe_hello:main ./hello
  hello, world
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.025 MB perf.data (1 samples) ]
  # perf script
           hello 21454 [002] 254116.874005: probe_hello:main: (401126)
  #
  # perf script -Ftrace:+period,-cpu
           hello 21454 254116.874005:          1 probe_hello:main: (401126)

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-script.txt | 6 ++++++
 tools/perf/builtin-script.c              | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 9e4def08d569..2e19fd7ffe35 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -159,6 +159,12 @@ OPTIONS
 	the override, and the result of the above is that only S/W and H/W
 	events are displayed with the given fields.
 
+	It's possible tp add/remove fields only for specific event type:
+
+		-Fsw:-cpu,-period
+
+	removes cpu and period from software events.
+
 	For the 'wildcard' option if a user selected field is invalid for an
 	event type, a message is displayed to the user that the option is
 	ignored for that type. For example:
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8d5fe092525c..373ea151dc60 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2560,6 +2560,10 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
 			pr_warning("Overriding previous field request for %s events.\n",
 				   event_type(type));
 
+		/* Don't override defaults for +- */
+		if (strchr(tok, '+') || strchr(tok, '-'))
+			goto parse;
+
 		output[type].fields = 0;
 		output[type].user_set = true;
 		output[type].wildcard_set = false;
@@ -2644,6 +2648,10 @@ parse:
 				rc = -EINVAL;
 				goto out;
 			}
+			if (change == REMOVE)
+				output[type].fields &= ~all_output_options[i].field;
+			else
+				output[type].fields |= all_output_options[i].field;
 			output[type].user_set = true;
 			output[type].wildcard_set = true;
 		}

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

* [tip:perf/core] perf bpf-event: Add missing new line into pr_debug call
  2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
  2019-02-20 19:23   ` Arnaldo Carvalho de Melo
@ 2019-02-28  7:46   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, songliubraving, linux-kernel, jolsa, hpa, namhyung, tglx,
	peterz, alexander.shishkin, mingo, ak

Commit-ID:  b20fe10642f90d17c07b5e621bf4c00093c5654b
Gitweb:     https://git.kernel.org/tip/b20fe10642f90d17c07b5e621bf4c00093c5654b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:27:58 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 16:23:07 -0300

perf bpf-event: Add missing new line into pr_debug call

Add a missing new line into pr_debug call in perf_event__synthesize_bpf_events(),
so that the error message does not screw the verbose output.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Link: http://lkml.kernel.org/r/20190220122800.864-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/bpf-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 62dda96b0096..028c8ec1f62a 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -233,7 +233,7 @@ int perf_event__synthesize_bpf_events(struct perf_tool *tool,
 				err = 0;
 				break;
 			}
-			pr_debug("%s: can't get next program: %s%s",
+			pr_debug("%s: can't get next program: %s%s\n",
 				 __func__, strerror(errno),
 				 errno == EINVAL ? " -- kernel too old?" : "");
 			/* don't report error on old kernel or EPERM  */

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

* [tip:perf/core] perf cpumap: Increase debug level for cpu_map__snprint verbose output
  2019-02-20 12:27 ` [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output Jiri Olsa
@ 2019-02-28  7:47   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, jolsa, peterz, acme, alexander.shishkin, ak, tglx, namhyung,
	linux-kernel, mingo

Commit-ID:  deb83da16c1f3412fcb33c8944b3d854c4b265d6
Gitweb:     https://git.kernel.org/tip/deb83da16c1f3412fcb33c8944b3d854c4b265d6
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:27:59 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 17:08:39 -0300

perf cpumap: Increase debug level for cpu_map__snprint verbose output

So it does not screw up single -v verbose output.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 0bbc3feb0894..0b599229bc7e 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -681,7 +681,7 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 
 #undef COMMA
 
-	pr_debug("cpumask list: %s\n", buf);
+	pr_debug2("cpumask list: %s\n", buf);
 	return ret;
 }
 

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

* [tip:perf/core] perf tools: Make rm_rf() remove single file
  2019-02-20 12:28 ` [PATCH 6/6] perf tools: Make rm_rf to remove single file Jiri Olsa
@ 2019-02-28  7:47   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-02-28  7:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, acme, tglx, alexander.shishkin, ak, hpa,
	alexey.budankov, linux-kernel, jolsa, namhyung

Commit-ID:  b4409ae112caa6315f6ee678e953b9fc93e6919c
Gitweb:     https://git.kernel.org/tip/b4409ae112caa6315f6ee678e953b9fc93e6919c
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 20 Feb 2019 13:28:00 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 20 Feb 2019 17:09:28 -0300

perf tools: Make rm_rf() remove single file

Let rm_rf() remove a file if it's provided by path, not just
directories.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190220122800.864-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/util.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 320b0fef249a..3ee410fc047a 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -120,16 +120,26 @@ int mkdir_p(char *path, mode_t mode)
 int rm_rf(const char *path)
 {
 	DIR *dir;
-	int ret = 0;
+	int ret;
 	struct dirent *d;
 	char namebuf[PATH_MAX];
+	struct stat statbuf;
 
+	/* Do not fail if there's no file. */
+	ret = lstat(path, &statbuf);
+	if (ret)
+		return 0;
+
+	/* Try to remove any file we get. */
+	if (!(statbuf.st_mode & S_IFDIR))
+		return unlink(path);
+
+	/* We have directory in path. */
 	dir = opendir(path);
 	if (dir == NULL)
-		return 0;
+		return -1;
 
 	while ((d = readdir(dir)) != NULL && !ret) {
-		struct stat statbuf;
 
 		if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
 			continue;

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

end of thread, other threads:[~2019-02-28  7:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 12:27 [PATCH 0/6] perf tools: Assorted fixes Jiri Olsa
2019-02-20 12:27 ` [PATCH 1/6] perf tools: Don't report zero period samples for slave events Jiri Olsa
2019-02-28  7:44   ` [tip:perf/core] perf session: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 2/6] perf tools: Force sample_type " Jiri Olsa
2019-02-28  7:45   ` [tip:perf/core] perf evsel: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 3/6] perf script: Allow +- operator for type specific fields option Jiri Olsa
2019-02-28  7:45   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 4/6] perf tools: Add missing new line into pr_debug call Jiri Olsa
2019-02-20 19:23   ` Arnaldo Carvalho de Melo
2019-02-28  7:46   ` [tip:perf/core] perf bpf-event: " tip-bot for Jiri Olsa
2019-02-20 12:27 ` [PATCH 5/6] perf tools: Increase debug leve for cpu_map__snprint verbose output Jiri Olsa
2019-02-28  7:47   ` [tip:perf/core] perf cpumap: Increase debug level " tip-bot for Jiri Olsa
2019-02-20 12:28 ` [PATCH 6/6] perf tools: Make rm_rf to remove single file Jiri Olsa
2019-02-28  7:47   ` [tip:perf/core] perf tools: Make rm_rf() " tip-bot for Jiri Olsa

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.