linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] x86/hyperv: Remove unregister syscore call from Hyper-V cleanup
@ 2022-11-26  6:14 Gaurav Kohli
  2022-11-28 19:23 ` Michael Kelley (LINUX)
  0 siblings, 1 reply; 3+ messages in thread
From: Gaurav Kohli @ 2022-11-26  6:14 UTC (permalink / raw)
  To: kys, decui, haiyangz, tglx, mingo, dave.hansen, x86,
	linux-hyperv, wei.liu, bp, mikelley
  Cc: gauravkohli

Hyper-V cleanup code comes under panic path where preemption and irq
is already disabled. So calling of unregister_syscore_ops might schedule
out the thread even for the case where mutex lock is free.
hyperv_cleanup
	unregister_syscore_ops
			mutex_lock(&syscore_ops_lock)
				might_sleep
Here might_sleep might schedule out this thread, where voluntary preemption
config is on and this thread will never comes back. And also this was added
earlier to maintain the symmetry which is not required as this can comes
during crash shutdown path only.

To prevent the same, removing unregister_syscore_ops function call.

Signed-off-by: Gaurav Kohli <gauravkohli@linux.microsoft.com>
---
v2: Update commit message
---
 arch/x86/hyperv/hv_init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index f49bc3ec76e6..5ec7badab600 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -537,8 +537,6 @@ void hyperv_cleanup(void)
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 	union hv_reference_tsc_msr tsc_msr;
 
-	unregister_syscore_ops(&hv_syscore_ops);
-
 	/* Reset our OS id */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
 	hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, 0);
-- 
2.17.1


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

* RE: [PATCH v2] x86/hyperv: Remove unregister syscore call from Hyper-V cleanup
  2022-11-26  6:14 [PATCH v2] x86/hyperv: Remove unregister syscore call from Hyper-V cleanup Gaurav Kohli
@ 2022-11-28 19:23 ` Michael Kelley (LINUX)
  2022-11-29 17:57   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kelley (LINUX) @ 2022-11-28 19:23 UTC (permalink / raw)
  To: Gaurav Kohli, KY Srinivasan, Dexuan Cui, Haiyang Zhang, tglx,
	mingo, dave.hansen, x86, linux-hyperv, wei.liu, bp

From: Gaurav Kohli <gauravkohli@linux.microsoft.com> Sent: Friday, November 25, 2022 10:15 PM
> 
> Hyper-V cleanup code comes under panic path where preemption and irq
> is already disabled. So calling of unregister_syscore_ops might schedule
> out the thread even for the case where mutex lock is free.
> hyperv_cleanup
> 	unregister_syscore_ops
> 			mutex_lock(&syscore_ops_lock)
> 				might_sleep
> Here might_sleep might schedule out this thread, where voluntary preemption
> config is on and this thread will never comes back. And also this was added
> earlier to maintain the symmetry which is not required as this can comes
> during crash shutdown path only.
> 
> To prevent the same, removing unregister_syscore_ops function call.
> 
> Signed-off-by: Gaurav Kohli <gauravkohli@linux.microsoft.com>
> ---
> v2: Update commit message
> ---
>  arch/x86/hyperv/hv_init.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index f49bc3ec76e6..5ec7badab600 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -537,8 +537,6 @@ void hyperv_cleanup(void)
>  	union hv_x64_msr_hypercall_contents hypercall_msr;
>  	union hv_reference_tsc_msr tsc_msr;
> 
> -	unregister_syscore_ops(&hv_syscore_ops);
> -
>  	/* Reset our OS id */
>  	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
>  	hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, 0);
> --
> 2.17.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>


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

* Re: [PATCH v2] x86/hyperv: Remove unregister syscore call from Hyper-V cleanup
  2022-11-28 19:23 ` Michael Kelley (LINUX)
@ 2022-11-29 17:57   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2022-11-29 17:57 UTC (permalink / raw)
  To: Michael Kelley (LINUX)
  Cc: Gaurav Kohli, KY Srinivasan, Dexuan Cui, Haiyang Zhang, tglx,
	mingo, dave.hansen, x86, linux-hyperv, wei.liu, bp

On Mon, Nov 28, 2022 at 07:23:32PM +0000, Michael Kelley (LINUX) wrote:
> From: Gaurav Kohli <gauravkohli@linux.microsoft.com> Sent: Friday, November 25, 2022 10:15 PM
> > 
> > Hyper-V cleanup code comes under panic path where preemption and irq
> > is already disabled. So calling of unregister_syscore_ops might schedule
> > out the thread even for the case where mutex lock is free.
> > hyperv_cleanup
> > 	unregister_syscore_ops
> > 			mutex_lock(&syscore_ops_lock)
> > 				might_sleep
> > Here might_sleep might schedule out this thread, where voluntary preemption
> > config is on and this thread will never comes back. And also this was added
> > earlier to maintain the symmetry which is not required as this can comes
> > during crash shutdown path only.
> > 
> > To prevent the same, removing unregister_syscore_ops function call.
> > 
> > Signed-off-by: Gaurav Kohli <gauravkohli@linux.microsoft.com>
> > ---
[...]
> 
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> 

Applied to hyperv-next. Thanks.

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

end of thread, other threads:[~2022-11-29 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-26  6:14 [PATCH v2] x86/hyperv: Remove unregister syscore call from Hyper-V cleanup Gaurav Kohli
2022-11-28 19:23 ` Michael Kelley (LINUX)
2022-11-29 17:57   ` Wei Liu

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).