From patchwork Thu Aug 19 14:20:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12447351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38BFBC4338F for ; Thu, 19 Aug 2021 14:25:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C0A51610FA for ; Thu, 19 Aug 2021 14:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0A51610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGizK-0005Ls-VX for qemu-devel@archiver.kernel.org; Thu, 19 Aug 2021 10:25:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuy-0003f2-Hh for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuv-0006gV-IP for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEyWPjQ7Gf9BUPz8WL5PzOlCAdvMwlwVzwTeHocd/5s=; b=daPx9HJETfmKooFyIoZ0r0+exmFUutScKBn9dGBkrARVyM4Ekvj5HJJll7zZLIbjVJfMkE qfFoBlqx4DM1s18jImk0Qw22Er76YTS1BWZrOQURL9/tR5cgm/iZcw0uUFhCIHBxsNXrfT S7rBueqsKlQ60C+ggHz4aeODiMd5yrs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-fuL0hYlvMBKY6cZhMLpYyw-1; Thu, 19 Aug 2021 10:21:12 -0400 X-MC-Unique: fuL0hYlvMBKY6cZhMLpYyw-1 Received: by mail-wm1-f71.google.com with SMTP id j33-20020a05600c1c21b02902e6828f7a20so1593975wms.7 for ; Thu, 19 Aug 2021 07:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QEyWPjQ7Gf9BUPz8WL5PzOlCAdvMwlwVzwTeHocd/5s=; b=ClXVsHRalQ0Bj3cZWF2mOSenR3pMHVUSBzMYYWV1xMfzZ/avdF0Csz9gcpOCS0mpZL 0SqMu+/xMrllOWCCqYylR7OfqSgq6U+Nch6b81D1UrnG92AUc/wVGi4i8cmedTzT7vqB ODxe9QV1Uml47hHkXLUZ+1Kg4X1JlopO+V3jBR4DfPw838cM9+XmmgLBLTd/69Zl4RP5 vOLeBYkDD7WNwE0c8aB7gwFG+zHrdBtQnVEON1IShgLHB+Cp2GsO9wGfzyYYxnyIjxzr nofpo6QGEPQZfH/u2979PJRO1/CL4KX+0wEl3k3zN1h7v2P0jleYajsd0Ssu0e1feOmE 1TKw== X-Gm-Message-State: AOAM5308Xipap9KUVnCVl2MXcpUbW+u+IOdnRZwy+ACGeMpP1SBRXmK8 zp/G050ugcot+JJjb6Oxx1xdX0Me428SU/4iAZkU+WcoKZvTgtaacdUNop9dmbMpNY5g4DcnYZ8 GU3jFD7PtM3Y+jlSBqUg8Sipp2wAu2rhU8FizG5R19CiwRj0kXEINpuBY5zyipzEW X-Received: by 2002:a7b:c756:: with SMTP id w22mr13968329wmk.169.1629382870409; Thu, 19 Aug 2021 07:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU2eFmgEMwmeuxPkpBabQdTNmtrIGJQ5ir7VEREfQX+1H+HLk1sQXOB7OkSAlvY+9nPvSZzg== X-Received: by 2002:a7b:c756:: with SMTP id w22mr13968302wmk.169.1629382870176; Thu, 19 Aug 2021 07:21:10 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id j17sm3000947wrt.69.2021.08.19.07.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:21:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 6/6] memory: Have address_space_create() re-use global &address_space_memory Date: Thu, 19 Aug 2021 16:20:39 +0200 Message-Id: <20210819142039.2825366-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We already have a global AddressSpace created along with the global get_system_memory(): address_space_memory. Return it directly instead of creating the same AS with a different name. This drastically reduce 'info mtree' on some boards (diff -c100): (echo info mtree; echo q) | ./qemu-system-aarch64 -S -monitor stdio -M raspi3b QEMU 6.0.93 monitor - type 'help' for more information (qemu) info mtree address-space: memory 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000003fffffff (prio 0, ram): ram 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp 000000003f006000-000000003f006fff (prio 0, i/o): mphi 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio 000000003f201000-000000003f201fff (prio 0, i/o): pl011 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 0000000040000000-00000000400000ff (prio 0, i/o): bcm2836-control address-space: I/O 0000000000000000-000000000000ffff (prio 0, i/o): io address-space: bcm2835-mbox-memory 0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox 0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb 0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property address-space: bcm2835-fb-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: bcm2835-property-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: bcm2835-dma-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: dwc2 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff - address-space: cpu-secure-memory-0 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system - 0000000000000000-000000003fffffff (prio 0, ram): ram - 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals - 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer - 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp - 000000003f006000-000000003f006fff (prio 0, i/o): mphi - 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma - 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic - 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 - 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox - 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt - 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman - 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng - 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio - 000000003f201000-000000003f201fff (prio 0, i/o): pl011 - 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost - 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s - 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 - 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 - 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp - 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal - 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis - 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux - 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci - 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi - 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 - 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 - 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus - 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 - 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 - 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io - 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo - 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d - 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc - 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 - 0000000040000000-00000000400000ff (prio 0, i/o): bcm2836-control - - address-space: cpu-memory-0 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-1 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-1 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-2 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-2 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-3 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-3 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - memory-region: ram 0000000000000000-000000003fffffff (prio 0, ram): ram memory-region: bcm2835-peripherals 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp 000000003f006000-000000003f006fff (prio 0, i/o): mphi 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio 000000003f201000-000000003f201fff (prio 0, i/o): pl011 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 (qemu) q Inspired-by: Jianxian Wen Signed-off-by: Philippe Mathieu-Daudé --- Note, we loose the specific description of the duplicated address spaces, but this doesn't seem very useful in this output, it is rather more confusing IMO. --- softmmu/memory.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/softmmu/memory.c b/softmmu/memory.c index 16a2b518d8d..e4506b5a0d5 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2941,6 +2941,10 @@ AddressSpace *address_space_create(MemoryRegion *root, const char *name) { AddressSpace *as; + if (root == get_system_memory()) { + return &address_space_memory; + } + as = g_new(AddressSpace, 1); address_space_init(as, root, name); @@ -2961,6 +2965,10 @@ void address_space_destroy(AddressSpace *as) { MemoryRegion *root = as->root; + if (as == &address_space_memory) { + return; + } + /* Flush out anything from MemoryListeners listening in on this */ memory_region_transaction_begin(); as->root = NULL;