linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: VMX: make read-only const array vmx_uret_msrs_list static
@ 2022-04-14 10:07 Colin Ian King
  2022-04-14 14:39 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2022-04-14 10:07 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, kvm
  Cc: kernel-janitors, linux-kernel

Don't populate the read-only array vmx_uret_msrs_list on the stack
but instead make it static. Also makes the object code a little smaller.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index c654c9d76e09..36429e2bb918 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7871,7 +7871,7 @@ static __init void vmx_setup_user_return_msrs(void)
 	 * but is never loaded into hardware.  MSR_CSTAR is also never loaded
 	 * into hardware and is here purely for emulation purposes.
 	 */
-	const u32 vmx_uret_msrs_list[] = {
+	static const u32 vmx_uret_msrs_list[] = {
 	#ifdef CONFIG_X86_64
 		MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR,
 	#endif
-- 
2.35.1


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

* Re: [PATCH] KVM: VMX: make read-only const array vmx_uret_msrs_list static
  2022-04-14 10:07 [PATCH] KVM: VMX: make read-only const array vmx_uret_msrs_list static Colin Ian King
@ 2022-04-14 14:39 ` Sean Christopherson
  2022-04-14 15:15   ` Colin King (gmail)
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2022-04-14 14:39 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Paolo Bonzini, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H . Peter Anvin, kvm, kernel-janitors,
	linux-kernel

On Thu, Apr 14, 2022, Colin Ian King wrote:
> Don't populate the read-only array vmx_uret_msrs_list on the stack
> but instead make it static. Also makes the object code a little smaller.

Why not put it on the stack?  It's an __init function, i.e. called once in the
lifetime of kvm-intel.ko, isn't all that big, and is certainly not performance
critical.  And making it static begs the question of whether or not the data gets
thrown away after init, i.e. this might consume _more_ memory once KVM has reached
steady state.

> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  arch/x86/kvm/vmx/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index c654c9d76e09..36429e2bb918 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7871,7 +7871,7 @@ static __init void vmx_setup_user_return_msrs(void)
>  	 * but is never loaded into hardware.  MSR_CSTAR is also never loaded
>  	 * into hardware and is here purely for emulation purposes.
>  	 */
> -	const u32 vmx_uret_msrs_list[] = {
> +	static const u32 vmx_uret_msrs_list[] = {
>  	#ifdef CONFIG_X86_64
>  		MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR,
>  	#endif
> -- 
> 2.35.1
> 

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

* Re: [PATCH] KVM: VMX: make read-only const array vmx_uret_msrs_list static
  2022-04-14 14:39 ` Sean Christopherson
@ 2022-04-14 15:15   ` Colin King (gmail)
  0 siblings, 0 replies; 3+ messages in thread
From: Colin King (gmail) @ 2022-04-14 15:15 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Paolo Bonzini, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H . Peter Anvin, kvm, kernel-janitors,
	linux-kernel

On 14/04/2022 15:39, Sean Christopherson wrote:
> On Thu, Apr 14, 2022, Colin Ian King wrote:
>> Don't populate the read-only array vmx_uret_msrs_list on the stack
>> but instead make it static. Also makes the object code a little smaller.
> 
> Why not put it on the stack?  It's an __init function, i.e. called once in the
> lifetime of kvm-intel.ko, isn't all that big, and is certainly not performance
> critical.  And making it static begs the question of whether or not the data gets
> thrown away after init, i.e. this might consume _more_ memory once KVM has reached
> steady state.

Doh, my bad, I forgot to check that it was an __init function. Please 
discard this patch.

Colin

> 
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>>   arch/x86/kvm/vmx/vmx.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>> index c654c9d76e09..36429e2bb918 100644
>> --- a/arch/x86/kvm/vmx/vmx.c
>> +++ b/arch/x86/kvm/vmx/vmx.c
>> @@ -7871,7 +7871,7 @@ static __init void vmx_setup_user_return_msrs(void)
>>   	 * but is never loaded into hardware.  MSR_CSTAR is also never loaded
>>   	 * into hardware and is here purely for emulation purposes.
>>   	 */
>> -	const u32 vmx_uret_msrs_list[] = {
>> +	static const u32 vmx_uret_msrs_list[] = {
>>   	#ifdef CONFIG_X86_64
>>   		MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR,
>>   	#endif
>> -- 
>> 2.35.1
>>


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

end of thread, other threads:[~2022-04-14 15:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 10:07 [PATCH] KVM: VMX: make read-only const array vmx_uret_msrs_list static Colin Ian King
2022-04-14 14:39 ` Sean Christopherson
2022-04-14 15:15   ` Colin King (gmail)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).