[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 05/73] cpu: introduce process_queued_cpu_work_locked
From: |
Robert Foley |
Subject: |
[PATCH v10 05/73] cpu: introduce process_queued_cpu_work_locked |
Date: |
Wed, 17 Jun 2020 17:01:23 -0400 |
From: "Emilio G. Cota" <cota@braap.org>
This completes the conversion to cpu_mutex_lock/unlock in the file.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Robert Foley <robert.foley@linaro.org>
---
cpus-common.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/cpus-common.c b/cpus-common.c
index b1069193c1..6f51ae127c 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -329,20 +329,19 @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func
func,
queue_work_on_cpu(cpu, wi);
}
-void process_queued_cpu_work(CPUState *cpu)
+/* Called with the CPU's lock held */
+static void process_queued_cpu_work_locked(CPUState *cpu)
{
struct qemu_work_item *wi;
bool has_bql = qemu_mutex_iothread_locked();
- qemu_mutex_lock(&cpu->lock);
if (QSIMPLEQ_EMPTY(&cpu->work_list)) {
- qemu_mutex_unlock(&cpu->lock);
return;
}
while (!QSIMPLEQ_EMPTY(&cpu->work_list)) {
wi = QSIMPLEQ_FIRST(&cpu->work_list);
QSIMPLEQ_REMOVE_HEAD(&cpu->work_list, node);
- qemu_mutex_unlock(&cpu->lock);
+ cpu_mutex_unlock(cpu);
if (wi->exclusive) {
/* Running work items outside the BQL avoids the following
deadlock:
* 1) start_exclusive() is called with the BQL taken while another
@@ -368,13 +367,19 @@ void process_queued_cpu_work(CPUState *cpu)
qemu_mutex_unlock_iothread();
}
}
- qemu_mutex_lock(&cpu->lock);
+ cpu_mutex_lock(cpu);
if (wi->free) {
g_free(wi);
} else {
atomic_mb_set(&wi->done, true);
}
}
- qemu_mutex_unlock(&cpu->lock);
qemu_cond_broadcast(&cpu->cond);
}
+
+void process_queued_cpu_work(CPUState *cpu)
+{
+ cpu_mutex_lock(cpu);
+ process_queued_cpu_work_locked(cpu);
+ cpu_mutex_unlock(cpu);
+}
--
2.17.1
- [PATCH v10 00/73] per-CPU locks, Robert Foley, 2020/06/17
- [PATCH v10 01/73] cpu: rename cpu->work_mutex to cpu->lock, Robert Foley, 2020/06/17
- [PATCH v10 03/73] cpu: make qemu_work_cond per-cpu, Robert Foley, 2020/06/17
- [PATCH v10 02/73] cpu: introduce cpu_mutex_lock/unlock, Robert Foley, 2020/06/17
- [PATCH v10 04/73] cpu: move run_on_cpu to cpus-common, Robert Foley, 2020/06/17
- [PATCH v10 06/73] cpu: make per-CPU locks an alias of the BQL in TCG rr mode, Robert Foley, 2020/06/17
- [PATCH v10 05/73] cpu: introduce process_queued_cpu_work_locked,
Robert Foley <=
- [PATCH v10 10/73] hppa: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 11/73] m68k: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 07/73] tcg-runtime: define helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 09/73] cris: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 08/73] ppc: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 14/73] cpu: define cpu_halted helpers, Robert Foley, 2020/06/17
- [PATCH v10 12/73] alpha: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 15/73] tcg-runtime: convert to cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 13/73] microblaze: convert to helper_cpu_halted_set, Robert Foley, 2020/06/17
- [PATCH v10 17/73] arm: convert to cpu_halted, Robert Foley, 2020/06/17