perf/core: Use static_call to optimize perf_guest_info_callbacks
authorSean Christopherson <seanjc@google.com>
Thu, 11 Nov 2021 02:07:30 +0000 (02:07 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 17 Nov 2021 13:49:09 +0000 (14:49 +0100)
commit87b940a0675e25261f022ac3e53e0dfff9cdb995
treedd444ca4e1ac34f6e0bf0b46317c9f24f666b279
parent2aef6f306b39bbe74e2287d6e2ee07c4867d87d0
perf/core: Use static_call to optimize perf_guest_info_callbacks

Use static_call to optimize perf's guest callbacks on arm64 and x86,
which are now the only architectures that define the callbacks.  Use
DEFINE_STATIC_CALL_RET0 as the default/NULL for all guest callbacks, as
the callback semantics are that a return value '0' means "not in guest".

static_call obviously avoids the overhead of CONFIG_RETPOLINE=y, but is
also advantageous versus other solutions, e.g. per-cpu callbacks, in that
a per-cpu memory load is not needed to detect the !guest case.

Based on code from Peter and Like.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
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-10-seanjc@google.com
include/linux/perf_event.h
kernel/events/core.c