From: Colton Lewis <coltonlewis@google.com>
To: kvm@vger.kernel.org
Cc: Oliver Upton <oliver.upton@linux.dev>,
Sean Christopherson <seanjc@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Will Deacon <will@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Naveen N Rao <naveen@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
Colton Lewis <coltonlewis@google.com>
Subject: [PATCH v2 0/5] Correct perf sampling with Guest VMs
Date: Wed, 11 Sep 2024 22:24:27 +0000 [thread overview]
Message-ID: <20240911222433.3415301-1-coltonlewis@google.com> (raw)
v2:
* Better explain commit messages
* Fix incorrect type in patch 2
* Fix missing argument in call to common_misc_flags() in patch 5
* Rebase to 6.11-rc7 and include base commit in letter
v1:
https://lore.kernel.org/kvm/20240904204133.1442132-1-coltonlewis@google.com/
This series cleans up perf recording around guest events and improves
the accuracy of the resulting perf reports.
Perf was incorrectly counting any PMU overflow interrupt that occurred
while a VCPU was loaded as a guest event even when the events were not
truely guest events. This lead to much less accurate and useful perf
recordings.
See as an example the below reports of `perf record
dirty_log_perf_test -m 2 -v 4` before and after the series on ARM64.
Without series:
Samples: 15K of event 'instructions', Event count (approx.): 31830580924
Overhead Command Shared Object Symbol
54.54% dirty_log_perf_ dirty_log_perf_test [.] run_test
5.39% dirty_log_perf_ dirty_log_perf_test [.] vcpu_worker
0.89% dirty_log_perf_ [kernel.vmlinux] [k] release_pages
0.70% dirty_log_perf_ [kernel.vmlinux] [k] free_pcppages_bulk
0.62% dirty_log_perf_ dirty_log_perf_test [.] userspace_mem_region_find
0.49% dirty_log_perf_ dirty_log_perf_test [.] sparsebit_is_set
0.46% dirty_log_perf_ dirty_log_perf_test [.] _virt_pg_map
0.46% dirty_log_perf_ dirty_log_perf_test [.] node_add
0.37% dirty_log_perf_ dirty_log_perf_test [.] node_reduce
0.35% dirty_log_perf_ [kernel.vmlinux] [k] free_unref_page_commit
0.33% dirty_log_perf_ [kernel.vmlinux] [k] __kvm_pgtable_walk
0.31% dirty_log_perf_ [kernel.vmlinux] [k] stage2_attr_walker
0.29% dirty_log_perf_ [kernel.vmlinux] [k] unmap_page_range
0.29% dirty_log_perf_ dirty_log_perf_test [.] test_assert
0.26% dirty_log_perf_ [kernel.vmlinux] [k] __mod_memcg_lruvec_state
0.24% dirty_log_perf_ [kernel.vmlinux] [k] kvm_s2_put_page
With series:
Samples: 15K of event 'instructions', Event count (approx.): 31830580924
Samples: 15K of event 'instructions', Event count (approx.): 30898031385
Overhead Command Shared Object Symbol
54.05% dirty_log_perf_ dirty_log_perf_test [.] run_test
5.48% dirty_log_perf_ [kernel.kallsyms] [k] kvm_arch_vcpu_ioctl_run
4.70% dirty_log_perf_ dirty_log_perf_test [.] vcpu_worker
3.11% dirty_log_perf_ [kernel.kallsyms] [k] kvm_handle_guest_abort
2.24% dirty_log_perf_ [kernel.kallsyms] [k] up_read
1.98% dirty_log_perf_ [kernel.kallsyms] [k] __kvm_tlb_flush_vmid_ipa_nsh
1.97% dirty_log_perf_ [kernel.kallsyms] [k] __pi_clear_page
1.30% dirty_log_perf_ [kernel.kallsyms] [k] down_read
1.13% dirty_log_perf_ [kernel.kallsyms] [k] release_pages
1.12% dirty_log_perf_ [kernel.kallsyms] [k] __kvm_pgtable_walk
1.08% dirty_log_perf_ [kernel.kallsyms] [k] folio_batch_move_lru
1.06% dirty_log_perf_ [kernel.kallsyms] [k] __srcu_read_lock
1.03% dirty_log_perf_ [kernel.kallsyms] [k] get_page_from_freelist
1.01% dirty_log_perf_ [kernel.kallsyms] [k] __pte_offset_map_lock
0.82% dirty_log_perf_ [kernel.kallsyms] [k] handle_mm_fault
0.74% dirty_log_perf_ [kernel.kallsyms] [k] mas_state_walk
Colton Lewis (5):
arm: perf: Drop unused functions
perf: Hoist perf_instruction_pointer() and perf_misc_flags()
powerpc: perf: Use perf_arch_instruction_pointer()
x86: perf: Refactor misc flag assignments
perf: Correct perf sampling with guest VMs
arch/arm/include/asm/perf_event.h | 7 ---
arch/arm/kernel/perf_callchain.c | 17 -------
arch/arm64/include/asm/perf_event.h | 4 --
arch/arm64/kernel/perf_callchain.c | 28 ------------
arch/powerpc/include/asm/perf_event_server.h | 6 +--
arch/powerpc/perf/callchain.c | 2 +-
arch/powerpc/perf/callchain_32.c | 2 +-
arch/powerpc/perf/callchain_64.c | 2 +-
arch/powerpc/perf/core-book3s.c | 4 +-
arch/s390/include/asm/perf_event.h | 6 +--
arch/s390/kernel/perf_event.c | 4 +-
arch/x86/events/core.c | 48 ++++++++++++--------
arch/x86/include/asm/perf_event.h | 12 +++--
include/linux/perf_event.h | 26 +++++++++--
kernel/events/core.c | 27 ++++++++++-
15 files changed, 96 insertions(+), 99 deletions(-)
base-commit: da3ea35007d0af457a0afc87e84fddaebc4e0b63
--
2.46.0.598.g6f2099f65c-goog
next reply other threads:[~2024-09-11 22:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 22:24 Colton Lewis [this message]
2024-09-11 22:24 ` [PATCH v2 1/5] arm: perf: Drop unused functions Colton Lewis
2024-09-11 22:24 ` [PATCH v2 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags() Colton Lewis
2024-09-11 22:24 ` [PATCH v2 3/5] powerpc: perf: Use perf_arch_instruction_pointer() Colton Lewis
2024-09-11 22:24 ` [PATCH v2 4/5] x86: perf: Refactor misc flag assignments Colton Lewis
2024-09-11 22:24 ` [PATCH v2 5/5] perf: Correct perf sampling with guest VMs Colton Lewis
2024-09-11 22:56 ` Sean Christopherson
2024-09-12 20:31 ` Colton Lewis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240911222433.3415301-1-coltonlewis@google.com \
--to=coltonlewis@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=agordeev@linux.ibm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=namhyung@kernel.org \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=oliver.upton@linux.dev \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=svens@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).