Skip to content

Commit b40934a

Browse files
ahunter6namhyung
authored andcommitted
perf intel-pt: Fix exclude_guest setting
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: 6e86bfd ("perf intel-pt: Support decoding of guest kernel") Signed-off-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 36b4cd9 commit b40934a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/perf/arch/x86/util/intel-pt.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "../../../util/tsc.h"
3333
#include <internal/lib.h> // page_size
3434
#include "../../../util/intel-pt.h"
35+
#include <api/fs/fs.h>
3536

3637
#define KiB(x) ((x) * 1024)
3738
#define MiB(x) ((x) * 1024 * 1024)
@@ -428,6 +429,16 @@ static int intel_pt_track_switches(struct evlist *evlist)
428429
}
429430
#endif
430431

432+
static bool intel_pt_exclude_guest(void)
433+
{
434+
int pt_mode;
435+
436+
if (sysfs__read_int("module/kvm_intel/parameters/pt_mode", &pt_mode))
437+
pt_mode = 0;
438+
439+
return pt_mode == 1;
440+
}
441+
431442
static void intel_pt_valid_str(char *str, size_t len, u64 valid)
432443
{
433444
unsigned int val, last = 0, state = 1;
@@ -620,6 +631,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
620631
}
621632
evsel->core.attr.freq = 0;
622633
evsel->core.attr.sample_period = 1;
634+
evsel->core.attr.exclude_guest = intel_pt_exclude_guest();
623635
evsel->no_aux_samples = true;
624636
evsel->needs_auxtrace_mmap = true;
625637
intel_pt_evsel = evsel;

0 commit comments

Comments
 (0)