* [PATCH 0/2] perf intel-pt: Fix system_wide dummy event for hybrid
@ 2022-10-12 8:22 Adrian Hunter
2022-10-12 8:22 ` [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Adrian Hunter
2022-10-12 8:22 ` [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
0 siblings, 2 replies; 6+ messages in thread
From: Adrian Hunter @ 2022-10-12 8:22 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users
Hi
Here are a couple of minor Intel PT fixes.
Adrian Hunter (2):
perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
perf intel-pt: Fix system_wide dummy event for hybrid
tools/perf/arch/x86/util/intel-pt.c | 2 +-
tools/perf/util/intel-pt.c | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
Regards
Adrian
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
2022-10-12 8:22 [PATCH 0/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
@ 2022-10-12 8:22 ` Adrian Hunter
2022-10-12 16:20 ` Namhyung Kim
2022-10-12 8:22 ` [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
1 sibling, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2022-10-12 8:22 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users
uClibc segfaulted because NULL was passed as the format to fprintf().
That happened because one of the format strings was missing and
intel_pt_print_info() didn't check that before calling fprintf().
Add the missing format string, and check format is not NULL before calling
fprintf().
Fixes: 11fa7cb86b56 ("perf tools: Pass Intel PT information for decoding MTC and CYC")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/intel-pt.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index b34cb3dec1aa..e3548ddef254 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -4046,6 +4046,7 @@ static const char * const intel_pt_info_fmts[] = {
[INTEL_PT_SNAPSHOT_MODE] = " Snapshot mode %"PRId64"\n",
[INTEL_PT_PER_CPU_MMAPS] = " Per-cpu maps %"PRId64"\n",
[INTEL_PT_MTC_BIT] = " MTC bit %#"PRIx64"\n",
+ [INTEL_PT_MTC_FREQ_BITS] = " MTC freq bits %#"PRIx64"\n",
[INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n",
[INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n",
[INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n",
@@ -4060,8 +4061,12 @@ static void intel_pt_print_info(__u64 *arr, int start, int finish)
if (!dump_trace)
return;
- for (i = start; i <= finish; i++)
- fprintf(stdout, intel_pt_info_fmts[i], arr[i]);
+ for (i = start; i <= finish; i++) {
+ const char *fmt = intel_pt_info_fmts[i];
+
+ if (fmt)
+ fprintf(stdout, fmt, arr[i]);
+ }
}
static void intel_pt_print_info_str(const char *name, const char *str)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid
2022-10-12 8:22 [PATCH 0/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
2022-10-12 8:22 ` [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Adrian Hunter
@ 2022-10-12 8:22 ` Adrian Hunter
2022-10-12 16:25 ` Namhyung Kim
1 sibling, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2022-10-12 8:22 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users
User space tasks can migrate between CPUs, so when tracing selected CPUs,
system-wide sideband is still needed, however evlist->core.has_user_cpus
is not set in the hybrid case, so check the target cpu_list instead.
Fixes: 7d189cadbeeb ("perf intel-pt: Track sideband system-wide when needed")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/arch/x86/util/intel-pt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 793b35f2221a..af102f471e9f 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -866,7 +866,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
* User space tasks can migrate between CPUs, so when tracing
* selected CPUs, sideband for all CPUs is still needed.
*/
- need_system_wide_tracking = evlist->core.has_user_cpus &&
+ need_system_wide_tracking = opts->target.cpu_list &&
!intel_pt_evsel->core.attr.exclude_user;
tracking_evsel = evlist__add_aux_dummy(evlist, need_system_wide_tracking);
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
2022-10-12 8:22 ` [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Adrian Hunter
@ 2022-10-12 16:20 ` Namhyung Kim
0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2022-10-12 16:20 UTC (permalink / raw)
To: Adrian Hunter
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, linux-kernel,
linux-perf-users
Hi Adrian,
On Wed, Oct 12, 2022 at 1:23 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> uClibc segfaulted because NULL was passed as the format to fprintf().
Sounds like glibc has a NULL check in fprintf().
>
> That happened because one of the format strings was missing and
> intel_pt_print_info() didn't check that before calling fprintf().
>
> Add the missing format string, and check format is not NULL before calling
> fprintf().
>
> Fixes: 11fa7cb86b56 ("perf tools: Pass Intel PT information for decoding MTC and CYC")
> 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 | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> index b34cb3dec1aa..e3548ddef254 100644
> --- a/tools/perf/util/intel-pt.c
> +++ b/tools/perf/util/intel-pt.c
> @@ -4046,6 +4046,7 @@ static const char * const intel_pt_info_fmts[] = {
> [INTEL_PT_SNAPSHOT_MODE] = " Snapshot mode %"PRId64"\n",
> [INTEL_PT_PER_CPU_MMAPS] = " Per-cpu maps %"PRId64"\n",
> [INTEL_PT_MTC_BIT] = " MTC bit %#"PRIx64"\n",
> + [INTEL_PT_MTC_FREQ_BITS] = " MTC freq bits %#"PRIx64"\n",
> [INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n",
> [INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n",
> [INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n",
> @@ -4060,8 +4061,12 @@ static void intel_pt_print_info(__u64 *arr, int start, int finish)
> if (!dump_trace)
> return;
>
> - for (i = start; i <= finish; i++)
> - fprintf(stdout, intel_pt_info_fmts[i], arr[i]);
> + for (i = start; i <= finish; i++) {
> + const char *fmt = intel_pt_info_fmts[i];
> +
> + if (fmt)
> + fprintf(stdout, fmt, arr[i]);
> + }
> }
>
> static void intel_pt_print_info_str(const char *name, const char *str)
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid
2022-10-12 8:22 ` [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
@ 2022-10-12 16:25 ` Namhyung Kim
2022-10-14 20:09 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2022-10-12 16:25 UTC (permalink / raw)
To: Adrian Hunter
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, linux-kernel,
linux-perf-users
On Wed, Oct 12, 2022 at 1:23 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> User space tasks can migrate between CPUs, so when tracing selected CPUs,
> system-wide sideband is still needed, however evlist->core.has_user_cpus
> is not set in the hybrid case, so check the target cpu_list instead.
>
> Fixes: 7d189cadbeeb ("perf intel-pt: Track sideband system-wide when needed")
> 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/arch/x86/util/intel-pt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> index 793b35f2221a..af102f471e9f 100644
> --- a/tools/perf/arch/x86/util/intel-pt.c
> +++ b/tools/perf/arch/x86/util/intel-pt.c
> @@ -866,7 +866,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
> * User space tasks can migrate between CPUs, so when tracing
> * selected CPUs, sideband for all CPUs is still needed.
> */
> - need_system_wide_tracking = evlist->core.has_user_cpus &&
> + need_system_wide_tracking = opts->target.cpu_list &&
> !intel_pt_evsel->core.attr.exclude_user;
>
> tracking_evsel = evlist__add_aux_dummy(evlist, need_system_wide_tracking);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid
2022-10-12 16:25 ` Namhyung Kim
@ 2022-10-14 20:09 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-14 20:09 UTC (permalink / raw)
To: Namhyung Kim
Cc: Adrian Hunter, Jiri Olsa, Ian Rogers, linux-kernel,
linux-perf-users
Em Wed, Oct 12, 2022 at 09:25:14AM -0700, Namhyung Kim escreveu:
> On Wed, Oct 12, 2022 at 1:23 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > User space tasks can migrate between CPUs, so when tracing selected CPUs,
> > system-wide sideband is still needed, however evlist->core.has_user_cpus
> > is not set in the hybrid case, so check the target cpu_list instead.
> >
> > Fixes: 7d189cadbeeb ("perf intel-pt: Track sideband system-wide when needed")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied both fixes.
- Arnaldo
> Thanks,
> Namhyung
>
>
> > ---
> > tools/perf/arch/x86/util/intel-pt.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> > index 793b35f2221a..af102f471e9f 100644
> > --- a/tools/perf/arch/x86/util/intel-pt.c
> > +++ b/tools/perf/arch/x86/util/intel-pt.c
> > @@ -866,7 +866,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
> > * User space tasks can migrate between CPUs, so when tracing
> > * selected CPUs, sideband for all CPUs is still needed.
> > */
> > - need_system_wide_tracking = evlist->core.has_user_cpus &&
> > + need_system_wide_tracking = opts->target.cpu_list &&
> > !intel_pt_evsel->core.attr.exclude_user;
> >
> > tracking_evsel = evlist__add_aux_dummy(evlist, need_system_wide_tracking);
> > --
> > 2.25.1
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-14 20:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 8:22 [PATCH 0/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
2022-10-12 8:22 ` [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Adrian Hunter
2022-10-12 16:20 ` Namhyung Kim
2022-10-12 8:22 ` [PATCH 2/2] perf intel-pt: Fix system_wide dummy event for hybrid Adrian Hunter
2022-10-12 16:25 ` Namhyung Kim
2022-10-14 20:09 ` Arnaldo Carvalho de Melo
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.