* [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support
@ 2024-09-10 16:34 David Hildenbrand
2024-09-10 18:26 ` Michael S. Tsirkin
2024-09-13 0:16 ` Gavin Shan
0 siblings, 2 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-09-10 16:34 UTC (permalink / raw)
To: qemu-devel
Cc: David Hildenbrand, Michael S. Tsirkin, Gavin Shan, Juraj Marcin
If the config directory in sysfs does not exist at all, we are dealing
with a system that does not support THPs. Simply use 1 MiB block size
then, instead of warning "Could not detect THP size, falling back to
..." and falling back to the default THP size.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Gavin Shan <gshan@redhat.com>
Cc: Juraj Marcin <jmarcin@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ef64bf1b4a..4075f3d4ce 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -88,6 +88,7 @@ static uint32_t virtio_mem_default_thp_size(void)
static uint32_t thp_size;
#define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
+#define HPAGE_PATH "/sys/kernel/mm/transparent_hugepage/"
static uint32_t virtio_mem_thp_size(void)
{
gchar *content = NULL;
@@ -98,6 +99,12 @@ static uint32_t virtio_mem_thp_size(void)
return thp_size;
}
+ /* No THP -> no restrictions. */
+ if (!g_file_test(HPAGE_PATH, G_FILE_TEST_EXISTS)) {
+ thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
+ return thp_size;
+ }
+
/*
* Try to probe the actual THP size, fallback to (sane but eventually
* incorrect) default sizes.
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support
2024-09-10 16:34 [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support David Hildenbrand
@ 2024-09-10 18:26 ` Michael S. Tsirkin
2024-09-10 18:44 ` David Hildenbrand
2024-09-13 0:16 ` Gavin Shan
1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2024-09-10 18:26 UTC (permalink / raw)
To: David Hildenbrand; +Cc: qemu-devel, Gavin Shan, Juraj Marcin
On Tue, Sep 10, 2024 at 06:34:33PM +0200, David Hildenbrand wrote:
> If the config directory in sysfs does not exist at all, we are dealing
> with a system that does not support THPs. Simply use 1 MiB block size
> then, instead of warning "Could not detect THP size, falling back to
> ..." and falling back to the default THP size.
>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Gavin Shan <gshan@redhat.com>
> Cc: Juraj Marcin <jmarcin@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Okay, I picked it up. But I have a question
> ---
> hw/virtio/virtio-mem.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> index ef64bf1b4a..4075f3d4ce 100644
> --- a/hw/virtio/virtio-mem.c
> +++ b/hw/virtio/virtio-mem.c
> @@ -88,6 +88,7 @@ static uint32_t virtio_mem_default_thp_size(void)
> static uint32_t thp_size;
>
> #define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
> +#define HPAGE_PATH "/sys/kernel/mm/transparent_hugepage/"
If this code runs e.g. on windows, it will poke at cwd root with
unpredictable results.
It doesn't look like this is linux specific, did I miss anything?
> static uint32_t virtio_mem_thp_size(void)
> {
> gchar *content = NULL;
> @@ -98,6 +99,12 @@ static uint32_t virtio_mem_thp_size(void)
> return thp_size;
> }
>
> + /* No THP -> no restrictions. */
> + if (!g_file_test(HPAGE_PATH, G_FILE_TEST_EXISTS)) {
> + thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
> + return thp_size;
> + }
> +
> /*
> * Try to probe the actual THP size, fallback to (sane but eventually
> * incorrect) default sizes.
> --
> 2.46.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support
2024-09-10 18:26 ` Michael S. Tsirkin
@ 2024-09-10 18:44 ` David Hildenbrand
0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-09-10 18:44 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, Gavin Shan, Juraj Marcin
On 10.09.24 20:26, Michael S. Tsirkin wrote:
> On Tue, Sep 10, 2024 at 06:34:33PM +0200, David Hildenbrand wrote:
>> If the config directory in sysfs does not exist at all, we are dealing
>> with a system that does not support THPs. Simply use 1 MiB block size
>> then, instead of warning "Could not detect THP size, falling back to
>> ..." and falling back to the default THP size.
>>
>> Cc: "Michael S. Tsirkin" <mst@redhat.com>
>> Cc: Gavin Shan <gshan@redhat.com>
>> Cc: Juraj Marcin <jmarcin@redhat.com>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>
> Okay, I picked it up. But I have a question
Thanks, I can also route it via my memory device tree, whatever you prefer.
>
>> ---
>> hw/virtio/virtio-mem.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
>> index ef64bf1b4a..4075f3d4ce 100644
>> --- a/hw/virtio/virtio-mem.c
>> +++ b/hw/virtio/virtio-mem.c
>> @@ -88,6 +88,7 @@ static uint32_t virtio_mem_default_thp_size(void)
>> static uint32_t thp_size;
>>
>> #define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
>> +#define HPAGE_PATH "/sys/kernel/mm/transparent_hugepage/"
>
>
> If this code runs e.g. on windows, it will poke at cwd root with
> unpredictable results.
> It doesn't look like this is linux specific, did I miss anything?
VIRTIO_MEM has
"depends on LINUX"
so that code will never run on Windows.
Thanks!
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support
2024-09-10 16:34 [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support David Hildenbrand
2024-09-10 18:26 ` Michael S. Tsirkin
@ 2024-09-13 0:16 ` Gavin Shan
1 sibling, 0 replies; 4+ messages in thread
From: Gavin Shan @ 2024-09-13 0:16 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel; +Cc: Michael S. Tsirkin, Juraj Marcin
On 9/11/24 2:34 AM, David Hildenbrand wrote:
> If the config directory in sysfs does not exist at all, we are dealing
> with a system that does not support THPs. Simply use 1 MiB block size
> then, instead of warning "Could not detect THP size, falling back to
> ..." and falling back to the default THP size.
>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Gavin Shan <gshan@redhat.com>
> Cc: Juraj Marcin <jmarcin@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> hw/virtio/virtio-mem.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
Reviewed-by: Gavin Shan <gshan@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-13 0:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 16:34 [PATCH v1] virtio-mem: don't warn about THP sizes on a kernel without THP support David Hildenbrand
2024-09-10 18:26 ` Michael S. Tsirkin
2024-09-10 18:44 ` David Hildenbrand
2024-09-13 0:16 ` Gavin Shan
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).