From: David Marchand <david.marchand@redhat.com>
To: maxime.coquelin@redhat.com, dev@dpdk.org
Cc: Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH 1/5] vhost: decouple guest pages population from async datapath
Date: Wed, 26 Aug 2026 16:02:02 +0200 [thread overview]
Message-ID: <20260826140206.1099433-2-david.marchand@redhat.com> (raw)
In-Reply-To: <20260826140206.1099433-1-david.marchand@redhat.com>
The vhost crypto zero-copy feature relies on the
RTE_VHOST_USER_ASYNC_COPY flag to enable guest page tracking
(guest_pages array population and MAP_POPULATE during mmap).
Introduce a RTE_VHOST_USER_MAP_POPULATE flag that maps to
RTE_VHOST_USER_ASYNC_COPY at this point in time.
Adjust vhost_crypto example and remove the unnecessary
ALLOW_EXPERIMENTAL_API flag as this example does not use any
experimental APIs.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
doc/guides/prog_guide/vhost_lib.rst | 9 +++++++++
examples/vhost_crypto/Makefile | 1 -
examples/vhost_crypto/main.c | 2 +-
examples/vhost_crypto/meson.build | 1 -
lib/vhost/rte_vhost.h | 1 +
lib/vhost/socket.c | 9 +++++++++
lib/vhost/vhost.h | 1 +
lib/vhost/vhost_user.c | 4 ++--
8 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index 345a621716..2bea814a62 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -118,6 +118,15 @@ The following is an overview of some key Vhost API functions:
It is disabled by default.
+ - ``RTE_VHOST_USER_MAP_POPULATE``
+
+ Guest memory regions will be mapped with ``MAP_POPULATE`` when this flag
+ is set, pre-faulting pages into memory. This is useful for applications
+ requiring direct access to guest memory, such as vhost-crypto zero-copy
+ operations.
+
+ It is disabled by default.
+
- ``RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS``
Since v16.04, the vhost library forwards checksum and gso requests for
diff --git a/examples/vhost_crypto/Makefile b/examples/vhost_crypto/Makefile
index cc7f2abb90..130953c38e 100644
--- a/examples/vhost_crypto/Makefile
+++ b/examples/vhost_crypto/Makefile
@@ -6,7 +6,6 @@ APP = vhost-crypto
# all source are stored in SRCS-y
SRCS-y := main.c
-CFLAGS += -DALLOW_EXPERIMENTAL_API
PKGCONF ?= pkg-config
diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c
index 8bdfc40c4b..53bd8fa825 100644
--- a/examples/vhost_crypto/main.c
+++ b/examples/vhost_crypto/main.c
@@ -623,7 +623,7 @@ main(int argc, char *argv[])
for (j = 0; j < lo->nb_sockets; j++) {
ret = rte_vhost_driver_register(lo->socket_files[j],
- RTE_VHOST_USER_ASYNC_COPY);
+ RTE_VHOST_USER_MAP_POPULATE);
if (ret < 0) {
RTE_LOG(ERR, USER1, "socket %s already exists\n",
lo->socket_files[j]);
diff --git a/examples/vhost_crypto/meson.build b/examples/vhost_crypto/meson.build
index 1c294c286f..47c8fa829f 100644
--- a/examples/vhost_crypto/meson.build
+++ b/examples/vhost_crypto/meson.build
@@ -6,7 +6,6 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
-allow_experimental_apis = true
deps += ['vhost', 'cryptodev']
sources = files(
'main.c',
diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index a7f9700538..095f9b6d3c 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -39,6 +39,7 @@ extern "C" {
/* support only linear buffers (no chained mbufs) */
#define RTE_VHOST_USER_LINEARBUF_SUPPORT (1ULL << 6)
#define RTE_VHOST_USER_ASYNC_COPY (1ULL << 7)
+#define RTE_VHOST_USER_MAP_POPULATE RTE_VHOST_USER_ASYNC_COPY
#define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS (1ULL << 8)
#define RTE_VHOST_USER_NET_STATS_ENABLE (1ULL << 9)
#define RTE_VHOST_USER_ASYNC_CONNECT (1ULL << 10)
diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index 70e582a18d..8b29271f97 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -44,6 +44,7 @@ struct vhost_user_socket {
bool extbuf;
bool linearbuf;
bool async_copy;
+ bool map_populate;
bool net_compliant_ol_flags;
bool stats_enabled;
bool async_connect;
@@ -248,6 +249,13 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
dev->async_copy = 1;
}
+ if (vsocket->map_populate) {
+ dev = get_device(vid);
+
+ if (dev)
+ dev->map_populate = 1;
+ }
+
VHOST_CONFIG_LOG(vsocket->path, INFO, "new device, handle is %d", vid);
if (vsocket->notify_ops->new_connection) {
@@ -939,6 +947,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
vsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT;
vsocket->linearbuf = flags & RTE_VHOST_USER_LINEARBUF_SUPPORT;
vsocket->async_copy = flags & RTE_VHOST_USER_ASYNC_COPY;
+ vsocket->map_populate = flags & RTE_VHOST_USER_MAP_POPULATE;
vsocket->net_compliant_ol_flags = flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
vsocket->stats_enabled = flags & RTE_VHOST_USER_NET_STATS_ENABLE;
vsocket->async_connect = flags & RTE_VHOST_USER_ASYNC_CONNECT;
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index ee61f7415e..8575a9bb1c 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -499,6 +499,7 @@ struct __rte_cache_aligned virtio_net {
RTE_ATOMIC(int16_t) broadcast_rarp;
uint32_t nr_vring;
int async_copy;
+ int map_populate;
int extbuf;
int linearbuf;
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 020c993b29..e87ab82e63 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -1384,7 +1384,7 @@ vhost_user_mmap_region(struct virtio_net *dev,
return -1;
}
- populate = dev->async_copy ? MAP_POPULATE : 0;
+ populate = dev->map_populate ? MAP_POPULATE : 0;
mmap_addr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
MAP_SHARED | populate, region->fd, 0);
@@ -1398,7 +1398,7 @@ vhost_user_mmap_region(struct virtio_net *dev,
region->host_user_addr = (uint64_t)(uintptr_t)mmap_addr + mmap_offset;
mem_set_dump(dev, mmap_addr, mmap_size, false, alignment);
- if (dev->async_copy) {
+ if (dev->map_populate) {
if (add_guest_pages(dev, region, alignment) < 0) {
VHOST_CONFIG_LOG(dev->ifname, ERR,
"adding guest pages to region failed.");
--
2.54.0
next prev parent reply other threads:[~2026-08-26 14:02 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 15:31 [RFC 0/3] Drop vhost async (DMA-accelerated) datapath David Marchand
2026-07-23 15:31 ` [RFC 1/3] examples: stop using vhost async datapath David Marchand
2026-08-25 11:39 ` David Marchand
2026-07-23 15:31 ` [RFC 2/3] vhost: refuse " David Marchand
2026-07-23 15:31 ` [RFC 3/3] vhost: drop " David Marchand
2026-08-18 9:10 ` [RFC 0/3] Drop vhost async (DMA-accelerated) datapath Maxime Coquelin
2026-08-26 14:02 ` [PATCH 0/5] " David Marchand
2026-08-26 14:02 ` David Marchand [this message]
2026-08-26 14:02 ` [PATCH 2/5] examples/vhost: stop using async datapath David Marchand
2026-08-26 14:02 ` [PATCH 3/5] vhost: drop " David Marchand
2026-08-26 14:02 ` [PATCH 4/5] vhost: rename packed layout helpers for batches David Marchand
2026-08-26 14:02 ` [PATCH 5/5] vhost: simplify some descriptor handling David Marchand
2026-09-04 7:46 ` [PATCH v2 0/6] Drop vhost async (DMA-accelerated) datapath David Marchand
2026-09-04 7:46 ` [PATCH v2 1/6] vhost: decouple guest pages population from async datapath David Marchand
2026-09-29 7:45 ` Maxime Coquelin
2026-09-04 7:46 ` [PATCH v2 2/6] examples/vhost: stop using " David Marchand
2026-09-29 7:54 ` Maxime Coquelin
2026-09-04 7:46 ` [PATCH v2 3/6] examples/vdpa: remove dependency on PCI library David Marchand
2026-09-29 7:54 ` Maxime Coquelin
2026-09-04 7:46 ` [PATCH v2 4/6] vhost: drop async datapath David Marchand
2026-09-04 7:46 ` [PATCH v2 5/6] vhost: rename packed layout helpers for batches David Marchand
2026-09-04 7:46 ` [PATCH v2 6/6] vhost: simplify some descriptor handling David Marchand
2026-10-02 7:44 ` [PATCH v3 0/6] Drop vhost async (DMA-accelerated) datapath David Marchand
2026-10-02 7:44 ` [PATCH v3 1/6] vhost: decouple guest pages population from async datapath David Marchand
2026-10-02 7:44 ` [PATCH v3 2/6] examples/vhost: stop using " David Marchand
2026-10-02 7:44 ` [PATCH v3 3/6] examples/vdpa: remove dependency on PCI library David Marchand
2026-10-02 7:44 ` [PATCH v3 4/6] vhost: drop async datapath David Marchand
2026-10-05 19:07 ` Maxime Coquelin
2026-10-02 7:44 ` [PATCH v3 5/6] vhost: rename packed layout helpers for batches David Marchand
2026-10-05 19:14 ` Maxime Coquelin
2026-10-02 7:44 ` [PATCH v3 6/6] vhost: simplify some descriptor handling David Marchand
2026-10-05 19:24 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826140206.1099433-2-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.