Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/2] vhost: set dirty log bits without pinning pages on x86
@ 2026-11-12  8:56 zhaoguohan
  2026-11-12  8:56 ` [PATCH 1/2] " zhaoguohan
  2026-11-12  8:56 ` [PATCH 2/2] tools/virtio: add a vhost dirty log test zhaoguohan
  0 siblings, 2 replies; 7+ messages in thread
From: zhaoguohan @ 2026-11-12  8:56 UTC (permalink / raw)
  To: mst
  Cc: jasowangio, eperezma, xuanzhuo, kvm, virtualization, netdev,
	linux-kernel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-12 10:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12  8:56 [PATCH 0/2] vhost: set dirty log bits without pinning pages on x86 zhaoguohan
2026-11-12  8:56 ` [PATCH 1/2] " zhaoguohan
2026-11-12  9:15   ` Michael S. Tsirkin
2026-11-12  9:50   ` Michael S. Tsirkin
2026-11-12 10:10   ` Michael S. Tsirkin
2026-11-12 10:32     ` Michael S. Tsirkin
2026-11-12  8:56 ` [PATCH 2/2] tools/virtio: add a vhost dirty log test zhaoguohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox