Remove CONFIG_PERF_EVENT=n stubs for functions that are effectively
KVM-only. KVM selects PERF_EVENT and will never consume the stubs.
Dropping the unnecessary stubs will allow simplifying x86_perf_get_lbr()
by getting rid of the impossible-to-hit error path (which KVM doesn't
even check).
Opportunstically reorganize the declarations to collapse multiple
CONFIG_PERF_EVENTS #ifdefs.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/include/asm/perf_event.h | 53 ++++++++-----------------------
1 file changed, 13 insertions(+), 40 deletions(-)
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index f6fc8dd51ef4..f839eb55f298 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -525,46 +525,18 @@ extern u64 perf_get_hw_event_config(int hw_event);
extern void perf_check_microcode(void);
extern void perf_clear_dirty_counters(void);
extern int x86_perf_rdpmc_index(struct perf_event *event);
-#else
-static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
-{
- memset(cap, 0, sizeof(*cap));
-}
-static inline u64 perf_get_hw_event_config(int hw_event)
-{
- return 0;
-}
-
-static inline void perf_events_lapic_init(void) { }
-static inline void perf_check_microcode(void) { }
-#endif
-
-#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL)
+#ifdef CONFIG_CPU_SUP_INTEL
extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data);
extern int x86_perf_get_lbr(struct x86_pmu_lbr *lbr);
-#else
-struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data);
-static inline int x86_perf_get_lbr(struct x86_pmu_lbr *lbr)
-{
- return -1;
-}
-#endif
+extern void intel_pt_handle_vmx(int on);
+#endif /* CONFIG_CPU_SUP_INTEL */
-#ifdef CONFIG_CPU_SUP_INTEL
- extern void intel_pt_handle_vmx(int on);
-#else
-static inline void intel_pt_handle_vmx(int on)
-{
+#ifdef CONFIG_CPU_SUP_AMD
+extern void amd_pmu_enable_virt(void);
+extern void amd_pmu_disable_virt(void);
-}
-#endif
-
-#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD)
- extern void amd_pmu_enable_virt(void);
- extern void amd_pmu_disable_virt(void);
-
-#if defined(CONFIG_PERF_EVENTS_AMD_BRS)
+#ifdef CONFIG_PERF_EVENTS_AMD_BRS
#define PERF_NEEDS_LOPWR_CB 1
@@ -582,12 +554,13 @@ static inline void perf_lopwr_cb(bool lopwr_in)
static_call_mod(perf_lopwr_cb)(lopwr_in);
}
-#endif /* PERF_NEEDS_LOPWR_CB */
+#endif /* CONFIG_PERF_EVENTS_AMD_BRS */
+#endif /* CONFIG_CPU_SUP_AMD */
-#else
- static inline void amd_pmu_enable_virt(void) { }
- static inline void amd_pmu_disable_virt(void) { }
-#endif
+#else /* !CONFIG_PERF_EVENTS */
+static inline void perf_events_lapic_init(void) { }
+static inline void perf_check_microcode(void) { }
+#endif /* CONFIG_PERF_EVENTS */
#define arch_perf_out_copy_user copy_from_user_nmi
--
2.37.2.789.g6183377224-goog
Hi Sean,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 372d07084593dc7a399bf9bee815711b1fb1bcf2]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
base: 372d07084593dc7a399bf9bee815711b1fb1bcf2
config: x86_64-randconfig-a001 (https://download.01.org/0day-ci/archive/20220902/202209021001.ubosxpCd-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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
# https://github.com/intel-lab-lkp/linux/commit/b1f1d2f5eb44253f5d059757c03e7fd413b2e306
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
git checkout b1f1d2f5eb44253f5d059757c03e7fd413b2e306
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/events/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> arch/x86/events/core.c:696:31: warning: no previous prototype for function 'perf_guest_get_msrs' [-Wmissing-prototypes]
struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
^
arch/x86/events/core.c:696: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, void *data)
^
static
1 warning generated.
vim +/perf_guest_get_msrs +696 arch/x86/events/core.c
f87ad35d37fa54 arch/x86/kernel/cpu/perf_counter.c Jaswinder Singh Rajput 2009-02-27 695
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 @696 struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 697 {
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 698 return static_call(x86_pmu_guest_get_msrs)(nr, data);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 699 }
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 700 EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 701
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Hi Sean,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 372d07084593dc7a399bf9bee815711b1fb1bcf2]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
base: 372d07084593dc7a399bf9bee815711b1fb1bcf2
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20220902/202209021033.bPC3ttgM-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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
# https://github.com/intel-lab-lkp/linux/commit/b1f1d2f5eb44253f5d059757c03e7fd413b2e306
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
git checkout b1f1d2f5eb44253f5d059757c03e7fd413b2e306
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/events/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> arch/x86/events/core.c:696:31: warning: no previous prototype for function 'perf_guest_get_msrs' [-Wmissing-prototypes]
struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
^
arch/x86/events/core.c:696: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, void *data)
^
static
1 warning generated.
vim +/perf_guest_get_msrs +696 arch/x86/events/core.c
f87ad35d37fa54 arch/x86/kernel/cpu/perf_counter.c Jaswinder Singh Rajput 2009-02-27 695
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 @696 struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 697 {
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 698 return static_call(x86_pmu_guest_get_msrs)(nr, data);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 699 }
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 700 EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 701
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Hi Sean,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 372d07084593dc7a399bf9bee815711b1fb1bcf2]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
base: 372d07084593dc7a399bf9bee815711b1fb1bcf2
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220902/202209021042.UcDPO3lL-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/b1f1d2f5eb44253f5d059757c03e7fd413b2e306
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sean-Christopherson/KVM-x86-Intel-LBR-related-perf-cleanups/20220902-013352
git checkout b1f1d2f5eb44253f5d059757c03e7fd413b2e306
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/events/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> arch/x86/events/core.c:696:31: warning: no previous prototype for 'perf_guest_get_msrs' [-Wmissing-prototypes]
696 | struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
| ^~~~~~~~~~~~~~~~~~~
vim +/perf_guest_get_msrs +696 arch/x86/events/core.c
f87ad35d37fa54 arch/x86/kernel/cpu/perf_counter.c Jaswinder Singh Rajput 2009-02-27 695
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 @696 struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data)
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 697 {
39a4d779546a99 arch/x86/events/core.c Like Xu 2022-04-11 698 return static_call(x86_pmu_guest_get_msrs)(nr, data);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 699 }
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 700 EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
abd562df94d19d arch/x86/events/core.c Like Xu 2021-01-25 701
--
0-DAY CI Kernel Test Service
https://01.org/lkp
© 2016 - 2026 Red Hat, Inc.