{"id":2233212,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2233212/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505202640.1011006-4-peterx@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","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":"<20260505202640.1011006-4-peterx@redhat.com>","date":"2026-05-05T20:26:20","name":"[PULL,03/23] migration/rdma: add x-rdma-chunk-size parameter","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"14e470752ed06eb801bf81eaed2336ab5f674e9d","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/1.1/people/67717/?format=json","name":"Peter Xu","email":"peterx@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505202640.1011006-4-peterx@redhat.com/mbox/","series":[{"id":502897,"url":"http://patchwork.ozlabs.org/api/1.1/series/502897/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502897","date":"2026-05-05T20:26:17","name":"[PULL,01/23] migration: Fix blocking in POSTCOPY_DEVICE during package load","version":1,"mbox":"http://patchwork.ozlabs.org/series/502897/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2233212/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2233212/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=JWTAGjxS;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=N81xyfGa;\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 4g99832995z1yJV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 06:28:35 +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 1wKMM4-0004PT-R7; Tue, 05 May 2026 16:26:56 -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 <peterx@redhat.com>) id 1wKMM1-0004Mr-OZ\n for qemu-devel@nongnu.org; Tue, 05 May 2026 16:26:53 -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 <peterx@redhat.com>) id 1wKMLz-0002aC-9m\n for qemu-devel@nongnu.org; Tue, 05 May 2026 16:26:53 -0400","from mail-qv1-f70.google.com (mail-qv1-f70.google.com\n [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-614-8H0zrU3yOfu0u8sEeOm6vg-1; Tue, 05 May 2026 16:26:49 -0400","by mail-qv1-f70.google.com with SMTP id\n 6a1803df08f44-8b597b14a22so10660946d6.0\n for <qemu-devel@nongnu.org>; Tue, 05 May 2026 13:26:49 -0700 (PDT)","from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b53c6b8123sm155283806d6.35.2026.05.05.13.26.46\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 05 May 2026 13:26:46 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1778012810;\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=ebiyZAuHPg80vY31UF8UVr2ykPbfE9ba9kbGfZ1Nazg=;\n b=JWTAGjxS1ToXoQvpui3Dupgaj2hyo1Si2cXTz7OEDv03A3VK0cY7YK3zWTWgtNkDEheUmD\n Q/A6TYXsMsVhMVjvdoN/u66wlKnKPRBWEE980yGZaMxh1dYmFxmUPLyeh2M19RPsKJJ5ks\n H4uCztQNhhQSaE2rcLLZivpPfhmbl8g=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1778012808; x=1778617608; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=ebiyZAuHPg80vY31UF8UVr2ykPbfE9ba9kbGfZ1Nazg=;\n b=N81xyfGaCY6GEF5Iazf6zunBof6FYYZ2GOl5Z2JCBDzb/Ge2lcFSMY3OVdSVmzXzTX\n +EcLFTzgDJ40DYLwUbXLes7jTP/hm+ECfTFiu8/iJHoER9fzMixmr1hBpBiGFOhcyU7+\n pEQqBiLaHvkXIA2sYK6UW/gWDnynL5oY/CDoccUSi2w7ahY/VCSjciy5Wt36B4X7UTY1\n vpFzJty//3NFcJvibe7Y5FLmkfSazyhRBLEsaab3x33q0Laexo1ZZaPF3FsxSzTTs+3r\n WdYmhV9NcAAa39ZTTirqJjDwgsynRi7aZfshl+UTjoDl2G79C0XB+L9APtJbmz0DQQuN\n ZADA=="],"X-MC-Unique":"8H0zrU3yOfu0u8sEeOm6vg-1","X-Mimecast-MFC-AGG-ID":"8H0zrU3yOfu0u8sEeOm6vg_1778012809","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1778012808; x=1778617608;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=ebiyZAuHPg80vY31UF8UVr2ykPbfE9ba9kbGfZ1Nazg=;\n b=KiB69Y+saiVpLxhaGAELl3LpBsJN3ngnDkYU2xMomZau8+p83MYYtnk74md2fwV9YV\n sockiZydswhFnmfy1rVUepdAiq4yTA3cWYx3OUCZ5GNM55eXxT1v+G+WIbQFx0+1+JAt\n HxdMVhXnQzn8z7MQQPx4IIS8oAwB45eo3oD+zG3Q1hQeX5Rk7Oz5Z+WESyrFh4lF9xEE\n 2Re09L7KB1XPZcRnk4+PeUEi2zbiP+98nwHm8RuVkg0wFDlJw9o0s1Opbq54ga1ETbN9\n loTuKYXNcjBcU+B0l+gaSdFnBxZKqfp8y67Iy4jOVFkN9pl7iGEJSgdPz//uSko/O2ys\n Cp8Q==","X-Gm-Message-State":"AOJu0YxefgB32wrP+OuE7JupyPhUCyc89xAESYQa3+A0TozH+7F2EGF7\n bTyzIdzxTZ8NxHHDoc8Yb3uB5iM7EsMbch8wLYv9z8PGx7MBhVVPB+CE5oeZtZGliXGWdJWyi4k\n Q0b+v/RHoIXwwSFzyfaG8vbv29gPwOE0964Bzwu6Jtc+nXmq4LxSf5QeVKpKv2oKd4yqb6F1qPJ\n I34L5gfK9yRYXTSKPWWIK0hS05mO/FzFbq7nFHWw==","X-Gm-Gg":"AeBDieskUnQpXVrCwEoSKtp2b1NcfnbujzK2w5kBcASGndsm84eAuwfEsZTqqu4gNIJ\n RmQSx+tiWb9H1by4UrSNcKiezFFznIYn0DNNEc1E6rS2W4uQ/XcR6hEDz7Tphjqx64kszatnQ8G\n vYfloAa2uhw0lCa+cLRezBb2eJvZNAbWiNdlCcxPlTNstjBxIqsNbPCC1P37r0AlWADxR6Jkczz\n s+1nPVSiLx4ErYHmupKqU3bU3cc5LJj2adyLtH50WvZwMfyScIzxOhkrMW/0DufH9kLmw0RUxad\n RjShk/wZbJbVoINcyHYM6IpKZsZi3MVUr82VU20gA0FWYAyKD17QGFyQdUUwONKoO2yPrLqDnEu\n 373yNFoIjzI5l7TD9BLeewAoIvctsDiMenGc0eV2XdxG7rDplgPaPClQ=","X-Received":["by 2002:a05:6214:e86:b0:89c:3f06:537a with SMTP id\n 6a1803df08f44-8baa05bda05mr77133536d6.21.1778012808182;\n Tue, 05 May 2026 13:26:48 -0700 (PDT)","by 2002:a05:6214:e86:b0:89c:3f06:537a with SMTP id\n 6a1803df08f44-8baa05bda05mr77133006d6.21.1778012807498;\n Tue, 05 May 2026 13:26:47 -0700 (PDT)"],"From":"Peter Xu <peterx@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Fabiano Rosas <farosas@suse.de>, Paolo Bonzini <pbonzini@redhat.com>,\n Peter Xu <peterx@redhat.com>, Samuel Zhang <guoqing.zhang@amd.com>,\n Markus Armbruster <armbru@redhat.com>, Li Zhijian <lizhijian@fujitsu.com>","Subject":"[PULL 03/23] migration/rdma: add x-rdma-chunk-size parameter","Date":"Tue,  5 May 2026 16:26:20 -0400","Message-ID":"<20260505202640.1011006-4-peterx@redhat.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260505202640.1011006-1-peterx@redhat.com>","References":"<20260505202640.1011006-1-peterx@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-24","X-Spam_score":"-2.5","X-Spam_bar":"--","X-Spam_report":"(-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.443,\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, SPF_PASS=-0.001 autolearn=ham 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: Samuel Zhang <guoqing.zhang@amd.com>\n\nThe default 1MB RDMA chunk size causes slow live migration because\neach chunk triggers a write_flush (ibv_post_send). For 8GB RAM,\n1MB chunk size produces ~15000 flushes vs ~3700 with 1024MB chunk size.\n\nAdd x-rdma-chunk-size parameter to configure the RDMA chunk size for\nfaster migration.\nUsage: `migrate_set_parameter x-rdma-chunk-size 1024M`\n\nPerformance with RDMA live migration of 8GB RAM VM:\n\n| x-rdma-chunk-size (B) | time (s) | throughput (MB/s) |\n|-----------------------|----------|-------------------|\n| 1M (default)          | 37.915   |  1,007            |\n| 32M                   | 17.880   |  2,260            |\n| 1024M                 |  4.368   | 17,529            |\n\nSigned-off-by: Samuel Zhang <guoqing.zhang@amd.com>\nAcked-by: Markus Armbruster <armbru@redhat.com>\nAcked-by: Li Zhijian <lizhijian@fujitsu.com>\nTested-by: Li Zhijian <lizhijian@fujitsu.com>\nAcked-by: Fabiano Rosas <farosas@suse.de>\nAcked-by: Peter Xu <peterx@redhat.com>\nLink: https://lore.kernel.org/r/20260427031401.3895523-1-guoqing.zhang@amd.com\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n qapi/migration.json            | 13 +++++++++++--\n migration/options.h            |  1 +\n migration/migration-hmp-cmds.c | 11 +++++++++++\n migration/options.c            | 33 ++++++++++++++++++++++++++++++++-\n migration/rdma.c               | 30 ++++++++++++++++--------------\n 5 files changed, 71 insertions(+), 17 deletions(-)","diff":"diff --git a/qapi/migration.json b/qapi/migration.json\nindex 7134d4ce47..0db115ec5e 100644\n--- a/qapi/migration.json\n+++ b/qapi/migration.json\n@@ -806,7 +806,7 @@\n #\n # Features:\n #\n-# @unstable: Members @x-checkpoint-delay and\n+# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size, and\n #     @x-vcpu-dirty-limit-period are experimental.\n #\n # Since: 2.4\n@@ -831,6 +831,7 @@\n            'mode',\n            'zero-page-detection',\n            'direct-io',\n+           { 'name': 'x-rdma-chunk-size', 'features': [ 'unstable' ] },\n            'cpr-exec-command'] }\n \n ##\n@@ -1007,9 +1008,15 @@\n #     is @cpr-exec.  The first list element is the program's filename,\n #     the remainder its arguments.  (Since 10.2)\n #\n+# @x-rdma-chunk-size: RDMA memory registration chunk size in bytes.\n+#     Default is 1MiB.  Must be a power of 2 in the range\n+#     [1MiB, 1024MiB].  Only applies when migrating via RDMA.\n+#     Must be set to the same value on both source and destination\n+#     before migration starts.  (Since 11.1)\n+#\n # Features:\n #\n-# @unstable: Members @x-checkpoint-delay and\n+# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size, and\n #     @x-vcpu-dirty-limit-period are experimental.\n #\n # Since: 2.4\n@@ -1046,6 +1053,8 @@\n             '*mode': 'MigMode',\n             '*zero-page-detection': 'ZeroPageDetection',\n             '*direct-io': 'bool',\n+            '*x-rdma-chunk-size': { 'type': 'uint64',\n+                                    'features': [ 'unstable' ] },\n             '*cpr-exec-command': [ 'str' ]} }\n \n ##\ndiff --git a/migration/options.h b/migration/options.h\nindex b502871097..b46221998a 100644\n--- a/migration/options.h\n+++ b/migration/options.h\n@@ -87,6 +87,7 @@ const char *migrate_tls_creds(void);\n const char *migrate_tls_hostname(void);\n uint64_t migrate_xbzrle_cache_size(void);\n ZeroPageDetection migrate_zero_page_detection(void);\n+uint64_t migrate_rdma_chunk_size(void);\n \n /* parameters helpers */\n \ndiff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c\nindex 0a193b8f54..4f6c1dbf89 100644\n--- a/migration/migration-hmp-cmds.c\n+++ b/migration/migration-hmp-cmds.c\n@@ -451,6 +451,13 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)\n                            params->direct_io ? \"on\" : \"off\");\n         }\n \n+        if (params->has_x_rdma_chunk_size) {\n+            monitor_printf(mon, \"%s: %\" PRIu64 \" bytes\\n\",\n+                           MigrationParameter_str(\n+                               MIGRATION_PARAMETER_X_RDMA_CHUNK_SIZE),\n+                           params->x_rdma_chunk_size);\n+        }\n+\n         assert(params->has_cpr_exec_command);\n         monitor_print_cpr_exec_command(mon, params->cpr_exec_command);\n     }\n@@ -734,6 +741,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)\n         p->has_direct_io = true;\n         visit_type_bool(v, param, &p->direct_io, &err);\n         break;\n+    case MIGRATION_PARAMETER_X_RDMA_CHUNK_SIZE:\n+        p->has_x_rdma_chunk_size = true;\n+        visit_type_size(v, param, &p->x_rdma_chunk_size, &err);\n+        break;\n     case MIGRATION_PARAMETER_CPR_EXEC_COMMAND: {\n         /*\n          * NOTE: g_autofree will only auto g_free() the strv array when\ndiff --git a/migration/options.c b/migration/options.c\nindex 68441f0276..5cbfd29099 100644\n--- a/migration/options.c\n+++ b/migration/options.c\n@@ -13,6 +13,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"qemu/error-report.h\"\n+#include \"qemu/units.h\"\n #include \"exec/target_page.h\"\n #include \"qapi/clone-visitor.h\"\n #include \"qapi/error.h\"\n@@ -90,6 +91,7 @@ const PropertyInfo qdev_prop_StrOrNull;\n \n #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD     1000    /* milliseconds */\n #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT            1       /* MB/s */\n+#define DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE           MiB\n \n const Property migration_properties[] = {\n     DEFINE_PROP_BOOL(\"store-global-state\", MigrationState,\n@@ -183,6 +185,9 @@ const Property migration_properties[] = {\n     DEFINE_PROP_ZERO_PAGE_DETECTION(\"zero-page-detection\", MigrationState,\n                        parameters.zero_page_detection,\n                        ZERO_PAGE_DETECTION_MULTIFD),\n+    DEFINE_PROP_UINT64(\"x-rdma-chunk-size\", MigrationState,\n+                      parameters.x_rdma_chunk_size,\n+                      DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE),\n \n     /* Migration capabilities */\n     DEFINE_PROP_MIG_CAP(\"x-xbzrle\", MIGRATION_CAPABILITY_XBZRLE),\n@@ -1000,6 +1005,15 @@ ZeroPageDetection migrate_zero_page_detection(void)\n     return s->parameters.zero_page_detection;\n }\n \n+uint64_t migrate_rdma_chunk_size(void)\n+{\n+    MigrationState *s = migrate_get_current();\n+    uint64_t size = s->parameters.x_rdma_chunk_size;\n+\n+    assert(MiB <= size && size <= GiB && is_power_of_2(size));\n+    return size;\n+}\n+\n /* parameters helpers */\n \n AnnounceParameters *migrate_announce_params(void)\n@@ -1062,7 +1076,7 @@ static void migrate_mark_all_params_present(MigrationParameters *p)\n         &p->has_announce_step, &p->has_block_bitmap_mapping,\n         &p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit,\n         &p->has_mode, &p->has_zero_page_detection, &p->has_direct_io,\n-        &p->has_cpr_exec_command,\n+        &p->has_x_rdma_chunk_size, &p->has_cpr_exec_command,\n     };\n \n     len = ARRAY_SIZE(has_fields);\n@@ -1273,6 +1287,15 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)\n         return false;\n     }\n \n+    if (params->has_x_rdma_chunk_size &&\n+        (params->x_rdma_chunk_size < MiB ||\n+         params->x_rdma_chunk_size > GiB ||\n+         !is_power_of_2(params->x_rdma_chunk_size))) {\n+        error_setg(errp, \"Option x_rdma_chunk_size expects \"\n+                   \"a power of 2 in the range 1MiB to 1024MiB\");\n+        return false;\n+    }\n+\n     return true;\n }\n \n@@ -1393,6 +1416,10 @@ static void migrate_params_test_apply(MigrationParameters *params,\n         dest->direct_io = params->direct_io;\n     }\n \n+    if (params->has_x_rdma_chunk_size) {\n+        dest->x_rdma_chunk_size = params->x_rdma_chunk_size;\n+    }\n+\n     if (params->has_cpr_exec_command) {\n         qapi_free_strList(dest->cpr_exec_command);\n         dest->cpr_exec_command = QAPI_CLONE(strList, params->cpr_exec_command);\n@@ -1520,6 +1547,10 @@ static void migrate_params_apply(MigrationParameters *params)\n         s->parameters.direct_io = params->direct_io;\n     }\n \n+    if (params->has_x_rdma_chunk_size) {\n+        s->parameters.x_rdma_chunk_size = params->x_rdma_chunk_size;\n+    }\n+\n     if (params->has_cpr_exec_command) {\n         qapi_free_strList(s->parameters.cpr_exec_command);\n         s->parameters.cpr_exec_command =\ndiff --git a/migration/rdma.c b/migration/rdma.c\nindex 55ab85650a..3e37a1d440 100644\n--- a/migration/rdma.c\n+++ b/migration/rdma.c\n@@ -45,10 +45,12 @@\n #define RDMA_RESOLVE_TIMEOUT_MS 10000\n \n /* Do not merge data if larger than this. */\n-#define RDMA_MERGE_MAX (2 * 1024 * 1024)\n-#define RDMA_SIGNALED_SEND_MAX (RDMA_MERGE_MAX / 4096)\n+static inline uint64_t rdma_merge_max(void)\n+{\n+    return migrate_rdma_chunk_size() * 2;\n+}\n \n-#define RDMA_REG_CHUNK_SHIFT 20 /* 1 MB */\n+#define RDMA_SIGNALED_SEND_MAX 512\n \n /*\n  * This is only for non-live state being migrated.\n@@ -527,21 +529,21 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,\n static inline uint64_t ram_chunk_index(const uint8_t *start,\n                                        const uint8_t *host)\n {\n-    return ((uintptr_t) host - (uintptr_t) start) >> RDMA_REG_CHUNK_SHIFT;\n+    return ((uintptr_t) host - (uintptr_t) start) / migrate_rdma_chunk_size();\n }\n \n static inline uint8_t *ram_chunk_start(const RDMALocalBlock *rdma_ram_block,\n                                        uint64_t i)\n {\n     return (uint8_t *)(uintptr_t)(rdma_ram_block->local_host_addr +\n-                                  (i << RDMA_REG_CHUNK_SHIFT));\n+                                  (i * migrate_rdma_chunk_size()));\n }\n \n static inline uint8_t *ram_chunk_end(const RDMALocalBlock *rdma_ram_block,\n                                      uint64_t i)\n {\n     uint8_t *result = ram_chunk_start(rdma_ram_block, i) +\n-                                         (1UL << RDMA_REG_CHUNK_SHIFT);\n+                                         migrate_rdma_chunk_size();\n \n     if (result > (rdma_ram_block->local_host_addr + rdma_ram_block->length)) {\n         result = rdma_ram_block->local_host_addr + rdma_ram_block->length;\n@@ -1841,6 +1843,7 @@ static int qemu_rdma_write_one(RDMAContext *rdma,\n     struct ibv_send_wr *bad_wr;\n     int reg_result_idx, ret, count = 0;\n     uint64_t chunk, chunks;\n+    uint64_t chunk_size = migrate_rdma_chunk_size();\n     uint8_t *chunk_start, *chunk_end;\n     RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]);\n     RDMARegister reg;\n@@ -1861,22 +1864,21 @@ retry:\n     chunk_start = ram_chunk_start(block, chunk);\n \n     if (block->is_ram_block) {\n-        chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT);\n+        chunks = length / chunk_size;\n \n-        if (chunks && ((length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {\n+        if (chunks && ((length % chunk_size) == 0)) {\n             chunks--;\n         }\n     } else {\n-        chunks = block->length / (1UL << RDMA_REG_CHUNK_SHIFT);\n+        chunks = block->length / chunk_size;\n \n-        if (chunks && ((block->length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {\n+        if (chunks && ((block->length % chunk_size) == 0)) {\n             chunks--;\n         }\n     }\n \n     trace_qemu_rdma_write_one_top(chunks + 1,\n-                                  (chunks + 1) *\n-                                  (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);\n+                                  (chunks + 1) * chunk_size / 1024 / 1024);\n \n     chunk_end = ram_chunk_end(block, chunk + chunks);\n \n@@ -2176,7 +2178,7 @@ static int qemu_rdma_write(RDMAContext *rdma,\n     rdma->current_length += len;\n \n     /* flush it if buffer is too large */\n-    if (rdma->current_length >= RDMA_MERGE_MAX) {\n+    if (rdma->current_length >= rdma_merge_max()) {\n         return qemu_rdma_write_flush(rdma, errp);\n     }\n \n@@ -3522,7 +3524,7 @@ int rdma_registration_handle(QEMUFile *f)\n                 } else {\n                     chunk = reg->key.chunk;\n                     host_addr = block->local_host_addr +\n-                        (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT));\n+                        (reg->key.chunk * migrate_rdma_chunk_size());\n                     /* Check for particularly bad chunk value */\n                     if (host_addr < (void *)block->local_host_addr) {\n                         error_report(\"rdma: bad chunk for block %s\"\n","prefixes":["PULL","03/23"]}