Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217550/?format=api
{ "id": 2217550, "url": "http://patchwork.ozlabs.org/api/patches/2217550/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260330064758.2816891-1-guoqing.zhang@amd.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/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": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260330064758.2816891-1-guoqing.zhang@amd.com>", "list_archive_url": null, "date": "2026-03-30T06:47:58", "name": "[v4] migration/rdma: add x-rdma-chunk-size parameter", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a8903748ab402766587ce7d204bbc5f9a12e0dbc", "submitter": { "id": 92875, "url": "http://patchwork.ozlabs.org/api/people/92875/?format=api", "name": "Samuel Zhang", "email": "guoqing.zhang@amd.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260330064758.2816891-1-guoqing.zhang@amd.com/mbox/", "series": [ { "id": 497965, "url": "http://patchwork.ozlabs.org/api/series/497965/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497965", "date": "2026-03-30T06:47:58", "name": "[v4] migration/rdma: add x-rdma-chunk-size parameter", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/497965/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217550/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217550/checks/", "tags": {}, "related": [], "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=amd.com header.i=@amd.com header.a=rsa-sha256\n header.s=selector1 header.b=OYRLMy+6;\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=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.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 4fkhsg4h7Lz1xrn\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 17:58:15 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w76ZJ-0005CW-29; Mon, 30 Mar 2026 02:57:49 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <GuoQing.Zhang@amd.com>)\n id 1w76ZG-0005CK-Ro\n for qemu-devel@nongnu.org; Mon, 30 Mar 2026 02:57:46 -0400", "from mail-eastusazon11012042.outbound.protection.outlook.com\n ([52.101.53.42] helo=BL0PR03CU003.outbound.protection.outlook.com)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <GuoQing.Zhang@amd.com>)\n id 1w76ZD-0003WG-SE\n for qemu-devel@nongnu.org; Mon, 30 Mar 2026 02:57:46 -0400", "from SA0PR11CA0190.namprd11.prod.outlook.com (2603:10b6:806:1bc::15)\n by LV2PR12MB5774.namprd12.prod.outlook.com (2603:10b6:408:17a::14)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.15; Mon, 30 Mar\n 2026 06:52:35 +0000", "from SN1PEPF0002BA50.namprd03.prod.outlook.com\n (2603:10b6:806:1bc:cafe::58) by SA0PR11CA0190.outlook.office365.com\n (2603:10b6:806:1bc::15) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.28 via Frontend Transport; Mon,\n 30 Mar 2026 06:52:17 +0000", "from satlexmb07.amd.com (165.204.84.17) by\n SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9745.21 via Frontend Transport; Mon, 30 Mar 2026 06:52:34 +0000", "from hjbog-srdc-36.amd.com (10.180.168.240) by satlexmb07.amd.com\n (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Mon, 30 Mar\n 2026 01:52:30 -0500" ], "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=iqqbEEEl1OyZW5LvY8O7tFmc9fNF4j6av+FHYHyubQg11G3ZPI3oWnrQ0+NNLJgAtjOy3A9QyWCQ/sIb/odnR3I9epLLC/0Rx6yst1npESPreXy0PGrvdhhTCYWhtZorPq4zrCMYy1zkxKQm77dJinwP6pBSqTepMBrZQF2mYrevB3fwp0QeEvinciguBxwOwmx+UZ4zjcqkKinDwHSQEVWZG1Jg40wOG0jzELDTz3BenNVjfooBldraIBjMwouXzkIaR6xI5TxnklXFL6CLGoVYV66plxsE8/RuLhpTDjUKi0D5wbDbjdRFSd0FYPCAAritJ78nFbfq9WnkgSG1vQ==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=ke5kFyl8xovVspHdlYJQUwJ6ZP09TMERrWYpKUoLCrQ=;\n b=SpdrpGNpTIazeHeXga4h/p9yBNgUmQQRII9Qnfee0YoWNZplbWnk7FGZW+qTahHNMkhK5W821Zqu5iQE0ddK9QpZ/X377ncpAMci3Yx5IPgFkTgEdXaR2Xz8yAw3fgN0mkNiBipEu4TXd9ztfM3jvY0AKbPLxH4TAOnNHZFB50l++43fVmgTOMSRn0mLnZ/CD/YSUT5u+1Wj4mb5x79sr2YKUD7zjn7T+cqCe+qBC8glb3/90v7cwhL4AzThu+ZxRqllhDW37jYaWsia1zakm2sa6+5gCrfETwFm5HWJv9VRuV6XJLppPJFavTl7Hz4eBwY0rZWgmHpytvPfnjCrWw==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass\n (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com;\n dkim=none (message not signed); arc=none (0)", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=ke5kFyl8xovVspHdlYJQUwJ6ZP09TMERrWYpKUoLCrQ=;\n b=OYRLMy+6FYBORgdV81Mt21nJUtCQshoKEGN2WdtxDmw9R13v4xXzpdPVUCLK+6QCgCVSTq2+VIEQzlPAJaq3Ed3G976SSNQFH8dHSc9/Y4JeOCFy8reR4o5Atu45E1JrZ5Mdv6G+pb/vJJ+X5u4FOgsGJru5/UAWgUV9PqZLmeQ=", "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 165.204.84.17)\n smtp.mailfrom=amd.com; dkim=none (message not signed)\n header.d=none;dmarc=pass action=none header.from=amd.com;", "Received-SPF": [ "Pass (protection.outlook.com: domain of amd.com designates\n 165.204.84.17 as permitted sender) receiver=protection.outlook.com;\n client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C", "permerror client-ip=52.101.53.42;\n envelope-from=GuoQing.Zhang@amd.com;\n helo=BL0PR03CU003.outbound.protection.outlook.com" ], "From": "Samuel Zhang <guoqing.zhang@amd.com>", "To": "<qemu-devel@nongnu.org>", "CC": "<peterx@redhat.com>, <farosas@suse.de>, <lizhijian@fujitsu.com>,\n <eblake@redhat.com>, <armbru@redhat.com>, <Emily.Deng@amd.com>,\n <Victor.Zhao@amd.com>, <PengJu.Zhou@amd.com>, <Qing.Ma@amd.com>, Samuel Zhang\n <guoqing.zhang@amd.com>", "Subject": "[PATCH v4] migration/rdma: add x-rdma-chunk-size parameter", "Date": "Mon, 30 Mar 2026 14:47:58 +0800", "Message-ID": "<20260330064758.2816891-1-guoqing.zhang@amd.com>", "X-Mailer": "git-send-email 2.43.7", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-Originating-IP": "[10.180.168.240]", "X-ClientProxiedBy": "satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com\n (10.181.42.216)", "X-EOPAttributedMessage": "0", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "SN1PEPF0002BA50:EE_|LV2PR12MB5774:EE_", "X-MS-Office365-Filtering-Correlation-Id": "8c4d7f61-e533-4d49-e35e-08de8e28ec17", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "BCL:0;\n ARA:13230040|82310400026|36860700016|1800799024|376014|56012099003|18002099003;", "X-Microsoft-Antispam-Message-Info": "\n SehqD4EJXbu0TNRbIhNggL1Z0H2/haYSFeODkU6jZR2hmlHUwXK6OdCaygO4tOcaJNhOjvlReOP9Ep3HM/zwGQsqBGPvTORoHByrJM1oDJl4PduHle/oDM/4DWKfQPZHc0qBNEkz0FdCfU111TvayaG2zhoTzvbTTsdjwguQAYL/cT2QNck+I1UBShTaCLnXkMxvHuo1Fugd+fiOabPEv6VXyvxGfUkh/GRMy8H+9alBzXiUdDiC4rXqntqjgkvg0NOXtWFxUnMThuKAl/VWjXFKvi4wLkUuYp+tG4fS1Aa/iry+yVFoZfsVSAM/1yzfzPzOfFvKJWo2qnxyT6xP0TrwezPIj6oaf9UtEoEHqIyVxlNXDWftAf8AG/06M46IupuZR2aqRV6jY48UDpeGSRb6f47CoSwBNqbXdGYl4y0JIdqFRV+Xj1iyIfPh2K16bNKyhnlqukTUCO+C4zjO+Ov+1MvTRCWSGVGqSTDTKJvCv0rdJNkrPhGgZMpUxzSwyuyDt02Ro3GCNYSj/9bqjnSnNjIwkYNd3KJ41Ym6DLavmCmah2pe30f7+ZOS7Mx0AnMWzOuFwzUFJ0BAyd42uoE3uwPHbnSDYmXvidp70cx006WWG4VFDVn4RXXjYLfYrJQp+Qg3t+5VxyR02IQuCk5P7tnpKRd6+xzs1WTHSmBXUTLEPZQ/in3Pn9xuKzxNuzjP+FXK7ySW6jqi4kEGaAWwoqX50pcOOC/dExyx0h96DZyFuTjWYgtcFofzpSj6La1GnkxwikxP62G97u9LTw==", "X-Forefront-Antispam-Report": "CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE;\n SFS:(13230040)(82310400026)(36860700016)(1800799024)(376014)(56012099003)(18002099003);\n DIR:OUT; SFP:1101;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "\n s4RETuM2G9EPxezwpA74yZuuiGPFxctyyI9Q1xl/WGUAiSLZfyYf/a1NeDXqU1gzSZ2YN5jq7Pucfe97dq/KVBzOaGbw6qHzR/MKR+M2jVZ56oJCcyjvQpSvYcoHIyaxydr2cbWSRtja5Wagxh98YlRzE4xwRr/v+yZ4ajqrrY9vtA5VAAIPQEpqEAC5gs3tbnPeA8s+sDcufjxzS1lH+A3yPmAs+lXi30lsHiiu6OLQAnaZMxfUUZTnyVvmItr+bylquXGYK3VInRUHr9MEwZsXpzmkaQl2sN6fdIGRKJ5m+x+f9xnMtgX8UZdvd1WN1X3b1akN78mkFwmYk/EB0poesTx9q2+/uZyV0I7KTwPFyDPY+1R29/YX1yfwn7S/Nws2xbLtuNR2ck3gZBXLtJu2tQz5PjKlNfTO3bwBsiU6pL3EFVnvQwsZN1SaSXoE", "X-OriginatorOrg": "amd.com", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "30 Mar 2026 06:52:34.3392 (UTC)", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 8c4d7f61-e533-4d49-e35e-08de8e28ec17", "X-MS-Exchange-CrossTenant-Id": "3dd8961f-e488-4e60-8e11-a82d994e183d", "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17];\n Helo=[satlexmb07.amd.com]", "X-MS-Exchange-CrossTenant-AuthSource": "\n SN1PEPF0002BA50.namprd03.prod.outlook.com", "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous", "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "LV2PR12MB5774", "X-Spam_score_int": "-6", "X-Spam_score": "-0.7", "X-Spam_bar": "/", "X-Spam_report": "(-0.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\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_H2=-0.01,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=1,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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": "The 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>\n---\nv2:\n- Renamed x-rdma-chunk-shift to x-rdma-chunk-size (byte count)\n- Added validation in migrate_params_check()\n- Added hmp_migrate_set_parameter() support\n- Added hmp_info_migrate_parameters() support\n- Added migrate_mark_all_params_present()\n- Use qemu_strtosz() for size suffix support\nv3: [Markus]\n- Use visit_type_size() in HMP set parameter\n- Use MiB/GiB constants\nv4: [Markus]\n- Remove superfluous comment on DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE\n- Use \"Only applies when migrating via RDMA\" in QAPI doc\n\n migration/migration-hmp-cmds.c | 11 +++++++++++\n migration/options.c | 33 ++++++++++++++++++++++++++++++++-\n migration/options.h | 1 +\n migration/rdma.c | 30 ++++++++++++++++--------------\n qapi/migration.json | 12 ++++++++++--\n 5 files changed, 70 insertions(+), 17 deletions(-)", "diff": "diff --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 f33b297929..b3565235d7 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@@ -993,6 +998,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@@ -1055,7 +1069,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@@ -1266,6 +1280,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@@ -1391,6 +1414,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 dest->cpr_exec_command = params->cpr_exec_command;\n }\n@@ -1517,6 +1544,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/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/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\"\ndiff --git a/qapi/migration.json b/qapi/migration.json\nindex 7134d4ce47..f78a20f65a 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,14 @@\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+# (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 +1052,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 ##\n", "prefixes": [ "v4" ] }