From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBCGb-0003P0-84 for qemu-devel@nongnu.org; Tue, 13 Jan 2015 19:57:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBCGY-0007yV-0u for qemu-devel@nongnu.org; Tue, 13 Jan 2015 19:57:01 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40738 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBCGX-0007y9-Qh for qemu-devel@nongnu.org; Tue, 13 Jan 2015 19:56:57 -0500 From: Alexander Graf Date: Wed, 14 Jan 2015 01:56:56 +0100 Message-Id: <1421197016-69426-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH] AIO: Reduce number of threads for 32bit hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Stefan Hajnoczi 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 --- thread-pool.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/thread-pool.c b/thread-pool.c index e2cac8e..87a3ea9 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -299,7 +299,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); -- 1.7.12.4