From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Wesley Hershberger <wesley.hershberger@canonical.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
Hector Cao <hector.cao@canonical.com>,
alex.ramirez@canonical.com
Subject: Re: [PATCH v2 2/2] util/coroutine: Reduce default idle pool max size
Date: Tue, 13 Oct 2026 16:47:18 +0100 [thread overview]
Message-ID: <as5Shuj9MJy_zlNn@redhat.com> (raw)
In-Reply-To: <20261013-set-default-pool-size-v2-2-f4fd6f2a3303@canonical.com>
On Tue, Oct 13, 2026 at 10:21:59AM -0500, Wesley Hershberger wrote:
> If g_file_get_contents fails (AppArmor or other LSM), use a more
> conservative default max size for the idle coroutine pool; this avoids
> any possibility of the failure described in 86a637e48104 unless the host
> kernel is configured with a low vm.max_map_count.
>
> This change is motivated by a discussion of backport risk:
> https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/2168803/comments/8
>
> Fixes: 86a637e48104 ("coroutine: cap per-thread local pool size")
> Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
> ---
> util/qemu-coroutine.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
> index 5af61995437..cfe10c033e4 100644
> --- a/util/qemu-coroutine.c
> +++ b/util/qemu-coroutine.c
> @@ -366,6 +366,11 @@ static unsigned int get_global_pool_hard_max_size(void)
> #ifdef __linux__
> g_autofree char *contents = NULL;
> int max_map_count;
> + /*
> + * Read from /proc might fail due to LSM; use (DEFAULT_MAX_MAP_COUNT - 5000)
> + * for distributions that don't change the kernel default
> + */
> + int default_pool_hard_max_size = 60530 / 2;
>
> /*
> * Linux processes can have up to max_map_count virtual memory areas
> @@ -378,7 +383,7 @@ static unsigned int get_global_pool_hard_max_size(void)
> /* contents has trailing newline, remove it before conversion */
> g_strchomp(contents);
> if (qemu_strtoi(contents, NULL, 10, &max_map_count) != 0) {
> - return UINT_MAX;
> + return default_pool_hard_max_size;
> }
> /*
> * This is an upper bound that avoids exceeding max_map_count. Leave a
> @@ -395,7 +400,7 @@ static unsigned int get_global_pool_hard_max_size(void)
> }
> #endif
>
> - return UINT_MAX;
> + return default_pool_hard_max_size;
This code is outside the __linux__ condition, but this is now applying
a Linux derived limit to it.
I'd suggest splitting the methods so it is more like this:
#ifdef __linux__
static unsigned int get_max_map_count(void)
{
g_autofree char *contents = NULL;
if (g_file_get_contents("/proc/sys/vm/max_map_count", &contents,
NULL, NULL)) {
g_strchomp(contents);
if (qemu_strtoi(contents, NULL, 10, &max_map_count) == 0) {
return max_map_count;
}
}
return 0;
}
static unsigned int get_global_pool_hard_max_size(void)
{
int max_map_count = get_max_map_count();
if (!max_map_count) {
max_map_count = 65530;
}
...snip comments...
if (max_map_count > 5000) {
return (max_map_count - 5000) / 2;
} else {
/* Disable the global pool but threads still have local pools */
return 0;
}
}
#else
static unsigned int get_global_pool_hard_max_size(void)
{
return UINT_MAX;
}
#endif
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
prev parent reply other threads:[~2026-10-13 15:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 15:21 [PATCH v2 0/2] util/coroutine: Reduce default idle pool max size Wesley Hershberger
2026-10-13 15:21 ` [PATCH v2 1/2] util/coroutine: trim sysctl's max_map_count newline before parsing Wesley Hershberger
2026-10-13 15:21 ` [PATCH v2 2/2] util/coroutine: Reduce default idle pool max size Wesley Hershberger
2026-10-13 15:47 ` Daniel P. Berrangé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=as5Shuj9MJy_zlNn@redhat.com \
--to=berrange@redhat.com \
--cc=alex.ramirez@canonical.com \
--cc=hector.cao@canonical.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wesley.hershberger@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.