qemu-ppc
[Top][All Lists]
Advanced

[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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]