[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/13] system/cpus: Add cpu_pause() function
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 06/13] system/cpus: Add cpu_pause() function |
Date: |
Tue, 16 Jul 2024 20:09:33 +0200 |
From: Nicholas Piggin <npiggin@gmail.com>
This factors the CPU pause function from pause_all_vcpus() into a
new cpu_pause() function, similarly to cpu_resume(). cpu_resume()
is moved to keep it next to cpu_pause().
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-ID: <20240712120247.477133-17-npiggin@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/cpu.h | 8 ++++++++
system/cpus.c | 30 +++++++++++++++++-------------
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index a2c8536943..e6acfcb59a 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -984,6 +984,14 @@ void cpu_reset_interrupt(CPUState *cpu, int mask);
*/
void cpu_exit(CPUState *cpu);
+/**
+ * cpu_pause:
+ * @cpu: The CPU to pause.
+ *
+ * Pauses CPU, i.e. puts CPU into stopped state.
+ */
+void cpu_pause(CPUState *cpu);
+
/**
* cpu_resume:
* @cpu: The CPU to resume.
diff --git a/system/cpus.c b/system/cpus.c
index d3640c9503..5e3a988a0a 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -568,6 +568,22 @@ void cpu_thread_signal_destroyed(CPUState *cpu)
qemu_cond_signal(&qemu_cpu_cond);
}
+void cpu_pause(CPUState *cpu)
+{
+ if (qemu_cpu_is_self(cpu)) {
+ qemu_cpu_stop(cpu, true);
+ } else {
+ cpu->stop = true;
+ qemu_cpu_kick(cpu);
+ }
+}
+
+void cpu_resume(CPUState *cpu)
+{
+ cpu->stop = false;
+ cpu->stopped = false;
+ qemu_cpu_kick(cpu);
+}
static bool all_vcpus_paused(void)
{
@@ -588,12 +604,7 @@ void pause_all_vcpus(void)
qemu_clock_enable(QEMU_CLOCK_VIRTUAL, false);
CPU_FOREACH(cpu) {
- if (qemu_cpu_is_self(cpu)) {
- qemu_cpu_stop(cpu, true);
- } else {
- cpu->stop = true;
- qemu_cpu_kick(cpu);
- }
+ cpu_pause(cpu);
}
/* We need to drop the replay_lock so any vCPU threads woken up
@@ -613,13 +624,6 @@ void pause_all_vcpus(void)
bql_lock();
}
-void cpu_resume(CPUState *cpu)
-{
- cpu->stop = false;
- cpu->stopped = false;
- qemu_cpu_kick(cpu);
-}
-
void resume_all_vcpus(void)
{
CPUState *cpu;
--
2.41.0
- [PULL 00/13] Misc HW/UI patches for 2024-07-16, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 01/13] hw/core/loader: allow loading larger ROMs, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 02/13] hw/isa/vt82c686: Turn "intr" irq into a named gpio, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 03/13] include/hw/qdev-core.h: Correct and clarify gpio doc comments, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 04/13] loader: remove load_image_gzipped function as its not used anywhere, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 05/13] accel/tcg: Make cpu_exec_interrupt hook mandatory, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 06/13] system/cpus: Add cpu_pause() function,
Philippe Mathieu-Daudé <=
- [PULL 07/13] esp: remove transfer size check from DMA DATA IN and DATA OUT transfers, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 08/13] ui/cocoa: Release CGColorSpace, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 09/13] ui/console: Convert mouse visibility parameter into bool, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 13/13] system/physmem: use return value of ram_block_discard_require() as errno, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 10/13] ui/cocoa: Add cursor composition, Philippe Mathieu-Daudé, 2024/07/16
- [PULL 11/13] ui/console: Remove dpy_cursor_define_supported(), Philippe Mathieu-Daudé, 2024/07/16
- [PULL 12/13] vl: fix "type is NULL" in -vga help, Philippe Mathieu-Daudé, 2024/07/16
- Re: [PULL 00/13] Misc HW/UI patches for 2024-07-16, Richard Henderson, 2024/07/17