Commit 2c47e7a
perf/core: Correct perf sampling with guest VMs
Previously any PMU overflow interrupt that fired while a VCPU was
loaded was recorded as a guest event whether it truly was or not. This
resulted in nonsense perf recordings that did not honor
perf_event_attr.exclude_guest and recorded guest IPs where it should
have recorded host IPs.
Rework the sampling logic to only record guest samples for events with
exclude_guest = 0. This way any host-only events with exclude_guest
set will never see unexpected guest samples. The behaviour of events
with exclude_guest = 0 is unchanged.
Note that events configured to sample both host and guest may still
misattribute a PMI that arrived in the host as a guest event depending
on KVM arch and vendor behavior.
Signed-off-by: Colton Lewis <coltonlewis@google.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241113190156.2145593-6-coltonlewis@google.com1 parent baff01f commit 2c47e7a
File tree
5 files changed
+36
-41
lines changed- arch
- arm64
- include/asm
- kernel
- x86/events
- include/linux
- kernel/events
5 files changed
+36
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 13 | | |
18 | 14 | | |
19 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3005 | 3005 | | |
3006 | 3006 | | |
3007 | 3007 | | |
3008 | | - | |
3009 | | - | |
3010 | | - | |
3011 | 3008 | | |
3012 | 3009 | | |
3013 | 3010 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1676 | 1676 | | |
1677 | 1677 | | |
1678 | 1678 | | |
1679 | | - | |
1680 | | - | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
1681 | 1682 | | |
1682 | 1683 | | |
1683 | 1684 | | |
| |||
1688 | 1689 | | |
1689 | 1690 | | |
1690 | 1691 | | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
1691 | 1708 | | |
1692 | 1709 | | |
1693 | 1710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7026 | 7026 | | |
7027 | 7027 | | |
7028 | 7028 | | |
7029 | | - | |
| 7029 | + | |
7030 | 7030 | | |
| 7031 | + | |
| 7032 | + | |
| 7033 | + | |
| 7034 | + | |
| 7035 | + | |
| 7036 | + | |
| 7037 | + | |
| 7038 | + | |
| 7039 | + | |
7031 | 7040 | | |
7032 | 7041 | | |
7033 | 7042 | | |
7034 | | - | |
| 7043 | + | |
| 7044 | + | |
7035 | 7045 | | |
| 7046 | + | |
| 7047 | + | |
| 7048 | + | |
7036 | 7049 | | |
7037 | 7050 | | |
7038 | 7051 | | |
| |||
7853 | 7866 | | |
7854 | 7867 | | |
7855 | 7868 | | |
7856 | | - | |
| 7869 | + | |
7857 | 7870 | | |
7858 | 7871 | | |
7859 | 7872 | | |
| |||
8017 | 8030 | | |
8018 | 8031 | | |
8019 | 8032 | | |
8020 | | - | |
| 8033 | + | |
8021 | 8034 | | |
8022 | 8035 | | |
8023 | 8036 | | |
| |||
0 commit comments