* [PATCH 1/2] perf intel-pt: Fix aux_watermark calculation for 64-bit size
2024-06-25 10:45 [PATCH 0/2] perf intel-pt: Some small fixes Adrian Hunter
@ 2024-06-25 10:45 ` Adrian Hunter
2024-06-25 10:45 ` [PATCH 2/2] perf intel-pt: Fix exclude_guest setting Adrian Hunter
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2024-06-25 10:45 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, Kan Liang, linux-kernel,
linux-perf-users
aux_watermark is a u32. For a 64-bit size, cap the aux_watermark
calculation at UINT_MAX instead of truncating it to 32-bits.
Fixes: 874fc35cdd55 ("perf intel-pt: Use aux_watermark")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/arch/x86/util/intel-pt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 6de7e2d21075..c8fa15f280d2 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -758,7 +758,8 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
}
if (!opts->auxtrace_snapshot_mode && !opts->auxtrace_sample_mode) {
- u32 aux_watermark = opts->auxtrace_mmap_pages * page_size / 4;
+ size_t aw = opts->auxtrace_mmap_pages * (size_t)page_size / 4;
+ u32 aux_watermark = aw > UINT_MAX ? UINT_MAX : aw;
intel_pt_evsel->core.attr.aux_watermark = aux_watermark;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] perf intel-pt: Fix exclude_guest setting
2024-06-25 10:45 [PATCH 0/2] perf intel-pt: Some small fixes Adrian Hunter
2024-06-25 10:45 ` [PATCH 1/2] perf intel-pt: Fix aux_watermark calculation for 64-bit size Adrian Hunter
@ 2024-06-25 10:45 ` Adrian Hunter
2024-06-28 16:57 ` [PATCH 0/2] perf intel-pt: Some small fixes Namhyung Kim
2024-07-03 21:52 ` Namhyung Kim
3 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2024-06-25 10:45 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, Kan Liang, linux-kernel,
linux-perf-users
In the past, the exclude_guest setting has had no effect on Intel PT
tracing, but that may not be the case in the future.
Set the flag correctly based upon whether KVM is using Intel PT
"Host/Guest" mode, which is determined by the kvm_intel module
parameter pt_mode:
pt_mode=0 System-wide mode : host and guest output to host buffer
pt_mode=1 Host/Guest mode : host/guest output to host/guest
buffers respectively
Fixes: 6e86bfdc4a60 ("perf intel-pt: Support decoding of guest kernel")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/arch/x86/util/intel-pt.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index c8fa15f280d2..4b710e875953 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -32,6 +32,7 @@
#include "../../../util/tsc.h"
#include <internal/lib.h> // page_size
#include "../../../util/intel-pt.h"
+#include <api/fs/fs.h>
#define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024)
@@ -428,6 +429,16 @@ static int intel_pt_track_switches(struct evlist *evlist)
}
#endif
+static bool intel_pt_exclude_guest(void)
+{
+ int pt_mode;
+
+ if (sysfs__read_int("module/kvm_intel/parameters/pt_mode", &pt_mode))
+ pt_mode = 0;
+
+ return pt_mode == 1;
+}
+
static void intel_pt_valid_str(char *str, size_t len, u64 valid)
{
unsigned int val, last = 0, state = 1;
@@ -620,6 +631,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
}
evsel->core.attr.freq = 0;
evsel->core.attr.sample_period = 1;
+ evsel->core.attr.exclude_guest = intel_pt_exclude_guest();
evsel->no_aux_samples = true;
evsel->needs_auxtrace_mmap = true;
intel_pt_evsel = evsel;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/2] perf intel-pt: Some small fixes
2024-06-25 10:45 [PATCH 0/2] perf intel-pt: Some small fixes Adrian Hunter
2024-06-25 10:45 ` [PATCH 1/2] perf intel-pt: Fix aux_watermark calculation for 64-bit size Adrian Hunter
2024-06-25 10:45 ` [PATCH 2/2] perf intel-pt: Fix exclude_guest setting Adrian Hunter
@ 2024-06-28 16:57 ` Namhyung Kim
2024-07-03 21:52 ` Namhyung Kim
3 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2024-06-28 16:57 UTC (permalink / raw)
To: Adrian Hunter
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, Kan Liang,
linux-kernel, linux-perf-users
On Tue, Jun 25, 2024 at 01:45:30PM +0300, Adrian Hunter wrote:
> Hi
>
> Here are a couple of small Intel PT fixes.
>
>
> Adrian Hunter (2):
> perf intel-pt: Fix aux_watermark calculation for 64-bit size
> perf intel-pt: Fix exclude_guest setting
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
>
> tools/perf/arch/x86/util/intel-pt.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
>
> Regards
> Adrian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] perf intel-pt: Some small fixes
2024-06-25 10:45 [PATCH 0/2] perf intel-pt: Some small fixes Adrian Hunter
` (2 preceding siblings ...)
2024-06-28 16:57 ` [PATCH 0/2] perf intel-pt: Some small fixes Namhyung Kim
@ 2024-07-03 21:52 ` Namhyung Kim
3 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2024-07-03 21:52 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Adrian Hunter
Cc: Jiri Olsa, Ian Rogers, Kan Liang, linux-kernel, linux-perf-users
On Tue, 25 Jun 2024 13:45:30 +0300, Adrian Hunter wrote:
> Here are a couple of small Intel PT fixes.
>
>
> Adrian Hunter (2):
> perf intel-pt: Fix aux_watermark calculation for 64-bit size
> perf intel-pt: Fix exclude_guest setting
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 5+ messages in thread