From nobody Mon Nov 23 04:26: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=1794847862; cv=none; d=zohomail.com; s=zohoarc; b=Yw2h/1b+QSEEXvYdLDJ1jvcBbBq7CG8hsUxD6m99QMkWuI9XaMNnquuANDsdyjXWw0cYVR+KvDyN1ikDJjbzEcpl4tyDgl+Rqd1JDwXC1/97TP2iYoMRRcOCTvcQX/8+hUwwVb56qp2MgFZmggYV3ygaqTx7ulN2L/5PYRLKbmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847862; 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=VZSzn4ITGSBB9Y8uZVgu3YecElXhFeIW1SMd8QUM9iY=; b=GYmSHtA44l5Rpn0CdKI4G1dAVvOpfO9sXcIdnz8bWz8ozf9ghKNBnmuTo8jvhS0RF4zWeWyr0SWTkEnBFR13k40UuLJJPDPLU8sUs3mVhYv5WJK16tPaJFIZL+OW2mFOlH4ty8smreKjYmDz3ASF+e1QzciMV0N0yviqQ9TJULY= 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 1794847862306800.0097998813492; Mon, 16 Nov 2026 08:51:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzup-0007dK-GI; Mon, 16 Nov 2026 11:50:51 -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 1xSzuO-0007S7-TX for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:20 -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 1xSzuM-00075g-RZ for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:20 -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-587-l0QcV9AJN8mX-CotliXd1Q-1; Mon, 16 Nov 2026 11:50:15 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 91B5819560B4; Mon, 16 Nov 2026 16:50:11 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDB2A195B3C7; Mon, 16 Nov 2026 16:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847817; 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=VZSzn4ITGSBB9Y8uZVgu3YecElXhFeIW1SMd8QUM9iY=; b=NA/m6K15W/whuf8xUXPaclEfFnQ3ZIydI6jEWD3d8XzLTcBMDoeKJHc0s9oAEbWFArY8W8 YfJKAm1eIlELv1D/k+R+cdxegU7mOHxkRO6X8WDtBv1rNBrXngDN9RuhCygh3TYLb0dKm/ qPfZOxXtyCWGO2VNjsZkfd6gJqJyyHo= X-MC-Unique: l0QcV9AJN8mX-CotliXd1Q-1 X-Mimecast-MFC-AGG-ID: l0QcV9AJN8mX-CotliXd1Q_1794847812 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 1/7] debug/mem: add utility to name anonymous memory mappings Date: Mon, 16 Nov 2026 11:49:56 -0500 Message-ID: <20261116165002.30939-2-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847863638158500 Content-Type: text/plain; charset="utf-8" Add support to name mmap'd memory regions using PR_SET_VMA_ANON_NAME. On unsupported platforms, these QEMU utility functions are no-ops. This is useful primarily for debugging and profiling QEMU; being able to see and correlate each VMA segment with a specific use within QEMU. Support for PR_SET_VMA_ANON_NAME was added in Linux 5.17, and requires CONFIG_ANON_VMA_NAME=3Dy to be set in the kernel configuration. Fedora (and RHEL) do not enable this feature by default. See also https://man7.org/linux/man-pages/man2/pr_set_vma.2const.html Signed-off-by: John Snow --- include/qemu/mmap-vma.h | 18 +++++++++++ util/mmap-vma.c | 71 +++++++++++++++++++++++++++++++++++++++++ util/meson.build | 1 + 3 files changed, 90 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..7a50965d496 --- /dev/null +++ b/util/mmap-vma.c @@ -0,0 +1,71 @@ +/* + * 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, ...) +{ + int rc; + va_list args; + + va_start(args, fmt); + rc =3D qemu_vname_vma(ptr, sz, fmt, args); + va_end(args); + + return rc; +} 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.1 From nobody Mon Nov 23 04:26: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=1794847868; cv=none; d=zohomail.com; s=zohoarc; b=g8m6JjCYBUl8NzZyG4TXkhmIe2Lt4HI3prozN91YV2qahhC5jl+YeMHBYU0uSmfDFNcL+U0cdcexSOx8cMMX9bIe6j2sXgokuqahAcC/Y2KB4smcTPWvFuH49RH/4hqcHosZH9UMsknZENQ+bVP0bFgWdTSb7IQvFi8byUSZUm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847868; h=Content-Type: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=ekrPifKeZKSKlAlu0PgB8G/oDkp8oZ++mIkvY8WR1Xw=; b=XSPbxRhP/Xo/Xq9w2HiUByX1gs6+xd83I/VV+jAjQPfTrkiH1+Xt0XrWzbFajD0fT4DVG1MCWEo2QNg2osNFF6GRVdijUg8BpruzKuk6AjYxToH/MW+ph2AZjXd1zbj8pcgpDbu6aPs/yxLUGxNLhTVD5EB2XA1CQrX5qI5LxdQ= 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 1794847868721571.3003827138009; Mon, 16 Nov 2026 08:51:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzv8-0007pE-8G; Mon, 16 Nov 2026 11:51:06 -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 1xSzug-0007bR-FQ for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:40 -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 1xSzuc-0007di-NL for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:37 -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-627-8lYezrWfP5qJWvLzQ-03nA-1; Mon, 16 Nov 2026 11:50:22 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 96FF919560B9; Mon, 16 Nov 2026 16:50:17 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C7C59195B3C9; Mon, 16 Nov 2026 16:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847825; 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=ekrPifKeZKSKlAlu0PgB8G/oDkp8oZ++mIkvY8WR1Xw=; b=M2IdfHx24yd4U/vC6+0D/JXg+jPbKogLeQEMZdqs2Vqp82Ss1x+/cC4X8SdBLrZ1ejwzHs ngCv+HaORtMEIpeCUjfp4YGvF0HRHWYyMQM5b4rA5lzYCCIEdHMoE/FX6QPXkk6p0FHJcF pKoFTJ6dnPAjbhdT1LitxG6awkuI3ec= X-MC-Unique: 8lYezrWfP5qJWvLzQ-03nA-1 X-Mimecast-MFC-AGG-ID: 8lYezrWfP5qJWvLzQ-03nA_1794847818 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 2/7] debug/mem: add tracing to qemu_vname_vma() Date: Mon, 16 Nov 2026 11:49:57 -0500 Message-ID: <20261116165002.30939-3-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847870045158500 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 7a50965d496..46ea98f1134 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.1 From nobody Mon Nov 23 04:26: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=1794847929; cv=none; d=zohomail.com; s=zohoarc; b=iH0FxmOFAfyA1Wlxvg1xqhhNlOYigYLozsm+U7qtWRBNfFK48bmMFQRZv/0dIHcYKeZvZ5ZgXWAB6v9nz5hwqNowWg16treVAA6Rka9gKK3lsyY8dejOljetI1KykFBGanyGRTwMExlQKa2fspdhN9PivHMPP5BuW4X1BhqatLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847929; h=Content-Type: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=JSlihkLJpIlxY9tcrA9GhmKKT3bZReqpBGh+tfoa3wk=; b=afLT+BbjbO8Va0cyQDTeizwkfzZFiPsMXll+VSLiffZae1+NoY2lnxcLKE1bkRdYvdm6s+3NcPCctzkLcSchzO13wpkRUvR7wRvYRMP4RTx1et4JbLj/7AvbTYajt80oPnYh9Ea9yCRVk8cTMKM1f+DSfj9LPQWvw0SXH6mWAvs= 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 1794847929630899.7028366509161; Mon, 16 Nov 2026 08:52:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzvs-0008M6-Nf; Mon, 16 Nov 2026 11:51:54 -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 1xSzug-0007bX-Hj for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:40 -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 1xSzue-0007dk-Hi for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:37 -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-610-yGqqOj_WOveyFYXSrH9_ZA-1; Mon, 16 Nov 2026 11:50:24 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 B798B180055B; Mon, 16 Nov 2026 16:50:21 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 007FE195B3C8; Mon, 16 Nov 2026 16:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847826; 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=JSlihkLJpIlxY9tcrA9GhmKKT3bZReqpBGh+tfoa3wk=; b=MhOmPRKM+UhTuUZg9JWhfHokIY52nhavBIAjAY82cyPfgxgY+MFgsS+klUSDoaa8xiGML2 Wghkskd/8h66NIJ8MI10cXobUtMlT54Drb2Ob9/4NV/TVCYdDES1O80z2pXl0U6XbQlAzA Rs+SE9Pt584wp3+xhe1fL2e1ElqOLnY= X-MC-Unique: yGqqOj_WOveyFYXSrH9_ZA-1 X-Mimecast-MFC-AGG-ID: yGqqOj_WOveyFYXSrH9_ZA_1794847822 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 3/7] debug/mem: name regions in mmap-alloc Date: Mon, 16 Nov 2026 11:49:58 -0500 Message-ID: <20261116165002.30939-4-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847932196158500 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.1 From nobody Mon Nov 23 04:26: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=1794847901; cv=none; d=zohomail.com; s=zohoarc; b=ns1DahOOEGZD3Vwt6IbjcWRdNW+kvxYTaMPzkXbGgZYKTtNfW1lnpbAzNjeoEPlhpl8XT03rniro6MATn6I6/rsq6k4QHlfjz0IAuT4wmnYcYT0fTZgF/FJI2gTzFdWQrwpf1AuTYoAu2Dg1W53mAEkArfFfcNJJXtU2KiHRHlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847901; 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=CRoYJNo2Ut/C9F0PKvSMgrpZBQkzD9p9HmTEG0fAlqU=; b=f0kgKZRPgWlt6a6L42C4XHxLY7NAuj5Esau25FCIi7BlW2KXxx5LPgyH3kZuXlgQp0qnyP/ynVJq7F4hHgebn4k82lwiZWrC5D+guOA9Dfkhstb+xAhOrY9QR6LqmSIMalYIiNbiHaJVeRtk7JdUYngpTqL9oKKzn/L6Mc43P6I= 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 1794847901138714.804380381131; Mon, 16 Nov 2026 08:51:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzvG-0007xp-PQ; Mon, 16 Nov 2026 11:51:18 -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 1xSzuh-0007ba-CE for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:40 -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 1xSzue-0007du-HR for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:39 -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-279-zsTcbiazNmSDz6sDb0s-AQ-1; Mon, 16 Nov 2026 11:50:29 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 9CC5D18002FC; Mon, 16 Nov 2026 16:50:27 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4272C195B3C9; Mon, 16 Nov 2026 16:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847831; 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=CRoYJNo2Ut/C9F0PKvSMgrpZBQkzD9p9HmTEG0fAlqU=; b=NXSnH0HZsopuI8tO56ZzZpUDiX2T6c3J6hijbt3UXog+EOldti1HAMNnwLJ7w7/vVZk6o6 4juvwxM2DOtRPjuJut9Fk9rRzaQuKHMb0DkLRrjw7TAc7RHzdiloEDKqyG4NSpK7ICKuZA rvuW1XGtNoVZaRwgA32xd70obcpHPig= X-MC-Unique: zsTcbiazNmSDz6sDb0s-AQ-1 X-Mimecast-MFC-AGG-ID: zsTcbiazNmSDz6sDb0s-AQ_1794847827 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 4/7] debug/mem: name pthreads Date: Mon, 16 Nov 2026 11:49:59 -0500 Message-ID: <20261116165002.30939-5-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847902037158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- meson.build | 8 ++++++++ util/qemu-thread-posix.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 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..967e0f15f6d 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,28 @@ 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_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.1 From nobody Mon Nov 23 04:26: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=1794847901; cv=none; d=zohomail.com; s=zohoarc; b=VEGl0hL2QsSlCUF4c4FUoqka/7od9kjTOleaXaoAsXDYIP/4S94fiHJJvg8DTi6ccz6bUQDyv/6+ee0r0qXeH03QRmoPFY29YsMAMfIPz9GZHqN0GcFjwpQS5aDVzKolyfmDjSwmd+VatAzmPBSc5o9Z8+Ifot0+NvCfDqsQSHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847901; 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=NIkcB0xFVInRVan0YUgAxqPrhANw4KC3xtWTa3NWmiE=; b=czdciaxh/RH5N7eAPBY/1fsrqQZlo/rdjb4nW8lq2SZKkC5lb5rb0Aq4sMZDzx1Womc3NWTgMYYqwr1mwOWlR3pbcW1zf76Wza+Boa9x1l3IsBdvgOUB3wWnzwbTZDIycXZAhm61rYL4D5EBRlCXr3/Y3doXctsXKzdljdMMuf4= 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 1794847901236924.2877649767681; Mon, 16 Nov 2026 08:51:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzvG-0007xb-PQ; Mon, 16 Nov 2026 11:51:18 -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 1xSzuj-0007c1-4b for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:42 -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 1xSzuh-0007eJ-K4 for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:40 -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-534-4TvjXVxqOGu-um8TZYAVbA-1; Mon, 16 Nov 2026 11:50:33 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 40DD91955EA8; Mon, 16 Nov 2026 16:50:31 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 24AB9195B3C7; Mon, 16 Nov 2026 16:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847838; 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=NIkcB0xFVInRVan0YUgAxqPrhANw4KC3xtWTa3NWmiE=; b=DpJd3MXM5kWrAf0HFtgx/jw3eFJ7+nT6q5buW0XNHO4PKanXQUKsnruTMvmcLXAl4+d8UM AWuxdj6rPMUodDMsLKUN6ayYzdWCwWy/iMM9RW0piWlRaIp3awD0rpqIFOOFaH8QDJpeYL esxM7P/pR5gO0UqG84DXVGNPEL5XoOQ= X-MC-Unique: 4TvjXVxqOGu-um8TZYAVbA-1 X-Mimecast-MFC-AGG-ID: 4TvjXVxqOGu-um8TZYAVbA_1794847831 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 5/7] debug/mem: name coroutine stacks Date: Mon, 16 Nov 2026 11:50:00 -0500 Message-ID: <20261116165002.30939-6-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847902005158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- 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.1 From nobody Mon Nov 23 04:26: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=1794847918; cv=none; d=zohomail.com; s=zohoarc; b=cDC+Soz46DsQEIBftaaHpB6ncJU/jylhhuXpmjLLkrJ1Gh7KGFJHRQYiIbBmWrBHXkf1WZenEebjhOy4IDA6dbLz51aWiL+iWLZrswDAyVfMP413ZQLVquh6dPY63flk/kigKNPY7EO+iUaysBjlCddCKGPOhvYazVsLhpR7jJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847918; h=Content-Type: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=YP0uMjXbMZzhkU1dEuU+r+EAx9s3iL97wWTm1GvIKRo=; b=D7lWlZ8wQFzIgnYLbb3Yd617TSz6usKeGqF1E4SndXsWk74Faq4T11ZxH7C7qK89F8cThkKovoe4pMbMqAYnlMrYpj8gd8f6kK6Y8RJOkdNhoFHuAkA/K6Y3AppmgFIhbFfivy7SZFiut5czzEfYiHn7V2xtngyZ4u8yOvYH1JE= 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 1794847918666991.3771527247278; Mon, 16 Nov 2026 08:51:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzvq-0008ID-ST; Mon, 16 Nov 2026 11:51:52 -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 1xSzun-0007e3-Vj for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50: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 1xSzum-0007ei-3M for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:45 -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-83-oXN2bRmCNliD4RMRV-JqRQ-1; Mon, 16 Nov 2026 11:50:37 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 8295D18004F6; Mon, 16 Nov 2026 16:50:34 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 75E1C195B3C7; Mon, 16 Nov 2026 16:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847843; 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=YP0uMjXbMZzhkU1dEuU+r+EAx9s3iL97wWTm1GvIKRo=; b=RPl+cxzBRiCCaRJvXffXemkoG0fzUT7FcckM0J67AzxRhzVnLlNJ5vd0E3Qlt1iWNkfx5v 3h/oMK9WkwyLqt47BGjKbRoPhLJnvXNtk9BpfsEm88WMQgAWRlmvRE8s1TzSKdkyPbC/B5 X+tR/aKYFtN0Pwuh7YhJg5+LodpPjqw= X-MC-Unique: oXN2bRmCNliD4RMRV-JqRQ-1 X-Mimecast-MFC-AGG-ID: oXN2bRmCNliD4RMRV-JqRQ_1794847834 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 6/7] debug/mem: name qemu_anon_ram_alloc/qemu_ram_mmap pages Date: Mon, 16 Nov 2026 11:50:01 -0500 Message-ID: <20261116165002.30939-7-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847920398158501 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.1 From nobody Mon Nov 23 04:26: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=1794847932; cv=none; d=zohomail.com; s=zohoarc; b=Z7oucf8tNKkN4KY4QC1NflVH57LtAmQWSFRMaVizQIUa1M9+fij0573yiQxct1cv+w/2VFvYmNL3rMK3+H9bXwY05GgoELK1/F0PMqRm/0bEBxIDYrs/JJAPjlFVe4z3R6jb9grBLoaw9E1WEG9lRhuDnVy462KZ0kDeJJZd+UA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794847932; 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=Jp0mGo3e+aoHROpQxWmlVJQlrDv/FWEXONRrD+RSbRk=; b=hWygy+JKJT9+m7+MP/ZxC7Dn8yPNEsvWhN5Yl40opdPq0KmjtR+UZCfLpm3kY54URghrPX4CV5qHNcm4j1jC56emIhEgZqr/WFEoqtcrxoErg31dD2v6YzlQm+KXHWF2CCloVKmlPOasSAl+AivxboTSBS1cEcOyR7pCQUpKGVc= 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 1794847932679907.5124092312091; Mon, 16 Nov 2026 08:52:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xSzw8-0000Yh-4l; Mon, 16 Nov 2026 11:52:10 -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 1xSzv8-0007q7-QX for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:51:07 -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 1xSzuy-0007f6-UT for qemu-devel@nongnu.org; Mon, 16 Nov 2026 11:50:58 -0500 Received: from mx-prod-mc-05.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-620-Xt4MFfkuMampiktxB2dtPg-1; Mon, 16 Nov 2026 11:50:50 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EE0C1195604C; Mon, 16 Nov 2026 16:50:37 +0000 (UTC) Received: from jsnow-thinkpadp16vgen1.westford.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A4884195B3C7; Mon, 16 Nov 2026 16:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794847856; 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=Jp0mGo3e+aoHROpQxWmlVJQlrDv/FWEXONRrD+RSbRk=; b=DfpBCFhWTlK0KbrW1pemVxsTRIITwCJbharE74+DjuHGYVqlpac66pQqBjq8yVr3+INegT i1kHLDzq8TNsjzYuuUORb+W8fa9jfNskPB49lt2XbPyScK6MTxt2BWqxEKO1URgxKxwVXG HjN4dtDREy6XLLMeRZ8TT9eyC2+9ICw= X-MC-Unique: Xt4MFfkuMampiktxB2dtPg-1 X-Mimecast-MFC-AGG-ID: Xt4MFfkuMampiktxB2dtPg_1794847838 From: John Snow To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, Dmitry Osipenko , Fabiano Rosas , Alistair Francis , Pierrick Bouvier , Stefan Weil , Peter Xu , Richard Henderson , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Akihiko Odaki , Marcelo Tosatti , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow Subject: [PATCH v2 7/7] debug/mem: HACK add qemu_name_buffer Date: Mon, 16 Nov 2026 11:50:02 -0500 Message-ID: <20261116165002.30939-8-jsnow@redhat.com> In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com> References: <20261116165002.30939-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: 1794847934309158500 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 46ea98f1134..083400a9c2e 100644 --- a/util/mmap-vma.c +++ b/util/mmap-vma.c @@ -73,3 +73,26 @@ int qemu_name_vma(void *ptr, size_t sz, const char *fmt,= ...) =20 return rc; } + +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.1