diff mbox series

[iproute2-next,v2,2/2] rdma: Add copy-on-fork to get sys command

Message ID 20210429064803.58458-3-galpress@amazon.com (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series Add copy-on-fork to get sys command | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Gal Pressman April 29, 2021, 6:48 a.m. UTC
The new attribute indicates that the kernel copies DMA pages on fork,
hence fork support through madvise and MADV_DONTFORK is not needed.

If the attribute is not reported (expected on older kernels),
copy-on-fork is disabled.

Example:
$ rdma sys
netns shared copy-on-fork on

Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 rdma/sys.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky April 29, 2021, 7:12 a.m. UTC | #1
On Thu, Apr 29, 2021 at 09:48:03AM +0300, Gal Pressman wrote:
> The new attribute indicates that the kernel copies DMA pages on fork,
> hence fork support through madvise and MADV_DONTFORK is not needed.
> 
> If the attribute is not reported (expected on older kernels),
> copy-on-fork is disabled.
> 
> Example:
> $ rdma sys
> netns shared copy-on-fork on
> 
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  rdma/sys.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 

Thanks,
Acked-by: Leon Romanovsky <leonro@nvidia.com>
diff mbox series

Patch

diff --git a/rdma/sys.c b/rdma/sys.c
index 8fb565d70598..fd785b253e20 100644
--- a/rdma/sys.c
+++ b/rdma/sys.c
@@ -20,6 +20,7 @@  static const char *netns_modes_str[] = {
 static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
 {
 	struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
+	bool cof = false;
 
 	mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
 
@@ -35,9 +36,17 @@  static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
 		else
 			mode_str = "unknown";
 
-		print_color_string(PRINT_ANY, COLOR_NONE, "netns", "netns %s\n",
+		print_color_string(PRINT_ANY, COLOR_NONE, "netns", "netns %s ",
 				   mode_str);
 	}
+
+	if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+		cof = mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]);
+
+	print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+			   "copy-on-fork %s\n",
+			   cof);
+
 	return MNL_CB_OK;
 }