From nobody Tue Feb 10 12:40:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) client-ip=209.85.128.42; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f42.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=quarantine dis=quarantine) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1642507362; cv=none; d=zohomail.com; s=zohoarc; b=bR/2VV5F+45Sv/fCwus24D7O3AXc2HCES5Rz83FDV+rWhjStUhPjNWh6wIFPjlemkYNAh4yBX7jsh7myRcrInmOGqeE1veCgUJwB3ISBr8AtYgcFYhdAEzQBIeKXyUk//IPsqlpW/rOeRtiEWvJYb2dmxy/6Whtubb2L7xkSOPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642507362; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DWxXs/yisq3shP3JsRPbu1icyNFhILJ+qdkOwqqhAt0=; b=YMAJMagI/dcrHkaM6YOlPaYRF7tuNS1vT5S71cWbLirI5kL6W1j4lQqE8YtstdTw6PeieVQshdznXXqKo/ud2W7zz+T6UZv5kx8G/UzWgPP5WH99LvEf69SG/EH+T5q/+Van2bcIBcoEth4Nt01htR5Ms5MciZK5EtYJOxXiunY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.zohomail.com with SMTPS id 1642507362143945.4189859937055; Tue, 18 Jan 2022 04:02:42 -0800 (PST) Received: by mail-wm1-f42.google.com with SMTP id az27-20020a05600c601b00b0034d2956eb04so4333116wmb.5 for ; Tue, 18 Jan 2022 04:02:41 -0800 (PST) Return-Path: Return-Path: Received: from nuc.. (154.red-83-50-83.dynamicip.rima-tde.net. [83.50.83.154]) by smtp.gmail.com with ESMTPSA id g17sm3089762wmq.9.2022.01.18.04.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 04:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DWxXs/yisq3shP3JsRPbu1icyNFhILJ+qdkOwqqhAt0=; b=O5L7l8X7EPmelOOW+n4cyoT9OMiWkBqCqr2cyEDt2As2s5dz/GKyveZo4LdYIgReRL JqXApVKoeFl/KorAES+Ebmg8Djy1bX8tcdHZ6appLtqTVBEtiyFjX4XUZTn2NKZ6+2Bf 2kQUKi+Z/Dv2AMK1cU9btdBFC14zS4nQg0YBwJXapDrXVZe2Nzb7/ZgCeqOF3BejEXBl WqRSkyYFPY1Tbb6MKAkhPOA2yftgme3qcp7WyY7KnpznTSTAJJ7+79rWVDk6jJMDxFbU JcMbQWm8zs8iG1xnsNjwwznn1O0sPcUYyIw/yBXkXpcPMw/Tm0XCTaRtoKhjaKYqneb1 jgPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DWxXs/yisq3shP3JsRPbu1icyNFhILJ+qdkOwqqhAt0=; b=hY5//QfONAiee2XV4f1Kik4YIKqyhn3r5+N73jizfpLXhTJ/+c31V51xpRdycBDQED 2GNZ+5QKyfR2Ziuh23Ds/e2c1QTeykH6Nljzv/hHQuZtNzGqiHKg1apfR5smFvpp8JKk AoY9TZPTrFQG1R3RABvNlnXoR8tdgBUAyGsgUO2eEakUIakgfX6crc1TflKUX24/apa0 BwVdG7dD/pxRbKHrJMgfh+bY3JA5IKN1l5xCaKrmmxHUkMQRLAFDpM/x2t6CQqD1416b 1+8ZSE4usPqaIVxPkczF5rLwOumDj5axUm60Ev/QatlGBDVINF8icu5HjagjCVF/XAZF o56g== X-Gm-Message-State: AOAM530dK/xjanh1ii+kIDijr7HSH8hSlkqHMV970OlUVmsEUjsmKmy4 D66SNwTKmT70aYUs7qF+NP8= X-Google-Smtp-Source: ABdhPJzT3j/PZ1SIy36c3A1rH/4JTGLVogV14luxYuulCccOOXeALBnYPgMQ1O6MIBvl748/MP/OHw== X-Received: by 2002:a05:600c:35d0:: with SMTP id r16mr17408118wmq.195.1642507360375; Tue, 18 Jan 2022 04:02:40 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , David Hildenbrand , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/19] memory: Split mtree_info() as mtree_info_flatview() + mtree_info_as() Date: Tue, 18 Jan 2022 13:02:12 +0100 Message-Id: <20220118120229.196337-3-f4bug@amsat.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118120229.196337-1-f4bug@amsat.org> References: <20220118120229.196337-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1642507362682100001 From: Philippe Mathieu-Daud=C3=A9 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 Reviewed-by: Peter Xu Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210904231101.1071929-2-philmd@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/memory.c | 87 ++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index 0c463e0fe53..2cb823c642f 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3284,50 +3284,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) { @@ -3348,6 +3348,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.34.1