patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] common/mlx5: adjust fork call with the new kernel API
@ 2023-05-24 12:01 erezf
  2023-05-24 14:50 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: erezf @ 2023-05-24 12:01 UTC (permalink / raw)
  To: dev; +Cc: viacheslavo, matan, rasland, Erez Ferber, stable

From: Erez Ferber <erezf@nvidia.com>

While doing process fork() the operating system remaps all the parent
process's memory to the address space of the child process and activates
the Copy-on-Write mechanics - it duplicates physical pages once memory
writing happens in the child process. Sometimes memory duplication is
not allowed - for example, if the page contains hardware queue
descriptors. To handle similar issues the rdma-core library should be
prepared for forking.

The ibv_fork_init() prepares the library to track all the related memory
and prevent it from forking using madvise() system API. This approach
allows fork, but not all the memory is forked to the child process and,
application should care not to touch pages where the parent application
allocated the rdma-core objects.

The newer kernels propose an option of copy-on-fork for DMA pages and
tracking all the memory and disabling it for the forking is no longer
needed. The new API routine ibv_is_fork_initialized() should be involved
to decide if library initialization for forking is required.

Fixes: 0e83b8e536 ("net/mlx5: move rdma-core calls to separate file")
Cc: stable@dpdk.org
Signed-off-by: Erez Ferber <erezf@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build | 2 ++
 drivers/common/mlx5/linux/mlx5_glue.c | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 96a6c6c9be..c1fcb36fdd 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -219,6 +219,8 @@ has_sym_args = [
             'ibv_import_device' ],
         [ 'HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE', 'infiniband/mlx5dv.h',
             'mlx5dv_dr_action_create_dest_root_table' ],
+	[ 'HAVE_IBV_FORK_UNNEEDED', 'infiniband/verbs.h',
+		'ibv_is_fork_initialized'],
 ]
 if  libmtcr_ul_found
     has_sym_args += [
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 702eb36b62..88b99fe029 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -19,6 +19,10 @@
 static int
 mlx5_glue_fork_init(void)
 {
+#ifdef HAVE_IBV_FORK_UNNEEDED
+	if (ibv_is_fork_initialized() == IBV_FORK_UNNEEDED)
+		return 0; /* ibv_fork_init() not needed */
+#endif
 	return ibv_fork_init();
 }
 
-- 
2.14.1


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

end of thread, other threads:[~2023-06-22 12:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 12:01 [PATCH] common/mlx5: adjust fork call with the new kernel API erezf
2023-05-24 14:50 ` Stephen Hemminger
2023-05-25  8:10   ` Slava Ovsiienko
2023-05-25 15:27     ` Stephen Hemminger
2023-05-26  8:05       ` Slava Ovsiienko
2023-05-24 16:05 ` Slava Ovsiienko
2023-06-22 12:19 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).