From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250835; cv=none; d=zohomail.com; s=zohoarc; b=QEcm8IILjAYK/8mTftdBPWemtlS1yHn6+mQ+jb4NlJrixa6GJzvY+NdvjxfJwpV35Lpl+tIAiCIIN1yFodC7cDkxrko8S1py3bjO2Vx1WoZQnb5a17pCDsxJ+ey48SXzS6xJ1+sKXOjS/IyWwWXl83Vw/3ijwdGKc+zRZIhZUnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250835; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p/W6/kz7VuD287OKmOjU7aNE//F1vy6wR+oe/2sb3P4=; b=PwYIEbY49zzPuS9nONUnc3KOlysyVv6b2GTDScc7CtPgPCK+xvOrfAROLWMwOVAh1m7FaERfP2OuRyOJhTnpTuWH92pIZ/C+CbUDJdx82Z+VSjvqkgFWRdWubiWpve7iDdfU7RFzsWbmgMhyjLoYhIMH90yZW4yrvQzkqmcDQSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250835428909.1598317831046; Mon, 9 Nov 2026 11:00:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUaa-0001Es-D9; Mon, 09 Nov 2026 13:59:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaT-0001DT-Ft for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaR-0006Dt-5N for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:25 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-Uu7lIUJtOUmgZqlUQ2aYAw-1; Mon, 09 Nov 2026 13:59:18 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 043061800660; Mon, 9 Nov 2026 18:59:16 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 017891956089; Mon, 9 Nov 2026 18:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p/W6/kz7VuD287OKmOjU7aNE//F1vy6wR+oe/2sb3P4=; b=Bt5GGm6YRhyY/07GZWh+Ide2NzmiGyG/AY2u1VHdQFCGl6H1ZA6tRgdGmiagELA3M9my7P ASGNsed1MR00y2LaWhGBxg0/aSUSZ0qLMoOHHkHfmgLVmYZ0EsA5f6C2xi4DjE1FOkgNYg +H74o6UNzQtHyE8yUgpQ56+Owhsco7Q= X-MC-Unique: Uu7lIUJtOUmgZqlUQ2aYAw-1 X-Mimecast-MFC-AGG-ID: Uu7lIUJtOUmgZqlUQ2aYAw_1794250757 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 1/7] debug/mem: add utility to name anonymous memory mappings Date: Mon, 9 Nov 2026 13:59:01 -0500 Message-ID: <20261109185907.3220584-2-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250837330158500 Content-Type: text/plain; charset="utf-8" Add support to name mmap'd memory regions using PR_SET_VMA_ANON_NAME. On supported platforms, the QEMU utility functions are no-ops. This is useful primarily for debugging and profiling QEMU; beind able to see and correlate each VMA segment with a specific use within QEMU. Signed-off-by: John Snow --- include/qemu/mmap-vma.h | 18 +++++++++++ util/mmap-vma.c | 67 +++++++++++++++++++++++++++++++++++++++++ util/meson.build | 1 + 3 files changed, 86 insertions(+) create mode 100644 include/qemu/mmap-vma.h create mode 100644 util/mmap-vma.c diff --git a/include/qemu/mmap-vma.h b/include/qemu/mmap-vma.h new file mode 100644 index 00000000000..763ea5a5cab --- /dev/null +++ b/include/qemu/mmap-vma.h @@ -0,0 +1,18 @@ +/* + * Utility for naming VMA allocations in linux + * + * Copyright (c) Red Hat, Inc 2026 + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __QEMU_MMAP_VMA_H +#define __QEMU_MMAP_VMA_H + +#include +#include "osdep.h" + +int qemu_name_vma(void *ptr, size_t sz, const char *fmt, ...) + G_GNUC_PRINTF(3, 4); + +#endif diff --git a/util/mmap-vma.c b/util/mmap-vma.c new file mode 100644 index 00000000000..7dcef3b7455 --- /dev/null +++ b/util/mmap-vma.c @@ -0,0 +1,67 @@ +/* + * Utility for naming VMA allocations in linux + * + * Copyright (c) Red Hat, Inc 2026 + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ +#include "qemu/mmap-vma.h" +#include "qemu/osdep.h" + +#include +#include +#include + +#if defined(__linux__) +#include +#endif + +#define VMA_PREFIX " qemu: " +#define VMA_MAXLEN 80 + +/* + * Give a human-readable name to a previously mmap'd memory segment. + * This feature is only available on Linux >=3D 5.17, and only when the + * kernel was configured with CONFIG_ANON_VMA_NAME=3Dy. + * + * For systems without this option, prctl() will return -1 and set + * errno to EINVAL, and can be safely ignored. + * + * For systems with this option, these human-readable names will be + * visible in /proc/$pid/[s]maps, pmap output, etc. + */ +G_GNUC_PRINTF(3, 0) +static int qemu_vname_vma(void *ptr, size_t sz, const char *fmt, va_list a= rgs) +{ + int rc =3D 0; + +#if defined(PR_SET_VMA_ANON_NAME) + char strbuf[VMA_MAXLEN]; + + assert(sizeof(VMA_PREFIX) < sizeof(strbuf)); + strncpy(strbuf, VMA_PREFIX, sizeof(strbuf)); + rc =3D vsnprintf(strbuf + sizeof(VMA_PREFIX), + sizeof(strbuf) - sizeof(VMA_PREFIX), fmt, args); + if (rc < 0) { + return -errno; + } else if (rc >=3D (sizeof(strbuf) - sizeof(VMA_PREFIX))) { + sprintf(strbuf + sizeof(strbuf) - 4, "..."); + } + + rc =3D prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, sz, strbuf); + if (rc) { + return -errno; + } +#endif + + return rc; +} + +G_GNUC_PRINTF(3, 4) +int qemu_name_vma(void *ptr, size_t sz, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + return qemu_vname_vma(ptr, sz, fmt, args); +} diff --git a/util/meson.build b/util/meson.build index fa174c07a57..861ee228d5b 100644 --- a/util/meson.build +++ b/util/meson.build @@ -1,5 +1,6 @@ util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c= ')) util_ss.add(files('thread-context.c'), numa) +util_ss.add(files('mmap-vma.c')) if host_os !=3D 'windows' util_ss.add(files('aio-posix.c')) util_ss.add(files('fdmon-poll.c')) --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250852; cv=none; d=zohomail.com; s=zohoarc; b=bRxx3YkU6LHN3AlsTDWl7LI4kGC3NJTaO/nBFlNUG+Qlmq8AcYdlsOIloQ3e6GOy4oNDs7lJPM0MBfQsJWH5BZF3/6q2bwpxNGF0Xx3nhtHnuLr88rgVID63iHUAzcfPA7X2XL5LOppfxH+uCZHvTps1LzGPB6v0AOIyNpywxUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250852; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FeG2iVfFCj3eeKpRFunQ9Lno80LNeMsj8TqH/TijHYQ=; b=iLRsGbPtp51yDIIjKLHIiu95zV4rP3wpSIiRhNNKD0fM2dWQtLTJeAzYAcOvURebB+MFLRVina+lGK4ZvJmyWodUNE46PggIrQpX4+Xp8xyTBZkDKtiCKgW4xNG0M4nqA0ErShP9/EZf21iIhsjFPZJ93pgdPSRUYiRUn45vVzM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250852160818.9183277176242; Mon, 9 Nov 2026 11:00:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUad-0001Fj-UZ; Mon, 09 Nov 2026 13:59:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUab-0001FJ-Sc for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaa-0006I5-FI for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:33 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-c7EJXxBqMOO7x5dAD2cMjQ-1; Mon, 09 Nov 2026 13:59:25 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 618871955E83; Mon, 9 Nov 2026 18:59:19 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A3391956087; Mon, 9 Nov 2026 18:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FeG2iVfFCj3eeKpRFunQ9Lno80LNeMsj8TqH/TijHYQ=; b=JURhhYBAi5AsiIcC/PvjGWk3MSIaUCYGjvyjo3oJo7sR/csHjGnoRbL24zA0Ca8z5p3SFu ZSAURiZx2iHfF2RC7+HOzLOIfPQudl1ZI467S+9eOB7DCno+2f9mQwme3OSIuYw81lsq1P p9s99apzJEBWCt1oE5h/ZGKOpsyF5Fw= X-MC-Unique: c7EJXxBqMOO7x5dAD2cMjQ-1 X-Mimecast-MFC-AGG-ID: c7EJXxBqMOO7x5dAD2cMjQ_1794250760 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 2/7] debug/mem: add tracing to qemu_vname_vma() Date: Mon, 9 Nov 2026 13:59:02 -0500 Message-ID: <20261109185907.3220584-3-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250855398158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- util/mmap-vma.c | 6 +++++- util/trace-events | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/util/mmap-vma.c b/util/mmap-vma.c index 7dcef3b7455..93ca7f608d7 100644 --- a/util/mmap-vma.c +++ b/util/mmap-vma.c @@ -7,6 +7,7 @@ */ #include "qemu/mmap-vma.h" #include "qemu/osdep.h" +#include "trace.h" =20 #include #include @@ -36,6 +37,7 @@ static int qemu_vname_vma(void *ptr, size_t sz, const cha= r *fmt, va_list args) int rc =3D 0; =20 #if defined(PR_SET_VMA_ANON_NAME) + int err; char strbuf[VMA_MAXLEN]; =20 assert(sizeof(VMA_PREFIX) < sizeof(strbuf)); @@ -49,8 +51,10 @@ static int qemu_vname_vma(void *ptr, size_t sz, const ch= ar *fmt, va_list args) } =20 rc =3D prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, sz, strbuf); + err =3D errno; + trace_qemu_vname_vma(strbuf, ptr, sz, rc, err); if (rc) { - return -errno; + return -err; } #endif =20 diff --git a/util/trace-events b/util/trace-events index df549646d12..5ffc6cd205c 100644 --- a/util/trace-events +++ b/util/trace-events @@ -117,3 +117,6 @@ module_lookup_object_type(const char *name) "name %s" =20 # datadir.c load_file(const char *name, const char *path) "name %s location %s" + +# mmap-vma.c +qemu_vname_vma(const char *name, void *addr, size_t sz, int rc, int err) "= name %s addr %p size %zu: rc %i errno %i" --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250834; cv=none; d=zohomail.com; s=zohoarc; b=hlXZY+7t9yZfFDDRcFcrZKbiG9gOIdJRCi9ARYTz2VKRUNdcx7qnsDvy7bUtNWQgV1EU8+Eb786xSoAOK7o9d52K5IP8mO+Ua3EW/EKOhcrdp3cLiXrhD4qJpOZJ2Oh4o2zAARRSqkcpM+ikMJnt2kzCffBQ/zsv+VGRDGf3g0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250834; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5LNh5reSh+NvyeWrxM7NVu1un75hnLmQqK+4v90MiUo=; b=flB6KbqUe+A1anQVOTUJm8k/qkDWUGyjLjXxw61Kh9Jv/rabx5u31x8HgO3GNiGbT3KhxnsQvMVzuIYCI9svZdOo694yS8BDf9yklHMX1mdxKMbqQmqvpcWegUIgMrVWhqHES++hWkVcceFo3yQu++yA2Tm+UswHEHwloV6qvvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250834416522.5734656379158; Mon, 9 Nov 2026 11:00:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUab-0001F6-M5; Mon, 09 Nov 2026 13:59:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaY-0001EH-IJ for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaX-0006GZ-0m for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:30 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-4sYdBX3CO0ydzcpUbvpdJg-1; Mon, 09 Nov 2026 13:59:24 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C7064180059D; Mon, 9 Nov 2026 18:59:22 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 96C7E195608A; Mon, 9 Nov 2026 18:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5LNh5reSh+NvyeWrxM7NVu1un75hnLmQqK+4v90MiUo=; b=dPPCBJh+U6sEJ7qmvWtByMpUQvQuyEBHQwYJJv3xZn2hg9jiYQwBW3IehvkA5mkw661w5Y h78xuTDeWeZ2lypYJc2X+1Gjq85RtTPP1y6rDKbqwJZaBUNayF2LD8BH6NaYff6Lt4MOqY diwaT6iVvzaYnLqm9TDf95Wb/jp5vOY= X-MC-Unique: 4sYdBX3CO0ydzcpUbvpdJg-1 X-Mimecast-MFC-AGG-ID: 4sYdBX3CO0ydzcpUbvpdJg_1794250762 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 3/7] debug/mem: name regions in mmap-alloc Date: Mon, 9 Nov 2026 13:59:03 -0500 Message-ID: <20261109185907.3220584-4-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250837300158500 Content-Type: text/plain; charset="utf-8" For mmap memory reserved by QEMU, give it the name "". This will show up in maps output as "anon: qemu: ". Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- util/mmap-alloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index ed14f9c64de..2133b2c9bda 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -22,6 +22,7 @@ #include "qemu/host-utils.h" #include "qemu/cutils.h" #include "qemu/error-report.h" +#include "qemu/mmap-vma.h" =20 #define HUGETLBFS_MAGIC 0x958458f6 =20 @@ -152,6 +153,7 @@ static bool map_noreserve_effective(int fd, uint32_t qe= mu_map_flags) static void *mmap_reserve(size_t size, int fd) { int flags =3D MAP_PRIVATE; + void *ptr; =20 #if defined(__powerpc64__) && defined(__linux__) /* @@ -174,7 +176,10 @@ static void *mmap_reserve(size_t size, int fd) flags |=3D MAP_ANONYMOUS; #endif =20 - return mmap(0, size, PROT_NONE, flags, fd, 0); + ptr =3D mmap(0, size, PROT_NONE, flags, fd, 0); + qemu_name_vma(ptr, size, ""); + + return ptr; } =20 /* --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250857; cv=none; d=zohomail.com; s=zohoarc; b=UBUASqjVB4QU/u6gpcfU1MQJG/NJor8vqie/f9WBRua7ycSmArvznIYb+cpTSORMxPxXoXKQMV7k09YiDVJFZduYOF2xVqRMqk8hDCNrRTqxJj5tdy6Qh7UqjmvzIJjgCgKcAvnunn8klNI7YOHJUINW5u8/aSNJAGVOkOcH+mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250857; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VufcRdivSFDOtCXyYchwGh9ii+BaoE0frA+jUSq792o=; b=Tk8ghvRie018E5Hj3mxUxkjvNrf5ijFnrGWmnk0e4j6mZI4qe0fOetmxyfpp43rHGYm+BewXtr0BylrXO2sq4aM7P1+HEaGW6nKskR9nOehZxmypSIQHDm7mqv6oe/+1bBdP0WO+2S0SYxWoyiLmjDV11uFVgXUzzLZ5RR+9PCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250857815869.3523488594245; Mon, 9 Nov 2026 11:00:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUag-0001G9-4a; Mon, 09 Nov 2026 13:59:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUae-0001Fm-JD for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUad-0006KT-3W for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:36 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-lrIugugqNHC6N9MjxKk_Pg-1; Mon, 09 Nov 2026 13:59:29 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 435DB19560AE; Mon, 9 Nov 2026 18:59:26 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 086391956087; Mon, 9 Nov 2026 18:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VufcRdivSFDOtCXyYchwGh9ii+BaoE0frA+jUSq792o=; b=SUmqrcHtS4SiDUIWjd1XH8LEpOqpmc1h8GtzUJ42laP2AB+XUgH9uuNhrP0fyoUyX3tSk0 WXjcW0SaZy+29TxmnfUmVNSiD+kSFZqgt/jfOnnBJPVb863BHopEESYz8Kb69/07KENCHF AXlIdclV5GUBTZAzDBAwKQ92+KiA+1w= X-MC-Unique: lrIugugqNHC6N9MjxKk_Pg-1 X-Mimecast-MFC-AGG-ID: lrIugugqNHC6N9MjxKk_Pg_1794250767 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 4/7] debug/mem: name pthreads Date: Mon, 9 Nov 2026 13:59:04 -0500 Message-ID: <20261109185907.3220584-5-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250859464158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- meson.build | 8 ++++++++ util/qemu-thread-posix.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/meson.build b/meson.build index d7bcb581c18..ef961df2f64 100644 --- a/meson.build +++ b/meson.build @@ -2878,7 +2878,15 @@ config_host_data.set('CONFIG_PTHREAD_GET_NAME_NP', c= c.links(osdep_prefix + ''' pthread_get_name_np(pthread_self(), buf, sizeof(buf)); return 0; }''', dependencies: threads)) +config_host_data.set('CONFIG_PTHREAD_GETATTR_NP', cc.links(osdep_prefix + = ''' + #include =20 + int main(void) + { + pthread_attr_t attr; + pthread_getattr_np(pthread_self(), &attr); + return 0; + }''', dependencies: threads)) config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(osdep_pr= efix + ''' #include =20 diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 089606c93fb..353fc1a4be5 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -17,6 +17,7 @@ #include "qemu-thread-common.h" #include "qemu/tsan.h" #include "qemu/bitmap.h" +#include "qemu/mmap-vma.h" =20 #if defined(CONFIG_PTHREAD_SET_NAME_NP) || defined(CONFIG_PTHREAD_GET_NAME= _NP) #include @@ -362,6 +363,13 @@ static void qemu_thread_atexit_notify(void *arg) =20 void qemu_thread_set_name(const char *name) { +# if defined(CONFIG_PTHREAD_GETATTR_NP) + pthread_attr_t real_attr; + void *pthread_addr; + size_t stacksize; + size_t guardsize; +# endif + /* * Attempt to set the thread name; note that this is for debug, so * we're not going to fail if we can't set it. @@ -373,6 +381,32 @@ void qemu_thread_set_name(const char *name) # elif defined(CONFIG_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); # endif + +# if defined(CONFIG_PTHREAD_GETATTR_NP) + if (pthread_getattr_np(pthread_self(), &real_attr)) { + return; + } + + if (pthread_attr_getguardsize(&real_attr, &guardsize)) { + goto cleanup; + } + + if (pthread_attr_getguardsize(&real_attr, &guardsize)) { + goto cleanup; + } + + if (pthread_attr_getstack(&real_attr, &pthread_addr, &stacksize)) { + goto cleanup; + } + + /* Though there's a guard page, it isn't actually marked RO, so + * just label the entire region */ + qemu_name_vma(pthread_addr - guardsize, stacksize + guardsize, + "pthread (%s)", name); + + cleanup: + pthread_attr_destroy(&real_attr); +# endif } =20 typedef struct { --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250827; cv=none; d=zohomail.com; s=zohoarc; b=dp5kQUSHj+UZbT+v/ND5GZDWPiJs5niiUrwjRoHRtvnw6jTVt15A4gA/x5RVK/OqoWq7o0fT3x1CN2df4xjSlWqO+QlJjne62CCC3NYA8JIVz7o0ghJOkh2DAvpzo++JaMtX4WizowQ+RAAMZVLW9khOktG/r4kSpzzVWYad9d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250827; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=R8AIIl3lqxkoUiy2gww46SkIgsFvv8BhihUMvgLblus=; b=DeEXhEoYQ6p6SEDqP9MUiYZ/kZY7OVYdaZDF3F7K/c/87MRvXO2HbCMmycM42uCmjaN0uYPGYVxwDEGXRtYpLaxADtFm8U1f0VCP1YrDXPczu87zhDRIFxpxvQ2P2WbVZWLs9Eg63yGnsJA4ZWK+ATU28F93wpOa9aYjl8fIIBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250827279852.1366316369425; Mon, 9 Nov 2026 11:00:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUam-0001RW-5l; Mon, 09 Nov 2026 13:59:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUaj-0001Mo-Lv for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUai-0006LL-A2 for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:41 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-Z7wKWRe6OneiSd1nS9wdAg-1; Mon, 09 Nov 2026 13:59:34 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 45C8B1800654; Mon, 9 Nov 2026 18:59:32 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 79FB6195608A; Mon, 9 Nov 2026 18:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R8AIIl3lqxkoUiy2gww46SkIgsFvv8BhihUMvgLblus=; b=VlQo6VJvPpSADeHe8pxtvmfP2qL22HIYu/9yqpm0Y1uTF2NsDgx5EMbavsL9ckbTvlU2P4 Ff1BcSxdUOubwZsr6g2ID5WS700pbWkT2Pdc5YiV5fgZ0PAoH99N6KwQJswfoKFpdLVwLJ g9Nnx1XSB9M3dE7Bp+xx/RR9Dm2TPnE= X-MC-Unique: Z7wKWRe6OneiSd1nS9wdAg-1 X-Mimecast-MFC-AGG-ID: Z7wKWRe6OneiSd1nS9wdAg_1794250772 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 5/7] debug/mem: name coroutine stacks Date: Mon, 9 Nov 2026 13:59:05 -0500 Message-ID: <20261109185907.3220584-6-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250829053158500 Content-Type: text/plain; charset="utf-8" Simple enough. RFC: Is there a better name we can give these to help tell them apart during analysis? Signed-off-by: John Snow --- util/oslib-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index dc001da66dd..454579c72df 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -60,6 +60,7 @@ =20 #include "qemu/memalign.h" #include "qemu/mmap-alloc.h" +#include "qemu/mmap-vma.h" =20 #define MAX_MEM_PREALLOC_THREAD_COUNT 32 =20 @@ -742,6 +743,8 @@ void *qemu_alloc_stack(size_t *sz) abort(); } =20 + qemu_name_vma(ptr, *sz, "coroutine-stack"); + /* Stack grows down -- guard page at the bottom. */ if (mprotect(ptr, pagesz, PROT_NONE) !=3D 0) { perror("failed to set up stack guard page"); --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250835; cv=none; d=zohomail.com; s=zohoarc; b=J2ZSpwffscDjor8U7zLkAO5OOhQExxbf/s0i2yUees0uE+fSHp/FpE61s+OIl0wBf0jVGt0hLb4D9E7AuNMgsciDjBAvKhY7zcxlEZe0QUqpkXd9fxwdBRmfGAqi//I3diXcAfJfRA1RxfHwvhu1HL31b6sYYLDsWaZlxTZiiKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250835; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SNLz6irjVQKxLXxuAQmNIycOrT3Nu0qZclK5ldZ9vmY=; b=QbWDif4eTsr4v2d0DAiAIDpXdFuF9Qa2d0BGvf5UCc45QxZta0qIsmuL0eQ/xkGgf4u/2yPZJlUXp46K0oRwTCFj7ecrzhAuii+goj1CzsksCBsYcmDosLlO3+nQ5PCaME3C8WfWMXnxpSE9Z6qjEPnAtxOCEmxJ49TbFDPA6As= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250835073539.7927301743218; Mon, 9 Nov 2026 11:00:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUar-0001WC-E7; Mon, 09 Nov 2026 13:59:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUao-0001T8-1R for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUam-0006Lr-7z for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:45 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-cM0Duoa-MY2dZd_Uoh7GIA-1; Mon, 09 Nov 2026 13:59:39 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42A7E195608E; Mon, 9 Nov 2026 18:59:37 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9FDA21956087; Mon, 9 Nov 2026 18:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SNLz6irjVQKxLXxuAQmNIycOrT3Nu0qZclK5ldZ9vmY=; b=XFeKEF/CnSa64oGSfDBlWqHcWwLWZmHyRLPB2rioW9oI4BLSqHUetw/zSk5DmbxYUHChTi MuxUjFPpqywcpnI2yTHSMqmI9yMoDKDGbEkRXjY169ZBYJE5y1ubUjDvMXNSkciDRURwGL Twhz/myPg8zF22+uNNWDbX2nLa1TyCQ= X-MC-Unique: cM0Duoa-MY2dZd_Uoh7GIA-1 X-Mimecast-MFC-AGG-ID: cM0Duoa-MY2dZd_Uoh7GIA_1794250777 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 6/7] debug/mem: name qemu_anon_ram_alloc/qemu_ram_mmap pages Date: Mon, 9 Nov 2026 13:59:06 -0500 Message-ID: <20261109185907.3220584-7-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250837390158500 Content-Type: text/plain; charset="utf-8" This patch adds a nickname parameter to qemu_anon_ram_alloc, which passes it to qemu_ram_mmap, which passes it in turn to mmap_activate, where it is used to name the region being allocated. Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- include/qemu/mmap-alloc.h | 3 ++- include/qemu/osdep.h | 2 +- hw/display/virtio-gpu-gl.c | 2 +- migration/ram.c | 3 ++- system/physmem.c | 7 +++++-- target/i386/kvm/tdx.c | 3 ++- util/mmap-alloc.c | 10 +++++++--- util/oslib-posix.c | 4 ++-- util/oslib-win32.c | 2 +- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h index 8344daaa03f..c34587179b6 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -36,7 +36,8 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, uint32_t qemu_map_flags, - off_t map_offset); + off_t map_offset, + const char *nickname); =20 void qemu_ram_munmap(int fd, void *ptr, size_t size); =20 diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b27d159d5bb..5e712ff1c6c 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -552,7 +552,7 @@ void QEMU_ERROR("code path is reachable") =20 int qemu_daemon(int nochdir, int noclose); void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared, - bool noreserve); + bool noreserve, const char *nickname); void qemu_anon_ram_free(void *ptr, size_t size); int qemu_shm_alloc(size_t size, Error **errp); =20 diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 2b7a41c4664..66c302315c5 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -145,7 +145,7 @@ static void virtio_gpu_gl_device_realize(DeviceState *q= dev, Error **errp) #if !defined(CONFIG_WIN32) if (virtio_gpu_hostmem_enabled(b->conf)) { map =3D qemu_ram_mmap(-1, b->conf.hostmem, qemu_real_host_page_siz= e(), - 0, 0); + 0, 0, "virgl-hostmem"); if (map =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "virgl hostmem region could not be initialize= d"); diff --git a/migration/ram.c b/migration/ram.c index e6db3bf5238..c48e05078d1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3720,7 +3720,8 @@ int colo_init_ram_cache(Error **errp) WITH_RCU_READ_LOCK_GUARD() { RAMBLOCK_FOREACH_NOT_IGNORED(block) { block->colo_cache =3D qemu_anon_ram_alloc(block->used_length, - NULL, false, false); + NULL, false, false, + "colo cache"); if (!block->colo_cache) { error_setg(errp, "Can't alloc memory for COLO cache of " "block %s, size 0x" RAM_ADDR_FMT, diff --git a/system/physmem.c b/system/physmem.c index a7300bb9d97..202e3a5cd00 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1767,7 +1767,8 @@ static void *file_ram_alloc(RAMBlock *block, qemu_map_flags |=3D (block->flags & RAM_SHARED) ? QEMU_MAP_SHARED : 0; qemu_map_flags |=3D (block->flags & RAM_PMEM) ? QEMU_MAP_SYNC : 0; qemu_map_flags |=3D (block->flags & RAM_NORESERVE) ? QEMU_MAP_NORESERV= E : 0; - area =3D qemu_ram_mmap(fd, memory, block->mr->align, qemu_map_flags, o= ffset); + area =3D qemu_ram_mmap(fd, memory, block->mr->align, qemu_map_flags, o= ffset, + "file_ram_alloc"); if (area =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "unable to map backing store for guest RAM"); @@ -2169,7 +2170,9 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) } else { new_block->host =3D qemu_anon_ram_alloc(new_block->max_length, &new_block->mr->align, - shared, noreserve); + shared, noreserve, + new_block->mr->name); + if (!new_block->host) { g_autofree char *size_s =3D size_to_str(new_block->max_len= gth); error_setg_errno(errp, errno, diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 52bb2ec6ced..e4d589fc950 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -354,7 +354,8 @@ static void tdx_finalize_vm(Notifier *notifier, void *u= nused) case TDVF_SECTION_TYPE_TD_HOB: case TDVF_SECTION_TYPE_TEMP_MEM: entry->mem_ptr =3D qemu_ram_mmap(-1, entry->size, - qemu_real_host_page_size(), 0, = 0); + qemu_real_host_page_size(), 0, = 0, + "tdx"); if (entry->mem_ptr =3D=3D MAP_FAILED) { error_report("Failed to mmap memory for TDVF section %d", entry->type); diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 2133b2c9bda..f0b903dfdbe 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -187,7 +187,8 @@ static void *mmap_reserve(size_t size, int fd) * it accessible. */ static void *mmap_activate(void *ptr, size_t size, int fd, - uint32_t qemu_map_flags, off_t map_offset) + uint32_t qemu_map_flags, off_t map_offset, + const char *nickname) { const bool noreserve =3D qemu_map_flags & QEMU_MAP_NORESERVE; const bool readonly =3D qemu_map_flags & QEMU_MAP_READONLY; @@ -236,6 +237,8 @@ static void *mmap_activate(void *ptr, size_t size, int = fd, */ activated_ptr =3D mmap(ptr, size, prot, flags, fd, map_offset); } + + qemu_name_vma(ptr, size, "%s", nickname); return activated_ptr; } =20 @@ -253,7 +256,8 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, uint32_t qemu_map_flags, - off_t map_offset) + off_t map_offset, + const char *nickname) { const size_t guard_pagesize =3D mmap_guard_pagesize(fd); size_t offset, total; @@ -277,7 +281,7 @@ void *qemu_ram_mmap(int fd, offset =3D QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guar= dptr; =20 ptr =3D mmap_activate(guardptr + offset, size, fd, qemu_map_flags, - map_offset); + map_offset, nickname); if (ptr =3D=3D MAP_FAILED) { munmap(guardptr, total); return MAP_FAILED; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 454579c72df..ba3ebb52eb5 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -207,13 +207,13 @@ fail_close: =20 /* alloc shared memory pages */ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared, - bool noreserve) + bool noreserve, const char *nickname) { const uint32_t qemu_map_flags =3D (shared ? QEMU_MAP_SHARED : 0) | (noreserve ? QEMU_MAP_NORESERVE : 0); size_t align =3D QEMU_VMALLOC_ALIGN; #ifndef EMSCRIPTEN - void *ptr =3D qemu_ram_mmap(-1, size, align, qemu_map_flags, 0); + void *ptr =3D qemu_ram_mmap(-1, size, align, qemu_map_flags, 0, nickna= me); =20 if (ptr =3D=3D MAP_FAILED) { return NULL; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 5f3e8f4d980..52c6335995c 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -45,7 +45,7 @@ static int get_allocation_granularity(void) } =20 void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared, - bool noreserve) + bool noreserve, const char *nickname) { void *ptr; =20 --=20 2.56.0 From nobody Mon Nov 23 04:34:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794250871; cv=none; d=zohomail.com; s=zohoarc; b=S/++2x/H+Czw21BplPW9BcyrforgzNPmcy40WK1TmkUQv1Z2BWwq0nb9WMPYjMxXhx0dZfuj3GbuqOPM03XudVBS0fEDMwsOaM7XPnmI8mPQDb/bvgbUR3v3AZWD6KKV8eHSgLMYV76p5ww+COTVfOIi3I+ryv6DlR3fEulKm0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794250871; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OBhOYGW63+HK7TQ6MenaEpD8gvCGw1S/+JkFwZX0PFI=; b=aWabtyi65XPYI4jcnLZEM1Gb016wKQ4DL/M+kxwGYXEjyufsb7eMQvKqtLeLTvfziZ9T614zK7s7N7Yv/blAzRO93xlhrdISsCuy8K8UsxG/vrYowJCorYikbdV3hblUNAUHO/oKbOceL6Iwu6fAQ+GUno5QuyFu7Pn+wDaN2qE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794250871737100.3083073919421; Mon, 9 Nov 2026 11:01:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQUav-0001dt-6T; Mon, 09 Nov 2026 13:59:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUar-0001WR-5b for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQUap-0006M4-BS for qemu-devel@nongnu.org; Mon, 09 Nov 2026 13:59:48 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-vpTCLsTbPRmlaLBpyEUBxQ-1; Mon, 09 Nov 2026 13:59:42 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3F508195BDF0; Mon, 9 Nov 2026 18:59:40 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (unknown [10.22.80.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 779C61956087; Mon, 9 Nov 2026 18:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794250786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OBhOYGW63+HK7TQ6MenaEpD8gvCGw1S/+JkFwZX0PFI=; b=fZnyGpsRVgKDomz4XtO8E7fHHaUZLCi+q2HAimLktX0iGkMd0/go2Ng6bYWRHZ45f3E4dU MPPhm3Er4iRjA4t3vxj15+SfHujIbSkcJRdcn+yVvinzK1yfLRPrN7EQwk1yfhCPQz6l9Q W2yRzi5pX0o/Y22MnU6Z3hgcO2D6bkQ= X-MC-Unique: vpTCLsTbPRmlaLBpyEUBxQ-1 X-Mimecast-MFC-AGG-ID: vpTCLsTbPRmlaLBpyEUBxQ_1794250780 From: John Snow To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Marcelo Tosatti , David Gibson , Alistair Francis , Stefan Weil , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Paolo Bonzini , kvm@vger.kernel.org, Richard Henderson , Dmitry Osipenko , Akihiko Odaki , John Snow Subject: [PATCH 7/7] debug/mem: HACK add qemu_name_buffer Date: Mon, 9 Nov 2026 13:59:07 -0500 Message-ID: <20261109185907.3220584-8-jsnow@redhat.com> In-Reply-To: <20261109185907.3220584-1-jsnow@redhat.com> References: <20261109185907.3220584-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794250873783158501 Content-Type: text/plain; charset="utf-8" This is a hack to allow us to name malloc'd buffers that are backed by anonymous mmap allocations. Quite useful in my debugging, probably not quite appropriate for upstream unless we can figure out a more robust method for identifying when we get an mmap'd page from malloc and adjusting the pointer offset accordingly - I am currently subtracting a fixed 16 bytes because that "works on my system", and I have no clue if that's appropriate everywhere or not. At least this way, my trick is published to the list for posterity. Signed-off-by: John Snow --- include/qemu/bitmap.h | 6 ++++++ include/qemu/mmap-vma.h | 3 +++ hw/core/loader.c | 3 +++ hw/i386/x86-common.c | 3 +++ system/device_tree.c | 2 ++ system/physmem.c | 8 ++++++-- util/mmap-vma.c | 23 +++++++++++++++++++++++ 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 0044333cb51..6681c87737f 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -104,6 +104,12 @@ static inline unsigned long *bitmap_try_new(long nbits) return g_try_new0(unsigned long, nelem); } =20 +static inline size_t bitmap_size(long nbits) +{ + long nelem =3D BITS_TO_LONGS(nbits); + return sizeof(unsigned long) * nelem; +} + static inline unsigned long *bitmap_new(long nbits) { long nelem =3D BITS_TO_LONGS(nbits); diff --git a/include/qemu/mmap-vma.h b/include/qemu/mmap-vma.h index 763ea5a5cab..4646657022c 100644 --- a/include/qemu/mmap-vma.h +++ b/include/qemu/mmap-vma.h @@ -15,4 +15,7 @@ int qemu_name_vma(void *ptr, size_t sz, const char *fmt, ...) G_GNUC_PRINTF(3, 4); =20 +int qemu_name_buffer(void *ptr, size_t sz, const char *fmt, ...) + G_GNUC_PRINTF(3, 4); + #endif diff --git a/hw/core/loader.c b/hw/core/loader.c index 5cbfba0a86d..cc0e0d6979a 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -45,6 +45,7 @@ #include "qemu/osdep.h" #include "qemu/datadir.h" #include "qemu/error-report.h" +#include "qemu/mmap-vma.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" #include "qapi/type-helpers.h" @@ -1111,6 +1112,8 @@ ssize_t rom_add_file(const char *file, const char *fw= _dir, goto err; } =20 + qemu_name_buffer(rom->data, size, "%s", file); + if (fw_dir) { rom->fw_dir =3D g_strdup(fw_dir); rom->fw_file =3D g_strdup(file); diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index dcd4fa8eb79..608c4cf4202 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -25,6 +25,7 @@ #include "qemu/cutils.h" #include "qemu/units.h" #include "qemu/datadir.h" +#include "qemu/mmap-vma.h" #include "qapi/error.h" #include "system/numa.h" #include "system/system.h" @@ -914,6 +915,8 @@ void x86_load_linux(X86MachineState *x86ms, =20 setup =3D g_malloc(setup_size); kernel =3D g_malloc(kernel_size); + qemu_name_buffer(kernel, kernel_size, "%s", kernel_filename); + fseek(f, 0, SEEK_SET); if (fread(setup, 1, setup_size, f) !=3D setup_size) { fprintf(stderr, "fread() failed\n"); diff --git a/system/device_tree.c b/system/device_tree.c index 48365435ea0..816874fb299 100644 --- a/system/device_tree.c +++ b/system/device_tree.c @@ -27,6 +27,7 @@ #include "hw/core/loader.h" #include "hw/core/boards.h" #include "qemu/config-file.h" +#include "qemu/mmap-vma.h" #include "qapi/qapi-commands-machine.h" #include "qobject/qdict.h" =20 @@ -41,6 +42,7 @@ void *create_device_tree(int *sizep) =20 *sizep =3D FDT_MAX_SIZE; fdt =3D g_malloc0(FDT_MAX_SIZE); + qemu_name_buffer(fdt, FDT_MAX_SIZE, "device_tree"); ret =3D fdt_create(fdt, FDT_MAX_SIZE); if (ret < 0) { goto fail; diff --git a/system/physmem.c b/system/physmem.c index 202e3a5cd00..dc0e9540919 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -26,6 +26,7 @@ #include "qemu/hbitmap.h" #include "qemu/madvise.h" #include "qemu/lockable.h" +#include "qemu/mmap-vma.h" =20 #ifdef CONFIG_TCG #include "accel/tcg/cpu-ops.h" @@ -2105,7 +2106,7 @@ void qemu_ram_msync(RAMBlock *block, ram_addr_t start= , ram_addr_t length) } =20 /* Called with ram_list.mutex held */ -static void dirty_memory_extend(ram_addr_t new_ram_size) +static void dirty_memory_extend(ram_addr_t new_ram_size, const char *nickn= ame) { unsigned int old_num_blocks =3D ram_list.num_dirty_blocks; unsigned int new_num_blocks =3D DIV_ROUND_UP(new_ram_size, @@ -2133,6 +2134,9 @@ static void dirty_memory_extend(ram_addr_t new_ram_si= ze) =20 for (j =3D old_num_blocks; j < new_num_blocks; j++) { new_blocks->blocks[j] =3D bitmap_new(DIRTY_MEMORY_BLOCK_SIZE); + qemu_name_buffer(new_blocks->blocks[j], + bitmap_size(DIRTY_MEMORY_BLOCK_SIZE), + "bitmap<%s>", nickname); } =20 qatomic_rcu_set(&ram_list.dirty_memory[i], new_blocks); @@ -2254,7 +2258,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) } =20 ram_size =3D (new_block->offset + new_block->max_length) >> TARGET_PAG= E_BITS; - dirty_memory_extend(ram_size); + dirty_memory_extend(ram_size, new_block->mr->name); /* Keep the list sorted from biggest to smallest block. Unlike QTAILQ, * QLIST (which has an RCU-friendly variant) does not have insertion at * tail, so save the last element in last_block. diff --git a/util/mmap-vma.c b/util/mmap-vma.c index 93ca7f608d7..9b1309df635 100644 --- a/util/mmap-vma.c +++ b/util/mmap-vma.c @@ -69,3 +69,26 @@ int qemu_name_vma(void *ptr, size_t sz, const char *fmt,= ...) va_start(args, fmt); return qemu_vname_vma(ptr, sz, fmt, args); } + +G_GNUC_PRINTF(3, 4) +int qemu_name_buffer(void *ptr, size_t sz, const char *fmt, ...) +{ + /* + * this is hacky as hell, but ptmalloc will occasionally use + * mmap() for large buffers - when it does so, you get a pointer + * to 16 bytes after the actual mmap. This function compensates + * for that to guess at what the real mmap allocation was. + * + * This can be used unconditionally whether or not the allocation + * was actually mmap'd - if it wasn't, this just fails. Yes, it's + * still very ugly. + */ + va_list args; + size_t pagesz =3D qemu_real_host_page_size(); + + ptr =3D ptr - 0x10; + sz =3D ROUND_UP(sz + 0x10, pagesz); + + va_start(args, fmt); + return qemu_vname_vma(ptr, sz, fmt, args); +} --=20 2.56.0