From nobody Mon Feb 9 08:57:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630563975; cv=none; d=zohomail.com; s=zohoarc; b=FDo5/bh8cG8pA82XYx4nl1fEE+AwaegcGEnEuF5T1BC6HOT+IpI0YjZ1dATbBtUsNfPbmc0DbZbA+kLSovw3rFEbth0M1cpv9sqyt5pVDyMGJZRtSHhCvNLxGrB5fCF9N+X7JM1tZcZz2WuRE7QlX9LRPKOjk+teu0yrLEO9gjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630563975; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=axU1eGtomFFs/YWvr0SMZ0YoAylghsRvdBxczilBqhA=; b=PfWKx2nUsjJ65boCKKySvg7xnklhxa5WBkL72jdrpr/2UC7Khku2R4hbpQl9Lt06i6w5d8zSjOpSdjGhGgPWlIJyEXn0SWU3YKZxmIj7DHdSjAdumJ6xC+CsroSWnSN0bWFDuiLaN3HVjiugCWPq4pFi3NxFSeDn9HBfj6ZxD+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1630563975302287.0833243142748; Wed, 1 Sep 2021 23:26:15 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-ODeDcCpVNbO4nylhAObsTA-1; Thu, 02 Sep 2021 02:26:12 -0400 Received: by mail-wr1-f71.google.com with SMTP id v18-20020adfe2920000b029013bbfb19640so186710wri.17 for ; Wed, 01 Sep 2021 23:26:12 -0700 (PDT) Return-Path: Return-Path: 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 a133sm716565wme.5.2021.09.01.23.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 23:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630563974; 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=axU1eGtomFFs/YWvr0SMZ0YoAylghsRvdBxczilBqhA=; b=d5/In5e+B6XREEMLDawV4aILtakYisqSyqaaXGP/uGh9JqjCle2CdH/bq4WeoVuEAiuiyb SSwV28MzTLt3dPZnrM1XG2dFAhYlwjqLMj0nygGXCEFfiJciL8woiijtDQLg1NtqIfPzSW /RvEDg+MU/jr5V1DxakdRhRVhbFBuTc= X-MC-Unique: ODeDcCpVNbO4nylhAObsTA-1 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=axU1eGtomFFs/YWvr0SMZ0YoAylghsRvdBxczilBqhA=; b=KNQHyrV1K8+cchCnaePgBDMF2sZXmY4CNHBsAtj8okj2v7nAFTZ0Cz15mjbb0KIs4i u1sTEeN3C2TBjXQzLEeUip/l1c67L6Mlqf3ndkjRcam+eBQzDoPwqD/ABY7s9zidYrWe TTSQ+GL6+h42tF+VAJU5L6AXaLfHfp30Zg4CO6Aunsm65Fgqx2MhvPxjhdJzXtWjyxYt zsxjS5Vm84/6eoRN2fJ2UmVfhm6wMSfp1gB5UnqfDE+cgPZTF6GTGisNrC7oHaFGn849 4QCkczn9cLVGbMbanrF5D0o0W24WDWKM8N3bWgm4nczYepjNOFChJmmEW1W/JMzlJDhq qKJQ== X-Gm-Message-State: AOAM530KngDglQSc3uUJhjdMBDZzbknEy2NkIUUFCeUlme0MLS3go89r aupPC+cP91jS/gAGoJ8OeUlPTsFDKfxve0Za5k03+tA4ya7ROrgzbcg5vo5wZAKaPHlEMzlSWed zREESKadkLs9YYg== X-Received: by 2002:a05:600c:350b:: with SMTP id h11mr1388915wmq.101.1630563970313; Wed, 01 Sep 2021 23:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJythrPuQcQAGFwmlP+GprwYn0Omg7UL4Va9MWSc8udffXt4K6RTw3n4VuMfebcHo9WfGGFGoQ== X-Received: by 2002:a05:600c:350b:: with SMTP id h11mr1388886wmq.101.1630563970033; Wed, 01 Sep 2021 23:26:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Xu , Paolo Bonzini , Gerd Hoffmann , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v5 1/2] memory: Split mtree_info() as mtree_info_flatview() + mtree_info_as() Date: Thu, 2 Sep 2021 08:26:03 +0200 Message-Id: <20210902062604.182620-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902062604.182620-1-philmd@redhat.com> References: <20210902062604.182620-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630563976413100001 While mtree_info() handles both ASes and flatviews cases, the two cases share basically no code. Split mtree_info() as mtree_info_flatview() + mtree_info_as() to simplify. Suggested-by: Peter Maydell Reviewed-by: David Hildenbrand Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu --- softmmu/memory.c | 87 ++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index bfedaf9c4df..5be7d5e7412 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3246,50 +3246,50 @@ static gboolean mtree_info_flatview_free(gpointer k= ey, gpointer value, return true; } =20 -void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabl= ed) +static void mtree_info_flatview(bool dispatch_tree, bool owner) +{ + struct FlatViewInfo fvi =3D { + .counter =3D 0, + .dispatch_tree =3D dispatch_tree, + .owner =3D owner, + }; + AddressSpace *as; + FlatView *view; + GArray *fv_address_spaces; + GHashTable *views =3D g_hash_table_new(g_direct_hash, g_direct_equal); + AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); + + if (ac->has_memory) { + fvi.ac =3D ac; + } + + /* Gather all FVs in one table */ + QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { + view =3D address_space_get_flatview(as); + + fv_address_spaces =3D g_hash_table_lookup(views, view); + if (!fv_address_spaces) { + fv_address_spaces =3D g_array_new(false, false, sizeof(as)); + g_hash_table_insert(views, view, fv_address_spaces); + } + + g_array_append_val(fv_address_spaces, as); + } + + /* Print */ + g_hash_table_foreach(views, mtree_print_flatview, &fvi); + + /* Free */ + g_hash_table_foreach_remove(views, mtree_info_flatview_free, 0); + g_hash_table_unref(views); +} + +static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; AddressSpace *as; =20 - if (flatview) { - FlatView *view; - struct FlatViewInfo fvi =3D { - .counter =3D 0, - .dispatch_tree =3D dispatch_tree, - .owner =3D owner, - }; - GArray *fv_address_spaces; - GHashTable *views =3D g_hash_table_new(g_direct_hash, g_direct_equ= al); - AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); - - if (ac->has_memory) { - fvi.ac =3D ac; - } - - /* Gather all FVs in one table */ - QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { - view =3D address_space_get_flatview(as); - - fv_address_spaces =3D g_hash_table_lookup(views, view); - if (!fv_address_spaces) { - fv_address_spaces =3D g_array_new(false, false, sizeof(as)= ); - g_hash_table_insert(views, view, fv_address_spaces); - } - - g_array_append_val(fv_address_spaces, as); - } - - /* Print */ - g_hash_table_foreach(views, mtree_print_flatview, &fvi); - - /* Free */ - g_hash_table_foreach_remove(views, mtree_info_flatview_free, 0); - g_hash_table_unref(views); - - return; - } - QTAILQ_INIT(&ml_head); =20 QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { @@ -3310,6 +3310,15 @@ void mtree_info(bool flatview, bool dispatch_tree, b= ool owner, bool disabled) } } =20 +void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabl= ed) +{ + if (flatview) { + mtree_info_flatview(dispatch_tree, owner); + } else { + mtree_info_as(dispatch_tree, owner, disabled); + } +} + void memory_region_init_ram(MemoryRegion *mr, Object *owner, const char *name, --=20 2.31.1