public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH v8 0/5] Support add/remove memory region and get-max-slots
@ 2026-04-03  1:54 pravin.bathija
  2026-04-03  1:54 ` [PATCH v8 1/5] vhost: add user to mailmap and define to vhost hdr pravin.bathija
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: pravin.bathija @ 2026-04-03  1:54 UTC (permalink / raw)
  To: dev, stephen; +Cc: pravin.bathija, thomas, maxime.coquelin, fengchengwen

From: Pravin M Bathija <pravin.bathija@dell.com>

This is version v8 of the patchset and it incorporates the
recommendations made by Stephen Hemminger.
The async_dma_map_region function was rewritten to iterate guest pages
by host address range matching rather than assuming contiguous array
indices after sorting, and now returns an error code so that DMA mapping
failures are treated as fatal during add_mem_reg. The
dev_invalidate_vrings function was changed to accept a double pointer to
propagate pointer updates from numa_realloc through
translate_ring_addresses, preventing a user-after-free in both
add_mem_reg and rem_mem_reg callers.

A new remove_guest_pages function was added to clean up stale guest page
entries when removing a region. The rem_mem_reg handler now compacts the
regions array using memmove after removal, keeping it contiguous so that
all existing nregions-based iteration in address translation functions
like qva_to_vva and hva_togpa continues to work correctly. This
compaction also eliminates the need for the guest_user_addr == 0
free-slot sentinel in add_mem_reg, which was problematic since guest
virtual address zero is valid.

The add_mem_reg error path was narrowed to only clean up the single
failed region instead of destroying all existing regions. A missing
ctx->fds[0] = -1 assignment was added after the fd handoff to prevent
double-close on error paths. The overlap check was corrected to use
region size instead of mmap_size, which included alignment padding and
caused false positives. The rem_mem_reg handler registration was fixed
to accept file descriptors as required by the vhost-user protocol, with
proper fd cleanup added in all exit paths. Finally, the postcopy
registration in add_mem_reg was changed to call
vhost_user_postcopy_region_register directly for the single new region,
avoiding the use of vhost_user_postcopy_register which reads the wrong
payload union member, and a defensive guard was added to
vhost_user_initialize_memory against double initialization.

This implementation has been extensively tested by doing Read/Write I/O
from multiple instances of fio + libblkio (front-end) talking to
spdk/dpdk (back-end) based drives. Tested with qemu front-end talking to
dpdk testpmd (back-end) performing add/removal of memory regions. Also
tested post-copy live migration after doing add_memory_region.

Version Log:
Version v8 (Current version): Incorporate code review suggestions from
Stephen Hemminger as described above.
Version v7: Incorporate code review suggestions from Maxime Coquelin.
Add debug messages to vhost_postcopy_register function.
Version v6: Added the enablement of this feature as a final patch in
this patch-set and other code optimizations as suggested by Maxime
Coquelin.
Version v5: removed the patch that increased the number of memory regions
from 8 to 128. This will be submitted as a separate feature at a later
point after incorporating additional optimizations. Also includes code
optimizations as suggested by Feng Cheng Wen.
Version v4: code optimizations as suggested by Feng Cheng Wen.
Version v3: code optimizations as suggested by Maxime Coquelin
and Thomas Monjalon.
Version v2: code optimizations as suggested by Maxime Coquelin.
Version v1: Initial patch set.

Pravin M Bathija (5):
  vhost: add user to mailmap and define to vhost hdr
  vhost_user: header defines for add/rem mem region
  vhost_user: support function defines for back-end
  vhost_user: Function defs for add/rem mem regions
  vhost_user: enable configure memory slots

 .mailmap               |   1 +
 lib/vhost/rte_vhost.h  |   4 +
 lib/vhost/vhost_user.c | 392 ++++++++++++++++++++++++++++++++++++-----
 lib/vhost/vhost_user.h |  10 ++
 4 files changed, 364 insertions(+), 43 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-04-07  7:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  1:54 [PATCH v8 0/5] Support add/remove memory region and get-max-slots pravin.bathija
2026-04-03  1:54 ` [PATCH v8 1/5] vhost: add user to mailmap and define to vhost hdr pravin.bathija
2026-04-03  1:54 ` [PATCH v8 2/5] vhost_user: header defines for add/rem mem region pravin.bathija
2026-04-03  1:54 ` [PATCH v8 3/5] vhost_user: support function defines for back-end pravin.bathija
2026-04-03  1:54 ` [PATCH v8 4/5] vhost_user: Function defs for add/rem mem regions pravin.bathija
2026-04-03  1:54 ` [PATCH v8 5/5] vhost_user: enable configure memory slots pravin.bathija
2026-04-05 23:29 ` [PATCH v8 0/5] Support add/remove memory region and get-max-slots Stephen Hemminger
2026-04-07  7:46   ` Bathija, Pravin

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