[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 11/43] accel/tcg: Use QEMU_IOTHREAD_LOCK_GUARD in io_readx/io_
From: |
Richard Henderson |
Subject: |
[PATCH v5 11/43] accel/tcg: Use QEMU_IOTHREAD_LOCK_GUARD in io_readx/io_writex |
Date: |
Sat, 24 Dec 2022 15:56:48 -0800 |
Narrow the scope of the lock to the actual read/write,
moving the cpu_transation_failed call outside the lock.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/cputlb.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 03674d598f..4948729917 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1356,7 +1356,6 @@ static uint64_t io_readx(CPUArchState *env,
CPUTLBEntryFull *full,
MemoryRegionSection *section;
MemoryRegion *mr;
uint64_t val;
- bool locked = false;
MemTxResult r;
section = iotlb_to_section(cpu, full->xlat_section, full->attrs);
@@ -1367,11 +1366,11 @@ static uint64_t io_readx(CPUArchState *env,
CPUTLBEntryFull *full,
cpu_io_recompile(cpu, retaddr);
}
- if (!qemu_mutex_iothread_locked()) {
- qemu_mutex_lock_iothread();
- locked = true;
+ {
+ QEMU_IOTHREAD_LOCK_GUARD();
+ r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs);
}
- r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs);
+
if (r != MEMTX_OK) {
hwaddr physaddr = mr_offset +
section->offset_within_address_space -
@@ -1380,10 +1379,6 @@ static uint64_t io_readx(CPUArchState *env,
CPUTLBEntryFull *full,
cpu_transaction_failed(cpu, physaddr, addr, memop_size(op),
access_type,
mmu_idx, full->attrs, r, retaddr);
}
- if (locked) {
- qemu_mutex_unlock_iothread();
- }
-
return val;
}
@@ -1410,7 +1405,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull
*full,
hwaddr mr_offset;
MemoryRegionSection *section;
MemoryRegion *mr;
- bool locked = false;
MemTxResult r;
section = iotlb_to_section(cpu, full->xlat_section, full->attrs);
@@ -1427,11 +1421,11 @@ static void io_writex(CPUArchState *env,
CPUTLBEntryFull *full,
*/
save_iotlb_data(cpu, section, mr_offset);
- if (!qemu_mutex_iothread_locked()) {
- qemu_mutex_lock_iothread();
- locked = true;
+ {
+ QEMU_IOTHREAD_LOCK_GUARD();
+ r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs);
}
- r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs);
+
if (r != MEMTX_OK) {
hwaddr physaddr = mr_offset +
section->offset_within_address_space -
@@ -1441,9 +1435,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull
*full,
MMU_DATA_STORE, mmu_idx, full->attrs, r,
retaddr);
}
- if (locked) {
- qemu_mutex_unlock_iothread();
- }
}
static inline target_ulong tlb_read_ofs(CPUTLBEntry *entry, size_t ofs)
--
2.34.1
- [PATCH v5 02/43] meson: Move CONFIG_TCG_INTERPRETER to config_host, (continued)
- [PATCH v5 02/43] meson: Move CONFIG_TCG_INTERPRETER to config_host, Richard Henderson, 2022/12/24
- [PATCH v5 04/43] tcg: Cleanup trailing whitespace, Richard Henderson, 2022/12/24
- [PATCH v5 03/43] tcg/s390x: Fix coding style, Richard Henderson, 2022/12/24
- [PATCH v5 05/43] qemu/main-loop: Introduce QEMU_IOTHREAD_LOCK_GUARD, Richard Henderson, 2022/12/24
- [PATCH v5 07/43] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_maybe_interrupt, Richard Henderson, 2022/12/24
- [PATCH v5 06/43] hw/mips: Use QEMU_IOTHREAD_LOCK_GUARD in cpu_mips_irq_request, Richard Henderson, 2022/12/24
- [PATCH v5 08/43] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in cpu_interrupt_exittb, Richard Henderson, 2022/12/24
- [PATCH v5 01/43] tcg: convert tcg/README to rst, Richard Henderson, 2022/12/24
- [PATCH v5 09/43] target/riscv: Use QEMU_IOTHREAD_LOCK_GUARD in riscv_cpu_update_mip, Richard Henderson, 2022/12/24
- [PATCH v5 12/43] tcg: Tidy tcg_reg_alloc_op, Richard Henderson, 2022/12/24
- [PATCH v5 11/43] accel/tcg: Use QEMU_IOTHREAD_LOCK_GUARD in io_readx/io_writex,
Richard Henderson <=
- [PATCH v5 13/43] tcg: Remove TCG_TARGET_STACK_GROWSUP, Richard Henderson, 2022/12/24
- [PATCH v5 14/43] tci: MAX_OPC_PARAM_IARGS is no longer used, Richard Henderson, 2022/12/24
- [PATCH v5 10/43] hw/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_set_irq, Richard Henderson, 2022/12/24
- [PATCH v5 15/43] tcg: Fix tcg_reg_alloc_dup*, Richard Henderson, 2022/12/24
- [PATCH v5 17/43] tcg: Remove check_regs, Richard Henderson, 2022/12/24
- [PATCH v5 18/43] tcg: Massage process_op_defs(), Richard Henderson, 2022/12/24
- [PATCH v5 20/43] accel/tcg: Set cflags_next_tb in cpu_common_initfn, Richard Henderson, 2022/12/24
- [PATCH v5 21/43] target/sparc: Avoid TCGV_{LOW,HIGH}, Richard Henderson, 2022/12/24
- [PATCH v5 16/43] tcg: Centralize updates to reg_to_temp, Richard Henderson, 2022/12/24
- [PATCH v5 23/43] tcg: Add temp_subindex to TCGTemp, Richard Henderson, 2022/12/24