From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E97FC54EE9 for ; Tue, 20 Sep 2022 04:54:01 +0000 (UTC) Received: from localhost ([::1]:42932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaVGi-0004US-Vc for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 00:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaVFn-0003SF-T6; Tue, 20 Sep 2022 00:53:04 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:40895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaVFl-00012I-9j; Tue, 20 Sep 2022 00:53:02 -0400 Received: by mail-wr1-x42f.google.com with SMTP id e16so2318435wrx.7; Mon, 19 Sep 2022 21:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date; bh=yXWBrA+VdOJ2eLhZR3jbWLCq6szWmV0B8FUoTOgqB0Y=; b=aJV1CFqMLGvYtz55pBXOVpWmVSQoYNCnNBeTgMiTAsRFuzH5R6W2APpLLxvjT8WmD4 +Aq7iwdNNrStFOY9aOqRysX4Fi1hb2Ai05q9KoqfdPoBoG8CctBSGiXnl5/iVsdJ+gtv G1xO0rGV43OaEcuEgmtP7LmuG+YfSqRa24lK6FNEcUouwvSx2/shKBcNCI2GLEjS+cs3 iopHzNjcN5/YTwRaIMxWArxIjRTpTenXmoMfOgDIkxoUoUYf8tucr0luciR3FCLpBLPl nYQ3yr3DJaimwbslpab29lcOYdhw+Pw4taR5Nq2MUO+stSchiopNm0u210j4zdGi4ZvP JV+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date; bh=yXWBrA+VdOJ2eLhZR3jbWLCq6szWmV0B8FUoTOgqB0Y=; b=NxyEoB/JDeAEQ6qDKXlfBWAJ3I1wCkQLoDYty7nHEAbrdw2jXmTPYKBM+dU1ULRR2Q qM2ckdLy6LXb0o5DvUmqnR9ZXpHF7Az8/WwKExuPezQhpD3xOR0iAJz6Vq7UODJKexdR h9SIFLSURQ7sOGNsbUsiuzeW2Wai10kY7EBdOibQ4ZPJy2EpeFvUJRyEEuDcDHsI13wi VF9lAwarfYEsl9KcJhJl58VRbfUwOkHxxIwWSwUOvxresWjIPtWkySk2arTaixVwnRcr OQevrxv9A9KoQoaSucqGrTKb/goxvC0t1WDjUfUTkGb/l681fBRuuOl5PA5Gvv9SfpfK fU7w== X-Gm-Message-State: ACrzQf0++miHXEPQhULw99rnKcxcMtbGPVmSlYUbw3XlCJNVN0o1vRT3 RTrzr8uA1MNJreLZYaK974A= X-Google-Smtp-Source: AMsMyM6arlbxvVjWRWfyODWA+1XBF2D6twCUtKI65uSf3S2vAcndKsZknTjHvTjJhdM7wtQh4z6qXA== X-Received: by 2002:a5d:4284:0:b0:22a:291e:fa8f with SMTP id k4-20020a5d4284000000b0022a291efa8fmr12816362wrq.553.1663649577762; Mon, 19 Sep 2022 21:52:57 -0700 (PDT) Received: from [192.168.1.115] ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id a1-20020a05600c348100b003b477532e66sm1328087wmq.2.2022.09.19.21.52.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 21:52:56 -0700 (PDT) Message-ID: <6af33d73-1e34-304d-998f-a46c8c05f4bb@amsat.org> Date: Tue, 20 Sep 2022 06:52:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton Content-Language: en-US To: Bernhard Beschow , qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?UTF-8?Q?Daniel_P=2e_Berrang=c3=a9?= , Christian Borntraeger , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?Q?Herv=c3=a9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne References: <20220919231720.163121-1-shentey@gmail.com> <20220919231720.163121-4-shentey@gmail.com> In-Reply-To: <20220919231720.163121-4-shentey@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.952, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= via 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 > --- > 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;