From nobody Tue Nov 4 15:31:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219031584748.4665491325457; Thu, 28 Jun 2018 13:50:31 -0700 (PDT) Received: from localhost ([::1]:38524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYds6-0003Nc-QJ for importer@patchew.org; Thu, 28 Jun 2018 16:50:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAz-0007eg-W4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAy-0000zs-F4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:57 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:51042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAy-0000yV-4V for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:56 -0400 Received: by mail-wm0-x233.google.com with SMTP id e16-v6so10988119wmd.0 for ; Thu, 28 Jun 2018 13:05:56 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fV3TtfIT7p+pqtrmvhOtYj5D5G8NxO1/wN0xoD8R1sk=; b=n1txqVjrktjzPy51tjRnY2G/Vq6ifLzGD9zMB+dpruIK1h1hHR16NpHygTR1QKSRBn n1Cg9Kg17QVUm0+PpnWsAFCK0DCd1M6ZuxKVmtSBw6p/k0xSwRsUDguOfkvLB8XVMS7B 00HBip96x9D4rRqrkoYR8swIovNzZt+SHG68FxrGIRLdTXzPcmIXiztVUyViRKiRFEm0 44bOfinVi8d6p5U0OH3anzqDcVT9cB4H+6ovcN+mnH8H2QrmpDIuSOwqbM2TGFDhzJ39 WtIhtcYduC9012IMoV3gsRpqNRm1YgyfCZUFAxwxbEqYJqR3JKNeOMvHu0nrsnGC2FlH nWSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=fV3TtfIT7p+pqtrmvhOtYj5D5G8NxO1/wN0xoD8R1sk=; b=PhEROC2iF/NgOr5MeXK+9gL97GlzkE7dOt8OH/p9/SLaoDZg8Jb4enMd7LRGV63Z7F MWj+KatTryNoFypL0LayoizG3iG71jHmIRA/yyCuK3HdYC2MdJ+eGPgJJOU0+fzycYqh onXME5NjMuU0qqWzx2DHHMbOtVdeXOg2Ox+H9OIAyj7s8He8wI330M92E+UeImFRTi05 reeDL1QUvUhYO8VKgRR17iHGoH8HNOoLeVV80SghTkE1dnrq4KYT9AlEigJdkeRGwuFO aA/LwVoZJhSim2YK6MjqTt7vw67Z6hCJZx6t5UwkZIjdVcZw7Z/NxylATj/FeHWHtadj CgwQ== X-Gm-Message-State: APt69E309fd0nGVAQJC8dPxvU5tlEnV73Rgv0ymtrd4h7CgNpIxDsHTA Zntnhah8NILewu1W/kifHYF3ESzD X-Google-Smtp-Source: AAOMgpfxDqltjzLzrWEjrdNwaFuhNHVp5crf7QlSujfVxFCaoFwJZueNkyBYrnNTOc+p0S+yXtnt2Q== X-Received: by 2002:a1c:1205:: with SMTP id 5-v6mr3666730wms.41.1530216354767; Thu, 28 Jun 2018 13:05:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:52 +0200 Message-Id: <1530216310-52873-43-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::233 Subject: [Qemu-devel] [PULL 42/60] memory/hmp: Print owners/parents in "info mtree" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy This adds owners/parents (which are the same, just occasionally owner=3D=3DNULL) printing for memory regions; a new '-o' flag enabled new output. Signed-off-by: Alexey Kardashevskiy Message-Id: <20180604032511.6980-1-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 7 ++--- include/exec/memory.h | 2 +- memory.c | 72 ++++++++++++++++++++++++++++++++++++++++++++---= ---- monitor.c | 4 ++- 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 6db3457..59bdd8f 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -253,10 +253,11 @@ ETEXI =20 { .name =3D "mtree", - .args_type =3D "flatview:-f,dispatch_tree:-d", - .params =3D "[-f][-d]", + .args_type =3D "flatview:-f,dispatch_tree:-d,owner:-o", + .params =3D "[-f][-d][-o]", .help =3D "show memory tree (-f: dump flat view for address = spaces;" - "-d: dump dispatch tree, valid with -f only)", + "-d: dump dispatch tree, valid with -f only);" + "-o: dump region owners/parents", .cmd =3D hmp_info_mtree, }, =20 diff --git a/include/exec/memory.h b/include/exec/memory.h index 050323f..448d41a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1665,7 +1665,7 @@ void memory_global_dirty_log_start(void); void memory_global_dirty_log_stop(void); =20 void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree); + bool dispatch_tree, bool owner); =20 /** * memory_region_request_mmio_ptr: request a pointer to an mmio diff --git a/memory.c b/memory.c index 21aa57d..e9cd446 100644 --- a/memory.c +++ b/memory.c @@ -2858,10 +2858,49 @@ typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) Memo= ryRegionListHead; int128_sub((size), int128_one())) : 0) #define MTREE_INDENT " " =20 +static void mtree_expand_owner(fprintf_function mon_printf, void *f, + const char *label, Object *obj) +{ + DeviceState *dev =3D (DeviceState *) object_dynamic_cast(obj, TYPE_DEV= ICE); + + mon_printf(f, " %s:{%s", label, dev ? "dev" : "obj"); + if (dev && dev->id) { + mon_printf(f, " id=3D%s", dev->id); + } else { + gchar *canonical_path =3D object_get_canonical_path(obj); + if (canonical_path) { + mon_printf(f, " path=3D%s", canonical_path); + g_free(canonical_path); + } else { + mon_printf(f, " type=3D%s", object_get_typename(obj)); + } + } + mon_printf(f, "}"); +} + +static void mtree_print_mr_owner(fprintf_function mon_printf, void *f, + const MemoryRegion *mr) +{ + Object *owner =3D mr->owner; + Object *parent =3D memory_region_owner((MemoryRegion *)mr); + + if (!owner && !parent) { + mon_printf(f, " orphan"); + return; + } + if (owner) { + mtree_expand_owner(mon_printf, f, "owner", owner); + } + if (parent && parent !=3D owner) { + mtree_expand_owner(mon_printf, f, "parent", parent); + } +} + static void mtree_print_mr(fprintf_function mon_printf, void *f, const MemoryRegion *mr, unsigned int level, hwaddr base, - MemoryRegionListHead *alias_print_queue) + MemoryRegionListHead *alias_print_queue, + bool owner) { MemoryRegionList *new_ml, *ml, *next_ml; MemoryRegionListHead submr_print_queue; @@ -2907,7 +2946,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, } mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): alias %s @%s " TARGET_FMT_plx - "-" TARGET_FMT_plx "%s\n", + "-" TARGET_FMT_plx "%s", cur_start, cur_end, mr->priority, memory_region_type((MemoryRegion *)mr), @@ -2916,15 +2955,22 @@ static void mtree_print_mr(fprintf_function mon_pri= ntf, void *f, mr->alias_offset, mr->alias_offset + MR_SIZE(mr->size), mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mon_printf, f, mr); + } } else { mon_printf(f, - TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s= \n", + TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s= ", cur_start, cur_end, mr->priority, memory_region_type((MemoryRegion *)mr), memory_region_name(mr), mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mon_printf, f, mr); + } } + mon_printf(f, "\n"); =20 QTAILQ_INIT(&submr_print_queue); =20 @@ -2947,7 +2993,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { mtree_print_mr(mon_printf, f, ml->mr, level + 1, cur_start, - alias_print_queue); + alias_print_queue, owner); } =20 QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, mrqueue, next_ml) { @@ -2960,6 +3006,7 @@ struct FlatViewInfo { void *f; int counter; bool dispatch_tree; + bool owner; }; =20 static void mtree_print_flatview(gpointer key, gpointer value, @@ -3000,7 +3047,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, mr =3D range->mr; if (range->offset_in_region) { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx "\n", + TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx, int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, @@ -3009,13 +3056,17 @@ static void mtree_print_flatview(gpointer key, gpoi= nter value, range->offset_in_region); } else { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s\n", + TARGET_FMT_plx " (prio %d, %s): %s", int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, range->readonly ? "rom" : memory_region_type(mr), memory_region_name(mr)); } + if (fvi->owner) { + mtree_print_mr_owner(p, f, mr); + } + p(f, "\n"); range++; } =20 @@ -3041,7 +3092,7 @@ static gboolean mtree_info_flatview_free(gpointer key= , gpointer value, } =20 void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree) + bool dispatch_tree, bool owner) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; @@ -3053,7 +3104,8 @@ void mtree_info(fprintf_function mon_printf, void *f,= bool flatview, .mon_printf =3D mon_printf, .f =3D f, .counter =3D 0, - .dispatch_tree =3D dispatch_tree + .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); @@ -3085,14 +3137,14 @@ void mtree_info(fprintf_function mon_printf, void *= f, bool flatview, =20 QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { mon_printf(f, "address-space: %s\n", as->name); - mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head); + mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head, owner); mon_printf(f, "\n"); } =20 /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { mon_printf(f, "memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head); + mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head, owner); mon_printf(f, "\n"); } =20 diff --git a/monitor.c b/monitor.c index 0730a27..0988eb4 100644 --- a/monitor.c +++ b/monitor.c @@ -2007,8 +2007,10 @@ static void hmp_info_mtree(Monitor *mon, const QDict= *qdict) { bool flatview =3D qdict_get_try_bool(qdict, "flatview", false); bool dispatch_tree =3D qdict_get_try_bool(qdict, "dispatch_tree", fals= e); + bool owner =3D qdict_get_try_bool(qdict, "owner", false); =20 - mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_t= ree); + mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_t= ree, + owner); } =20 static void hmp_info_numa(Monitor *mon, const QDict *qdict) --=20 1.8.3.1