[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 62/74] cpu: call .cpu_has_work with the CPU lock held
From: |
Robert Foley |
Subject: |
[PATCH v8 62/74] cpu: call .cpu_has_work with the CPU lock held |
Date: |
Thu, 26 Mar 2020 15:31:44 -0400 |
From: "Emilio G. Cota" <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Robert Foley <address@hidden>
---
include/hw/core/cpu.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 1c3701b142..a01c258320 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -80,7 +80,8 @@ struct TranslationBlock;
* instantiatable CPU type.
* @parse_features: Callback to parse command line arguments.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
- * @has_work: Callback for checking if there is work to do.
+ * @has_work: Callback for checking if there is work to do. Called with the
+ * CPU lock held.
* @do_interrupt: Callback for interrupt handling.
* @do_unaligned_access: Callback for unaligned access handling, if
* the target defines #TARGET_ALIGNED_ONLY.
@@ -799,9 +800,16 @@ const char *parse_cpu_option(const char *cpu_option);
static inline bool cpu_has_work(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ bool ret;
g_assert(cc->has_work);
- return cc->has_work(cpu);
+ if (cpu_mutex_locked(cpu)) {
+ return cc->has_work(cpu);
+ }
+ cpu_mutex_lock(cpu);
+ ret = cc->has_work(cpu);
+ cpu_mutex_unlock(cpu);
+ return ret;
}
/**
--
2.17.1
- [PATCH v8 53/74] s390x: convert to cpu_interrupt_request, (continued)
- [PATCH v8 53/74] s390x: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 54/74] alpha: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 55/74] moxie: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 57/74] openrisc: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 58/74] unicore32: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 56/74] sparc: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 59/74] microblaze: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 60/74] accel/tcg: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 44/74] i386/hvf: convert to cpu_request_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 61/74] cpu: convert to interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 62/74] cpu: call .cpu_has_work with the CPU lock held,
Robert Foley <=
- [PATCH v8 63/74] cpu: introduce cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 64/74] ppc: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 65/74] mips: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 66/74] s390x: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 67/74] riscv: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 68/74] sparc: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 69/74] xtensa: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/03/26
- [PATCH v8 70/74] cpu: rename all_cpu_threads_idle to qemu_tcg_rr_all_cpu_threads_idle, Robert Foley, 2020/03/26
- [PATCH v8 72/74] cpus-common: release BQL earlier in run_on_cpu, Robert Foley, 2020/03/26
- [PATCH v8 71/74] cpu: protect CPU state with cpu->lock instead of the BQL, Robert Foley, 2020/03/26