[PATCH] util/coroutine: Reduce default idle pool max size

Wesley Hershberger posted 1 patch 1 month, 1 week ago
Failed in applying to current master (apply log)
There is a newer version of this series
util/qemu-coroutine.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] util/coroutine: Reduce default idle pool max size
Posted by Wesley Hershberger 1 month, 1 week ago
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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
index d17135f585a..d8853e3b227 100644
--- a/util/qemu-coroutine.c
+++ b/util/qemu-coroutine.c
@@ -391,7 +391,11 @@ static unsigned int get_global_pool_hard_max_size(void)
     }
 #endif
 
-    return UINT_MAX;
+    /*
+     * Read from /proc might fail due to LSM; use (DEFAULT_MAX_MAP_COUNT - 5000)
+     * for distributions that don't change the kernel default
+     */
+    return (60530) / 2;
 }
 
 static void __attribute__((constructor)) qemu_coroutine_init(void)

---
base-commit: 615ece3c406b262996e569f29ea6eed0d81c4d8d
change-id: 20261013-set-default-pool-size-8b27c0fca8e3

Best regards,
-- 
Wesley Hershberger <wesley.hershberger@canonical.com>
Re: [PATCH] util/coroutine: Reduce default idle pool max size
Posted by Philippe Mathieu-Daudé 1 month, 1 week ago
Hi,

On 13/10/26 16:38, 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 | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
> index d17135f585a..d8853e3b227 100644
> --- a/util/qemu-coroutine.c
> +++ b/util/qemu-coroutine.c
> @@ -391,7 +391,11 @@ static unsigned int get_global_pool_hard_max_size(void)
>       }

I think you want here

           else { your Linux code }

>   #endif
>   
> -    return UINT_MAX;
> +    /*
> +     * Read from /proc might fail due to LSM; use (DEFAULT_MAX_MAP_COUNT - 5000)

I've heard of AppArmor, not LSM acronym.

> +     * for distributions that don't change the kernel default
> +     */

because this ladder is used on BSD, Windows, ...

Also since modifying this area it would be nice to add some
self-describing #define for this fixed amount for non-coroutine
users magic number.

> +    return (60530) / 2;
>   }
>   
>   static void __attribute__((constructor)) qemu_coroutine_init(void)
> 
> ---
> base-commit: 615ece3c406b262996e569f29ea6eed0d81c4d8d
> change-id: 20261013-set-default-pool-size-8b27c0fca8e3
> 
> Best regards,