aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/x86/events/core.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2021-11-11 02:07:28 +0000
committerPeter Zijlstra <peterz@infradead.org>2021-11-17 14:49:08 +0100
commit1c3430516b0732d923de9fd3bfb3e2e537eeb235 (patch)
tree5c0f082876f3d6915b25af636d43bd2df7e00f4c /arch/x86/events/core.c
parentperf/core: Rework guest callbacks to prepare for static_call support (diff)
downloadwireguard-linux-1c3430516b0732d923de9fd3bfb3e2e537eeb235.tar.xz
wireguard-linux-1c3430516b0732d923de9fd3bfb3e2e537eeb235.zip
perf: Add wrappers for invoking guest callbacks
Add helpers for the guest callbacks to prepare for burying the callbacks behind a Kconfig (it's a lot easier to provide a few stubs than to #ifdef piles of code), and also to prepare for converting the callbacks to static_call(). perf_instruction_pointer() in particular will have subtle semantics with static_call(), as the "no callbacks" case will return 0 if the callbacks are unregistered between querying guest state and getting the IP. Implement the change now to avoid a functional change when adding static_call() support, and because the new helper needs to return _something_ in this case. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20211111020738.2512932-8-seanjc@google.com
Diffstat (limited to 'arch/x86/events/core.c')
-rw-r--r--arch/x86/events/core.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index e29312a1003a..620347398027 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2768,11 +2768,10 @@ static bool perf_hw_regs(struct pt_regs *regs)
void
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
- struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
struct unwind_state state;
unsigned long addr;
- if (guest_cbs && guest_cbs->state()) {
+ if (perf_guest_state()) {
/* TODO: We don't support guest os callchain now */
return;
}
@@ -2872,11 +2871,10 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
void
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
{
- struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
struct stack_frame frame;
const struct stack_frame __user *fp;
- if (guest_cbs && guest_cbs->state()) {
+ if (perf_guest_state()) {
/* TODO: We don't support guest os callchain now */
return;
}
@@ -2953,18 +2951,15 @@ static unsigned long code_segment_base(struct pt_regs *regs)
unsigned long perf_instruction_pointer(struct pt_regs *regs)
{
- struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
-
- if (guest_cbs && guest_cbs->state())
- return guest_cbs->get_ip();
+ if (perf_guest_state())
+ return perf_guest_get_ip();
return regs->ip + code_segment_base(regs);
}
unsigned long perf_misc_flags(struct pt_regs *regs)
{
- struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
- unsigned int guest_state = guest_cbs ? guest_cbs->state() : 0;
+ unsigned int guest_state = perf_guest_state();
int misc = 0;
if (guest_state) {