From nobody Tue Feb 10 01:59:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1630685196; cv=none; d=zohomail.com; s=zohoarc; b=RYmHuJA2Ej13CyQgyDSsu2bZsb73wXPTKEvSTMhL/3ryk7e2G4EMysFpLtjzIK4BUkWkSwCShQKREsYFYrNxiboW5h/WM15qxIsETBKZxntXlTQiXz4C+nqsRHkSZkWqqP6zxpFN75pHRjphhV/paqx+8laQk0haGMtq63WKyHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630685196; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Iw9k0Bp351OSq0GNnrA6pD6+12eNcWfk/Y1LfqMHJS0=; b=QLNm4616QPstaTaWCoA/Td21oOvaGzB2jtSN0fb4Gb80hKxs4Ggs1bVRCzP80DyDOtY1p5R+WXAp9T6MPNXGI5Bwr2DGYi1RwkqXygIA1FARPUPswO8WsBUJwmdNVSjYT5mPzZ60zLD5WQUD1Cmx/9QJo7mBjZG57nKywYDPUHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1630685196382520.9493233405216; Fri, 3 Sep 2021 09:06:36 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-2svAQvDYM8CSUursy_KvYQ-1; Fri, 03 Sep 2021 12:06:33 -0400 Received: by mail-wr1-f69.google.com with SMTP id m16-20020a056000181000b0015964e4ae48so700632wrh.14 for ; Fri, 03 Sep 2021 09:06:33 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id z2sm4500133wma.45.2021.09.03.09.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 09:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630685195; 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=Iw9k0Bp351OSq0GNnrA6pD6+12eNcWfk/Y1LfqMHJS0=; b=CupUxF8No4St+6RjxDLXE/QGK44Jwn93sKXl7C08Yjv9OmzwarwJv5HLbQqCkUoP9XUduf o1NDPlvu2s0gmOTDaxrc5/Z2a3Clg/eWl6iqq6H2AAa68+Y212pIQYQlSlY+l1+kS72qxs 0Beo010ULApTjIXCoEwwujDqjJ5/Ji8= X-MC-Unique: 2svAQvDYM8CSUursy_KvYQ-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=Iw9k0Bp351OSq0GNnrA6pD6+12eNcWfk/Y1LfqMHJS0=; b=AsR3qA+FSRTrxLlZDW0nT3iYhQCpnMNSJ3YTAzXc03zCN2jkxJZ2NFXbJrqOWVSzkQ VGTJP9Cht5LpEATJdkgC4D7qR1zTRh93k6Om50ZGqB3zWLIwW8G7Tq6O71He95yo3bkp BZM+mNjymzUSA1SlqWi+LpsWW1HH1CUjQPFMG95bB7bZAxeqeU4aVBUCG+wB8E4+tfZO qSqlB6CFVy816cmcMdw2kkh/HIp6GsNG+Zg/k2rgz0u/0kizQKwBjaD5fGwBd1XGxk/O TlTK6/mmf11UTL1xU/3Yl7EN+qLFugq1x6ghHCew5vjity/lvdB56Rd0SM6ZRLozr64d +aMQ== X-Gm-Message-State: AOAM532nFfjI/0l+QD8ORRPoKpNgpUZmuqQGu9bqM0iH+/BFafKKin8c P4WFwgvL5wuqjQj/hbrGQAdSBqX3ynINvCORtX8lua/oYEtt340LtwzfoH7fy404hgtSCGzZ6Vs K83yRWH4KIQ6WMw== X-Received: by 2002:a5d:63d2:: with SMTP id c18mr5051192wrw.240.1630685190809; Fri, 03 Sep 2021 09:06:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSQbt3qV2bzmAvywjF0y1oNeSuwfb+9gpQUEYW05q0H3vHX32DqHb0mSW7j/sLCTvvrkdahg== X-Received: by 2002:a5d:63d2:: with SMTP id c18mr5051172wrw.240.1630685190651; Fri, 03 Sep 2021 09:06:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , David Hildenbrand , Gerd Hoffmann , Peter Xu , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v6 1/2] memory: Split mtree_info() as mtree_info_flatview() + mtree_info_as() Date: Fri, 3 Sep 2021 18:06:18 +0200 Message-Id: <20210903160619.699632-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903160619.699632-1-philmd@redhat.com> References: <20210903160619.699632-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: 1630685198402100001 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 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 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