From nobody Wed Nov 5 09:04:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499671353510245.80362256248884; Mon, 10 Jul 2017 00:22:33 -0700 (PDT) Received: from localhost ([::1]:38959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUT1b-0001Mm-4F for importer@patchew.org; Mon, 10 Jul 2017 03:22:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUSzo-0000Kz-Tl for qemu-devel@nongnu.org; Mon, 10 Jul 2017 03:20:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUSzn-0000jX-36 for qemu-devel@nongnu.org; Mon, 10 Jul 2017 03:20:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUSzm-0000hu-PJ for qemu-devel@nongnu.org; Mon, 10 Jul 2017 03:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A661B81227 for ; Mon, 10 Jul 2017 07:20:37 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-94.pek2.redhat.com [10.72.12.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BB1A7D571; Mon, 10 Jul 2017 07:20:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A661B81227 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A661B81227 From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 10 Jul 2017 15:20:23 +0800 Message-Id: <20170710072027.7948-2-famz@redhat.com> In-Reply-To: <20170710072027.7948-1-famz@redhat.com> References: <20170710072027.7948-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Jul 2017 07:20:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RFC 1/5] aio: Wrap poll parameters into AioContextPollParams X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Fam Zheng , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The same set of parameters will also be wanted by the coming iothread group object, make a structure to slightly reduce the code duplication. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- include/block/aio.h | 18 ++++++++++++------ include/sysemu/iothread.h | 5 +---- iothread.c | 24 +++++++++--------------- util/aio-posix.c | 10 +++++----- util/aio-win32.c | 4 ++-- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index e9aeeae..fcf1faf 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -551,17 +551,23 @@ static inline bool aio_context_in_iothread(AioContext= *ctx) */ void aio_context_setup(AioContext *ctx); =20 +typedef struct { + /* how long to busy poll for, in nanoseconds. 0 means don't poll */ + int64_t max_ns; + /* polling time growth factor */ + int64_t grow; + /* polling time shrink factor */ + int64_t shrink; +} AioContextPollParams; + /** * aio_context_set_poll_params: * @ctx: the aio context - * @max_ns: how long to busy poll for, in nanoseconds - * @grow: polling time growth factor - * @shrink: polling time shrink factor + * @params: the new params to update to * - * Poll mode can be disabled by setting poll_max_ns to 0. + * Poll mode can be disabled by setting params.max_ns to 0. */ -void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, - int64_t grow, int64_t shrink, +void aio_context_set_poll_params(AioContext *ctx, AioContextPollParams par= ams, Error **errp); =20 #endif diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h index e6da1a4..eecfc19 100644 --- a/include/sysemu/iothread.h +++ b/include/sysemu/iothread.h @@ -29,10 +29,7 @@ typedef struct { bool stopping; int thread_id; =20 - /* AioContext poll parameters */ - int64_t poll_max_ns; - int64_t poll_grow; - int64_t poll_shrink; + AioContextPollParams poll_params; } IOThread; =20 #define IOTHREAD(obj) \ diff --git a/iothread.c b/iothread.c index beeb870..f5a01bb 100644 --- a/iothread.c +++ b/iothread.c @@ -81,7 +81,7 @@ static void iothread_instance_init(Object *obj) { IOThread *iothread =3D IOTHREAD(obj); =20 - iothread->poll_max_ns =3D IOTHREAD_POLL_MAX_NS_DEFAULT; + iothread->poll_params.max_ns =3D IOTHREAD_POLL_MAX_NS_DEFAULT; } =20 static void iothread_instance_finalize(Object *obj) @@ -111,10 +111,7 @@ static void iothread_complete(UserCreatable *obj, Erro= r **errp) return; } =20 - aio_context_set_poll_params(iothread->ctx, - iothread->poll_max_ns, - iothread->poll_grow, - iothread->poll_shrink, + aio_context_set_poll_params(iothread->ctx, iothread->poll_params, &local_error); if (local_error) { error_propagate(errp, local_error); @@ -151,13 +148,13 @@ typedef struct { } PollParamInfo; =20 static PollParamInfo poll_max_ns_info =3D { - "poll-max-ns", offsetof(IOThread, poll_max_ns), + "poll-max-ns", offsetof(IOThread, poll_params.max_ns), }; static PollParamInfo poll_grow_info =3D { - "poll-grow", offsetof(IOThread, poll_grow), + "poll-grow", offsetof(IOThread, poll_params.grow), }; static PollParamInfo poll_shrink_info =3D { - "poll-shrink", offsetof(IOThread, poll_shrink), + "poll-shrink", offsetof(IOThread, poll_params.shrink), }; =20 static void iothread_get_poll_param(Object *obj, Visitor *v, @@ -193,10 +190,7 @@ static void iothread_set_poll_param(Object *obj, Visit= or *v, *field =3D value; =20 if (iothread->ctx) { - aio_context_set_poll_params(iothread->ctx, - iothread->poll_max_ns, - iothread->poll_grow, - iothread->poll_shrink, + aio_context_set_poll_params(iothread->ctx, iothread->poll_params, &local_err); } =20 @@ -268,9 +262,9 @@ static int query_one_iothread(Object *object, void *opa= que) info =3D g_new0(IOThreadInfo, 1); info->id =3D iothread_get_id(iothread); info->thread_id =3D iothread->thread_id; - info->poll_max_ns =3D iothread->poll_max_ns; - info->poll_grow =3D iothread->poll_grow; - info->poll_shrink =3D iothread->poll_shrink; + info->poll_max_ns =3D iothread->poll_params.max_ns; + info->poll_grow =3D iothread->poll_params.grow; + info->poll_shrink =3D iothread->poll_params.shrink; =20 elem =3D g_new0(IOThreadInfoList, 1); elem->value =3D info; diff --git a/util/aio-posix.c b/util/aio-posix.c index 2d51239..1db8f3c 100644 --- a/util/aio-posix.c +++ b/util/aio-posix.c @@ -713,16 +713,16 @@ void aio_context_setup(AioContext *ctx) #endif } =20 -void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, - int64_t grow, int64_t shrink, Error **err= p) +void aio_context_set_poll_params(AioContext *ctx, AioContextPollParams par= ams, + Error **errp) { /* No thread synchronization here, it doesn't matter if an incorrect v= alue * is used once. */ - ctx->poll_max_ns =3D max_ns; + ctx->poll_max_ns =3D params.max_ns; ctx->poll_ns =3D 0; - ctx->poll_grow =3D grow; - ctx->poll_shrink =3D shrink; + ctx->poll_grow =3D params.grow; + ctx->poll_shrink =3D params.shrink; =20 aio_notify(ctx); } diff --git a/util/aio-win32.c b/util/aio-win32.c index bca496a..d8a1b20 100644 --- a/util/aio-win32.c +++ b/util/aio-win32.c @@ -400,8 +400,8 @@ void aio_context_setup(AioContext *ctx) { } =20 -void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, - int64_t grow, int64_t shrink, Error **err= p) +void aio_context_set_poll_params(AioContext *ctx, AioContextPollParams par= ams, + Error **errp) { error_setg(errp, "AioContext polling is not implemented on Windows"); } --=20 2.9.4