[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton |
Date: |
Tue, 20 Sep 2022 06:52:51 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 |
On 20/9/22 01:17, Bernhard Beschow wrote:
In QEMU, a machine and the main_system_bus always go togehter. Usually
the bus is part of the machine which suggsts to host it there.
"together", "suggests"
Since tere is already a current_machine singleton, all code that
accesses the main_system_bus can be changed (behind the scenes) to go
through current_machine. This resolves a singleton. Futhermore, by
"Furthermore"
reifying it in code, the every-machine-has-exactly-one-main-system-bus
relationship becomes very obvious.
Note that the main_system_bus attribute is a value rather than a
pointer. This trades pointer dereferences for pointer arithmetic. The
idea is to reduce cache misses - a rule of thumb says that
every pointer dereference causes a cache miss while arithmetic is
basically free.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/core/bus.c | 5 ++++-
hw/core/machine.c | 3 +++
hw/core/sysbus.c | 22 +++++-----------------
include/hw/boards.h | 1 +
4 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 311ed17e18..7af940102d 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
Likely missing the BusState declaration:
#include "hw/qdev-core.h"
@@ -346,6 +346,7 @@ struct MachineState {
*/
MemoryRegion *ram;
DeviceMemoryState *device_memory;
+ BusState main_system_bus;
ram_addr_t ram_size;
ram_addr_t maxram_size;
- Re: [PATCH 1/9] hw/riscv/sifive_e: Fix inheritance of SiFiveEState, (continued)
Re: [PATCH 1/9] hw/riscv/sifive_e: Fix inheritance of SiFiveEState, Philippe Mathieu-Daudé, 2022/09/20
[PATCH 2/9] exec/hwaddr.h: Add missing include, Bernhard Beschow, 2022/09/19
[PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton, Bernhard Beschow, 2022/09/19
- Re: [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton,
Philippe Mathieu-Daudé <=
[PATCH 4/9] hw/ppc/spapr: Fix code style problems reported by checkpatch, Bernhard Beschow, 2022/09/19
[PATCH 5/9] exec/address-spaces: Wrap address space singletons into functions, Bernhard Beschow, 2022/09/19
[PATCH 6/9] target/loongarch/cpu: Remove unneeded include directive, Bernhard Beschow, 2022/09/19
[PATCH 7/9] hw/sysbus: Introduce dedicated struct SysBusState for TYPE_SYSTEM_BUS, Bernhard Beschow, 2022/09/19
[PATCH 8/9] softmmu/physmem: Let SysBusState absorb memory region and address space singletons, Bernhard Beschow, 2022/09/19