[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 06/74] cpu: introduce process_queued_cpu_work_locked
From: |
Robert Foley |
Subject: |
[PATCH v9 06/74] cpu: introduce process_queued_cpu_work_locked |
Date: |
Thu, 21 May 2020 12:39:03 -0400 |
From: "Emilio G. Cota" <address@hidden>
This completes the conversion to cpu_mutex_lock/unlock in the file.
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>
---
cpus-common.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/cpus-common.c b/cpus-common.c
index 907ba5f0fc..e2f609c8e2 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 v9 00/74] per-CPU locks, Robert Foley, 2020/05/21
- [PATCH v9 01/74] cpu: convert queued work to a QSIMPLEQ, Robert Foley, 2020/05/21
- [PATCH v9 02/74] cpu: rename cpu->work_mutex to cpu->lock, Robert Foley, 2020/05/21
- [PATCH v9 03/74] cpu: introduce cpu_mutex_lock/unlock, Robert Foley, 2020/05/21
- [PATCH v9 04/74] cpu: make qemu_work_cond per-cpu, Robert Foley, 2020/05/21
- [PATCH v9 05/74] cpu: move run_on_cpu to cpus-common, Robert Foley, 2020/05/21
- [PATCH v9 06/74] cpu: introduce process_queued_cpu_work_locked,
Robert Foley <=
- [PATCH v9 07/74] cpu: make per-CPU locks an alias of the BQL in TCG rr mode, Robert Foley, 2020/05/21
- [PATCH v9 08/74] tcg-runtime: define helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 09/74] ppc: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 10/74] cris: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 12/74] m68k: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 11/74] hppa: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 13/74] alpha: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21
- [PATCH v9 14/74] microblaze: convert to helper_cpu_halted_set, Robert Foley, 2020/05/21