* [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name
@ 2023-04-11 4:11 Eiichi Tsukata
2023-04-11 7:51 ` David Hildenbrand
2023-04-11 17:00 ` Peter Xu
0 siblings, 2 replies; 3+ messages in thread
From: Eiichi Tsukata @ 2023-04-11 4:11 UTC (permalink / raw)
To: pbonzini, marcandre.lureau, berrange, thuth, philmd, peterx,
david, qemu-devel
Cc: Eiichi Tsukata
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name
2023-04-11 4:11 [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name Eiichi Tsukata
@ 2023-04-11 7:51 ` David Hildenbrand
2023-04-11 17:00 ` Peter Xu
1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2023-04-11 7:51 UTC (permalink / raw)
To: Eiichi Tsukata, pbonzini, marcandre.lureau, berrange, thuth,
philmd, peterx, qemu-devel
On 11.04.23 06:11, Eiichi Tsukata wrote:
> 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'))
Nit: I'd suggest placing that directly next to the
CONFIG_PRCTL_PR_SET_TIMERSLACK check.
>
> # 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);
We might not have anon memory. I assume that we expect that the prctl
will simply silently fail (maybe worth a comment) in case we have !anon
memory.
I assume new_block->mr->name should be set in all cases we care about,
so LGTM.
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name
2023-04-11 4:11 [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name Eiichi Tsukata
2023-04-11 7:51 ` David Hildenbrand
@ 2023-04-11 17:00 ` Peter Xu
1 sibling, 0 replies; 3+ messages in thread
From: Peter Xu @ 2023-04-11 17:00 UTC (permalink / raw)
To: Eiichi Tsukata
Cc: pbonzini, marcandre.lureau, berrange, thuth, philmd, david,
qemu-devel
On Tue, Apr 11, 2023 at 04:11:58AM +0000, Eiichi Tsukata wrote:
> 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>
Acked-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-11 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-11 4:11 [PATCH] physmem: use PR_SET_VMA_ANON_NAME to set ram block name Eiichi Tsukata
2023-04-11 7:51 ` David Hildenbrand
2023-04-11 17:00 ` Peter Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).