linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf intel-pt: 3 more small fixes
@ 2021-12-15  8:06 Adrian Hunter
  2021-12-15  8:06 ` [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Adrian Hunter @ 2021-12-15  8:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Riccardo Mancini, Namhyung Kim

Hi

Here are 3 more small fixes.


Adrian Hunter (3):
      perf intel-pt: Fix parsing of VM time correlation arguments
      perf script: Fix CPU filtering of a script's switch events
      perf scripts python: intel-pt-events.py: Fix printing of switch events

 tools/perf/builtin-script.c                  |  2 +-
 tools/perf/scripts/python/intel-pt-events.py | 23 +++++++++++++----------
 tools/perf/util/intel-pt.c                   |  1 +
 3 files changed, 15 insertions(+), 11 deletions(-)


Regards
Adrian

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

* [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments
  2021-12-15  8:06 [PATCH 0/3] perf intel-pt: 3 more small fixes Adrian Hunter
@ 2021-12-15  8:06 ` Adrian Hunter
  2021-12-15 18:04   ` Namhyung Kim
  2021-12-15  8:06 ` [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events Adrian Hunter
  2021-12-15  8:06 ` [PATCH 3/3] perf scripts python: intel-pt-events.py: Fix printing of " Adrian Hunter
  2 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2021-12-15  8:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Riccardo Mancini, Namhyung Kim

Parser did not take ':' into account.

Example:

 Before:

  $ perf record -e intel_pt//u uname
  Linux
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.026 MB perf.data ]
  $ perf inject -i perf.data --vm-time-correlation="dry-run 123"
  $ perf inject -i perf.data --vm-time-correlation="dry-run 123:456"
  Failed to parse VM Time Correlation options
  0x620 [0x98]: failed to process type: 70 [Invalid argument]
  $

 After:

  $ perf inject -i perf.data --vm-time-correlation="dry-run 123:456"
  $

Fixes: e3ff42bdebcfe ("perf intel-pt: Parse VM Time Correlation options and set up decoding")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/intel-pt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 10c3187e4c5a..e8613cbda331 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -3625,6 +3625,7 @@ static int intel_pt_parse_vm_tm_corr_arg(struct intel_pt *pt, char **args)
 		*args = p;
 		return 0;
 	}
+	p += 1;
 	while (1) {
 		vmcs = strtoull(p, &p, 0);
 		if (errno)
-- 
2.25.1


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

* [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events
  2021-12-15  8:06 [PATCH 0/3] perf intel-pt: 3 more small fixes Adrian Hunter
  2021-12-15  8:06 ` [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments Adrian Hunter
@ 2021-12-15  8:06 ` Adrian Hunter
  2021-12-15 18:05   ` Namhyung Kim
  2021-12-15  8:06 ` [PATCH 3/3] perf scripts python: intel-pt-events.py: Fix printing of " Adrian Hunter
  2 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2021-12-15  8:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Riccardo Mancini, Namhyung Kim

CPU filtering was not being applied to a script's switch events.

Fixes: 5bf83c29a0ad2 ("perf script: Add scripting operation process_switch()")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9434367af166..c82b033e8942 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2473,7 +2473,7 @@ static int process_switch_event(struct perf_tool *tool,
 	if (perf_event__process_switch(tool, event, sample, machine) < 0)
 		return -1;
 
-	if (scripting_ops && scripting_ops->process_switch)
+	if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample))
 		scripting_ops->process_switch(event, sample, machine);
 
 	if (!script->show_switch_events)
-- 
2.25.1


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

* [PATCH 3/3] perf scripts python: intel-pt-events.py: Fix printing of switch events
  2021-12-15  8:06 [PATCH 0/3] perf intel-pt: 3 more small fixes Adrian Hunter
  2021-12-15  8:06 ` [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments Adrian Hunter
  2021-12-15  8:06 ` [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events Adrian Hunter
@ 2021-12-15  8:06 ` Adrian Hunter
  2 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2021-12-15  8:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Riccardo Mancini, Namhyung Kim

The intel-pt-events.py script displays only the last of consecutive switch
statements but that may not be the last switch event for the CPU. Fix by
keeping a dictionary of last context switch keyed by CPU, and make it
possible to see all switch events by adding option --all-switch-events.

Fixes: a92bf335fd82e ("perf scripts python: intel-pt-events.py: Add branches to script")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/scripts/python/intel-pt-events.py | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
index 1d3a189a9a54..66452a8ec358 100644
--- a/tools/perf/scripts/python/intel-pt-events.py
+++ b/tools/perf/scripts/python/intel-pt-events.py
@@ -32,8 +32,7 @@ try:
 except:
 	broken_pipe_exception = IOError
 
-glb_switch_str		= None
-glb_switch_printed	= True
+glb_switch_str		= {}
 glb_insn		= False
 glb_disassembler	= None
 glb_src			= False
@@ -70,6 +69,7 @@ def trace_begin():
 	ap = argparse.ArgumentParser(usage = "", add_help = False)
 	ap.add_argument("--insn-trace", action='store_true')
 	ap.add_argument("--src-trace", action='store_true')
+	ap.add_argument("--all-switch-events", action='store_true')
 	global glb_args
 	global glb_insn
 	global glb_src
@@ -256,10 +256,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn):
 	print(start_str, src_str)
 
 def do_process_event(param_dict):
-	global glb_switch_printed
-	if not glb_switch_printed:
-		print(glb_switch_str)
-		glb_switch_printed = True
 	event_attr = param_dict["attr"]
 	sample	   = param_dict["sample"]
 	raw_buf	   = param_dict["raw_buf"]
@@ -274,6 +270,11 @@ def do_process_event(param_dict):
 	dso    = get_optional(param_dict, "dso")
 	symbol = get_optional(param_dict, "symbol")
 
+	cpu = sample["cpu"]
+	if cpu in glb_switch_str:
+		print(glb_switch_str[cpu])
+		del glb_switch_str[cpu]
+
 	if name[0:12] == "instructions":
 		if glb_src:
 			print_srccode(comm, param_dict, sample, symbol, dso, True)
@@ -336,8 +337,6 @@ def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x):
 		sys.exit(1)
 
 def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x):
-	global glb_switch_printed
-	global glb_switch_str
 	if out:
 		out_str = "Switch out "
 	else:
@@ -350,6 +349,10 @@ def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_pree
 		machine_str = ""
 	else:
 		machine_str = "machine PID %d" % machine_pid
-	glb_switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \
+	switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \
 		(out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str)
-	glb_switch_printed = False
+	if glb_args.all_switch_events:
+		print(switch_str);
+	else:
+		global glb_switch_str
+		glb_switch_str[cpu] = switch_str
-- 
2.25.1


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

* Re: [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments
  2021-12-15  8:06 ` [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments Adrian Hunter
@ 2021-12-15 18:04   ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2021-12-15 18:04 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, linux-kernel,
	Riccardo Mancini

Hi Adrian,

On Wed, Dec 15, 2021 at 12:07 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Parser did not take ':' into account.
>
> Example:
>
>  Before:
>
>   $ perf record -e intel_pt//u uname
>   Linux
>   [ perf record: Woken up 1 times to write data ]
>   [ perf record: Captured and wrote 0.026 MB perf.data ]
>   $ perf inject -i perf.data --vm-time-correlation="dry-run 123"
>   $ perf inject -i perf.data --vm-time-correlation="dry-run 123:456"
>   Failed to parse VM Time Correlation options
>   0x620 [0x98]: failed to process type: 70 [Invalid argument]
>   $
>
>  After:
>
>   $ perf inject -i perf.data --vm-time-correlation="dry-run 123:456"
>   $
>
> Fixes: e3ff42bdebcfe ("perf intel-pt: Parse VM Time Correlation options and set up decoding")
> Cc: stable@vger.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/util/intel-pt.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> index 10c3187e4c5a..e8613cbda331 100644
> --- a/tools/perf/util/intel-pt.c
> +++ b/tools/perf/util/intel-pt.c
> @@ -3625,6 +3625,7 @@ static int intel_pt_parse_vm_tm_corr_arg(struct intel_pt *pt, char **args)
>                 *args = p;
>                 return 0;
>         }
> +       p += 1;
>         while (1) {
>                 vmcs = strtoull(p, &p, 0);
>                 if (errno)
> --
> 2.25.1
>

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

* Re: [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events
  2021-12-15  8:06 ` [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events Adrian Hunter
@ 2021-12-15 18:05   ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2021-12-15 18:05 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, linux-kernel,
	Riccardo Mancini

On Wed, Dec 15, 2021 at 12:07 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> CPU filtering was not being applied to a script's switch events.
>
> Fixes: 5bf83c29a0ad2 ("perf script: Add scripting operation process_switch()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/builtin-script.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 9434367af166..c82b033e8942 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2473,7 +2473,7 @@ static int process_switch_event(struct perf_tool *tool,
>         if (perf_event__process_switch(tool, event, sample, machine) < 0)
>                 return -1;
>
> -       if (scripting_ops && scripting_ops->process_switch)
> +       if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample))
>                 scripting_ops->process_switch(event, sample, machine);
>
>         if (!script->show_switch_events)
> --
> 2.25.1
>

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

end of thread, other threads:[~2021-12-15 18:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15  8:06 [PATCH 0/3] perf intel-pt: 3 more small fixes Adrian Hunter
2021-12-15  8:06 ` [PATCH 1/3] perf intel-pt: Fix parsing of VM time correlation arguments Adrian Hunter
2021-12-15 18:04   ` Namhyung Kim
2021-12-15  8:06 ` [PATCH 2/3] perf script: Fix CPU filtering of a script's switch events Adrian Hunter
2021-12-15 18:05   ` Namhyung Kim
2021-12-15  8:06 ` [PATCH 3/3] perf scripts python: intel-pt-events.py: Fix printing of " Adrian Hunter

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).