x86/perf: Use static_call for x86_pmu.guest_get_msrs
Subsystems (2)
PATCH v2 1/1 x86/perf: Use static_call for x86_pmu.guest_get_msrs
Clean up that CONFIG_RETPOLINE crud and replace the indirect call x86_pmu.guest_get_msrs with static_call().
--- arch/x86/events/core.c | 20 ++++++++++++++++++++ arch/x86/events/intel/core.c | 20 -------------------- arch/x86/include/asm/perf_event.h | 5 ----- 3 files changed, 20 insertions(+), 25 deletions(-)
arch/x86/events/core.c +20 -0
@@ -81,6 +81,8 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_swap_task_ctx, *x86_pmu.swap_task_ctx);DEFINE_STATIC_CALL_NULL (x86_pmu_drain_pebs, *x86_pmu.drain_pebs);DEFINE_STATIC_CALL_NULL (x86_pmu_pebs_aliases, *x86_pmu.pebs_aliases); +DEFINE_STATIC_CALL_NULL (x86_pmu_guest_get_msrs, *x86_pmu.guest_get_msrs); +u64 __read_mostly hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX ] [PERF_COUNT_HW_CACHE_OP_MAX ]
@@ -665,6 +667,12 @@ void x86_pmu_disable_all(void) } } +struct perf_guest_switch_msr *perf_guest_get_msrs (int *nr) +{ +return static_call (x86_pmu_guest_get_msrs)(nr); +} +EXPORT_SYMBOL_GPL (perf_guest_get_msrs); +/* * There may be PMI landing after enabled=0. The PMI hitting could be before or * after disable_all.
@@ -1923,6 +1931,8 @@ static void x86_pmu_static_call_update(void)static_call_update (x86_pmu_drain_pebs, x86_pmu.drain_pebs);static_call_update (x86_pmu_pebs_aliases, x86_pmu.pebs_aliases); + +static_call_update (x86_pmu_guest_get_msrs, x86_pmu.guest_get_msrs); }static void _x86_pmu_read (struct perf_event *event)
@@ -1930,6 +1940,13 @@ static void _x86_pmu_read(struct perf_event *event)x86_perf_event_update (event); } +static inline struct perf_guest_switch_msr * +perf_guest_get_msrs_nop (int *nr) +{ + *nr =0 ; +return NULL ; +} +static int __init init_hw_perf_events (void ) {struct x86_pmu_quirk *quirk;
@@ -2001,6 +2018,9 @@ static int __init init_hw_perf_events(void)if (!x86_pmu.read) x86_pmu.read = _x86_pmu_read; +if (!x86_pmu.guest_get_msrs) + x86_pmu.guest_get_msrs = perf_guest_get_msrs_nop; +x86_pmu_static_call_update ();/*
arch/x86/events/intel/core.c +0 -20
@@ -3680,26 +3680,6 @@ static int intel_pmu_hw_config(struct perf_event *event)return 0 ; } -#ifdef CONFIG_RETPOLINE -static struct perf_guest_switch_msr *core_guest_get_msrs (int *nr); -static struct perf_guest_switch_msr *intel_guest_get_msrs (int *nr); -#endif - -struct perf_guest_switch_msr *perf_guest_get_msrs (int *nr) -{ -#ifdef CONFIG_RETPOLINE -if (x86_pmu.guest_get_msrs == intel_guest_get_msrs) -return intel_guest_get_msrs (nr); -else if (x86_pmu.guest_get_msrs == core_guest_get_msrs) -return core_guest_get_msrs (nr); -#endif -if (x86_pmu.guest_get_msrs) -return x86_pmu.guest_get_msrs (nr); - *nr =0 ; -return NULL ; -} -EXPORT_SYMBOL_GPL (perf_guest_get_msrs); -static struct perf_guest_switch_msr *intel_guest_get_msrs (int *nr) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);
arch/x86/include/asm/perf_event.h +0 -5
@@ -483,11 +483,6 @@ static inline void perf_check_microcode(void) { }extern struct perf_guest_switch_msr *perf_guest_get_msrs (int *nr);extern int x86_perf_get_lbr (struct x86_pmu_lbr *lbr);#else -static inline struct perf_guest_switch_msr *perf_guest_get_msrs (int *nr) -{ - *nr =0 ; -return NULL ; -}static inline int x86_perf_get_lbr (struct x86_pmu_lbr *lbr) {return -1 ;
Signature · 1 line
2.29.2
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Like,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tip/perf/core]
[also build test WARNING on tip/master v5.11-rc4 next-20210121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Like-Xu/x86-perf-Use-static_call-for-x86_pmu-guest_get_msrs/20210122-112838 base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3 config: i386-randconfig-r033-20210122 (attached as .config) compiler: gcc-9 (Debian 9.3.0-20) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/8e16a2c508abb30462013fd0782d6dd1bf8aa7e2 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Like-Xu/x86-perf-Use-static_call-for-x86_pmu-guest_get_msrs/20210122-112838 git checkout 8e16a2c508abb30462013fd0782d6dd1bf8aa7e2 # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> arch/x86/events/core.c:670:31: warning: no previous prototype for 'perf_guest_get_msrs' [-Wmissing-prototypes]
670 | struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
| ^~~~~~~~~~~~~~~~~~~
vim +/perf_guest_get_msrs +670 arch/x86/events/core.c
669
> 670 struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
671 {
672 return static_call(x86_pmu_guest_get_msrs)(nr);
673 }
674 EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
675
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Like,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tip/perf/core]
[also build test WARNING on tip/master v5.11-rc4 next-20210121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Like-Xu/x86-perf-Use-static_call-for-x86_pmu-guest_get_msrs/20210122-112838 base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3 config: x86_64-randconfig-a004-20210122 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project bd3a387ee76f58caa0d7901f3f84e9bb3d006f27)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/8e16a2c508abb30462013fd0782d6dd1bf8aa7e2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Like-Xu/x86-perf-Use-static_call-for-x86_pmu-guest_get_msrs/20210122-112838 git checkout 8e16a2c508abb30462013fd0782d6dd1bf8aa7e2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> arch/x86/events/core.c:670:31: warning: no previous prototype for function 'perf_guest_get_msrs' [-Wmissing-prototypes]
struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
^ arch/x86/events/core.c:670:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
^
static
1 warning generated.
vim +/perf_guest_get_msrs +670 arch/x86/events/core.c
669
> 670 struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
671 {
672 return static_call(x86_pmu_guest_get_msrs)(nr);
673 }
674 EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
675
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Peter Zijlstra
maintainerQuoted 3 lines · Like Xu
Clean up that
CONFIG_RETPOLINEcrud and replace the indirect call x86_pmu.guest_get_msrs withstatic_call().
Looks good in principle, but the robot complains about a missing func decl. I think you removed a little too much when you killed the inline thing.