From patchwork Thu Aug 1 16:54:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 11071049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45D0C14E5 for ; Thu, 1 Aug 2019 17:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 249AF28515 for ; Thu, 1 Aug 2019 17:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15E5D285CE; Thu, 1 Aug 2019 17:05:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC00528515 for ; Thu, 1 Aug 2019 17:05:57 +0000 (UTC) Received: from localhost ([::1]:57838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htEWb-0006Gv-1V for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Aug 2019 13:05:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36515) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htETp-00050a-8r for qemu-devel@nongnu.org; Thu, 01 Aug 2019 13:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htETo-0002Gc-7L for qemu-devel@nongnu.org; Thu, 01 Aug 2019 13:03:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1htELn-0005Y2-UF for qemu-devel@nongnu.org; Thu, 01 Aug 2019 12:54:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AEC117C52F; Thu, 1 Aug 2019 16:54:42 +0000 (UTC) Received: from localhost (ovpn-116-232.ams2.redhat.com [10.36.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99CCB5D9CD; Thu, 1 Aug 2019 16:54:37 +0000 (UTC) From: Stefan Hajnoczi To: virtio-fs@redhat.com, qemu-devel@nongnu.org Date: Thu, 1 Aug 2019 17:54:09 +0100 Message-Id: <20190801165409.20121-5-stefanha@redhat.com> In-Reply-To: <20190801165409.20121-1-stefanha@redhat.com> References: <20190801165409.20121-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Aug 2019 16:54:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] virtiofsd: add --thread-pool-size=NUM option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liu Bo , "Dr. David Alan Gilbert" , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add an option to control the size of the thread pool. Requests are now processed in parallel by default. Signed-off-by: Stefan Hajnoczi --- contrib/virtiofsd/fuse_i.h | 1 + contrib/virtiofsd/fuse_lowlevel.c | 8 ++++++-- contrib/virtiofsd/fuse_virtio.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/contrib/virtiofsd/fuse_i.h b/contrib/virtiofsd/fuse_i.h index dcde9feb97..5c82cf2eac 100644 --- a/contrib/virtiofsd/fuse_i.h +++ b/contrib/virtiofsd/fuse_i.h @@ -74,6 +74,7 @@ struct fuse_session { int vu_listen_fd; int vu_socketfd; struct fv_VuDev *virtio_dev; + int thread_pool_size; }; struct fuse_chan { diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c index 483a1bc9be..b692791fbc 100644 --- a/contrib/virtiofsd/fuse_lowlevel.c +++ b/contrib/virtiofsd/fuse_lowlevel.c @@ -26,7 +26,7 @@ #include #include - +#define THREAD_POOL_SIZE 64 #define OFFSET_MAX 0x7fffffffffffffffLL @@ -2556,6 +2556,7 @@ static const struct fuse_opt fuse_ll_opts[] = { LL_OPTION("--socket-path=%s", vu_socket_path, 0), LL_OPTION("vhost_user_socket=%s", vu_socket_path, 0), LL_OPTION("--fd=%d", vu_listen_fd, 0), + LL_OPTION("--thread-pool-size=%d", thread_pool_size, 0), FUSE_OPT_END }; @@ -2575,7 +2576,9 @@ void fuse_lowlevel_help(void) " --socket-path=PATH path for the vhost-user socket\n" " -o vhost_user_socket=PATH path for the vhost-user socket\n" " --fd=FDNUM fd number of vhost-user socket\n" -" -o auto_unmount auto unmount on process termination\n"); +" -o auto_unmount auto unmount on process termination\n" +" --thread-pool-size=NUM thread pool size limit (default %d)\n", + THREAD_POOL_SIZE); } void fuse_session_destroy(struct fuse_session *se) @@ -2629,6 +2632,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, } se->fd = -1; se->vu_listen_fd = -1; + se->thread_pool_size = THREAD_POOL_SIZE; se->conn.max_write = UINT_MAX; se->conn.max_readahead = UINT_MAX; diff --git a/contrib/virtiofsd/fuse_virtio.c b/contrib/virtiofsd/fuse_virtio.c index 0c52911144..e13b3cc2e6 100644 --- a/contrib/virtiofsd/fuse_virtio.c +++ b/contrib/virtiofsd/fuse_virtio.c @@ -663,8 +663,8 @@ static void *fv_queue_thread(void *opaque) struct fuse_session *se = qi->virtio_dev->se; GThreadPool *pool; - pool = g_thread_pool_new(fv_queue_worker, qi, 1 /* TODO max_threads */, - TRUE, NULL); + pool = g_thread_pool_new(fv_queue_worker, qi, se->thread_pool_size, + TRUE, NULL); if (!pool) { fuse_err("%s: g_thread_pool_new failed\n", __func__); return NULL;