From nobody Mon Feb 9 16:19:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1630513195; cv=none; d=zohomail.com; s=zohoarc; b=EhD+/OcPia5+fgNH8feB+CHDvjKL1wBrKg+HXqRcxVK1Vrdw9kTmUWL+imbIhS2ZW8126eXDpuItAE29uQLGzi5UVWhsYXRCVBVenZJTJGvTI0xc+Z1ZUmWWj62bQwmixah1cyrDM2vHDfzPyQfxZyitJdsHHFQq0U/VJ6p31ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630513195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tAiJThYlf1S7x56S9WL4YRBDxzxck2gItvUxPEZ3WZ0=; b=i3pLfPOuNdp/QHLfP+V5dZR2MhWWUEA1LGJAnJ3vu+j/duaj2IY/Yu/2X0eLlzPNThypkwPjKqz43bdol/4hysIYuKfm0uW/tJjguobBW7aMkroPhUQYJ4KbmA2Wqs55Se1x8lk0DWalgwkSr/BschWExf5IpSL43u12i7RTCQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630513195487594.5253455842079; Wed, 1 Sep 2021 09:19:55 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-117-Pr-UOv1EM0GtoJ92kO_Qrg-1; Wed, 01 Sep 2021 12:19:50 -0400 Received: by mail-wm1-f70.google.com with SMTP id m16-20020a7bca50000000b002ee5287d4bfso20844wml.7 for ; Wed, 01 Sep 2021 09:19:50 -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 o15sm6273559wra.3.2021.09.01.09.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 09:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630513194; 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=tAiJThYlf1S7x56S9WL4YRBDxzxck2gItvUxPEZ3WZ0=; b=U6crk7wUmttDgntYBlQDUYTsR251dkdo73g0IuKz7YQFXa9X6WfToTgFCd72hpE5FB71Dg phZAoyo0DdNlcO/D/g5We8ZHkLjhoRCwXLYMXIBtRzlVcj1OI5yv4AKFFOHqZ1+pDj8r/d EvUteoq6QLRXygs5fBQ1bMCcfGH7CZg= X-MC-Unique: Pr-UOv1EM0GtoJ92kO_Qrg-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=tAiJThYlf1S7x56S9WL4YRBDxzxck2gItvUxPEZ3WZ0=; b=XpqwAQJgZmEZkn429UaYdxGP7s7D9kLmBfX2h934g3WxF344RfWbyEkbi0MygVqor7 EvR8ORGnvHdHH9VdgmwoGPLnkAoFzb3O/2/aSB+/R8PVrq9P8VNOLMAdEzBjTUd9xI2N EK+PFWB1NombfABEYC59SHct8auFEZj3sGvdVCGk5FYS/zzxslD8zAiE/M0UF3b0igci dBv222+Te66PC+mY+3NkPTGO6BAsKVqNBycp+iYyFb9Eu+wq5qjY/9iGMM+pulXXfrTO bFdmACkwHCUevBevZCeyUXd/jhvNnodj4iXqCcnwue/GB4FTf8H6m2r2FIMIF3Dp+NSu M/Ww== X-Gm-Message-State: AOAM532EAZazF6O/xVZ1R65H4fl9ViV/ckyJ8+rQ8WHOQXZgkxrKgQTY 7gOlkkKb6SfY3QYPgD0bWo4xyFHu3BBSu9EaBeSml0dPIXTurhsX2mcdqArvLMx5x8h//dmfaH1 RUPxwhHbcBbLS/Q== X-Received: by 2002:adf:fd8c:: with SMTP id d12mr186608wrr.21.1630513189689; Wed, 01 Sep 2021 09:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQUi9fb8zCAfTxFoBTcrpsjRDxcs2UQiylWLGolXdY2BluMogTiqqv3xmyf20DdhU1/3WS7w== X-Received: by 2002:adf:fd8c:: with SMTP id d12mr186589wrr.21.1630513189532; Wed, 01 Sep 2021 09:19:49 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Paolo Bonzini , Peter Xu , Gerd Hoffmann , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v4 1/3] memory: Extract mtree_info_flatview() from mtree_info() Date: Wed, 1 Sep 2021 18:19:41 +0200 Message-Id: <20210901161943.4174212-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210901161943.4174212-1-philmd@redhat.com> References: <20210901161943.4174212-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: 1630513196969100003 While mtree_info() handles both ASes and flatviews cases, the two cases share basically no code. Split mtree_info_flatview() out of mtree_info() to simplify. Note: Patch easier to review using 'git-diff --color-moved=3Dblocks'. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Reviewed-by: Richard Henderson --- softmmu/memory.c | 72 ++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index bfedaf9c4df..3eb6f52de67 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3246,6 +3246,44 @@ static gboolean mtree_info_flatview_free(gpointer ke= y, gpointer value, return true; } =20 +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); +} + void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabl= ed) { MemoryRegionListHead ml_head; @@ -3253,39 +3291,7 @@ void mtree_info(bool flatview, bool dispatch_tree, b= ool owner, bool disabled) 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); + mtree_info_flatview(dispatch_tree, owner); =20 return; } --=20 2.31.1