qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name


From: Eiichi Tsukata
Subject: [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name
Date: Tue, 11 Apr 2023 04:11:58 +0000

Use linux specific PR_SET_VMA_ANON_NAME (introduced in v5.17) to set ram
block name in the kernel. This makes each ram block distinguishable and
can help debugging and inspection. The names of ram blocks are shown in
/proc/pid/maps like this:

  7f00e9400000-7f00f1400000 rw-p 00000000 00:00 0      [anon:pc.ram]
  7f0115200000-7f0115201000 rw-p 00000000 00:00 0      [anon:/rom@etc/acpi/rsdp]
  7f0115400000-7f0115410000 rw-p 00000000 00:00 0      
[anon:/rom@etc/table-loader]
  7f0115600000-7f0115800000 rw-p 00000000 00:00 0      
[anon:/rom@etc/acpi/tables]
  7f0115a00000-7f0115a40000 rw-p 00000000 00:00 0      [anon:e1000.rom]
  ...

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
---
 meson.build       | 2 ++
 softmmu/physmem.c | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/meson.build b/meson.build
index 29f8644d6d..aca889f5f0 100644
--- a/meson.build
+++ b/meson.build
@@ -2040,6 +2040,8 @@ config_host_data.set('HAVE_OPTRESET',
                      cc.has_header_symbol('getopt.h', 'optreset'))
 config_host_data.set('HAVE_IPPROTO_MPTCP',
                      cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
+config_host_data.set('CONFIG_PRCTL_PR_SET_VMA_ANON_NAME',
+                     cc.has_header_symbol('sys/prctl.h', 
'PR_SET_VMA_ANON_NAME'))
 
 # has_member
 config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index e35061bba4..4fe3e14193 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -80,6 +80,10 @@
 #include <daxctl/libdaxctl.h>
 #endif
 
+#ifdef CONFIG_PRCTL_PR_SET_VMA_ANON_NAME
+#include <sys/prctl.h>
+#endif
+
 //#define DEBUG_SUBPAGE
 
 /* ram_list is read under rcu_read_lock()/rcu_read_unlock().  Writes
@@ -1810,6 +1814,11 @@ static void ram_block_add(RAMBlock *new_block, Error 
**errp)
                 return;
             }
             memory_try_enable_merging(new_block->host, new_block->max_length);
+#ifdef CONFIG_PRCTL_PR_SET_VMA_ANON_NAME
+            prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME,
+                  (unsigned long) new_block->host, new_block->max_length,
+                  (unsigned long) new_block->mr->name);
+#endif
         }
     }
 
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]