Skip to contentSkip to conversation

Add copy-on-fork to get sys command

PATCH Applied Gal Pressman 3 participants 6 messages Apr 29, 2021 – May 3, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 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]/

Changelog -
v1->v2: https://lore.kernel.org/linux-rdma/[email protected]/
* Rebase kernel headers
* Print attributes on the same line
* Simplify if statement

Thanks

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

 rdma/include/uapi/rdma/rdma_netlink.h |  3 +++
 rdma/sys.c                            | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 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 | 3 +++
 1 file changed, 3 insertions(+)
rdma/include/uapi/rdma/rdma_netlink.h +3 -0
index e161c245bf71..37f583ee58fc 100644
@@ -546,6 +546,9 @@ enum rdma_nldev_attr {
 
 	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
#3 lore raw

PATCH v2 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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
rdma/sys.c +10 -1
index 8fb565d70598..fd785b253e20 100644
@@ -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;
 }
 
Signature · 1 line
2.31.1
Acked-by on v2 2/2
#4 lore raw

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

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 9 lines

Example:

$ rdma sys
netns shared copy-on-fork on
---
 rdma/sys.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Thanks,

Applied
#5 lore raw
In reply to Gal Pressman
Quoted 17 lines · Gal Pressman

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]/

Changelog -
v1->v2: https://lore.kernel.org/linux-rdma/[email protected]/
* Rebase kernel headers
* Print attributes on the same line
* Simplify if statement

Thanks

Quoted 8 lines

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

 rdma/include/uapi/rdma/rdma_netlink.h |  3 +++
 rdma/sys.c                            | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

applied to iproute2-next