Skip to contentSkip to conversation

Add copy-on-fork to get sys command

PATCH Superseded Gal Pressman 2 participants 5 messages Apr 28, 2021 – Apr 29, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add copy-on-fork to get sys command

This is the userspace part for the new copy-on-fork attribute added to the get sys netlink command.

The new attribute indicates that the kernel copies DMA pages on fork, hence fork support through madvise and MADV_DONTFORK is not needed.

Kernel series was merged:
https://lore.kernel.org/linux-rdma/[email protected]/

Thanks

Gal Pressman (2):
rdma: update uapi headers
rdma: Add copy-on-fork to get sys command

 rdma/include/uapi/rdma/rdma_netlink.h | 16 ++++++++++++++++
 rdma/sys.c                            |  9 +++++++++
 2 files changed, 25 insertions(+)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 rdma: update uapi headers

Update rdma_netlink.h file upto kernel commit
6cc9e215eb27 ("RDMA/nldev: Add copy-on-fork attribute to get sys command")

---
 rdma/include/uapi/rdma/rdma_netlink.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
rdma/include/uapi/rdma/rdma_netlink.h +16 -0
index 4aef76ae317b..37f583ee58fc 100644
@@ -293,6 +293,10 @@ enum rdma_nldev_command {
 
 	RDMA_NLDEV_CMD_RES_MR_GET_RAW,
 
+	RDMA_NLDEV_CMD_RES_CTX_GET, /* can dump */
+
+	RDMA_NLDEV_CMD_RES_SRQ_GET, /* can dump */
+
 	RDMA_NLDEV_NUM_OPS
 };
 
@@ -533,6 +537,18 @@ enum rdma_nldev_attr {
 
 	RDMA_NLDEV_ATTR_RES_RAW,	/* binary */
 
+	RDMA_NLDEV_ATTR_RES_CTX,		/* nested table */
+	RDMA_NLDEV_ATTR_RES_CTX_ENTRY,		/* nested table */
+
+	RDMA_NLDEV_ATTR_RES_SRQ,		/* nested table */
+	RDMA_NLDEV_ATTR_RES_SRQ_ENTRY,		/* nested table */
+	RDMA_NLDEV_ATTR_RES_SRQN,		/* u32 */
+
+	RDMA_NLDEV_ATTR_MIN_RANGE,		/* u32 */
+	RDMA_NLDEV_ATTR_MAX_RANGE,		/* u32 */
+
+	RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK,	/* u8 */
+
 	/*
 	 * Always the end
 	 */
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/2 rdma: Add copy-on-fork to get sys command

In reply to Gal Pressman

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
---
 rdma/sys.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rdma/sys.c +9 -0
index 8fb565d70598..dd9c6da33e2a 100644
@@ -38,6 +38,15 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
 		print_color_string(PRINT_ANY, COLOR_NONE, "netns", "netns %s\n",
 				   mode_str);
 	}
+
+	if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n",
+				   mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]));
+	else
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n", false);
+
 	return MNL_CB_OK;
 }
 
Signature · 1 line
2.31.1
#3 lore raw

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

Quoted 10 lines · Gal Pressman

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

I don't think that we need to print them on separate lines.

$ rdma sys
netns shared copy-on-fork on
Quoted 12 lines
---
 rdma/sys.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rdma/sys.c +0 -0
index 8fb565d70598..dd9c6da33e2a 100644
@@ -38,6 +38,15 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
 		print_color_string(PRINT_ANY, COLOR_NONE, "netns", "netns %s\n",

rdma/sys.c static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data) · line 48

Quoted 10 lines
rdma/sys.c +8 -0
 				   mode_str);
 	}
+
+	if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n",
+				   mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]));
+	else
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n", false);

Let's simplify it

        bool cow = false;

+ if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+ cow = 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", cow);

Quoted 7 lines
rdma/sys.c +1 -0
+
 	return MNL_CB_OK;
 }
 
Signature · 1 line
2.31.1
#4 lore raw

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

Quoted 7 lines · Leon Romanovsky
Quoted 6 lines · Gal Pressman

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.

Quoted 8 lines
Quoted 4 lines

Example:

$ rdma sys
netns shared
copy-on-fork on

I don't think that we need to print them on separate lines.

$ rdma sys
netns shared copy-on-fork on

Ack.

Quoted 23 lines
Quoted 11 lines
---
 rdma/sys.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rdma/sys.c +0 -0
index 8fb565d70598..dd9c6da33e2a 100644
@@ -38,6 +38,15 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
 		print_color_string(PRINT_ANY, COLOR_NONE, "netns", "netns %s\n",

rdma/sys.c static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data) · line 48

Quoted 10 lines
rdma/sys.c +8 -0
 				   mode_str);
 	}
+
+	if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n",
+				   mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]));
+	else
+		print_color_on_off(PRINT_ANY, COLOR_NONE, "copy-on-fork",
+				   "copy-on-fork %s\n", false);

Let's simplify it

Quoted 6 lines
        bool cow = false;

+ if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK])
+ cow = 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", cow);

Ack (changed cow -> cof).

Thanks