virtio-mem: don't warn about THP sizes on a kernel without THP support
PATCH 1/1 virtio-mem: don't warn about THP sizes on a kernel without THP support
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.
--- hw/virtio/virtio-mem.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/virtio/virtio-mem.c +7 -0
@@ -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.
Signature · 1 line
2.46.0
Quoted 9 lines · David Hildenbrand
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" <[email protected]>Cc Gavin Shan <[email protected]>Cc Juraj Marcin <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Okay, I picked it up. But I have a question
hw/virtio/virtio-mem.c static uint32_t virtio_mem_default_thp_size(void) · line 91
Quoted 13 lines
--- hw/virtio/virtio-mem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/virtio/virtio-mem.c +1
-0@@ -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?
Quoted 18 lines
hw/virtio/virtio-mem.c +6
-0static 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. Signature · 1 line
2.46.0
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · David Hildenbrand
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.
Quoted 6 lines
Quoted 4 lines
Cc "Michael S. Tsirkin" <[email protected]>Cc Gavin Shan <[email protected]>Cc Juraj Marcin <[email protected]>Signed-off-by David Hildenbrand <[email protected]>Okay, I picked it up. But I have a question
Thanks, I can also route it via my memory device tree, whatever you prefer.
Quoted 12 lines
Quoted 12 lines
--- hw/virtio/virtio-mem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/virtio/virtio-mem.c +0
-0@@ -88,6 +88,7 @@ static uint32_t virtio_mem_default_thp_size(void)static uint32_t thp_size;
Quoted 7 lines
hw/virtio/virtio-mem.c static uint32_t virtio_mem_default_thp_size(void) · line 91
Quoted 2 lines
hw/virtio/virtio-mem.c +1
-0#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!
Signature · 3 lines
Cheers, David / dhildenb
Quoted 5 lines · David Hildenbrand
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.
Quoted 8 lines
Cc "Michael S. Tsirkin" <[email protected]>Cc Gavin Shan <[email protected]>Cc Juraj Marcin <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- hw/virtio/virtio-mem.c | 7 +++++++ 1 file changed, 7 insertions(+)