From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: "Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Mohamed Mediouni" <mohamed@unpredictable.fr>,
"Alexander Graf" <agraf@csgraf.de>,
qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, kvm@vger.kernel.org,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-arm@nongnu.org,
"Magnus Kulke" <magnuskulke@linux.microsoft.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>
Subject: Re: [PATCH 02/16] cpus: Improve qemu_cpu_kick_self() docstring
Date: Mon, 17 Aug 2026 17:45:51 +0200 [thread overview]
Message-ID: <32b54253-a109-44b2-bbdf-ab6440814522@oss.qualcomm.com> (raw)
In-Reply-To: <13c02cbb-79db-4ebd-9fa1-63ffeb0b43f4@redhat.com>
On 17/8/26 17:28, Paolo Bonzini wrote:
> On 8/13/26 20:16, Philippe Mathieu-Daudé wrote:
>> Be a bit more descriptive than "Unblock cpu" :)
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
>> ---
>> include/system/cpus.h | 10 +++++++++-
>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/system/cpus.h b/include/system/cpus.h
>> index 508444ccf1c..ade13e068eb 100644
>> --- a/include/system/cpus.h
>> +++ b/include/system/cpus.h
>> @@ -30,7 +30,15 @@ void resume_all_vcpus(void);
>> void pause_all_vcpus(void);
>> void cpu_stop_current(void);
>> -/* Unblock cpu */
>> +/**
>> + * qemu_cpu_kick_self - Force vCPU to re-enter to its inner main loop
>> + *
>> + * Signal the current vCPU thread to exit any blocking operations and
>> + * re-enter its inner execution loop to process pending requests,
>> + * possibly returning to its outer execution loop.
>> + *
>> + * Must be called from within the vCPU thread itself.
>> + */
>
> Neither is correct.
"Must be called from within the vCPU thread itself." is because of
the assertion:
system/cpus.c:452:void qemu_cpu_kick_self(void)
system/cpus.c-453-{
system/cpus.c-454- assert(current_cpu);
system/cpus.c-455- cpus_kick_thread(current_cpu);
system/cpus.c-456-}
> What it does is force the vCPU not to enter the
> accelerator, and immediately exit again to process events. This is only
> needed because KVM doesn't want you to process events because KVM allows
> you to do so.
I got confused by this comment in accel/mshv/mshv-all.c and interpreted
too much:
/*
* The signal handler is triggered when QEMU's main thread receives a
SIG_IPI
* (SIGUSR1). This signal causes the current CPU thread to be kicked,
forcing a
* VM exit on the CPU. The VM exit generates an exit reason that breaks
the loop
* (see mshv_cpu_exec). If the exit is due to a Ctrl+A+x command, the
system
* will shut down. For other cases, the system will continue running.
*/
static void sa_ipi_handler(int sig)
{
/* TODO: call IOCTL to set_immediate_exit, once implemented. */
qemu_cpu_kick_self();
}
>
> I'd rather have something like:
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 83cbd120a84..e5d068e341f 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -3292,7 +3292,7 @@ static void kvm_cpu_kick_self(void)
> if (kvm_immediate_exit) {
> kvm_cpu_kick(current_cpu);
> } else {
> - qemu_cpu_kick_self();
> + cpus_kick_thread(current_cpu);
> }
> }
>
> diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
> index 8a1af35ed32..b9b1ee39850 100644
> --- a/target/i386/nvmm/nvmm-all.c
> +++ b/target/i386/nvmm/nvmm-all.c
> @@ -753,7 +753,7 @@ nvmm_vcpu_loop(CPUState *cpu)
> #if NVMM_USER_VERSION >= 2
> nvmm_vcpu_stop(vcpu);
> #else
> - qemu_cpu_kick_self();
> + cpus_kick_thread(current_cpu);
> #endif
> }
>
> and get rid of qemu_cpu_kick_self() completely.
OK I'll take that route.
next prev parent reply other threads:[~2026-08-17 15:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 18:16 [PATCH 00/16] cpus: Improvements around BQL locking, improving docstring Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 01/16] accel: Label outer / inner vCPU execution loops Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 02/16] cpus: Improve qemu_cpu_kick_self() docstring Philippe Mathieu-Daudé
2026-08-17 15:28 ` Paolo Bonzini
2026-08-17 15:45 ` Philippe Mathieu-Daudé [this message]
2026-08-18 10:27 ` Paolo Bonzini
2026-08-13 18:16 ` [PATCH 03/16] cpus: Rename cpu_stop_current() -> qemu_cpu_stop_self() Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 04/16] cpus: Rename qemu_cpu_stop() to qemu_cpu_ack_stop_request() Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 05/16] cpus: Improve cpu_pause() docstring Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 06/16] cpus: Improve cpu_exit() docstring Philippe Mathieu-Daudé
2026-08-17 15:46 ` Paolo Bonzini
2026-08-13 18:16 ` [PATCH 07/16] cpus: Document process_queued_cpu_work*() runs on current vCPU Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 08/16] cpus: Slightly improve *run_on_cpu() docstrings Philippe Mathieu-Daudé
2026-08-17 15:50 ` Paolo Bonzini
2026-08-17 16:00 ` Peter Maydell
2026-08-13 18:16 ` [PATCH 09/16] accel/tcg: Use RUN_ON_CPU_NULL for tcg_commit() callbacks Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 10/16] accel/kvm: Clarify use of @r variable in vcpu thread loop Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 11/16] accel/kvm: Consistently return CPU halt state from process_async_events Philippe Mathieu-Daudé
2026-08-17 15:59 ` Paolo Bonzini
2026-08-18 9:24 ` Philippe Mathieu-Daudé
2026-08-18 10:30 ` Paolo Bonzini
2026-08-18 13:07 ` Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 12/16] target/arm/hvf: Move flush_cpu_state() into the inner vCPU loop Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 13/16] target/arm/hvf: Lock BQL outside of the vCPU inner execution loop Philippe Mathieu-Daudé
2026-08-17 16:11 ` Paolo Bonzini
2026-08-18 8:48 ` Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 14/16] target/i386/hvf: " Philippe Mathieu-Daudé
2026-08-17 16:15 ` Paolo Bonzini
2026-08-13 18:16 ` [PATCH 15/16] target/arm/powerctl: Move BQL assertions to async work context Philippe Mathieu-Daudé
2026-08-13 18:16 ` [PATCH 16/16] target/arm/whpx: Fix argument order typo in memory access error message Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32b54253-a109-44b2-bbdf-ab6440814522@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=agraf@csgraf.de \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=kvm@vger.kernel.org \
--cc=magnuskulke@linux.microsoft.com \
--cc=mohamed@unpredictable.fr \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox