linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf intel-pt: Fix PEBS-via-PT with registers
@ 2020-06-30 13:39 Adrian Hunter
  2020-06-30 13:39 ` [PATCH 1/3] perf intel-pt: Fix recording " Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Adrian Hunter @ 2020-06-30 13:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

Hi

Here are some more Intel PT fixes for v5.8.


Adrian Hunter (3):
      perf intel-pt: Fix recording PEBS-via-PT with registers
      perf intel-pt: Fix displaying PEBS-via-PT with registers
      perf intel-pt: Fix PEBS sample for XMM registers

 tools/perf/arch/x86/util/intel-pt.c | 1 +
 tools/perf/builtin-script.c         | 2 +-
 tools/perf/util/evsel.c             | 4 ++--
 tools/perf/util/intel-pt.c          | 5 +++--
 4 files changed, 7 insertions(+), 5 deletions(-)


Regards
Adrian

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

* [PATCH 1/3] perf intel-pt: Fix recording PEBS-via-PT with registers
  2020-06-30 13:39 [PATCH 0/3] perf intel-pt: Fix PEBS-via-PT with registers Adrian Hunter
@ 2020-06-30 13:39 ` Adrian Hunter
  2020-07-03 11:25   ` Arnaldo Carvalho de Melo
  2020-06-30 13:39 ` [PATCH 2/3] perf intel-pt: Fix displaying " Adrian Hunter
  2020-06-30 13:39 ` [PATCH 3/3] perf intel-pt: Fix PEBS sample for XMM registers Adrian Hunter
  2 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2020-06-30 13:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

When recording PEBS-via-PT, the kernel will not accept the intel_pt event
with register sampling e.g.

 # perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
 Error:
 intel_pt/branch=0/: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'

Fix by suppressing register sampling on the intel_pt evsel.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 9e64cefe4335b ("perf intel-pt: Process options for PEBS event synthesis")
---
 tools/perf/arch/x86/util/intel-pt.c | 1 +
 tools/perf/util/evsel.c             | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 839ef52c1ac2..6ce451293634 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -641,6 +641,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 			}
 			evsel->core.attr.freq = 0;
 			evsel->core.attr.sample_period = 1;
+			evsel->no_aux_samples = true;
 			intel_pt_evsel = evsel;
 			opts->full_auxtrace = true;
 		}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a68ac3632ae6..ef802f6d40c1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1014,12 +1014,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
 	if (callchain && callchain->enabled && !evsel->no_aux_samples)
 		evsel__config_callchain(evsel, opts, callchain);
 
-	if (opts->sample_intr_regs) {
+	if (opts->sample_intr_regs && !evsel->no_aux_samples) {
 		attr->sample_regs_intr = opts->sample_intr_regs;
 		evsel__set_sample_bit(evsel, REGS_INTR);
 	}
 
-	if (opts->sample_user_regs) {
+	if (opts->sample_user_regs && !evsel->no_aux_samples) {
 		attr->sample_regs_user |= opts->sample_user_regs;
 		evsel__set_sample_bit(evsel, REGS_USER);
 	}
-- 
2.17.1


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

* [PATCH 2/3] perf intel-pt: Fix displaying PEBS-via-PT with registers
  2020-06-30 13:39 [PATCH 0/3] perf intel-pt: Fix PEBS-via-PT with registers Adrian Hunter
  2020-06-30 13:39 ` [PATCH 1/3] perf intel-pt: Fix recording " Adrian Hunter
@ 2020-06-30 13:39 ` Adrian Hunter
  2020-06-30 13:39 ` [PATCH 3/3] perf intel-pt: Fix PEBS sample for XMM registers Adrian Hunter
  2 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2020-06-30 13:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

After recording PEBS-via-PT, perf script will not accept 'iregs' field e.g.

 # perf record -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
 ...
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.062 MB perf.data ]
 # ./perf script --itrace=eop -F+iregs
 Samples for 'dummy:u' event do not have IREGS attribute set. Cannot print 'iregs' field.

Fix by using allow_user_set, which is true when recording AUX area data.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 9e64cefe4335b ("perf intel-pt: Process options for PEBS event synthesis")
---
 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 5da243676f12..31420baa1fb5 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -462,7 +462,7 @@ static int perf_evsel__check_attr(struct evsel *evsel, struct perf_session *sess
 		return -EINVAL;
 
 	if (PRINT_FIELD(IREGS) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS", PERF_OUTPUT_IREGS))
+	    evsel__do_check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS", PERF_OUTPUT_IREGS, allow_user_set))
 		return -EINVAL;
 
 	if (PRINT_FIELD(UREGS) &&
-- 
2.17.1


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

* [PATCH 3/3] perf intel-pt: Fix PEBS sample for XMM registers
  2020-06-30 13:39 [PATCH 0/3] perf intel-pt: Fix PEBS-via-PT with registers Adrian Hunter
  2020-06-30 13:39 ` [PATCH 1/3] perf intel-pt: Fix recording " Adrian Hunter
  2020-06-30 13:39 ` [PATCH 2/3] perf intel-pt: Fix displaying " Adrian Hunter
@ 2020-06-30 13:39 ` Adrian Hunter
  2 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2020-06-30 13:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

The condition to add XMM registers was missing, the regs array needed to be
in the outer scope, and the size of the regs array was too small.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 143d34a6b387b ("perf intel-pt: Add XMM registers to synthesized PEBS sample")
---
 tools/perf/util/intel-pt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index e4dd8bf610ce..cb3c1e569a2d 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1735,6 +1735,7 @@ static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq)
 	u64 sample_type = evsel->core.attr.sample_type;
 	u64 id = evsel->core.id[0];
 	u8 cpumode;
+	u64 regs[8 * sizeof(sample.intr_regs.mask)];
 
 	if (intel_pt_skip_event(pt))
 		return 0;
@@ -1784,8 +1785,8 @@ static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq)
 	}
 
 	if (sample_type & PERF_SAMPLE_REGS_INTR &&
-	    items->mask[INTEL_PT_GP_REGS_POS]) {
-		u64 regs[sizeof(sample.intr_regs.mask)];
+	    (items->mask[INTEL_PT_GP_REGS_POS] ||
+	     items->mask[INTEL_PT_XMM_POS])) {
 		u64 regs_mask = evsel->core.attr.sample_regs_intr;
 		u64 *pos;
 
-- 
2.17.1


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

* Re: [PATCH 1/3] perf intel-pt: Fix recording PEBS-via-PT with registers
  2020-06-30 13:39 ` [PATCH 1/3] perf intel-pt: Fix recording " Adrian Hunter
@ 2020-07-03 11:25   ` Arnaldo Carvalho de Melo
  2020-07-03 11:26     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-07-03 11:25 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

Em Tue, Jun 30, 2020 at 04:39:33PM +0300, Adrian Hunter escreveu:
> When recording PEBS-via-PT, the kernel will not accept the intel_pt event
> with register sampling e.g.
> 
>  # perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
>  Error:
>  intel_pt/branch=0/: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
> 
> Fix by suppressing register sampling on the intel_pt evsel.

Next time please inform what is the hardware that supports PEBS-via-PT,
I tried this on a:

[    0.245654] smpboot: CPU0: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (family: 0x6, model: 0x8e, stepping: 0xa)
[    0.245791] Performance Events: PEBS fmt3+, Skylake events, 32-deep LBR, full-width counters, Intel PMU driver.

And even after this fix I get:

[root@quaco ~]# perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
Error:
branch-loads: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
[root@quaco ~]#

Further details:

[root@quaco ~]# perf record -vv --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
Using CPUID GenuineIntel-6-8E-A
intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
Attempting to add event pmu 'intel_pt' with 'branch,' that may result in non-fatal errors
After aliases, add event pmu 'intel_pt' with 'branch,' that may result in non-fatal errors
nr_cblocks: 0
affinity: SYS
mmap flush: 1
comp level: 0
------------------------------------------------------------
perf_event_attr:
  type                             8
  size                             120
  config                           0x300c601
  { sample_period, sample_freq }   10000
  sample_type                      IP|TID|TIME|CPU|IDENTIFIER
  read_format                      ID
  disabled                         1
  inherit                          1
  enable_on_exec                   1
  sample_id_all                    1
  exclude_guest                    1
------------------------------------------------------------
sys_perf_event_open: pid 11131  cpu 0  group_fd -1  flags 0x8 = 5
sys_perf_event_open: pid 11131  cpu 1  group_fd -1  flags 0x8 = 6
sys_perf_event_open: pid 11131  cpu 2  group_fd -1  flags 0x8 = 7
sys_perf_event_open: pid 11131  cpu 3  group_fd -1  flags 0x8 = 9
sys_perf_event_open: pid 11131  cpu 4  group_fd -1  flags 0x8 = 10
sys_perf_event_open: pid 11131  cpu 5  group_fd -1  flags 0x8 = 11
sys_perf_event_open: pid 11131  cpu 6  group_fd -1  flags 0x8 = 12
sys_perf_event_open: pid 11131  cpu 7  group_fd -1  flags 0x8 = 13
------------------------------------------------------------
perf_event_attr:
  type                             3
  size                             120
  config                           0x5
  { sample_period, sample_freq }   10000
  sample_type                      IP|TID|TIME|IDENTIFIER|REGS_INTR
  read_format                      ID
  inherit                          1
  precise_ip                       3
  sample_id_all                    1
  exclude_guest                    1
  aux_output                       1
  sample_regs_intr                 0xff0fff
------------------------------------------------------------
sys_perf_event_open: pid 11131  cpu 0  group_fd 5  flags 0x8
sys_perf_event_open failed, error -95
Error:
branch-loads: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
[root@quaco ~]#




 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Fixes: 9e64cefe4335b ("perf intel-pt: Process options for PEBS event synthesis")
> ---
>  tools/perf/arch/x86/util/intel-pt.c | 1 +
>  tools/perf/util/evsel.c             | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> index 839ef52c1ac2..6ce451293634 100644
> --- a/tools/perf/arch/x86/util/intel-pt.c
> +++ b/tools/perf/arch/x86/util/intel-pt.c
> @@ -641,6 +641,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
>  			}
>  			evsel->core.attr.freq = 0;
>  			evsel->core.attr.sample_period = 1;
> +			evsel->no_aux_samples = true;
>  			intel_pt_evsel = evsel;
>  			opts->full_auxtrace = true;
>  		}
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a68ac3632ae6..ef802f6d40c1 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1014,12 +1014,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
>  	if (callchain && callchain->enabled && !evsel->no_aux_samples)
>  		evsel__config_callchain(evsel, opts, callchain);
>  
> -	if (opts->sample_intr_regs) {
> +	if (opts->sample_intr_regs && !evsel->no_aux_samples) {
>  		attr->sample_regs_intr = opts->sample_intr_regs;
>  		evsel__set_sample_bit(evsel, REGS_INTR);
>  	}
>  
> -	if (opts->sample_user_regs) {
> +	if (opts->sample_user_regs && !evsel->no_aux_samples) {
>  		attr->sample_regs_user |= opts->sample_user_regs;
>  		evsel__set_sample_bit(evsel, REGS_USER);
>  	}
> -- 
> 2.17.1
> 

-- 

- Arnaldo

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

* Re: [PATCH 1/3] perf intel-pt: Fix recording PEBS-via-PT with registers
  2020-07-03 11:25   ` Arnaldo Carvalho de Melo
@ 2020-07-03 11:26     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-07-03 11:26 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel, Luwei Kang

Em Fri, Jul 03, 2020 at 08:25:03AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Jun 30, 2020 at 04:39:33PM +0300, Adrian Hunter escreveu:
> > When recording PEBS-via-PT, the kernel will not accept the intel_pt event
> > with register sampling e.g.
> > 
> >  # perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
> >  Error:
> >  intel_pt/branch=0/: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
> > 
> > Fix by suppressing register sampling on the intel_pt evsel.
> 
> Next time please inform what is the hardware that supports PEBS-via-PT,
> I tried this on a:
> 
> [    0.245654] smpboot: CPU0: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (family: 0x6, model: 0x8e, stepping: 0xa)
> [    0.245791] Performance Events: PEBS fmt3+, Skylake events, 32-deep LBR, full-width counters, Intel PMU driver.

Also:

[acme@quaco perf]$ uname -a
Linux quaco 5.8.0-rc3+ #2 SMP Tue Jun 30 09:47:17 -03 2020 x86_64 x86_64 x86_64 GNU/Linux
 
> And even after this fix I get:
> 
> [root@quaco ~]# perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
> Error:
> branch-loads: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
> [root@quaco ~]#
> 
> Further details:
> 
> [root@quaco ~]# perf record -vv --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
> Using CPUID GenuineIntel-6-8E-A
> intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
> Attempting to add event pmu 'intel_pt' with 'branch,' that may result in non-fatal errors
> After aliases, add event pmu 'intel_pt' with 'branch,' that may result in non-fatal errors
> nr_cblocks: 0
> affinity: SYS
> mmap flush: 1
> comp level: 0
> ------------------------------------------------------------
> perf_event_attr:
>   type                             8
>   size                             120
>   config                           0x300c601
>   { sample_period, sample_freq }   10000
>   sample_type                      IP|TID|TIME|CPU|IDENTIFIER
>   read_format                      ID
>   disabled                         1
>   inherit                          1
>   enable_on_exec                   1
>   sample_id_all                    1
>   exclude_guest                    1
> ------------------------------------------------------------
> sys_perf_event_open: pid 11131  cpu 0  group_fd -1  flags 0x8 = 5
> sys_perf_event_open: pid 11131  cpu 1  group_fd -1  flags 0x8 = 6
> sys_perf_event_open: pid 11131  cpu 2  group_fd -1  flags 0x8 = 7
> sys_perf_event_open: pid 11131  cpu 3  group_fd -1  flags 0x8 = 9
> sys_perf_event_open: pid 11131  cpu 4  group_fd -1  flags 0x8 = 10
> sys_perf_event_open: pid 11131  cpu 5  group_fd -1  flags 0x8 = 11
> sys_perf_event_open: pid 11131  cpu 6  group_fd -1  flags 0x8 = 12
> sys_perf_event_open: pid 11131  cpu 7  group_fd -1  flags 0x8 = 13
> ------------------------------------------------------------
> perf_event_attr:
>   type                             3
>   size                             120
>   config                           0x5
>   { sample_period, sample_freq }   10000
>   sample_type                      IP|TID|TIME|IDENTIFIER|REGS_INTR
>   read_format                      ID
>   inherit                          1
>   precise_ip                       3
>   sample_id_all                    1
>   exclude_guest                    1
>   aux_output                       1
>   sample_regs_intr                 0xff0fff
> ------------------------------------------------------------
> sys_perf_event_open: pid 11131  cpu 0  group_fd 5  flags 0x8
> sys_perf_event_open failed, error -95
> Error:
> branch-loads: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
> [root@quaco ~]#
> 
> 
> 
> 
>  
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> > Fixes: 9e64cefe4335b ("perf intel-pt: Process options for PEBS event synthesis")
> > ---
> >  tools/perf/arch/x86/util/intel-pt.c | 1 +
> >  tools/perf/util/evsel.c             | 4 ++--
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> > index 839ef52c1ac2..6ce451293634 100644
> > --- a/tools/perf/arch/x86/util/intel-pt.c
> > +++ b/tools/perf/arch/x86/util/intel-pt.c
> > @@ -641,6 +641,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
> >  			}
> >  			evsel->core.attr.freq = 0;
> >  			evsel->core.attr.sample_period = 1;
> > +			evsel->no_aux_samples = true;
> >  			intel_pt_evsel = evsel;
> >  			opts->full_auxtrace = true;
> >  		}
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index a68ac3632ae6..ef802f6d40c1 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -1014,12 +1014,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
> >  	if (callchain && callchain->enabled && !evsel->no_aux_samples)
> >  		evsel__config_callchain(evsel, opts, callchain);
> >  
> > -	if (opts->sample_intr_regs) {
> > +	if (opts->sample_intr_regs && !evsel->no_aux_samples) {
> >  		attr->sample_regs_intr = opts->sample_intr_regs;
> >  		evsel__set_sample_bit(evsel, REGS_INTR);
> >  	}
> >  
> > -	if (opts->sample_user_regs) {
> > +	if (opts->sample_user_regs && !evsel->no_aux_samples) {
> >  		attr->sample_regs_user |= opts->sample_user_regs;
> >  		evsel__set_sample_bit(evsel, REGS_USER);
> >  	}
> > -- 
> > 2.17.1
> > 
> 
> -- 
> 
> - Arnaldo

-- 

- Arnaldo

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

end of thread, other threads:[~2020-07-03 11:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 13:39 [PATCH 0/3] perf intel-pt: Fix PEBS-via-PT with registers Adrian Hunter
2020-06-30 13:39 ` [PATCH 1/3] perf intel-pt: Fix recording " Adrian Hunter
2020-07-03 11:25   ` Arnaldo Carvalho de Melo
2020-07-03 11:26     ` Arnaldo Carvalho de Melo
2020-06-30 13:39 ` [PATCH 2/3] perf intel-pt: Fix displaying " Adrian Hunter
2020-06-30 13:39 ` [PATCH 3/3] perf intel-pt: Fix PEBS sample for XMM registers 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).