perf intel-pt: Fix system_wide dummy event for hybrid
Adrian Hunter
reviewercover perf intel-pt: Fix system_wide dummy event for hybrid
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
Adrian Hunter
reviewerPATCH 1/2 perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
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().
--- tools/perf/util/intel-pt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/intel-pt.c +7 -2
@@ -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)
Signature · 1 line
2.25.1
Re: [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
Hi Adrian,
Quoted 2 lines · Adrian Hunter
uClibc segfaulted because NULL was passed as the format to
fprintf().
Sounds like glibc has a NULL check in fprintf().
Quoted 10 lines
That happened because one of the format strings was missing and
intel_pt_print_info()didn't check that before callingfprintf().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")Signed-off-by Adrian Hunter <[email protected]>
Thanks,
Namhyung
Quoted 34 lines
--- tools/perf/util/intel-pt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tools/perf/util/intel-pt.c +7
-3@@ -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
Adrian Hunter
reviewerPATCH 2/2 perf intel-pt: Fix system_wide dummy event for hybrid
In reply to Adrian HunterUser 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.
--- tools/perf/arch/x86/util/intel-pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/x86/util/intel-pt.c +1 -1
@@ -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);
Signature · 1 line
2.25.1
Quoted 8 lines · Adrian Hunter
User space tasks can migrate between CPUs, so when tracing selected CPUs, system-wide sideband is still needed, however
evlist->core.has_user_cpusis not set in the hybrid case, so check the targetcpu_listinstead.Fixes 7d189cadbeeb ("perf intel-pt: Track sideband system-wide when needed")Signed-off-by Adrian Hunter <[email protected]>
Thanks,
Namhyung
Quoted 20 lines
--- tools/perf/arch/x86/util/intel-pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/arch/x86/util/intel-pt.c +1
-2@@ -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
Em Wed, Oct 12, 2022 at 09:25:14AM -0700, Namhyung Kim escreveu:
Quoted 11 lines · Adrian Hunter
Quoted 8 lines
User space tasks can migrate between CPUs, so when tracing selected CPUs, system-wide sideband is still needed, however
evlist->core.has_user_cpusis not set in the hybrid case, so check the targetcpu_listinstead.Fixes 7d189cadbeeb ("perf intel-pt: Track sideband system-wide when needed")Signed-off-by Adrian Hunter <[email protected]>Acked-by Namhyung Kim <[email protected]>
Thanks, applied both fixes.
- Arnaldo
Quoted 24 lines
Thanks,
NamhyungQuoted 20 lines
--- tools/perf/arch/x86/util/intel-pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/arch/x86/util/intel-pt.c +1
-2@@ -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
Signature · 1 line
- Arnaldo