🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14981

[PATCH 0/2] vhost: set dirty log bits without pinning pages on x86

#14981
From: zhaoguohan
Date: Thu, 12 Nov 2026 08:56
52 lines
10106 bytes
From: Khan Zhao <zhaoguohan@kylinos.cn>

We use vhost-net with live migration in our product. While dirty
logging is enabled, every used ring update and every logged write goes
through set_bit_to_user(), which pins the log page, maps it, sets a
single bit and unpins it again. The TODO above that function has noted
for a long time that a direct user access would be better.

Patch 1 does that on x86: it tries a byte-sized cmpxchg on the user
address with page faults disabled, and falls back to the existing
pin/kmap path if the access faults or keeps losing to concurrent
updates of the same byte. Other architectures are unchanged, since
unsafe_try_cmpxchg_user() is only implemented on x86.

Patch 2 adds a userspace test in tools/virtio that drives used-ring
logging through vhost_test and checks the bitmap, including fault,
COW, shared-file and concurrent cases, plus a small benchmark mode.

On an x86_64 KVM guest (i7-12800HX host), the benchmark with logging
enabled went from 243.60 to 171.11 ns per descriptor, averaged over
five alternating runs. This is the per-descriptor cost in the vhost
worker; I have not measured the effect on total migration time.

Tool usage: the test, its documentation and the benchmark in patch 2
were largely generated with OpenAI Codex (gpt-6.1-sol) from a request
to exercise vhost used-ring dirty logging, and Codex helped run the
build and VM tests. The changelogs were edited with help from an AI
assistant. I have reviewed all of the code and take responsibility
for it.

Testing: x86_64 with SMAP under QEMU/KVM, running the test from
patch 2 against both the unmodified and patched vhost modules. i386
and arm64 are build-tested only; non-x86 has not been runtime tested.

Khan Zhao (2):
  vhost: set dirty log bits without pinning pages on x86
  tools/virtio: add a vhost dirty log test

 drivers/vhost/vhost.c           |  50 +++-
 tools/virtio/.gitignore         |   1 +
 tools/virtio/Makefile           |   7 +-
 tools/virtio/vhost_log_test.c   | 393 ++++++++++++++++++++++++++++++++
 tools/virtio/vhost_log_test.rst |  53 +++++
 5 files changed, 497 insertions(+), 7 deletions(-)
 create mode 100644 tools/virtio/vhost_log_test.c
 create mode 100644 tools/virtio/vhost_log_test.rst


base-commit: 9d66f26fefacebfeed15de31c1123451a17ff119
-- 
2.43.0
Technical Details
Message-ID: <20261112085631.128819-1-zhaoguohan@kylinos.cn>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361619-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361619-linux-kernel-netdev=dewy.ru
From: zhaoguohan@kylinos.cn
Newsgroups: linux.kernel.netdev
Subject: [PATCH 0/2] vhost: set dirty log bits without pinning pages on x86
Date: Thu, 12 Nov 2026 16:56:29 +0800
Organization: Usenet Network
Message-ID: <20261112085631.128819-1-zhaoguohan@kylinos.cn>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1048926"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GUE1oNM2KHnOEGRkf54+LDE4/i8= sha256:/xnwrqehnfNPuWEJCEtfEanhFySHrMjIiOnHqxjJhBk=
	sha1:lelxt+DjHoEV41nHnhF/ZdiqC7M= sha256:KMcfQde1INBL2Si1lRRyVkAX4aZuoBr4LbVOmJJe5j0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C9446114172; Thu, 12 Nov 2026 12:22:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7IhmJvqooY2o;
	Thu, 12 Nov 2026 12:22:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-361619-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=kylinos.cn
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id CA0E211416E; Thu, 12 Nov 2026 12:22:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 0BAA4667A7F; Thu, 12 Nov 2026 08:57:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794473806;
	b=WERo8JCSSJgp4c0rq+1UhDEgypoLQ2uvVgwxVxC4FqwclmK6LCSyoZTLAi/pkWzej8fi
	 K6DUk1Gd4Ehw+y3ZONFKwi46MTP4so5eEh0XFZj7slZiPHDlzbAep2skjHwEByUO4k3PP
	 nN3/Q2CAx94lpfi1fljoBSplHO1JZCNuoYIqu5k1UzuUUpIO9TC5sFVIZLDhtoj4YQTgf
	 vCftI5p+LCLiTOTTgSePbmAmDqs3NZiZClzI2Q2jcagGit0JlVGJvkeHfK5OQFEyDb/vj
	 NPok4bpB8AfVNsbSVJtApCap3G08yijPtUxm2v18OXCkPqiVnn0YrCXatqPMzd9y7Mg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794473806;
	h=X-Original-To:Received:DMARC-Filter:X-UUID:X-CID-P-RULE:X-CID-O-INFO:
	 X-CID-META:X-CID-BVR:X-CID-BAS:X-CID-FACTOR:X-CID-RHF:X-UUID:X-User:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=LxcEEAoCt6n89bCpZ37twcsUB6ZoqztAQdy/4BmRnjc=;
	b=w8J73lTan/GpVtfM+lc5YIBAaSGFTaOmGQR2wmyy/7T6g7G4yqtb9dBsGpqD0UXaoeKR
	 e01rcWNnl7NoJMybzhjkg4Voa4Py1gyvkLB2NSOZuDJSpND60yiKiCZ0Fliw5hJV93FtJ
	 7KPVtn+DHpC2xUWFERDolSCIglpIJmP3MRVjB6AckKvM5416e2NsYxVPhvVyg8tjJqNim
	 q4+6R6uM4aFLX/nMZKwoHMGeB/RDCBzxXaD2BMjinbH2+YVnTWq00t8Vj9vpaLe0h968R
	 C/r2CiK6GVldSVT0KGD4Z6YMIgMKf0jsr51bToe6lvPxXSCIw3hVv7Psm+p76gICmIg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=kylinos.cn;
	spf=pass smtp.mailfrom=kylinos.cn;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D276606A8A6;
	Thu, 12 Nov 2026 08:56:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=124.126.103.232
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794473805;
	b=QQfJUGQQ9gkfdRJyctVm1ddKmKCsepJUczozXsculMjB5BfhqOYg3wOvNaPk+TvLnRF3
	 mxGfc0iOMyPtU2LHDjax5SpOCZ1jbuel54uHd6ZFCtCpxz5Q0pGUD2JtGoKURyQZK75ae
	 4LnfxIPthsH/iSxGoZXKENS+OPpJig1/0UBgX7mV/GAECYTHLe6rmVpW9xKN/Pkxe90oa
	 h/bd4mP4M2V1HhyRhqtMPqiejdJdbQ0Fd/tkrFLAvrEcJRC6WOgW3YEBPLCZPHplrPgke
	 FuzAk/elIHlpLkbYYxWV3E/pz1yBL+yipTOo92oEg2D3V6naUSCdMiwW6xleYu2rhzg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794473805;
	h=DMARC-Filter:X-UUID:X-CID-P-RULE:X-CID-O-INFO:X-CID-META:X-CID-BVR:
	 X-CID-BAS:X-CID-FACTOR:X-CID-RHF:X-UUID:X-User:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=LxcEEAoCt6n89bCpZ37twcsUB6ZoqztAQdy/4BmRnjc=;
	b=gJF8KAGePhzwzsbTakESBINYw2FEKlQG9fn7aYZUc26w0HwpHdDR18fOKbPB5VJ18yaS
	 wynl3uYPZRV16vx/jdI7+nNZXu2oVALA5X1RO11eZZduzj74esjMVD5keFAguTyvDamhc
	 OhRSbfGxC9pNhG1lx3DJtbUPtEV/Ybge84W+fCKxxmxyNy+lrDOa0tEfGKQD799yyqiHq
	 3WuTgmNnKqcknEeMEngcQf/MIcLOy+WLZfVgfPQpbqVD/1E3lyHsr1RH0g4y60iG68AZn
	 3jRStHq3ypl1TwGn8RyyYtvQYSmJzzjfKmS/SxPiU4MgS5IgTuIZ+e34KGpSbGYASLg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=kylinos.cn;
	spf=pass smtp.mailfrom=kylinos.cn;
	arc=none smtp.remote-ip=124.126.103.232
X-Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25FF9606A323;
	Thu, 12 Nov 2026 08:56:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25FF9606A323
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn
X-UUID: f805aa50de7611f19a56ed5b684f684d-20261112
X-CID-P-RULE: Release_Ham
X-CID-O-INFO: VERSION:1.3.19,REQID:e5d3c368-e4ec-46dd-b66a-e06561e210f7,IP:0,U
	RL:0,TC:0,Content:-5,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO
	N:release,TS:20
X-CID-META: VersionHash:7db8b62,CLOUDID:92feb5b01784c7e2b70c8a08b12f3392,BulkI
	D:nil,BulkQuantity:0,SF:102|123|865|898,TC:nil,Content:0|15|50|99,EDM:5,IP
	:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,
	LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0
X-CID-BVR: 2,SSN|SDN
X-CID-BAS: 2,SSN|SDN,0,_
X-CID-FACTOR: TF_CID_SPAM_SNR
X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E
X-UUID: f805aa50de7611f19a56ed5b684f684d-20261112
X-User: zhaoguohan@kylinos.cn
X-Received: from ubuntu.. [(10.44.16.150)] by mailgw.kylinos.cn
	(envelope-from <zhaoguohan@kylinos.cn>)
	(Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256)
	with ESMTP id 1107669512; Thu, 12 Nov 2026 16:56:37 +0800
X-Cc: jasowangio@gmail.com,
	eperezma@redhat.com,
	xuanzhuo@linux.alibaba.com,
	kvm@vger.kernel.org,
	virtualization@lists.linux.dev,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.43.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list