[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/68] tcg: round-robin: do not use mb_read for rr_current_cpu
From: |
Paolo Bonzini |
Subject: |
[PULL 14/68] tcg: round-robin: do not use mb_read for rr_current_cpu |
Date: |
Wed, 17 May 2023 19:44:26 +0200 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
accel/tcg/tcg-accel-ops-rr.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 5788efa5ff4d..b6d10fa9a250 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -72,11 +72,13 @@ static void rr_kick_next_cpu(void)
{
CPUState *cpu;
do {
- cpu = qatomic_mb_read(&rr_current_cpu);
+ cpu = qatomic_read(&rr_current_cpu);
if (cpu) {
cpu_exit(cpu);
}
- } while (cpu != qatomic_mb_read(&rr_current_cpu));
+ /* Finish kicking this cpu before reading again. */
+ smp_mb();
+ } while (cpu != qatomic_read(&rr_current_cpu));
}
static void rr_kick_thread(void *opaque)
@@ -241,8 +243,9 @@ static void *rr_cpu_thread_fn(void *arg)
}
while (cpu && cpu_work_list_empty(cpu) && !cpu->exit_request) {
-
+ /* Store rr_current_cpu before evaluating cpu_can_run(). */
qatomic_mb_set(&rr_current_cpu, cpu);
+
current_cpu = cpu;
qemu_clock_enable(QEMU_CLOCK_VIRTUAL,
@@ -280,7 +283,7 @@ static void *rr_cpu_thread_fn(void *arg)
cpu = CPU_NEXT(cpu);
} /* while (cpu && !cpu->exit_request).. */
- /* Does not need qatomic_mb_set because a spurious wakeup is okay. */
+ /* Does not need a memory barrier because a spurious wakeup is okay.
*/
qatomic_set(&rr_current_cpu, NULL);
if (cpu && cpu->exit_request) {
--
2.40.1
- [PULL 06/68] target/i386: Fix and add some comments next to SSE/AVX instructions., (continued)
- [PULL 06/68] target/i386: Fix and add some comments next to SSE/AVX instructions., Paolo Bonzini, 2023/05/17
- [PULL 08/68] target/i386: Fix exception classes for MOVNTPS/MOVNTPD., Paolo Bonzini, 2023/05/17
- [PULL 09/68] meson: Pass -j option to sphinx, Paolo Bonzini, 2023/05/17
- [PULL 04/68] target/i386: fix avx2 instructions vzeroall and vpermdq, Paolo Bonzini, 2023/05/17
- [PULL 07/68] target/i386: Fix exception classes for SSE/AVX instructions., Paolo Bonzini, 2023/05/17
- [PULL 11/68] kvm: Synchronize the backup bitmap in the last stage, Paolo Bonzini, 2023/05/17
- [PULL 10/68] migration: Add last stage indicator to global dirty log, Paolo Bonzini, 2023/05/17
- [PULL 12/68] kvm: Add helper kvm_dirty_ring_init(), Paolo Bonzini, 2023/05/17
- [PULL 13/68] kvm: Enable dirty ring for arm64, Paolo Bonzini, 2023/05/17
- [PULL 16/68] scsi-generic: fix buffer overflow on block limits inquiry, Paolo Bonzini, 2023/05/17
- [PULL 14/68] tcg: round-robin: do not use mb_read for rr_current_cpu,
Paolo Bonzini <=
- [PULL 17/68] make: clean after distclean deletes source files, Paolo Bonzini, 2023/05/17
- [PULL 18/68] python: shut up "pip install" during "make check-minreqs", Paolo Bonzini, 2023/05/17
- [PULL 15/68] coverity: the definitive COMPONENTS.md update, Paolo Bonzini, 2023/05/17
- [PULL 20/68] python: add mkvenv.py, Paolo Bonzini, 2023/05/17
- [PULL 28/68] mkvenv: work around broken pip installations on Debian 10, Paolo Bonzini, 2023/05/17
- [PULL 19/68] python: update pylint configuration, Paolo Bonzini, 2023/05/17
- [PULL 23/68] mkvenv: add ensure subcommand, Paolo Bonzini, 2023/05/17
- [PULL 21/68] mkvenv: add better error message for broken or missing ensurepip, Paolo Bonzini, 2023/05/17
- [PULL 24/68] mkvenv: add --diagnose option to explain "ensure" failures, Paolo Bonzini, 2023/05/17
- [PULL 22/68] mkvenv: add nested venv workaround, Paolo Bonzini, 2023/05/17