get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2230454/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2230454,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2230454/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260429182127.219776-4-stefanha@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260429182127.219776-4-stefanha@redhat.com>",
    "date": "2026-04-29T18:21:27",
    "name": "[PULL,3/3] qapi/iothread: introduce poll-weight parameter for aio-poll",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "03c8dfd3d330182a6b0f42f3d9a04e08f2475702",
    "submitter": {
        "id": 17227,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/17227/?format=api",
        "name": "Stefan Hajnoczi",
        "email": "stefanha@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260429182127.219776-4-stefanha@redhat.com/mbox/",
    "series": [
        {
            "id": 502128,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/502128/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502128",
            "date": "2026-04-29T18:21:24",
            "name": "[PULL,1/3] aio-poll: avoid unnecessary polling time computation",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/502128/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2230454/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2230454/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=ScOeHD+O;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5Qf20C03z1yK5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 04:23:06 +1000 (AEST)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wI9Yn-0003Ef-Vu; Wed, 29 Apr 2026 14:22:58 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <stefanha@redhat.com>)\n id 1wI9Xq-0002fI-K1\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 14:21:58 -0400",
            "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <stefanha@redhat.com>)\n id 1wI9Xk-0003it-EE\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 14:21:57 -0400",
            "from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-HG82EkBBPvOMBAp2a3Vcmw-1; Wed,\n 29 Apr 2026 14:21:46 -0400",
            "from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 28CF01800579; Wed, 29 Apr 2026 18:21:45 +0000 (UTC)",
            "from localhost (unknown [10.44.33.46])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id A8A5D19560AB; Wed, 29 Apr 2026 18:21:43 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777486910;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=8bUrkCrR0eARoen5Ol8TqCgzEV95zBAPnbtOs4MP4uU=;\n b=ScOeHD+OXB1PxKHwB9qZ0dU/vVaiTXuu1aXGgpgpz9GdoxwZ3o/RRICDOfAlZhtp6raOFI\n Bd+7wKeCCwmg0fkd7TLiWhqOOl8Mlkz/DaB09OY4DtqmbEx/+jozqqNlDRkVIjO4t8amBe\n YjC/GIf+DTTQpP/3ipPFv3Ghi3Uh+3o=",
        "X-MC-Unique": "HG82EkBBPvOMBAp2a3Vcmw-1",
        "X-Mimecast-MFC-AGG-ID": "HG82EkBBPvOMBAp2a3Vcmw_1777486905",
        "From": "Stefan Hajnoczi <stefanha@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Stefan Weil <sw@weilnetz.de>, Hanna Reitz <hreitz@redhat.com>,\n Peter Maydell <peter.maydell@linaro.org>, Kevin Wolf <kwolf@redhat.com>,\n Markus Armbruster <armbru@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>,\n qemu-block@nongnu.org, \"Dr. David Alan Gilbert\" <dave@treblig.org>,\n Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,\n \"Michael S. Tsirkin\" <mst@redhat.com>,\n =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Eric Blake <eblake@redhat.com>, Jaehoon Kim <jhkim@linux.ibm.com>",
        "Subject": "[PULL 3/3] qapi/iothread: introduce poll-weight parameter for\n aio-poll",
        "Date": "Wed, 29 Apr 2026 14:21:27 -0400",
        "Message-ID": "<20260429182127.219776-4-stefanha@redhat.com>",
        "In-Reply-To": "<20260429182127.219776-1-stefanha@redhat.com>",
        "References": "<20260429182127.219776-1-stefanha@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.12",
        "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=stefanha@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "qemu development <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "From: Jaehoon Kim <jhkim@linux.ibm.com>\n\nIntroduce a configurable poll-weight parameter for adaptive polling\nin IOThread. This parameter replaces the hardcoded POLL_WEIGHT_SHIFT\nconstant, allowing runtime control over how much the most recent\nevent interval affects the next polling duration calculation.\n\nThe poll-weight parameter uses a shift value where larger values\ndecrease the weight of the current interval, enabling more gradual\nadjustments. When set to 0, a default value of 3 is used (meaning\nthe current interval contributes approximately 1/8 to the weighted\naverage).\n\nThis patch also removes the hardcoded default value checks from\nadjust_polling_time(). Instead, poll-grow, poll-shrink, and\npoll-weight now use default values initialized in iothread.c\nduring IOThread creation.\n\nSigned-off-by: Jaehoon Kim <jhkim@linux.ibm.com>\nReviewed-by: Stefan Hajnoczi <stefanha@redhat.com>\nAcked-by: Markus Armbruster <armbru@redhat.com>\nMessage-ID: <20260423195918.661299-4-jhkim@linux.ibm.com>\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n---\n qapi/misc.json                    |  6 ++++\n qapi/qom.json                     | 10 ++++++-\n include/qemu/aio.h                |  4 ++-\n include/system/iothread.h         | 18 ++++++++++++\n iothread.c                        | 47 ++++++++++++++++++++++---------\n monitor/hmp-cmds.c                |  1 +\n tests/unit/test-nested-aio-poll.c |  2 +-\n util/aio-posix.c                  | 37 +++++++++---------------\n util/aio-win32.c                  |  3 +-\n util/async.c                      |  1 +\n qemu-options.hx                   |  8 +++++-\n 11 files changed, 95 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/qapi/misc.json b/qapi/misc.json\nindex 28c641fe2f..22b7afed9f 100644\n--- a/qapi/misc.json\n+++ b/qapi/misc.json\n@@ -85,6 +85,11 @@\n # @poll-shrink: how many ns will be removed from polling time, 0 means\n #     that it's not configured (since 2.9)\n #\n+# @poll-weight: the weight factor for adaptive polling.\n+#     Determines how much the current event interval contributes to\n+#     the next polling time calculation.  Valid values are 1 or\n+#     greater (since 11.1)\n+#\n # @aio-max-batch: maximum number of requests in a batch for the AIO\n #     engine, 0 means that the engine will use its default (since 6.1)\n #\n@@ -96,6 +101,7 @@\n            'poll-max-ns': 'int',\n            'poll-grow': 'int',\n            'poll-shrink': 'int',\n+           'poll-weight': 'int',\n            'aio-max-batch': 'int' } }\n \n ##\ndiff --git a/qapi/qom.json b/qapi/qom.json\nindex c653248f85..dd45ac1087 100644\n--- a/qapi/qom.json\n+++ b/qapi/qom.json\n@@ -606,6 +606,13 @@\n #     algorithm detects it is spending too long polling without\n #     encountering events.  0 selects a default behaviour (default: 0)\n #\n+# @poll-weight: the weight factor for adaptive polling.  Determines\n+#     how much the most recent event interval affects the next\n+#     polling duration calculation.  If set to 0, the system default\n+#     value of 3 is used.  Typical values: 1 (high weight on recent\n+#     interval), 2-4 (moderate weight on recent interval).\n+#     (default: 0) (since 11.1)\n+#\n # The @aio-max-batch option is available since 6.1.\n #\n # Since: 2.0\n@@ -614,7 +621,8 @@\n   'base': 'EventLoopBaseProperties',\n   'data': { '*poll-max-ns': 'int',\n             '*poll-grow': 'int',\n-            '*poll-shrink': 'int' } }\n+            '*poll-shrink': 'int',\n+            '*poll-weight': 'int' } }\n \n ##\n # @MainLoopProperties:\ndiff --git a/include/qemu/aio.h b/include/qemu/aio.h\nindex 6c22064a28..e65e90093a 100644\n--- a/include/qemu/aio.h\n+++ b/include/qemu/aio.h\n@@ -310,6 +310,7 @@ struct AioContext {\n     int64_t poll_max_ns;    /* maximum polling time in nanoseconds */\n     int64_t poll_grow;      /* polling time growth factor */\n     int64_t poll_shrink;    /* polling time shrink factor */\n+    int64_t poll_weight;    /* weight of current interval in calculation */\n \n     /* AIO engine parameters */\n     int64_t aio_max_batch;  /* maximum number of requests in a batch */\n@@ -791,12 +792,13 @@ void aio_context_destroy(AioContext *ctx);\n  * @max_ns: how long to busy poll for, in nanoseconds\n  * @grow: polling time growth factor\n  * @shrink: polling time shrink factor\n+ * @weight: weight factor applied to the current polling interval\n  *\n  * Poll mode can be disabled by setting poll_max_ns to 0.\n  */\n void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,\n                                  int64_t grow, int64_t shrink,\n-                                 Error **errp);\n+                                 int64_t weight, Error **errp);\n \n /**\n  * aio_context_set_aio_params:\ndiff --git a/include/system/iothread.h b/include/system/iothread.h\nindex e26d13c6c7..a1ef7696cb 100644\n--- a/include/system/iothread.h\n+++ b/include/system/iothread.h\n@@ -21,6 +21,23 @@\n \n #define TYPE_IOTHREAD \"iothread\"\n \n+#ifdef CONFIG_POSIX\n+/*\n+ * Benchmark results from 2016 on NVMe SSD drives show max polling times around\n+ * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32\n+ * workloads.\n+ */\n+#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL\n+#define IOTHREAD_POLL_GROW_DEFAULT 2ULL\n+#define IOTHREAD_POLL_SHRINK_DEFAULT 2ULL\n+#define IOTHREAD_POLL_WEIGHT_DEFAULT 3ULL\n+#else\n+#define IOTHREAD_POLL_MAX_NS_DEFAULT 0ULL\n+#define IOTHREAD_POLL_GROW_DEFAULT 0ULL\n+#define IOTHREAD_POLL_SHRINK_DEFAULT 0ULL\n+#define IOTHREAD_POLL_WEIGHT_DEFAULT 0ULL\n+#endif\n+\n struct IOThread {\n     EventLoopBase parent_obj;\n \n@@ -38,6 +55,7 @@ struct IOThread {\n     int64_t poll_max_ns;\n     int64_t poll_grow;\n     int64_t poll_shrink;\n+    int64_t poll_weight;\n };\n typedef struct IOThread IOThread;\n \ndiff --git a/iothread.c b/iothread.c\nindex caf68e0764..3558535b40 100644\n--- a/iothread.c\n+++ b/iothread.c\n@@ -25,17 +25,6 @@\n #include \"qemu/rcu.h\"\n #include \"qemu/main-loop.h\"\n \n-\n-#ifdef CONFIG_POSIX\n-/* Benchmark results from 2016 on NVMe SSD drives show max polling times around\n- * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32\n- * workloads.\n- */\n-#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL\n-#else\n-#define IOTHREAD_POLL_MAX_NS_DEFAULT 0ULL\n-#endif\n-\n static void *iothread_run(void *opaque)\n {\n     IOThread *iothread = opaque;\n@@ -103,6 +92,10 @@ static void iothread_instance_init(Object *obj)\n     IOThread *iothread = IOTHREAD(obj);\n \n     iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT;\n+    iothread->poll_grow = IOTHREAD_POLL_GROW_DEFAULT;\n+    iothread->poll_shrink = IOTHREAD_POLL_SHRINK_DEFAULT;\n+    iothread->poll_weight = IOTHREAD_POLL_WEIGHT_DEFAULT;\n+\n     iothread->thread_id = -1;\n     qemu_sem_init(&iothread->init_done_sem, 0);\n     /* By default, we don't run gcontext */\n@@ -164,6 +157,7 @@ static void iothread_set_aio_context_params(EventLoopBase *base, Error **errp)\n                                 iothread->poll_max_ns,\n                                 iothread->poll_grow,\n                                 iothread->poll_shrink,\n+                                iothread->poll_weight,\n                                 errp);\n     if (*errp) {\n         return;\n@@ -233,6 +227,9 @@ static IOThreadParamInfo poll_grow_info = {\n static IOThreadParamInfo poll_shrink_info = {\n     \"poll-shrink\", offsetof(IOThread, poll_shrink),\n };\n+static IOThreadParamInfo poll_weight_info = {\n+    \"poll-weight\", offsetof(IOThread, poll_weight),\n+};\n \n static void iothread_get_param(Object *obj, Visitor *v,\n         const char *name, IOThreadParamInfo *info, Error **errp)\n@@ -254,13 +251,31 @@ static bool iothread_set_param(Object *obj, Visitor *v,\n         return false;\n     }\n \n-    if (value < 0) {\n+    if (info->offset == offsetof(IOThread, poll_weight)) {\n+        if (value < 0 || value > 63) {\n+            error_setg(errp, \"%s value must be in range [0, 63]\",\n+                       info->name);\n+            return false;\n+        }\n+    } else if (value < 0) {\n         error_setg(errp, \"%s value must be in range [0, %\" PRId64 \"]\",\n                    info->name, INT64_MAX);\n         return false;\n     }\n \n-    *field = value;\n+    if (value == 0) {\n+        if (info->offset == offsetof(IOThread, poll_grow)) {\n+            *field = IOTHREAD_POLL_GROW_DEFAULT;\n+        } else if (info->offset == offsetof(IOThread, poll_shrink)) {\n+            *field = IOTHREAD_POLL_SHRINK_DEFAULT;\n+        } else if (info->offset == offsetof(IOThread, poll_weight)) {\n+            *field = IOTHREAD_POLL_WEIGHT_DEFAULT;\n+        } else {\n+            *field = value;\n+        }\n+    } else {\n+        *field = value;\n+    }\n \n     return true;\n }\n@@ -288,6 +303,7 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,\n                                     iothread->poll_max_ns,\n                                     iothread->poll_grow,\n                                     iothread->poll_shrink,\n+                                    iothread->poll_weight,\n                                     errp);\n     }\n }\n@@ -311,6 +327,10 @@ static void iothread_class_init(ObjectClass *klass, const void *class_data)\n                               iothread_get_poll_param,\n                               iothread_set_poll_param,\n                               NULL, &poll_shrink_info);\n+    object_class_property_add(klass, \"poll-weight\", \"int\",\n+                              iothread_get_poll_param,\n+                              iothread_set_poll_param,\n+                              NULL, &poll_weight_info);\n }\n \n static const TypeInfo iothread_info = {\n@@ -356,6 +376,7 @@ static int query_one_iothread(Object *object, void *opaque)\n     info->poll_max_ns = iothread->poll_max_ns;\n     info->poll_grow = iothread->poll_grow;\n     info->poll_shrink = iothread->poll_shrink;\n+    info->poll_weight = iothread->poll_weight;\n     info->aio_max_batch = iothread->parent_obj.aio_max_batch;\n \n     QAPI_LIST_APPEND(*tail, info);\ndiff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c\nindex bc26b39d70..afa7b709a6 100644\n--- a/monitor/hmp-cmds.c\n+++ b/monitor/hmp-cmds.c\n@@ -206,6 +206,7 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qdict)\n         monitor_printf(mon, \"  poll-max-ns=%\" PRId64 \"\\n\", value->poll_max_ns);\n         monitor_printf(mon, \"  poll-grow=%\" PRId64 \"\\n\", value->poll_grow);\n         monitor_printf(mon, \"  poll-shrink=%\" PRId64 \"\\n\", value->poll_shrink);\n+        monitor_printf(mon, \"  poll-weight=%\" PRId64 \"\\n\", value->poll_weight);\n         monitor_printf(mon, \"  aio-max-batch=%\" PRId64 \"\\n\",\n                        value->aio_max_batch);\n     }\ndiff --git a/tests/unit/test-nested-aio-poll.c b/tests/unit/test-nested-aio-poll.c\nindex 9ab1ad08a7..4c38f36fd4 100644\n--- a/tests/unit/test-nested-aio-poll.c\n+++ b/tests/unit/test-nested-aio-poll.c\n@@ -81,7 +81,7 @@ static void test(void)\n     qemu_set_current_aio_context(td.ctx);\n \n     /* Enable polling */\n-    aio_context_set_poll_params(td.ctx, 1000000, 2, 2, &error_abort);\n+    aio_context_set_poll_params(td.ctx, 1000000, 2, 2, 3, &error_abort);\n \n     /* Make the event notifier active (set) right away */\n     event_notifier_init(&td.poll_notifier, 1);\ndiff --git a/util/aio-posix.c b/util/aio-posix.c\nindex 8e9e9e5d8f..df1c213ce5 100644\n--- a/util/aio-posix.c\n+++ b/util/aio-posix.c\n@@ -29,7 +29,6 @@\n \n /* Stop userspace polling on a handler if it isn't active for some time */\n #define POLL_IDLE_INTERVAL_NS (7 * NANOSECONDS_PER_SECOND)\n-#define POLL_WEIGHT_SHIFT   (3)\n \n static void update_handler_poll_times(AioContext *ctx, int64_t block_ns,\n                                       int64_t dispatch_time);\n@@ -582,28 +581,11 @@ static bool try_poll_mode(AioContext *ctx, AioHandlerList *ready_list,\n \n static void adjust_polling_time(AioContext *ctx, int64_t block_ns)\n {\n-    if (block_ns < ctx->poll_ns) {\n-        int64_t old = ctx->poll_ns;\n-        int64_t shrink = ctx->poll_shrink;\n-\n-        if (shrink == 0) {\n-            shrink = 2;\n-        }\n-\n-        if (block_ns < (ctx->poll_ns / shrink)) {\n-            ctx->poll_ns /= shrink;\n-        }\n-\n-        trace_poll_shrink(ctx, old, ctx->poll_ns);\n-    } else if (block_ns > ctx->poll_ns) {\n+    if (block_ns > ctx->poll_ns) {\n         /* There is room to grow, poll longer */\n         int64_t old = ctx->poll_ns;\n         int64_t grow = ctx->poll_grow;\n \n-        if (grow == 0) {\n-            grow = 2;\n-        }\n-\n         if (block_ns > ctx->poll_ns * grow) {\n             ctx->poll_ns = block_ns;\n         } else {\n@@ -615,6 +597,11 @@ static void adjust_polling_time(AioContext *ctx, int64_t block_ns)\n         }\n \n         trace_poll_grow(ctx, old, ctx->poll_ns);\n+    } else if (block_ns < (ctx->poll_ns / ctx->poll_shrink)) {\n+        int64_t old = ctx->poll_ns;\n+        ctx->poll_ns /= ctx->poll_shrink;\n+\n+        trace_poll_shrink(ctx, old, ctx->poll_ns);\n     }\n }\n \n@@ -632,8 +619,8 @@ static void update_handler_poll_times(AioContext *ctx, int64_t block_ns,\n              * block_ns and previous poll.ns to smooth adjustments.\n              */\n             node->poll.ns = node->poll.ns\n-                ? (node->poll.ns - (node->poll.ns >> POLL_WEIGHT_SHIFT))\n-                + (block_ns >> POLL_WEIGHT_SHIFT) : block_ns;\n+                ? (node->poll.ns - (node->poll.ns >> ctx->poll_weight))\n+                + (block_ns >> ctx->poll_weight) : block_ns;\n \n             if (node->poll.ns > ctx->poll_max_ns) {\n                 node->poll.ns = 0;\n@@ -819,7 +806,8 @@ void aio_context_destroy(AioContext *ctx)\n }\n \n void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,\n-                                 int64_t grow, int64_t shrink, Error **errp)\n+                                 int64_t grow, int64_t shrink,\n+                                 int64_t weight, Error **errp)\n {\n     AioHandler *node;\n \n@@ -833,8 +821,9 @@ void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,\n      * is used once.\n      */\n     ctx->poll_max_ns = max_ns;\n-    ctx->poll_grow = grow;\n-    ctx->poll_shrink = shrink;\n+    ctx->poll_grow = (grow ? grow : IOTHREAD_POLL_GROW_DEFAULT);\n+    ctx->poll_shrink = (shrink ? shrink : IOTHREAD_POLL_SHRINK_DEFAULT);\n+    ctx->poll_weight = (weight ? weight : IOTHREAD_POLL_WEIGHT_DEFAULT);\n     ctx->poll_ns = 0;\n \n     aio_notify(ctx);\ndiff --git a/util/aio-win32.c b/util/aio-win32.c\nindex 6e6f699e4b..1985843233 100644\n--- a/util/aio-win32.c\n+++ b/util/aio-win32.c\n@@ -429,7 +429,8 @@ void aio_context_destroy(AioContext *ctx)\n }\n \n void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,\n-                                 int64_t grow, int64_t shrink, Error **errp)\n+                                 int64_t grow, int64_t shrink,\n+                                 int64_t weight, Error **errp)\n {\n     if (max_ns) {\n         error_setg(errp, \"AioContext polling is not implemented on Windows\");\ndiff --git a/util/async.c b/util/async.c\nindex 9d3627566f..741fcfd6a7 100644\n--- a/util/async.c\n+++ b/util/async.c\n@@ -609,6 +609,7 @@ AioContext *aio_context_new(Error **errp)\n     ctx->poll_ns = 0;\n     ctx->poll_grow = 0;\n     ctx->poll_shrink = 0;\n+    ctx->poll_weight = 0;\n \n     ctx->aio_max_batch = 0;\n \ndiff --git a/qemu-options.hx b/qemu-options.hx\nindex 21972f8326..29c09415c1 100644\n--- a/qemu-options.hx\n+++ b/qemu-options.hx\n@@ -6443,7 +6443,7 @@ SRST\n \n             CN=laptop.example.com,O=Example Home,L=London,ST=London,C=GB\n \n-    ``-object iothread,id=id,poll-max-ns=poll-max-ns,poll-grow=poll-grow,poll-shrink=poll-shrink,aio-max-batch=aio-max-batch``\n+    ``-object iothread,id=id,poll-max-ns=poll-max-ns,poll-grow=poll-grow,poll-shrink=poll-shrink,poll-weight=poll-weight,aio-max-batch=aio-max-batch``\n         Creates a dedicated event loop thread that devices can be\n         assigned to. This is known as an IOThread. By default device\n         emulation happens in vCPU threads or the main event loop thread.\n@@ -6479,6 +6479,12 @@ SRST\n         the polling time when the algorithm detects it is spending too\n         long polling without encountering events.\n \n+        The ``poll-weight`` parameter is the weight factor for adaptive\n+        polling. It determines how much the most recent event interval\n+        affects the next polling duration calculation. If set to 0, the\n+        system default value of 3 is used. Typical values: 1 (high weight\n+        on recent interval), 2-4 (moderate weight on recent interval).\n+\n         The ``aio-max-batch`` parameter is the maximum number of requests\n         in a batch for the AIO engine, 0 means that the engine will use\n         its default.\n",
    "prefixes": [
        "PULL",
        "3/3"
    ]
}