2015-01-14 01:42:12 +01:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Wed, 14 Jan 2015 01:32:11 +0100
|
2019-01-04 22:08:16 +01:00
|
|
|
Subject: AIO: Reduce number of threads for 32bit hosts
|
2015-01-14 01:42:12 +01:00
|
|
|
|
|
|
|
On hosts with limited virtual address space (32bit pointers), we can very
|
|
|
|
easily run out of virtual memory with big thread pools.
|
|
|
|
|
|
|
|
Instead, we should limit ourselves to small pools to keep memory footprint
|
|
|
|
low on those systems.
|
|
|
|
|
|
|
|
This patch fixes random VM stalls like
|
|
|
|
|
|
|
|
(process:25114): GLib-ERROR **: gmem.c:103: failed to allocate 1048576 bytes
|
|
|
|
|
|
|
|
on 32bit ARM systems for me.
|
|
|
|
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
|
|
---
|
2017-03-29 06:22:10 +02:00
|
|
|
util/thread-pool.c | 7 ++++++-
|
2015-01-14 01:42:12 +01:00
|
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
|
2017-03-29 06:22:10 +02:00
|
|
|
diff --git a/util/thread-pool.c b/util/thread-pool.c
|
2020-08-12 00:53:07 +02:00
|
|
|
index d763cea505b68575af8e1b39cd95..785487b8767d96ca76c643f1851f 100644
|
2017-03-29 06:22:10 +02:00
|
|
|
--- a/util/thread-pool.c
|
|
|
|
+++ b/util/thread-pool.c
|
2020-08-12 00:53:07 +02:00
|
|
|
@@ -306,7 +306,12 @@ static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
|
2015-01-14 01:42:12 +01:00
|
|
|
qemu_mutex_init(&pool->lock);
|
|
|
|
qemu_cond_init(&pool->worker_stopped);
|
|
|
|
qemu_sem_init(&pool->sem, 0);
|
|
|
|
- pool->max_threads = 64;
|
|
|
|
+ if (sizeof(pool) == 4) {
|
|
|
|
+ /* 32bit systems run out of virtual memory quickly */
|
|
|
|
+ pool->max_threads = 4;
|
|
|
|
+ } else {
|
|
|
|
+ pool->max_threads = 64;
|
|
|
|
+ }
|
|
|
|
pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool);
|
|
|
|
|
|
|
|
QLIST_INIT(&pool->head);
|