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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1377ECAAD8 for ; Tue, 20 Sep 2022 05:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbiITFQD (ORCPT ); Tue, 20 Sep 2022 01:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbiITFQB (ORCPT ); Tue, 20 Sep 2022 01:16:01 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C9C49B74 for ; Mon, 19 Sep 2022 22:15:59 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r7so2424839wrm.2 for ; Mon, 19 Sep 2022 22:15: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=zoCj17/FoLXwtexZcC8HC08ap2gyp0m31eL5ZvThkKo=; b=R32rY7NSj7Fx9wnIFsIakEDibCO9xnK1hZUIT2HKqPdw/Ary8UunlhchQEe50uZAKt IcHwDoHg8BNyr+4XdYGESfHcm//PXvOEVjvXhZPD7y8P5Fpsvk8XUpPTrNV902a8L/l1 kcrrndYyNFP2f9XhMPsIOO8AQ/iM1BglRxvcvsKItT0E660ecmBZDaSsn0HIoqSf61pq K8m/cNkANRYMDuR3+HLK4MzuEAvEdEvPrSnSDqRQAwpf1NMYx6hw3Df9VJdBqPRBqe1C BtFe2Lxkcsnodwk0vjI79xEIH7dEOtyIxG8EM0q8g5XNnP9vD2TPzFgVglIz9uW5QTr9 RzWA== 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=zoCj17/FoLXwtexZcC8HC08ap2gyp0m31eL5ZvThkKo=; b=YHLaR9rl0EhvlWmx9Jk0tCJsgsvguVtyJMGYkVQ5+gPisMuuGpYJTqfXozdg0n96uJ DKHQmK/GWzxj3DRn8qkUxgoidzxwXodmkpIh/3h/MgDz4jAyn3Y1jNCiMcPa3k1FljTd FMNaJEmvBSeL0d2rx/DoTVqAqBQOiYx4KH59IOVTtN30nxGYSq8Sn1Qjx13YDgdz9O/s afvZarKMPmVzpKCEcKijpIfs79Kuqfg4b3Cy/hsk/00Nf0vEGwfJODF9AOF4v4f2d4mM UiFyLXoCeDTtZXZg/wXtO+tGQ09+P0MEW8uBFWLe2k7UKHfn7pg4AaoysM0Vm6qw93zd OBUA== X-Gm-Message-State: ACrzQf3gII3kIIpTb7ttN7R5U/Z/VhYvJAhHr/S8lpYXKJHuM0TPEz9Q XFs92WMVgqylN71avCXEgpE= X-Google-Smtp-Source: AMsMyM765pemA7LP3GGPKGAEZ4snxehIWXXseDoYmmmzhMIFFSLEBCiGTStpb6E6ujtqvUpeq7Gp3g== X-Received: by 2002:a05:6000:2a7:b0:22a:f98f:b75f with SMTP id l7-20020a05600002a700b0022af98fb75fmr6627886wry.373.1663650957809; Mon, 19 Sep 2022 22:15:57 -0700 (PDT) Received: from [192.168.1.115] ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id t1-20020adfdc01000000b002252ec781f7sm480793wri.8.2022.09.19.22.15.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 22:15:55 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Message-ID: Date: Tue, 20 Sep 2022 07:15:50 +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 9/9] exec/address-spaces: Inline legacy functions 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-10-shentey@gmail.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= In-Reply-To: <20220919231720.163121-10-shentey@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 20/9/22 01:17, Bernhard Beschow wrote: > The functions just access a global pointer and perform some pointer > arithmetic on top. Allow the compiler to see through this by inlining. I thought about this while reviewing the previous patch, ... > Signed-off-by: Bernhard Beschow > --- > include/exec/address-spaces.h | 30 ++++++++++++++++++++++++++---- > softmmu/physmem.c | 28 ---------------------------- > 2 files changed, 26 insertions(+), 32 deletions(-) > > diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h > index b31bd8dcf0..182af27cad 100644 > --- a/include/exec/address-spaces.h > +++ b/include/exec/address-spaces.h > @@ -23,29 +23,51 @@ > > #ifndef CONFIG_USER_ONLY > > +#include "hw/boards.h" ... but I'm not a fan of including this header here. It is restricted to system emulation, but still... Let see what the others think. > /** > * Get the root memory region. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::system_memory directly. > */ > -MemoryRegion *get_system_memory(void); > +inline MemoryRegion *get_system_memory(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.system_memory; > +} > > /** > * Get the root I/O port region. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::system_io directly. > */ > -MemoryRegion *get_system_io(void); > +inline MemoryRegion *get_system_io(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.system_io; > +} > > /** > * Get the root memory address space. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::address_space_memory directly. > */ > -AddressSpace *get_address_space_memory(void); > +inline AddressSpace *get_address_space_memory(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.address_space_memory; > +} > > /** > * Get the root I/O port address space. This is a legacy function, provided > * for compatibility. Prefer using SysBusState::address_space_io directly. > */ > -AddressSpace *get_address_space_io(void); > +inline AddressSpace *get_address_space_io(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.address_space_io; > +} > > #endif > > diff --git a/softmmu/physmem.c b/softmmu/physmem.c > index 07e9a9171c..dce088f55c 100644 > --- a/softmmu/physmem.c > +++ b/softmmu/physmem.c > @@ -2674,34 +2674,6 @@ static void memory_map_init(SysBusState *sysbus) > address_space_init(&sysbus->address_space_io, system_io, "I/O"); > } > > -MemoryRegion *get_system_memory(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.system_memory; > -} > - > -MemoryRegion *get_system_io(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.system_io; > -} > - > -AddressSpace *get_address_space_memory(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.address_space_memory; > -} > - > -AddressSpace *get_address_space_io(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.address_space_io; > -} > - > static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, > hwaddr length) > { 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 9C26EC54EE9 for ; Tue, 20 Sep 2022 05:17:53 +0000 (UTC) Received: from localhost ([::1]:41226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaVdo-0005Zw-GW for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 01:17:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaVc3-00041o-Ud; Tue, 20 Sep 2022 01:16:04 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:43895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaVc1-0004Jp-AJ; Tue, 20 Sep 2022 01:16:03 -0400 Received: by mail-wr1-x42d.google.com with SMTP id t7so2336714wrm.10; Mon, 19 Sep 2022 22:15:58 -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=zoCj17/FoLXwtexZcC8HC08ap2gyp0m31eL5ZvThkKo=; b=R32rY7NSj7Fx9wnIFsIakEDibCO9xnK1hZUIT2HKqPdw/Ary8UunlhchQEe50uZAKt IcHwDoHg8BNyr+4XdYGESfHcm//PXvOEVjvXhZPD7y8P5Fpsvk8XUpPTrNV902a8L/l1 kcrrndYyNFP2f9XhMPsIOO8AQ/iM1BglRxvcvsKItT0E660ecmBZDaSsn0HIoqSf61pq K8m/cNkANRYMDuR3+HLK4MzuEAvEdEvPrSnSDqRQAwpf1NMYx6hw3Df9VJdBqPRBqe1C BtFe2Lxkcsnodwk0vjI79xEIH7dEOtyIxG8EM0q8g5XNnP9vD2TPzFgVglIz9uW5QTr9 RzWA== 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=zoCj17/FoLXwtexZcC8HC08ap2gyp0m31eL5ZvThkKo=; b=pPS2YtWXOkaINuKdC3WgIzm+72CSBg9ZUBrExMdngpjdmOvrhf/pS0hLSfv7sOXY3l iGAH6pE1NF9b5Tr6e/v+OHvWcGmi9+va3g6EpRmuIbs2iIRHMiRuaSyHPB1ZGoilKxbg Lzitl+vbg8VR2P4ee/OqnmiUAccSnB7TH9UB0h/Yx1bTWkBqZV10cq+NwqG0XP3oBaYy T6k2Nictty406gXiLbN9YjA4HrghdBNCTFoGzpZqb3K3QwaVQbf8eGsd2xy0TK4l6P5y RVGkgoIJ/k3ViYYHRJUd9Ain2744uw8nRYoR92vO8B9NhHqpPDbWupMQCN7vEqJa8Lmw TKkA== X-Gm-Message-State: ACrzQf0YfzgMiEN+Z2wGBb52rfhJ5ds7IART7BiW0b2Ge/Q0IA1Ug75W DgmbdY9Q/H0VqOD95LXMd0k= X-Google-Smtp-Source: AMsMyM765pemA7LP3GGPKGAEZ4snxehIWXXseDoYmmmzhMIFFSLEBCiGTStpb6E6ujtqvUpeq7Gp3g== X-Received: by 2002:a05:6000:2a7:b0:22a:f98f:b75f with SMTP id l7-20020a05600002a700b0022af98fb75fmr6627886wry.373.1663650957809; Mon, 19 Sep 2022 22:15:57 -0700 (PDT) Received: from [192.168.1.115] ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id t1-20020adfdc01000000b002252ec781f7sm480793wri.8.2022.09.19.22.15.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 22:15:55 -0700 (PDT) Message-ID: Date: Tue, 20 Sep 2022 07:15:50 +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 9/9] exec/address-spaces: Inline legacy functions 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-10-shentey@gmail.com> In-Reply-To: <20220919231720.163121-10-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::42d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42d.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: > The functions just access a global pointer and perform some pointer > arithmetic on top. Allow the compiler to see through this by inlining. I thought about this while reviewing the previous patch, ... > Signed-off-by: Bernhard Beschow > --- > include/exec/address-spaces.h | 30 ++++++++++++++++++++++++++---- > softmmu/physmem.c | 28 ---------------------------- > 2 files changed, 26 insertions(+), 32 deletions(-) > > diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h > index b31bd8dcf0..182af27cad 100644 > --- a/include/exec/address-spaces.h > +++ b/include/exec/address-spaces.h > @@ -23,29 +23,51 @@ > > #ifndef CONFIG_USER_ONLY > > +#include "hw/boards.h" ... but I'm not a fan of including this header here. It is restricted to system emulation, but still... Let see what the others think. > /** > * Get the root memory region. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::system_memory directly. > */ > -MemoryRegion *get_system_memory(void); > +inline MemoryRegion *get_system_memory(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.system_memory; > +} > > /** > * Get the root I/O port region. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::system_io directly. > */ > -MemoryRegion *get_system_io(void); > +inline MemoryRegion *get_system_io(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.system_io; > +} > > /** > * Get the root memory address space. This is a legacy function, provided for > * compatibility. Prefer using SysBusState::address_space_memory directly. > */ > -AddressSpace *get_address_space_memory(void); > +inline AddressSpace *get_address_space_memory(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.address_space_memory; > +} > > /** > * Get the root I/O port address space. This is a legacy function, provided > * for compatibility. Prefer using SysBusState::address_space_io directly. > */ > -AddressSpace *get_address_space_io(void); > +inline AddressSpace *get_address_space_io(void) > +{ > + assert(current_machine); > + > + return ¤t_machine->main_system_bus.address_space_io; > +} > > #endif > > diff --git a/softmmu/physmem.c b/softmmu/physmem.c > index 07e9a9171c..dce088f55c 100644 > --- a/softmmu/physmem.c > +++ b/softmmu/physmem.c > @@ -2674,34 +2674,6 @@ static void memory_map_init(SysBusState *sysbus) > address_space_init(&sysbus->address_space_io, system_io, "I/O"); > } > > -MemoryRegion *get_system_memory(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.system_memory; > -} > - > -MemoryRegion *get_system_io(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.system_io; > -} > - > -AddressSpace *get_address_space_memory(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.address_space_memory; > -} > - > -AddressSpace *get_address_space_io(void) > -{ > - assert(current_machine); > - > - return ¤t_machine->main_system_bus.address_space_io; > -} > - > static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, > hwaddr length) > {