[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] backends/hostmem: add an ability to make prealloc timeout fa
From: |
Daniil Tatianin |
Subject: |
[PATCH 4/4] backends/hostmem: add an ability to make prealloc timeout fatal |
Date: |
Fri, 20 Jan 2023 16:47:49 +0300 |
This is controlled via the new 'prealloc-timeout-fatal' property and can
be useful for cases when we cannot afford to not preallocate all guest
pages while being time constrained.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
backends/hostmem.c | 38 ++++++++++++++++++++++++++++++++++----
include/sysemu/hostmem.h | 1 +
qapi/qom.json | 4 ++++
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index be9af7515e..0808dc6951 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -39,12 +39,21 @@ host_memory_on_prealloc_timeout(void *opaque,
const PreallocStats *stats)
{
HostMemoryBackend *backend = opaque;
+ const char *msg = "HostMemory preallocation timeout %"PRIu64"s exceeded, "
+ "allocated %zu/%zu (%zu byte) pages (%d threads)";
+
+ if (backend->prealloc_timeout_fatal) {
+ error_report(msg, (uint64_t)stats->seconds_elapsed,
+ stats->allocated_pages, stats->total_pages,
+ stats->page_size, stats->threads);
+ exit(1);
+
+ }
backend->prealloc_did_timeout = true;
- warn_report("HostMemory preallocation timeout %"PRIu64"s exceeded, "
- "allocated %zu/%zu (%zu byte) pages (%d threads)",
- (uint64_t)stats->seconds_elapsed, stats->allocated_pages,
- stats->total_pages, stats->page_size, stats->threads);
+ warn_report(msg, (uint64_t)stats->seconds_elapsed,
+ stats->allocated_pages, stats->total_pages,
+ stats->page_size, stats->threads);
}
char *
@@ -315,6 +324,22 @@ static void
host_memory_backend_get_set_prealloc_timeout(Object *obj,
visit_type_uint32(v, name, &backend->prealloc_timeout, errp);
}
+static bool host_memory_backend_get_prealloc_timeout_fatal(
+ Object *obj, Error **errp)
+{
+ HostMemoryBackend *backend = MEMORY_BACKEND(obj);
+
+ return backend->prealloc_timeout_fatal;
+}
+
+static void host_memory_backend_set_prealloc_timeout_fatal(
+ Object *obj, bool value, Error **errp)
+{
+ HostMemoryBackend *backend = MEMORY_BACKEND(obj);
+
+ backend->prealloc_timeout_fatal = value;
+}
+
static void host_memory_backend_init(Object *obj)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
@@ -560,6 +585,11 @@ host_memory_backend_class_init(ObjectClass *oc, void *data)
NULL, NULL);
object_class_property_set_description(oc, "prealloc-timeout",
"Maximum memory preallocation timeout in seconds");
+ object_class_property_add_bool(oc, "prealloc-timeout-fatal",
+ host_memory_backend_get_prealloc_timeout_fatal,
+ host_memory_backend_set_prealloc_timeout_fatal);
+ object_class_property_set_description(oc, "prealloc-timeout-fatal",
+ "Consider preallocation timeout a fatal error");
object_class_property_add(oc, "size", "int",
host_memory_backend_get_size,
host_memory_backend_set_size,
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index 21910f3b45..b501b5eff2 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -67,6 +67,7 @@ struct HostMemoryBackend {
bool merge, dump, use_canonical_path;
bool prealloc, is_mapped, share, reserve;
bool prealloc_did_timeout;
+ bool prealloc_timeout_fatal;
uint32_t prealloc_threads;
uint32_t prealloc_timeout;
ThreadContext *prealloc_context;
diff --git a/qapi/qom.json b/qapi/qom.json
index 9149c064b8..70644d714b 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -584,6 +584,9 @@
# @prealloc-timeout: Maximum memory preallocation timeout in seconds
# (default: 0) (since 7.3)
#
+# @prealloc-timeout-fatal: Consider preallocation timeout a fatal error
+# (default: false) (since 7.3)
+#
# @share: if false, the memory is private to QEMU; if true, it is shared
# (default: false)
#
@@ -616,6 +619,7 @@
'*prealloc-threads': 'uint32',
'*prealloc-context': 'str',
'*prealloc-timeout': 'uint32',
+ '*prealloc-timeout-fatal': 'bool',
'*share': 'bool',
'*reserve': 'bool',
'size': 'size',
--
2.25.1
- [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Daniil Tatianin, 2023/01/20
- [PATCH 2/4] backends/hostmem: move memory region preallocation logic into a helper, Daniil Tatianin, 2023/01/20
- [PATCH 4/4] backends/hostmem: add an ability to make prealloc timeout fatal,
Daniil Tatianin <=
- [PATCH 3/4] backends/hostmem: add an ability to specify prealloc timeout, Daniil Tatianin, 2023/01/20
- [PATCH 1/4] oslib: introduce new qemu_prealloc_mem_with_timeout() api, Daniil Tatianin, 2023/01/20
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, David Hildenbrand, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Daniil Tatianin, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Daniel P . Berrangé, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, David Hildenbrand, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Daniil Tatianin, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, David Hildenbrand, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Daniel P . Berrangé, 2023/01/23
- Re: [PATCH v0 0/4] backends/hostmem: add an ability to specify prealloc timeout, Valentin Sinitsyn, 2023/01/24