diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2022-07-11 11:32:10 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-07-20 16:08:42 +0200 |
commit | f9de2f0fd35f23564c9ab5e8c5873e9087042b64 (patch) | |
tree | 87f5c5a85a639223fc23749592683d1d58d5ae0d /tools/perf/util | |
parent | perf tools: Handle injected guest kernel mmap event (diff) | |
download | linux-f9de2f0fd35f23564c9ab5e8c5873e9087042b64.tar.xz linux-f9de2f0fd35f23564c9ab5e8c5873e9087042b64.zip |
perf tools: Add perf_event__is_guest()
Add a helper function to determine if an event is a guest event.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kvm@vger.kernel.org
Link: https://lore.kernel.org/r/20220711093218.10967-28-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/event.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index a660f304f83c..a7b0931d5137 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -484,4 +484,25 @@ void arch_perf_synthesize_sample_weight(const struct perf_sample *data, __u64 *a const char *arch_perf_header_entry(const char *se_header); int arch_support_sort_key(const char *sort_key); +static inline bool perf_event_header__cpumode_is_guest(u8 cpumode) +{ + return cpumode == PERF_RECORD_MISC_GUEST_KERNEL || + cpumode == PERF_RECORD_MISC_GUEST_USER; +} + +static inline bool perf_event_header__misc_is_guest(u16 misc) +{ + return perf_event_header__cpumode_is_guest(misc & PERF_RECORD_MISC_CPUMODE_MASK); +} + +static inline bool perf_event_header__is_guest(const struct perf_event_header *header) +{ + return perf_event_header__misc_is_guest(header->misc); +} + +static inline bool perf_event__is_guest(const union perf_event *event) +{ + return perf_event_header__is_guest(&event->header); +} + #endif /* __PERF_RECORD_H */ |