[PATCH 19/19] tcg/user: do not set exit_request gratuitously

Paolo Bonzini posted 19 patches 5 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Riku Voipio <riku.voipio@iki.fi>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Laurent Vivier <laurent@vivier.eu>, Brian Cain <brian.cain@oss.qualcomm.com>, "Alex Bennée" <alex.bennee@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Michael Rolnik <mrolnik@gmail.com>, Marcelo Tosatti <mtosatti@redhat.com>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>, Stafford Horne <shorne@gmail.com>, Yoshinori Sato <yoshinori.sato@nifty.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH 19/19] tcg/user: do not set exit_request gratuitously
Posted by Paolo Bonzini 5 months ago
Whenever user-mode emulation needs to go all the way out of the cpu
exec loop, it uses cpu_exit(), which already sets cpu->exit_request.

Therefore, there is no need for tcg_kick_vcpu_thread() to set
cpu->exit_request again outside system emulation.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/tcg/cpu-exec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index ad94f96b252..7c20d9db122 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -751,6 +751,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
 
 void tcg_kick_vcpu_thread(CPUState *cpu)
 {
+#ifndef CONFIG_USER_ONLY
     /*
      * Ensure cpu_exec will see the reason why the exit request was set.
      * FIXME: this is not always needed.  Other accelerators instead
@@ -758,6 +759,7 @@ void tcg_kick_vcpu_thread(CPUState *cpu)
      * CPU thread; see kvm_arch_pre_run() for example.
      */
     qatomic_store_release(&cpu->exit_request, true);
+#endif
 
     /* Ensure cpu_exec will see the exit request after TCG has exited.  */
     qatomic_store_release(&cpu->neg.icount_decr.u16.high, -1);
-- 
2.51.0
Re: [PATCH 19/19] tcg/user: do not set exit_request gratuitously
Posted by Andreas Schwab 1 week, 4 days ago
On Sep 08 2025, Paolo Bonzini wrote:

> Whenever user-mode emulation needs to go all the way out of the cpu
> exec loop, it uses cpu_exit(), which already sets cpu->exit_request.
>
> Therefore, there is no need for tcg_kick_vcpu_thread() to set
> cpu->exit_request again outside system emulation.

This breaks go.  If you run go build in a loop, it eventually hangs
uninterruptible (except -9) with a couple of zombie children left over.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Re: [PATCH 19/19] tcg/user: do not set exit_request gratuitously
Posted by Paolo Bonzini 1 week, 4 days ago
I assume you have already tried to revert it?

Thanks,

Paolo

Il gio 29 gen 2026, 10:11 Andreas Schwab <schwab@suse.de> ha scritto:

> On Sep 08 2025, Paolo Bonzini wrote:
>
> > Whenever user-mode emulation needs to go all the way out of the cpu
> > exec loop, it uses cpu_exit(), which already sets cpu->exit_request.
> >
> > Therefore, there is no need for tcg_kick_vcpu_thread() to set
> > cpu->exit_request again outside system emulation.
>
> This breaks go.  If you run go build in a loop, it eventually hangs
> uninterruptible (except -9) with a couple of zombie children left over.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
>
Re: [PATCH 19/19] tcg/user: do not set exit_request gratuitously
Posted by Andreas Schwab 1 week ago
On Jan 29 2026, Paolo Bonzini wrote:

> I assume you have already tried to revert it?

Sure, that's how I verified it.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Re: [PATCH 19/19] tcg/user: do not set exit_request gratuitously
Posted by Paolo Bonzini 1 week ago
On 2/2/26 10:06, Andreas Schwab wrote:
> On Jan 29 2026, Paolo Bonzini wrote:
> 
>> I assume you have already tried to revert it?
> 
> Sure, that's how I verified it.

Yeah, sorry for the badly worded question---I meant reverting it from 
master as opposed to just reporting the bisection result.  I'll send a 
revert.

Paolo