Article View: linux.kernel.netdev
Article #17681[PATCH v2 2/2] tools/virtio: add a vhost dirty log test
From: zhaoguohan
Date: Tue, 17 Nov 2026 08:33
Date: Tue, 17 Nov 2026 08:33
592 lines
27968 bytes
27968 bytes
From: Khan Zhao <zhaoguohan@kylinos.cn>
Add vhost_log_test, which exercises used-ring dirty logging through the
existing vhost_test module. It sets a log base with VHOST_SET_LOG_BASE,
enables VHOST_VRING_F_LOG on the ring, submits descriptors and checks
the resulting bitmap from userspace. No new kernel interface is needed.
The test covers:
- every bit in a byte, repeated sets, and neighbouring bytes being left
untouched, including the last byte of a page followed by a PROT_NONE
guard page
- a used ring write that spans two log pages, with both bits in the
same bitmap byte and in adjacent bytes
- a log page that has not been faulted in yet, read-only, PROT_NONE
and unmapped log pages, and logging after access is restored
- private (COW) and shared file mappings, checking that the bit reaches
the file after msync/fsync
- eight vrings setting different bits of the same byte concurrently,
with and without a userspace thread atomically fetching and clearing
that byte
- two shared mappings of one file page, one of them zapped with
MADV_DONTNEED each round, so both resident and faulting pages are
hit
log_used() ignores errors from log_write(), so the fault cases can only
check that nothing crashes, that nothing is written to an inaccessible
log, and that logging works again afterwards.
A --bench mode reports ns per descriptor with logging disabled and
enabled. vhost_log_test.rst describes how to build and run the test.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Khan Zhao <zhaoguohan@kylinos.cn>
---
v2: add a used ring write spanning two log pages, use VHOST_PAGE_SIZE
from the UAPI, and print the bitmap on a cross-page mismatch.
tools/virtio/.gitignore | 1 +
tools/virtio/Makefile | 7 +-
tools/virtio/vhost_log_test.c | 432 ++++++++++++++++++++++++++++++++
tools/virtio/vhost_log_test.rst | 61 +++++
4 files changed, 499 insertions(+), 2 deletions(-)
create mode 100644 tools/virtio/vhost_log_test.c
create mode 100644 tools/virtio/vhost_log_test.rst
diff --git a/tools/virtio/.gitignore b/tools/virtio/.gitignore
index 7e47b281c442..9f3ebfa2c3b6 100644
--- a/tools/virtio/.gitignore
+++ b/tools/virtio/.gitignore
@@ -2,5 +2,6 @@
*.d
virtio_test
vhost_net_test
+vhost_log_test
vringh_test
virtio-trace/trace-agent
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index 2cac5fd4b979..a4af5140a1cd 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -1,9 +1,12 @@
# SPDX-License-Identifier: GPL-2.0
all: test mod
-test: virtio_test vringh_test vhost_net_test
+test: virtio_test vringh_test vhost_net_test vhost_log_test
virtio_test: virtio_ring.o virtio_test.o
vringh_test: vringh_test.o vringh.o virtio_ring.o
vhost_net_test: virtio_ring.o vhost_net_test.o
+vhost_log_test: vhost_log_test.o
+# This test uses only the userspace API, without the virtio kernel shims.
+vhost_log_test vhost_log_test.o: CFLAGS = -g -O2 -Wall -Wextra -Werror -pthread -I../../usr/include
try-run = $(shell set -e; \
if ($(1)) >/dev/null 2>&1; \
@@ -52,7 +55,7 @@ oot-clean: OOT_BUILD+=clean
.PHONY: all test mod clean vhost oot oot-clean oot-build
clean:
- ${RM} *.o vringh_test virtio_test vhost_net_test vhost_test/*.o \
+ ${RM} *.o vringh_test virtio_test vhost_net_test vhost_log_test vhost_test/*.o \
vhost_test/.*.cmd vhost_test/Module.symvers \
vhost_test/modules.order *.d
-include *.d
diff --git a/tools/virtio/vhost_log_test.c b/tools/virtio/vhost_log_test.c
new file mode 100644
index 000000000000..065ce7790f00
--- /dev/null
+++ b/tools/virtio/vhost_log_test.c
@@ -0,0 +1,432 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Exercise vhost used-ring dirty logging through /dev/vhost-test. */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <linux/vhost.h>
+#include <linux/virtio_ring.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/eventfd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include "../../drivers/vhost/test.h"
+
+#define RING_NUM 128
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define PAGE_BYTES VHOST_PAGE_SIZE
+#define CHECK(c) do { \
+ if (!(c)) { \
+ fprintf(stderr, "FAIL line %d: %s (errno=%d: %s)\n", \
+ __LINE__, #c, errno, strerror(errno)); \
+ exit(EXIT_FAILURE); \
+ } \
+} while (0)
+
+struct queue {
+ int fd;
+ int kick;
+ int call;
+ void *ring;
+ void *data;
+ struct vring_desc *desc;
+ struct vring_avail *avail;
+ struct vring_used *used;
+ uint16_t index;
+};
+
+static void *map_pages(size_t size)
+{
+ void *p = mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ CHECK(p != MAP_FAILED);
+ return p;
+}
+
+static void log_base(struct queue *q, void *base)
+{
+ uint64_t addr = (uintptr_t)base;
+
+ CHECK(!ioctl(q->fd, VHOST_SET_LOG_BASE, &addr));
+}
+
+static void queue_init_at(struct queue *q, void *bitmap, uint64_t log_addr,
+ bool logging)
+{
+ struct vhost_vring_state state = { .index = 0, .num = RING_NUM };
+ struct vhost_vring_file file = { .index = 0 };
+ struct vhost_vring_addr addr = { .index = 0 };
+ struct vhost_memory *mem;
+ uint64_t features = 0;
+ unsigned char *scratch;
+ int i, run = 1;
+
+ memset(q, 0, sizeof(*q));
+ q->fd = open("/dev/vhost-test", O_RDWR);
+ CHECK(q->fd >= 0);
+ CHECK(!ioctl(q->fd, VHOST_SET_OWNER, NULL));
+ CHECK(!ioctl(q->fd, VHOST_SET_FEATURES, &features));
+ q->kick = eventfd(0, EFD_NONBLOCK);
+ q->call = eventfd(0, EFD_NONBLOCK);
+ CHECK(q->kick >= 0 && q->call >= 0);
+ q->ring = map_pages(3 * PAGE_BYTES);
+ q->data = map_pages(PAGE_BYTES);
+ q->desc = q->ring;
+ q->avail = q->ring + PAGE_BYTES;
+ q->used = q->ring + 2 * PAGE_BYTES;
+ mem = calloc(1, sizeof(*mem) + sizeof(mem->regions[0]));
+ CHECK(mem);
+ mem->nregions = 1;
+ mem->regions[0].guest_phys_addr = 0;
+ mem->regions[0].userspace_addr = (uintptr_t)q->data;
+ mem->regions[0].memory_size = PAGE_BYTES;
+ CHECK(!ioctl(q->fd, VHOST_SET_MEM_TABLE, mem));
+ free(mem);
+ for (i = 0; i < RING_NUM; i++) {
+ q->desc[i].addr = 0;
+ q->desc[i].len = 1;
+ }
+ CHECK(!ioctl(q->fd, VHOST_SET_VRING_NUM, &state));
+ state.num = 0;
+ CHECK(!ioctl(q->fd, VHOST_SET_VRING_BASE, &state));
+ addr.desc_user_addr = (uintptr_t)q->desc;
+ addr.avail_user_addr = (uintptr_t)q->avail;
+ addr.used_user_addr = (uintptr_t)q->used;
+ addr.flags = logging ? 1U << VHOST_VRING_F_LOG : 0;
+ addr.log_guest_addr = log_addr;
+ CHECK(!ioctl(q->fd, VHOST_SET_VRING_ADDR, &addr));
+ file.fd = q->kick;
+ CHECK(!ioctl(q->fd, VHOST_SET_VRING_KICK, &file));
+ file.fd = q->call;
+ CHECK(!ioctl(q->fd, VHOST_SET_VRING_CALL, &file));
+ /* Starting a queue logs its flags; keep the tested mapping untouched. */
+ scratch = map_pages(PAGE_BYTES);
+ log_base(q, scratch);
+ CHECK(!ioctl(q->fd, VHOST_TEST_RUN, &run));
+ log_base(q, bitmap);
+ CHECK(!munmap(scratch, PAGE_BYTES));
+}
+
+static void queue_init(struct queue *q, void *bitmap, unsigned int bit,
+ bool logging)
+{
+ queue_init_at(q, bitmap, (uint64_t)bit * PAGE_BYTES, logging);
+}
+
+static void queue_submit(struct queue *q, unsigned int count)
+{
+ uint64_t kick = 1;
+ unsigned int i;
+
+ CHECK(count <= RING_NUM);
+ for (i = 0; i < count; i++)
+ q->avail->ring[(q->index + i) % RING_NUM] = i;
+ q->index += count;
+ __atomic_store_n(&q->avail->idx, q->index, __ATOMIC_RELEASE);
+ CHECK(write(q->kick, &kick, sizeof(kick)) == sizeof(kick));
+}
+
+static void queue_wait(struct queue *q)
+{
+ struct pollfd pfd = { .fd = q->call, .events = POLLIN };
+ uint64_t events;
+
+ /* Completion notification follows the dirty-log stores. */
+ do {
+ CHECK(poll(&pfd, 1, 5000) == 1);
+ CHECK(read(q->call, &events, sizeof(events)) == sizeof(events));
+ } while (__atomic_load_n(&q->used->idx, __ATOMIC_ACQUIRE) != q->index);
+}
+
+static void queue_destroy(struct queue *q)
+{
+ /* Release flushes the worker before freeing any userspace mappings. */
+ CHECK(!close(q->fd));
+ CHECK(!close(q->kick));
+ CHECK(!close(q->call));
+ CHECK(!munmap(q->ring, 3 * PAGE_BYTES));
+ CHECK(!munmap(q->data, PAGE_BYTES));
+}
+
+static void exercise(void *bitmap, unsigned int bit, unsigned int count)
+{
+ struct queue q;
+
+ queue_init(&q, bitmap, bit, true);
+ queue_submit(&q, count);
+ queue_wait(&q);
+ queue_destroy(&q);
+}
+
+static void basic_test(void)
+{
+ unsigned char *p = map_pages(2 * PAGE_BYTES);
+ unsigned int offsets[] = { 0, 1, 7, 63, PAGE_BYTES - 1 };
+ unsigned int i, bit;
+
+ CHECK(!mprotect(p + PAGE_BYTES, PAGE_BYTES, PROT_NONE));
+ for (i = 0; i < ARRAY_SIZE(offsets); i++) {
+ for (bit = 0; bit < 8; bit++) {
+ memset(p, 0, PAGE_BYTES);
+ exercise(p + offsets[i], bit, RING_NUM);
+ CHECK(p[offsets[i]] == (1U << bit));
+ if (offsets[i])
+ CHECK(!p[offsets[i] - 1]);
+ if (offsets[i] + 1 < PAGE_BYTES)
+ CHECK(!p[offsets[i] + 1]);
+ p[offsets[i]] = 0xa5;
+ exercise(p + offsets[i], bit, 1);
+ CHECK(p[offsets[i]] == (0xa5 | (1U << bit)));
+ }
+ }
+ CHECK(!munmap(p, 2 * PAGE_BYTES));
+ puts("PASS bits 0..7, repeated sets, unaligned and guarded page end");
+}
+
+static void cross_page_test(void)
+{
+ unsigned int pages[] = { 1, 8 };
+ unsigned char *p = map_pages(PAGE_BYTES);
+ unsigned char want[2];
+ unsigned int i, n;
+ struct queue q;
+
+ for (i = 0; i < ARRAY_SIZE(pages); i++) {
+ n = pages[i];
+ memset(p, 0, 2);
+ /* used->ring[0] is at offset 4, so it covers pages n - 1 and n. */
+ queue_init_at(&q, p, (uint64_t)n * PAGE_BYTES - 8, true);
+ queue_submit(&q, 1);
+ queue_wait(&q);
+ queue_destroy(&q);
+ memset(want, 0, sizeof(want));
+ want[(n - 1) / 8] |= 1U << ((n - 1) % 8);
+ want[n / 8] |= 1U << (n % 8);
+ if (p[0] != want[0] || p[1] != want[1]) {
+ fprintf(stderr,
+ "FAIL log pages %u/%u: got %02x %02x, want %02x %02x\n",
+ n - 1, n, (unsigned int)p[0], (unsigned int)p[1],
+ (unsigned int)want[0], (unsigned int)want[1]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ CHECK(!munmap(p, PAGE_BYTES));
+ puts("PASS used ring write spanning two log pages");
+}
+
+static void fault_test(void)
+{
+ unsigned char *p = map_pages(PAGE_BYTES);
+ unsigned char resident;
+ struct queue q;
+
+ queue_init(&q, p, 3, true);
+ CHECK(!mincore(p, PAGE_BYTES, &resident));
+ CHECK(!(resident & 1));
+ queue_submit(&q, 1);
+ queue_wait(&q);
+ queue_destroy(&q);
+ CHECK(*p == 8);
+ *p = 0;
+ CHECK(!mprotect(p, PAGE_BYTES, PROT_READ));
+ exercise(p, 2, 1);
+ CHECK(!*p);
+ CHECK(!mprotect(p, PAGE_BYTES, PROT_NONE));
+ exercise(p, 2, 1);
+ CHECK(!mprotect(p, PAGE_BYTES, PROT_READ | PROT_WRITE));
+ exercise(p, 4, 1);
+ CHECK(*p == 16);
+ queue_init(&q, p, 2, true);
+ CHECK(!munmap(p, PAGE_BYTES));
+ queue_submit(&q, 1);
+ queue_wait(&q);
+ queue_destroy(&q);
+ /* Used-ring logging ignores errors; check survival and no bad write. */
+ puts("PASS first touch, readonly, PROT_NONE, unmapped, recovery");
+}
+
+static void file_test(const char *path)
+{
+ unsigned char *p;
+ unsigned char byte;
+ int fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
+
+ CHECK(fd >= 0);
+ CHECK(!ftruncate(fd, PAGE_BYTES));
+ p = mmap(NULL, PAGE_BYTES, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ CHECK(p != MAP_FAILED);
+ CHECK(!*p);
+ exercise(p, 5, 1);
+ CHECK(*p == 32);
+ CHECK(pread(fd, &byte, 1, 0) == 1);
+ CHECK(!byte);
+ CHECK(!munmap(p, PAGE_BYTES));
+ p = mmap(NULL, PAGE_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ CHECK(p != MAP_FAILED);
+ *p = 0;
+ CHECK(!msync(p, PAGE_BYTES, MS_SYNC));
+ exercise(p, 6, 1);
+ CHECK(*p == 64);
+ CHECK(!msync(p, PAGE_BYTES, MS_SYNC));
+ CHECK(!munmap(p, PAGE_BYTES));
+ CHECK(!fsync(fd));
+ CHECK(!posix_fadvise(fd, 0, PAGE_BYTES, POSIX_FADV_DONTNEED));
+ CHECK(pread(fd, &byte, 1, 0) == 1);
+ CHECK(byte == 64);
+ CHECK(!close(fd));
+ CHECK(!unlink(path));
+ puts("PASS private file COW and shared file sync/re-read");
+}
+
+struct collector {
+ unsigned char *bitmap;
+ bool stop;
+ unsigned char seen;
+};
+
+static void *collect(void *arg)
+{
+ struct collector *c = arg;
+
+ while (!__atomic_load_n(&c->stop, __ATOMIC_ACQUIRE))
+ c->seen |= __atomic_exchange_n(c->bitmap, 0, __ATOMIC_SEQ_CST);
+ return NULL;
+}
+
+static void concurrent_test(void)
+{
+ unsigned char *p = map_pages(PAGE_BYTES);
+ struct queue q[8];
+ struct collector c = { .bitmap = p };
+ pthread_t thread;
+ unsigned int bit, round;
+
+ for (bit = 0; bit < 8; bit++)
+ queue_init(&q[bit], p, bit, true);
+ for (round = 0; round < 1000; round++) {
+ __atomic_store_n(p, 0, __ATOMIC_SEQ_CST);
+ for (bit = 0; bit < 8; bit++)
+ queue_submit(&q[bit], 1);
+ for (bit = 0; bit < 8; bit++)
+ queue_wait(&q[bit]);
+ CHECK(__atomic_load_n(p, __ATOMIC_SEQ_CST) == 255);
+ }
+ for (round = 0; round < 1000; round++) {
+ __atomic_store_n(p, 0, __ATOMIC_SEQ_CST);
+ c.stop = false;
+ c.seen = 0;
+ CHECK(!pthread_create(&thread, NULL, collect, &c));
+ for (bit = 0; bit < 8; bit++)
+ queue_submit(&q[bit], RING_NUM);
+ for (bit = 0; bit < 8; bit++)
+ queue_wait(&q[bit]);
+ __atomic_store_n(&c.stop, true, __ATOMIC_RELEASE);
+ CHECK(!pthread_join(thread, NULL));
+ c.seen |= __atomic_exchange_n(p, 0, __ATOMIC_SEQ_CST);
+ CHECK(c.seen == 255);
+ }
+ for (bit = 0; bit < 8; bit++)
+ queue_destroy(&q[bit]);
+ CHECK(!munmap(p, PAGE_BYTES));
+ puts("PASS eight workers sharing a byte, concurrent atomic collection");
+}
+
+static void alias_test(const char *path)
+{
+ unsigned char *p, *alias;
+ struct queue q[8];
+ unsigned int bit, round;
+ int fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
+
+ CHECK(fd >= 0);
+ CHECK(!ftruncate(fd, PAGE_BYTES));
+ p = mmap(NULL, PAGE_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ alias = mmap(NULL, PAGE_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, 0);
+ CHECK(p != MAP_FAILED && alias != MAP_FAILED);
+ for (bit = 0; bit < 8; bit++)
+ queue_init(&q[bit], bit & 1 ? alias : p, bit, true);
+ for (round = 0; round < 1000; round++) {
+ __atomic_store_n(p, 0, __ATOMIC_SEQ_CST);
+ /* Keep one alias writable, and force faults through the other. */
+ CHECK(!madvise(alias, PAGE_BYTES, MADV_DONTNEED));
+ for (bit = 0; bit < 8; bit++)
+ queue_submit(&q[bit], 1);
+ for (bit = 0; bit < 8; bit++)
+ queue_wait(&q[bit]);
+ CHECK(__atomic_load_n(p, __ATOMIC_SEQ_CST) == 255);
+ }
+ for (bit = 0; bit < 8; bit++)
+ queue_destroy(&q[bit]);
+ CHECK(!munmap(p, PAGE_BYTES));
+ CHECK(!munmap(alias, PAGE_BYTES));
+ CHECK(!close(fd));
+ CHECK(!unlink(path));
+ puts("PASS shared-file aliases with repeated PTE faults");
+}
+
+static uint64_t now_ns(void)
+{
+ struct timespec ts;
+
+ CHECK(!clock_gettime(CLOCK_MONOTONIC, &ts));
+ return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
+}
+
+static void benchmark(bool logging, unsigned int batches)
+{
+ unsigned char *p = map_pages(PAGE_BYTES);
+ struct queue q;
+ uint64_t start, elapsed;
+ unsigned int i;
+
+ *p = 0;
+ queue_init(&q, p, 0, logging);
+ for (i = 0; i < 100; i++) {
+ queue_submit(&q, RING_NUM);
+ queue_wait(&q);
+ }
+ start = now_ns();
+ for (i = 0; i < batches; i++) {
+ queue_submit(&q, RING_NUM);
+ queue_wait(&q);
+ }
+ elapsed = now_ns() - start;
+ queue_destroy(&q);
+ CHECK(*p == (logging ? 1 : 0));
+ printf("BENCH logging=%u descriptors=%u elapsed_ns=%" PRIu64
+ " ns_per_desc=%.2f\n", logging, batches * RING_NUM,
+ elapsed, (double)elapsed / (batches * RING_NUM));
+ CHECK(!munmap(p, PAGE_BYTES));
+}
+
+int main(int argc, char **argv)
+{
+ const char *path = argc > 1 ? argv[1] : "/tmp/vhost-log-test";
+
+ CHECK(sysconf(_SC_PAGESIZE) == PAGE_BYTES);
+ if (argc == 2 && !strcmp(argv[1], "--bench")) {
+ benchmark(false, 10000);
+ benchmark(true, 10000);
+ return 0;
+ }
+ basic_test();
+ cross_page_test();
+ fault_test();
+ file_test(path);
+ concurrent_test();
+ alias_test(path);
+ puts("PASS vhost dirty-log regression suite");
+ return 0;
+}
diff --git a/tools/virtio/vhost_log_test.rst b/tools/virtio/vhost_log_test.rst
new file mode 100644
index 000000000000..b990824172c1
--- /dev/null
+++ b/tools/virtio/vhost_log_test.rst
@@ -0,0 +1,61 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+Vhost dirty-log regression test
+==============================
+
+``vhost_log_test`` exercises used-ring logging through the existing
+``/dev/vhost-test`` interface. It requires a test kernel with vhost support
+and the ``vhost_test`` module built from ``tools/virtio/vhost_test`` for that
+same kernel. Run it in a disposable VM, with permission to open the device.
+
+Build the userspace executable from the kernel source root::
+
+ make -C tools/virtio vhost_log_test
+
+For a static initramfs executable, use ``LDFLAGS="-static -pthread"`` on a
+clean build. Load ``vhost``, its dependencies, and ``vhost_test`` in the
+guest, then run::
+
+ ./vhost_log_test /mnt/vhost-log-scratch
+
+The path is a disposable scratch file: the test truncates and removes it.
+Use a disk-backed filesystem such as ext4 to exercise file writeback.
+Omitting the path uses ``/tmp/vhost-log-test``. The test uses the vhost UAPI's
+fixed 4 KiB ``VHOST_PAGE_SIZE`` and assumes the native little-endian legacy
+vring layout; runtime coverage is intended for x86.
+
+Keep this as a separate tool from ``virtio_test`` and ``vhost_net_test``.
+It targets used-ring dirty logging through the dedicated ``/dev/vhost-test``
+interface, which those tests do not configure or verify. Folding it into
+either tool would add a separate module/device prerequisite without sharing
+their test setup.
+
+The suite covers every bit within a byte, repeated sets, neighboring-byte
+preservation, unaligned byte addresses, a guarded page end, a used ring
+write that spans two log pages (within one bitmap byte and across two),
+first touch, inaccessible mappings and recovery, private COW, shared-file
+sync/reread, eight workers sharing a byte, and concurrent userspace atomic
+collection.
+The collector checks each of 1000 independent rounds. Another 1000 rounds
+use two aliases of a shared file page and discard one alias's PTEs before
+each round, exercising resident and faulting accesses to the same bitmap.
+
+Used-ring logging currently discards ``log_used()`` errors. Consequently,
+the inaccessible-mapping cases check survival, absence of a successful
+write and recovery; they do not verify userspace-visible ``-EFAULT``.
+The collector verifies that all eight bits were observed in each round,
+not that every repeated dirty event was counted. Alias tests exercise
+fault fallback but do not establish a deterministic instruction ordering.
+These tests do not replace MM race analysis or live migration testing.
+
+Run the benchmark separately::
+
+ taskset -c 0 ./vhost_log_test --bench
+
+Each logging-disabled/enabled measurement warms up with 100 batches,
+then times 10000 batches of 128 descriptors. The result includes queue
+submission, worker execution and completion notification. It measures
+nanoseconds per descriptor, not isolated ``set_bit_to_user()`` latency,
+network throughput or migration time. Keep the kernel configuration and
+VM setup identical, alternate baseline/optimized runs, and report multiple
+samples. Affinity applies to the guest CPU; host CPU placement is separate.
--
2.43.0
Technical Details
Message-ID:
<20261117083323.89502-3-zhaoguohan@kylinos.cn>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365039-linux-kernel-netdev=dewy.ruReferences:
<20261117083323.89502-1-zhaoguohan@kylinos.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365039-linux-kernel-netdev=dewy.ru From: zhaoguohan@kylinos.cn Newsgroups: linux.kernel.netdev Subject: [PATCH v2 2/2] tools/virtio: add a vhost dirty log test Date: Tue, 17 Nov 2026 16:33:23 +0800 Organization: Usenet Network Message-ID: <20261117083323.89502-3-zhaoguohan@kylinos.cn> References: <20261117083323.89502-1-zhaoguohan@kylinos.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2278947"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:s67s851wgjdcrzJzuT3l2p+Jf90= sha256:YDddVFdRy8VhZOH71G09AJWEbJfAMsBt34LOXsSreMs= sha1:S/RDU2bMHLxep7t/LRyNtG4FFbE= sha256:oRnDR7bJFZCSovwgPG54hIeezc9+91VC+Wo5zK9Q3rE= 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 4B51C114E87; Tue, 17 Nov 2026 11:34:27 +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 b3JCC4df4o91; Tue, 17 Nov 2026 11:34:16 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-365039-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 0B972114911; Tue, 17 Nov 2026 11:34:13 +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 60FCE601B89; Tue, 17 Nov 2026 08:34:12 +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=1794904433; b=FE6WtBhfxrdlN2k5LtYqxP1bVMw9wv7YsEas/dm6zOtCXQmYnc61/FwQF6Y2apz3o6gQ lUJ7fALXTJclgiTI9IFsl0mymg/UFpV5zqWn0gbCng8S+aZeaPhBvDk1+o6fOBw505d7a mKqSwpJSMr6TFfTW3vIL+yk7iBUvtgUMiJPqCH1MRl/vpIoBoCedmYD/fsRADy+6+IKVQ Is0sXOfUUV/2rpXtoaSQkOs0LK0/6GIB3/h1nERvc1hmPYgubq7WymnmCSG8ZsoKEZp/2 UuXdhI+CzsWfiEgo9d0NmK+w0IJyO1/+8h3pNPuqTVkVBBwmjf7DhtpzojdMx73ZWpw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794904433; 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:In-Reply-To: References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=uc7PcYeaTdYHgQkAtiqlGoKQTWafPcgUztVNzuy5Z44=; b=y+aOMZvzxX5aDZh0RHni3rNqJ7h8bRb0ZwTE18fWEH66Xq04T6q4L7YLq3TyM1br9wrX eyN/bGd/x5w7IzsqHPeeoAMX4gM2TSSxM7Q1FkTgZQ4FMFX/HtpLYENphkdCFetRdk/Jv m6O7lFROA446oN/M3csA5smjjOhpNEaziKWf80mYvk4Nr35uvxyJcUbnp0hqCWX6PXAgG VT+boMCgHVPYUBg9x5gVgCA5rcCMyLkyVR6odZvIkwUHyFUZsR562YR8TCRiS75mq08Wg I+pBGIl5MbCe8HrON0LY7dIJoqh2icpAr7JdgwBsDlu6nhOgBgwNjQ2/D/bWaLbXwgQ== 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 D621860A2600; Tue, 17 Nov 2026 08:33:53 +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=1794904433; b=Lwp7MhuQ8MplRoNeHkaq+muY9uAfLhyf4UWXw1/t0S8BOS0itJgufGr4KOiaqlDA/GFw 9WU3wDnqDqtEL1IIKyMUhsRYwTNpYTa8udEfC80Tk0yD79QhqtkbhRoL2KkQdlCZeO8a9 xs3aQwCdQvgsOX3F5hp3Wtg0q3DXpmLoRlKgqjd6PXkyBygmRVCbuajxYRq/xGPGqPNSd Qf9Yv4D5I/IUsAa7+L+Wd+H54BM+gmbEziI/E3eH0dhCfFWWkDKTZool2pyzANezk7kus g3X/Ns94dI7hkBDldLXq1xXNwwj07wZ42Qde1NGZxTNuT9SQl0e/ilh9jeXlN5ZVorg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794904433; 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:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=uc7PcYeaTdYHgQkAtiqlGoKQTWafPcgUztVNzuy5Z44=; b=2AThM2V/L71e9Jxb5t/T8EOEfso3v0kwhJTzEy+epw5wugBl86IS7nJn4FloE5aVcf5q I/rin+/SMlQ6YNsoG3Rtb89ccMH5Hf6Im2GDt7IyoysxLIpywhmePgKMExzMMrGsdDWhQ WAOUQtK6/T2cN4tdNdU1AdUf9J3RUlR7q+E/dR36VBO91DlbA7BHrinVZOJcJI1yXB1Aw OEIwP+j9Zbnjq7uz3UIUBbo1y7ReU4PMyVPJO/b8hNNIMwbejaREtgvfK1YXNtaz64ZEX apUrksoSbS0gKRvaVLbE/Am0PPsEd5+usso+PIrVorzn0wPCI2PyDmZdQzHUc36uB5Q== 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 6DCDF606A8B5; Tue, 17 Nov 2026 08:33:49 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6DCDF606A8B5 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: 990b5cc2e26111f19a56ed5b684f684d-20261117 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.19,REQID:1a3665a7-b58e-4086-92ed-22180081b2ab,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:7db8b62,CLOUDID:2ee67d963fb9b5e345ac5c2751a8faa1,BulkI D:nil,BulkQuantity:0,SF:80|81|82|102|123|865|898,TC:nil,Content:0|15|50|99 ,EDM:-3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,O SA: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: 990b5cc2e26111f19a56ed5b684f684d-20261117 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 725401279; Tue, 17 Nov 2026 16:33:43 +0800 X-Cc: eperezma@redhat.com, xuanzhuo@linux.alibaba.com, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Khan Zhao <zhaoguohan@kylinos.cn> X-Mailer: git-send-email 2.43.0 X-In-Reply-To: <20261117083323.89502-1-zhaoguohan@kylinos.cn> 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