51 lines
1.8 KiB
Diff
51 lines
1.8 KiB
Diff
|
|
From 2fc1b97a5acd19c52d8af4bfd8bcf4824db48fb9 Mon Sep 17 00:00:00 2001
|
||
|
|
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 16 Sep 2024 16:53:58 +0800
|
||
|
|
Subject: [PATCH] virtio-mem: don't warn about THP sizes on a kernel without
|
||
|
|
THP support cheery-pick from 95b717a8154b955de2782305f305b63f357b0576 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>
|
||
|
|
Message-Id: <20240910163433.2100295-1-david@redhat.com>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.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 49749349e0..452f60266a 100644
|
||
|
|
--- a/hw/virtio/virtio-mem.c
|
||
|
|
+++ b/hw/virtio/virtio-mem.c
|
||
|
|
@@ -61,6 +61,7 @@
|
||
|
|
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;
|
||
|
|
@@ -71,6 +72,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.41.0.windows.1
|
||
|
|
|