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 DA5F3C54EE9 for ; Tue, 20 Sep 2022 05:29:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbiITF3z (ORCPT ); Tue, 20 Sep 2022 01:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbiITF3x (ORCPT ); Tue, 20 Sep 2022 01:29:53 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C6DDFF4 for ; Mon, 19 Sep 2022 22:29:51 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id e16so2406652wrx.7 for ; Mon, 19 Sep 2022 22:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date; bh=vLavNPct5HZ2zw6lCN44DF82TIWb7S+NcGLLhGiFgbY=; b=EK29FpxAwJTevxxTP1Jl5+8Y1nnFTDF4cikh0gdLoXjAqssLIc3NK6aJqtIC/sl76l dQN74iwKJIJ8m0vzpT+oBMXb5MWlRMSIdHBzXKYK5Up+7xMeAWU2OrFa0PkuuSntFnfD X7ztP7+ETA8Fnzon/RDPQskBBm2PsWXO/DiTgFqR7DYzUYuJeytUDF0rJT4iCR/ALlAA RNwcv8k60hb5BUXFwIL4fqj+86FL8NznWTo23V8HDCS9Sc8g3g84j4YS3ADG95ZJ5qc0 HY0W7gF2cKRT2O+FinLEbnd2WC7FWDJUGcCanGw3nw0m2niEWG4+ilLXeWs4pDnNwah0 Td6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date; bh=vLavNPct5HZ2zw6lCN44DF82TIWb7S+NcGLLhGiFgbY=; b=EGMiG9slGdXsSWmwGPvW/2hjOby5UzZrrWL5Bibto1JPOWD3oLL+W0HniLkRW6KW/c x/ZDRbQ6GhYPF8ATe8fqGSDCRToiaMOEVcO3nbIq/qkSdZBA1MVBRLE+1UWD9zIp62ez vBuQhwIt7ya9fGTldHfdsPdJiGaCzY4mWHM5cVSrruLQNrQ/ebk/EZ9j7RXfuFmWx+Zk oPQnnbxJF+SSWLRn1zT3bYJiiwcQCkn/Z3ow9cfFPDn+EgY4TsTTOGxHCGk16638m/jm oY1XD5OcN+MZA8cnFvKuRfzdE/43l5zvHiDPmE2GDQO4q1ysnhTV4Bp0XrjKTpma17m2 kf1w== X-Gm-Message-State: ACrzQf32MPZAxQ9oaeX4y8TSCZ/opOPIV1ZmErUGMuzvO/hT6EGnU7iW tHhjcMPmki+2ebKoGcP2/zY= X-Google-Smtp-Source: AMsMyM7ISxf8TowQHPXzwCB3gJbnhv9fjXayvDOx/H9iOPRnaX40Rdq5is+DoWs7bHq7Ygny4DwhKA== X-Received: by 2002:adf:eec3:0:b0:22a:d159:456c with SMTP id a3-20020adfeec3000000b0022ad159456cmr12283036wrp.463.1663651790518; Mon, 19 Sep 2022 22:29:50 -0700 (PDT) Received: from [192.168.1.115] ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id t18-20020adfdc12000000b0022762b0e2a2sm510363wri.6.2022.09.19.22.29.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 22:29:49 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Message-ID: <63a4afba-546b-5c4c-94f8-c689b8fa0e0b@amsat.org> Date: Tue, 20 Sep 2022 07:29:43 +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 From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= 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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 20/9/22 07:15, Philippe Mathieu-Daudé wrote: > 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; >> +} Maybe we can simply declare them with __attribute__ ((const)) in the previous patch? See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes 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 2EFF4C54EE9 for ; Tue, 20 Sep 2022 05:33:39 +0000 (UTC) Received: from localhost ([::1]:57488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaVt4-0001YN-2a for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 01:33:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaVpV-00081m-4s; Tue, 20 Sep 2022 01:29:57 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:42871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaVpR-0005wz-OZ; Tue, 20 Sep 2022 01:29:56 -0400 Received: by mail-wr1-x434.google.com with SMTP id n12so2374776wrx.9; Mon, 19 Sep 2022 22:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date; bh=vLavNPct5HZ2zw6lCN44DF82TIWb7S+NcGLLhGiFgbY=; b=EK29FpxAwJTevxxTP1Jl5+8Y1nnFTDF4cikh0gdLoXjAqssLIc3NK6aJqtIC/sl76l dQN74iwKJIJ8m0vzpT+oBMXb5MWlRMSIdHBzXKYK5Up+7xMeAWU2OrFa0PkuuSntFnfD X7ztP7+ETA8Fnzon/RDPQskBBm2PsWXO/DiTgFqR7DYzUYuJeytUDF0rJT4iCR/ALlAA RNwcv8k60hb5BUXFwIL4fqj+86FL8NznWTo23V8HDCS9Sc8g3g84j4YS3ADG95ZJ5qc0 HY0W7gF2cKRT2O+FinLEbnd2WC7FWDJUGcCanGw3nw0m2niEWG4+ilLXeWs4pDnNwah0 Td6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date; bh=vLavNPct5HZ2zw6lCN44DF82TIWb7S+NcGLLhGiFgbY=; b=eSk6rEa82XX5InFhimjETOCJHr/7sSMrs73/kTs+XlUnMgsu/162TA+cNS9hkypgQl Ejgy9o1XosWIJIgJpszJhcHnwz1FDD3gLKVCyvQ6S22Fh5EDh43VPk9UmS97jKlqM9Yu 2SQRgML0MfxpOHdjoGdRzZkqoJY8Euvr9pN9aUpc/wp3rkwFHLSBBwRlWfaJSWH8Jvfw SikUTS0CGFy5ZLJk05dcyuwF/9oJqNtlRu9WMurT+IqOY+SwI6DmFRDrAIdxUNU7RTf/ v7jfnYmR3QK5NixUhR/eoEx9MwoXaX8Bj92ft64SKa+5okGUPu6Xx0ouh5n1IuLQ/tc/ UMLg== X-Gm-Message-State: ACrzQf1OSIzgxOJB7Sjh6gwTZMI1ze3pPW8kK5pk9Uj0LpWFc7e9Mra+ r3Aaschi2+BHkWG9j20Fstc= X-Google-Smtp-Source: AMsMyM7ISxf8TowQHPXzwCB3gJbnhv9fjXayvDOx/H9iOPRnaX40Rdq5is+DoWs7bHq7Ygny4DwhKA== X-Received: by 2002:adf:eec3:0:b0:22a:d159:456c with SMTP id a3-20020adfeec3000000b0022ad159456cmr12283036wrp.463.1663651790518; Mon, 19 Sep 2022 22:29:50 -0700 (PDT) Received: from [192.168.1.115] ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id t18-20020adfdc12000000b0022762b0e2a2sm510363wri.6.2022.09.19.22.29.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 22:29:49 -0700 (PDT) Message-ID: <63a4afba-546b-5c4c-94f8-c689b8fa0e0b@amsat.org> Date: Tue, 20 Sep 2022 07:29:43 +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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x434.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 07:15, Philippe Mathieu-Daudé wrote: > 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; >> +} Maybe we can simply declare them with __attribute__ ((const)) in the previous patch? See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes