From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
kvm@vger.kernel.org,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Stefan Weil" <sw@weilnetz.de>, "Peter Xu" <peterx@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"John Snow" <jsnow@redhat.com>
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 [thread overview]
Message-ID: <20261116165002.30939-7-jsnow@redhat.com> (raw)
In-Reply-To: <20261116165002.30939-1-jsnow@redhat.com>
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 <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
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);
void qemu_ram_munmap(int fd, void *ptr, size_t size);
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")
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);
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 *qdev, Error **errp)
#if !defined(CONFIG_WIN32)
if (virtio_gpu_hostmem_enabled(b->conf)) {
map = qemu_ram_mmap(-1, b->conf.hostmem, qemu_real_host_page_size(),
- 0, 0);
+ 0, 0, "virgl-hostmem");
if (map == MAP_FAILED) {
error_setg_errno(errp, errno,
"virgl hostmem region could not be initialized");
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 = 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 |= (block->flags & RAM_SHARED) ? QEMU_MAP_SHARED : 0;
qemu_map_flags |= (block->flags & RAM_PMEM) ? QEMU_MAP_SYNC : 0;
qemu_map_flags |= (block->flags & RAM_NORESERVE) ? QEMU_MAP_NORESERVE : 0;
- area = qemu_ram_mmap(fd, memory, block->mr->align, qemu_map_flags, offset);
+ area = qemu_ram_mmap(fd, memory, block->mr->align, qemu_map_flags, offset,
+ "file_ram_alloc");
if (area == 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 = 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 = size_to_str(new_block->max_length);
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 *unused)
case TDVF_SECTION_TYPE_TD_HOB:
case TDVF_SECTION_TYPE_TEMP_MEM:
entry->mem_ptr = 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 == 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 = qemu_map_flags & QEMU_MAP_NORESERVE;
const bool readonly = qemu_map_flags & QEMU_MAP_READONLY;
@@ -236,6 +237,8 @@ static void *mmap_activate(void *ptr, size_t size, int fd,
*/
activated_ptr = mmap(ptr, size, prot, flags, fd, map_offset);
}
+
+ qemu_name_vma(ptr, size, "%s", nickname);
return activated_ptr;
}
@@ -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 = mmap_guard_pagesize(fd);
size_t offset, total;
@@ -277,7 +281,7 @@ void *qemu_ram_mmap(int fd,
offset = QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guardptr;
ptr = mmap_activate(guardptr + offset, size, fd, qemu_map_flags,
- map_offset);
+ map_offset, nickname);
if (ptr == 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:
/* 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 = (shared ? QEMU_MAP_SHARED : 0) |
(noreserve ? QEMU_MAP_NORESERVE : 0);
size_t align = QEMU_VMALLOC_ALIGN;
#ifndef EMSCRIPTEN
- void *ptr = qemu_ram_mmap(-1, size, align, qemu_map_flags, 0);
+ void *ptr = qemu_ram_mmap(-1, size, align, qemu_map_flags, 0, nickname);
if (ptr == 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)
}
void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared,
- bool noreserve)
+ bool noreserve, const char *nickname)
{
void *ptr;
--
2.56.1
next prev parent reply other threads:[~2026-11-16 16:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:49 [PATCH v2 0/7] debug: add PR_SET_VMA_ANON_NAME support John Snow
2026-11-16 16:49 ` [PATCH v2 1/7] debug/mem: add utility to name anonymous memory mappings John Snow
2026-11-17 13:39 ` Daniel P. Berrangé
2026-11-16 16:49 ` [PATCH v2 2/7] debug/mem: add tracing to qemu_vname_vma() John Snow
2026-11-16 16:49 ` [PATCH v2 3/7] debug/mem: name <reserved> regions in mmap-alloc John Snow
2026-11-16 16:49 ` [PATCH v2 4/7] debug/mem: name pthreads John Snow
2026-11-17 13:46 ` Daniel P. Berrangé
2026-11-17 13:47 ` Daniel P. Berrangé
2026-11-16 16:50 ` [PATCH v2 5/7] debug/mem: name coroutine stacks John Snow
2026-11-17 13:47 ` Daniel P. Berrangé
2026-11-16 16:50 ` John Snow [this message]
2026-11-16 16:50 ` [PATCH v2 7/7] debug/mem: HACK add qemu_name_buffer John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116165002.30939-7-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=berrange@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dmitry.osipenko@collabora.com \
--cc=farosas@suse.de \
--cc=kvm@vger.kernel.org \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox