From 479f36ef8e9763781ba53fca780b4e09c001fe0e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sat, 17 Feb 2018 17:20:41 -0500 Subject: [PATCH] exec: avoid unnecessary cacheline bounce on ram_list.mru_block Whenever the MRU cache hits for the list of RAM blocks, qemu_get_ram_block does an unnecessary write that causes a processor cache line to bounce from one core to another. This causes a performance hit. Backports commit 68851b98e5bf6d397498b74f1776801274ab8d48 from qemu --- qemu/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/exec.c b/qemu/exec.c index 9e5af124..5df6a3a8 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -683,7 +683,7 @@ static RAMBlock *qemu_get_ram_block(struct uc_struct *uc, ram_addr_t addr) /* The list is protected by the iothread lock here. */ block = uc->ram_list.mru_block; if (block && addr - block->offset < block->max_length) { - goto found; + return block; } QTAILQ_FOREACH(block, &uc->ram_list.blocks, next) { if (addr - block->offset < block->max_length) {