[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 2/8] cpus: Move do_run_on_cpu into softmmu/cpus.c
From: |
Peter Xu |
Subject: |
[PATCH v3 2/8] cpus: Move do_run_on_cpu into softmmu/cpus.c |
Date: |
Wed, 28 Jul 2021 14:31:45 -0400 |
It's only used by softmmu binaries not linux-user ones. Make it static and
drop the definition in the header too.
Since at it, initialize variable "wi" with less loc.
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
cpus-common.c | 25 -------------------------
include/hw/core/cpu.h | 12 ------------
softmmu/cpus.c | 23 +++++++++++++++++++++++
3 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/cpus-common.c b/cpus-common.c
index d814b2439a..670826363f 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -124,31 +124,6 @@ void queue_work_on_cpu(CPUState *cpu, struct
qemu_work_item *wi)
qemu_cpu_kick(cpu);
}
-void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data,
- QemuMutex *mutex)
-{
- struct qemu_work_item wi;
-
- if (qemu_cpu_is_self(cpu)) {
- func(cpu, data);
- return;
- }
-
- wi.func = func;
- wi.data = data;
- wi.done = false;
- wi.free = false;
- wi.exclusive = false;
-
- queue_work_on_cpu(cpu, &wi);
- while (!qatomic_mb_read(&wi.done)) {
- CPUState *self_cpu = current_cpu;
-
- qemu_cond_wait(&qemu_work_cond, mutex);
- current_cpu = self_cpu;
- }
-}
-
void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data
data)
{
struct qemu_work_item *wi;
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index f62ae88524..711ecad62f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -689,18 +689,6 @@ void qemu_cpu_kick(CPUState *cpu);
*/
bool cpu_is_stopped(CPUState *cpu);
-/**
- * do_run_on_cpu:
- * @cpu: The vCPU to run on.
- * @func: The function to be executed.
- * @data: Data to pass to the function.
- * @mutex: Mutex to release while waiting for @func to run.
- *
- * Used internally in the implementation of run_on_cpu.
- */
-void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data,
- QemuMutex *mutex);
-
/**
* run_on_cpu:
* @cpu: The vCPU to run on.
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 071085f840..49e0368438 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -382,6 +382,29 @@ void qemu_init_cpu_loop(void)
qemu_thread_get_self(&io_thread);
}
+static void
+do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data,
+ QemuMutex *mutex)
+{
+ struct qemu_work_item wi = {
+ .func = func,
+ .data = data,
+ };
+
+ if (qemu_cpu_is_self(cpu)) {
+ func(cpu, data);
+ return;
+ }
+
+ queue_work_on_cpu(cpu, &wi);
+ while (!qatomic_mb_read(&wi.done)) {
+ CPUState *self_cpu = current_cpu;
+
+ qemu_cond_wait(&qemu_work_cond, mutex);
+ current_cpu = self_cpu;
+ }
+}
+
void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
{
do_run_on_cpu(cpu, func, data, &qemu_global_mutex);
--
2.31.1
- [PATCH v3 0/8] memory: Sanity checks memory transaction when releasing BQL, Peter Xu, 2021/07/28
- [PATCH v3 1/8] cpus: Export queue work related fields to cpu.h, Peter Xu, 2021/07/28
- [PATCH v3 3/8] memory: Introduce memory_region_transaction_depth_{inc|dec}(), Peter Xu, 2021/07/28
- [PATCH v3 2/8] cpus: Move do_run_on_cpu into softmmu/cpus.c,
Peter Xu <=
- [PATCH v3 4/8] memory: Don't do topology update in memory finalize(), Peter Xu, 2021/07/28
- [PATCH v3 5/8] cpus: Use qemu_cond_wait_iothread() where proper, Peter Xu, 2021/07/28
- [PATCH v3 6/8] cpus: Remove the mutex parameter from do_run_on_cpu(), Peter Xu, 2021/07/28
- [PATCH v3 8/8] memory: Delay the transaction pop() until commit completed, Peter Xu, 2021/07/28
- [PATCH v3 7/8] memory: Assert on no ongoing memory transaction before release BQL, Peter Xu, 2021/07/28