All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
@ 2021-01-18  7:21 Like Xu
  2021-01-18 10:10 ` Peter Zijlstra
  2021-01-18 12:12   ` kernel test robot
  0 siblings, 2 replies; 10+ messages in thread
From: Like Xu @ 2021-01-18  7:21 UTC (permalink / raw)
  To: Peter Zijlstra, Josh Poimboeuf, Jason Baron
  Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
	Thomas Gleixner, Borislav Petkov, x86, linux-kernel

Clean up that CONFIG_RETPOLINE crud and replace the
indirect call x86_pmu.guest_get_msrs with static_call().

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
 arch/x86/events/core.c       | 16 ++++++++++++++++
 arch/x86/events/intel/core.c | 20 --------------------
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index e37de298a495..2eec3c8d0a13 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -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,18 @@ void x86_pmu_disable_all(void)
 	}
 }
 
+struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
+{
+	struct perf_guest_switch_msr *ret = NULL;
+
+	ret = static_call(x86_pmu_guest_get_msrs)(nr);
+	if (!ret)
+		*nr = 0;
+
+	return ret;
+}
+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 +1937,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)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index d4569bfa83e3..93adf53cce5f 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -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);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
  2021-01-18  7:21 [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs Like Xu
@ 2021-01-18 10:10 ` Peter Zijlstra
  2021-01-18 12:12   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2021-01-18 10:10 UTC (permalink / raw)
  To: Like Xu
  Cc: Josh Poimboeuf, Jason Baron, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Thomas Gleixner,
	Borislav Petkov, x86, linux-kernel

On Mon, Jan 18, 2021 at 03:21:51PM +0800, Like Xu wrote:
> Clean up that CONFIG_RETPOLINE crud and replace the
> indirect call x86_pmu.guest_get_msrs with static_call().
> 
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
  2021-01-18  7:21 [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs Like Xu
@ 2021-01-18 12:12   ` kernel test robot
  2021-01-18 12:12   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-01-18 12:12 UTC (permalink / raw)
  To: Like Xu, Peter Zijlstra, Josh Poimboeuf, Jason Baron
  Cc: kbuild-all, clang-built-linux, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Thomas Gleixner,
	Borislav Petkov, x86, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2557 bytes --]

Hi Like,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on v5.11-rc4 next-20210118]
[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/20210118-153219
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3
config: x86_64-randconfig-a002-20210118 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89)
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/0cd2262fad043a5edef91fca07d16759703658b8
        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/20210118-153219
        git checkout 0cd2262fad043a5edef91fca07d16759703658b8
        # 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
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> arch/x86/events/core.c:670:31: error: redefinition of 'perf_guest_get_msrs'
   struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
                                 ^
   arch/x86/include/asm/perf_event.h:486:45: note: previous definition is here
   static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
                                               ^
   1 error 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		struct perf_guest_switch_msr *ret = NULL;
   673	
   674		ret = static_call(x86_pmu_guest_get_msrs)(nr);
   675		if (!ret)
   676			*nr = 0;
   677	
   678		return ret;
   679	}
   680	EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
   681	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32212 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
@ 2021-01-18 12:12   ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-01-18 12:12 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2618 bytes --]

Hi Like,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on v5.11-rc4 next-20210118]
[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/20210118-153219
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3
config: x86_64-randconfig-a002-20210118 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89)
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/0cd2262fad043a5edef91fca07d16759703658b8
        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/20210118-153219
        git checkout 0cd2262fad043a5edef91fca07d16759703658b8
        # 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
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> arch/x86/events/core.c:670:31: error: redefinition of 'perf_guest_get_msrs'
   struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
                                 ^
   arch/x86/include/asm/perf_event.h:486:45: note: previous definition is here
   static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
                                               ^
   1 error 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		struct perf_guest_switch_msr *ret = NULL;
   673	
   674		ret = static_call(x86_pmu_guest_get_msrs)(nr);
   675		if (!ret)
   676			*nr = 0;
   677	
   678		return ret;
   679	}
   680	EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
   681	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32212 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
  2021-01-18 12:12   ` kernel test robot
@ 2021-01-18 13:05     ` Like Xu
  -1 siblings, 0 replies; 10+ messages in thread
From: Like Xu @ 2021-01-18 13:05 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: kbuild-all, clang-built-linux, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Thomas Gleixner,
	Borislav Petkov, x86, linux-kernel, Jason Baron, Josh Poimboeuf,
	kernel test robot

I guess this fix will silence the compiler error,
and v2 will be sent after the local 0day test passes.

diff --git a/arch/x86/include/asm/perf_event.h 
b/arch/x86/include/asm/perf_event.h
index b9a7fd0a27e2..517f546b6b45 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -479,15 +479,11 @@ 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)
  extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
+
+#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL)
  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;

On 2021/1/18 20:12, kernel test robot wrote:
> Hi Like,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on tip/perf/core]
> [also build test ERROR on v5.11-rc4 next-20210118]
> [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/20210118-153219
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3
> config: x86_64-randconfig-a002-20210118 (attached as .config)
> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89)
> 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/0cd2262fad043a5edef91fca07d16759703658b8
>          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/20210118-153219
>          git checkout 0cd2262fad043a5edef91fca07d16759703658b8
>          # 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
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>>> arch/x86/events/core.c:670:31: error: redefinition of 'perf_guest_get_msrs'
>     struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
>                                   ^
>     arch/x86/include/asm/perf_event.h:486:45: note: previous definition is here
>     static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
>                                                 ^
>     1 error 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		struct perf_guest_switch_msr *ret = NULL;
>     673	
>     674		ret = static_call(x86_pmu_guest_get_msrs)(nr);
>     675		if (!ret)
>     676			*nr = 0;
>     677	
>     678		return ret;
>     679	}
>     680	EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
>     681	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
@ 2021-01-18 13:05     ` Like Xu
  0 siblings, 0 replies; 10+ messages in thread
From: Like Xu @ 2021-01-18 13:05 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3759 bytes --]

I guess this fix will silence the compiler error,
and v2 will be sent after the local 0day test passes.

diff --git a/arch/x86/include/asm/perf_event.h 
b/arch/x86/include/asm/perf_event.h
index b9a7fd0a27e2..517f546b6b45 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -479,15 +479,11 @@ 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)
  extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
+
+#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL)
  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;

On 2021/1/18 20:12, kernel test robot wrote:
> Hi Like,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on tip/perf/core]
> [also build test ERROR on v5.11-rc4 next-20210118]
> [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/20210118-153219
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 9a7832ce3d920426a36cdd78eda4b3568d4d09e3
> config: x86_64-randconfig-a002-20210118 (attached as .config)
> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89)
> 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/0cd2262fad043a5edef91fca07d16759703658b8
>          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/20210118-153219
>          git checkout 0cd2262fad043a5edef91fca07d16759703658b8
>          # 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
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>>> arch/x86/events/core.c:670:31: error: redefinition of 'perf_guest_get_msrs'
>     struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
>                                   ^
>     arch/x86/include/asm/perf_event.h:486:45: note: previous definition is here
>     static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
>                                                 ^
>     1 error 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		struct perf_guest_switch_msr *ret = NULL;
>     673	
>     674		ret = static_call(x86_pmu_guest_get_msrs)(nr);
>     675		if (!ret)
>     676			*nr = 0;
>     677	
>     678		return ret;
>     679	}
>     680	EXPORT_SYMBOL_GPL(perf_guest_get_msrs);
>     681	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
> 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
  2021-01-18 13:05     ` Like Xu
@ 2021-01-18 13:35       ` Peter Zijlstra
  -1 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2021-01-18 13:35 UTC (permalink / raw)
  To: Like Xu
  Cc: kbuild-all, clang-built-linux, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Thomas Gleixner,
	Borislav Petkov, x86, linux-kernel, Jason Baron, Josh Poimboeuf,
	kernel test robot

On Mon, Jan 18, 2021 at 09:05:06PM +0800, Like Xu wrote:
> I guess this fix will silence the compiler error,
> and v2 will be sent after the local 0day test passes.

I think there's also a problem where you don't assign a function at all.

I think you want something like

	if (!x86_pmu.guest_get_msr)
		x86_pmu.guest_get_msr = guest_get_msr_nop;

right before x86_pmu_static_call_update();

And then have it be something like:

static void *guest_et_msr_nop(int *nr)
{
	*nr = 0;
	return NULL;
}

and then you can reduce the entire thing to:

struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
{
	return static_call(x86_pmu_guest_get_msrs)(nr);
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
@ 2021-01-18 13:35       ` Peter Zijlstra
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2021-01-18 13:35 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

On Mon, Jan 18, 2021 at 09:05:06PM +0800, Like Xu wrote:
> I guess this fix will silence the compiler error,
> and v2 will be sent after the local 0day test passes.

I think there's also a problem where you don't assign a function at all.

I think you want something like

	if (!x86_pmu.guest_get_msr)
		x86_pmu.guest_get_msr = guest_get_msr_nop;

right before x86_pmu_static_call_update();

And then have it be something like:

static void *guest_et_msr_nop(int *nr)
{
	*nr = 0;
	return NULL;
}

and then you can reduce the entire thing to:

struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
{
	return static_call(x86_pmu_guest_get_msrs)(nr);
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
  2021-01-18 13:35       ` Peter Zijlstra
@ 2021-01-22  3:19         ` Like Xu
  -1 siblings, 0 replies; 10+ messages in thread
From: Like Xu @ 2021-01-22  3:19 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: kbuild-all, clang-built-linux, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Thomas Gleixner,
	Borislav Petkov, x86, linux-kernel, Jason Baron, Josh Poimboeuf,
	kernel test robot

On 2021/1/18 21:35, Peter Zijlstra wrote:
> On Mon, Jan 18, 2021 at 09:05:06PM +0800, Like Xu wrote:
>> I guess this fix will silence the compiler error,
>> and v2 will be sent after the local 0day test passes.
> 
> I think there's also a problem where you don't assign a function at all.

Thank you!

> 
> I think you want something like
> 
> 	if (!x86_pmu.guest_get_msr)
> 		x86_pmu.guest_get_msr = guest_get_msr_nop;
> 
> right before x86_pmu_static_call_update();
> 
> And then have it be something like:
> 
> static void *guest_et_msr_nop(int *nr)

The [-Werror=incompatible-pointer-types] will yell at "void *".

Please review the v2 version.

https://lore.kernel.org/lkml/20210122030324.2754492-1-like.xu@linux.intel.com/T/#u

> {
> 	*nr = 0;
> 	return NULL;
> }
> 
> and then you can reduce the entire thing to:
> 
> struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
> {
> 	return static_call(x86_pmu_guest_get_msrs)(nr);
> }
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs
@ 2021-01-22  3:19         ` Like Xu
  0 siblings, 0 replies; 10+ messages in thread
From: Like Xu @ 2021-01-22  3:19 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

On 2021/1/18 21:35, Peter Zijlstra wrote:
> On Mon, Jan 18, 2021 at 09:05:06PM +0800, Like Xu wrote:
>> I guess this fix will silence the compiler error,
>> and v2 will be sent after the local 0day test passes.
> 
> I think there's also a problem where you don't assign a function at all.

Thank you!

> 
> I think you want something like
> 
> 	if (!x86_pmu.guest_get_msr)
> 		x86_pmu.guest_get_msr = guest_get_msr_nop;
> 
> right before x86_pmu_static_call_update();
> 
> And then have it be something like:
> 
> static void *guest_et_msr_nop(int *nr)

The [-Werror=incompatible-pointer-types] will yell at "void *".

Please review the v2 version.

https://lore.kernel.org/lkml/20210122030324.2754492-1-like.xu(a)linux.intel.com/T/#u

> {
> 	*nr = 0;
> 	return NULL;
> }
> 
> and then you can reduce the entire thing to:
> 
> struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
> {
> 	return static_call(x86_pmu_guest_get_msrs)(nr);
> }
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-22  3:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18  7:21 [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs Like Xu
2021-01-18 10:10 ` Peter Zijlstra
2021-01-18 12:12 ` kernel test robot
2021-01-18 12:12   ` kernel test robot
2021-01-18 13:05   ` Like Xu
2021-01-18 13:05     ` Like Xu
2021-01-18 13:35     ` Peter Zijlstra
2021-01-18 13:35       ` Peter Zijlstra
2021-01-22  3:19       ` Like Xu
2021-01-22  3:19         ` Like Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.