summaryrefslogtreecommitdiff
path: root/thread-pool.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2015-01-14 01:32:11 +0100
committerhyokeun <hyokeun.jeon@samsung.com>2016-09-06 15:55:35 +0900
commit47daf0814857cacd2be64ffe4a3846edc9d76a2f (patch)
tree207d14ab3098cf8857535773eed83b6aabec4e8a /thread-pool.c
parent4dfab751ab3974be0d5d4a7849e40c85cd135430 (diff)
downloadqemu-47daf0814857cacd2be64ffe4a3846edc9d76a2f.tar.gz
qemu-47daf0814857cacd2be64ffe4a3846edc9d76a2f.tar.bz2
qemu-47daf0814857cacd2be64ffe4a3846edc9d76a2f.zip
AIO: Reduce number of threads for 32bit hosts
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>
Diffstat (limited to 'thread-pool.c')
-rw-r--r--thread-pool.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/thread-pool.c b/thread-pool.c
index 6fba91352..ee0b485f0 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -297,7 +297,12 @@ static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
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);