Add copy-on-fork to get sys command
Subsystems (3)
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
PATCH 1/2 rdma: update uapi headers
Update rdma_netlink.h file upto kernel commit6cc9e215eb27 ("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
@@ -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
PATCH 2/2 rdma: Add copy-on-fork to get sys command
In reply to Gal PressmanThe 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
@@ -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
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_DONTFORKis 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
Signed-off-by Gal Pressman <[email protected]>--- rdma/sys.c | 9 +++++++++ 1 file changed, 9 insertions(+)rdma/sys.c +0
-0@@ -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
-0mode_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
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_DONTFORKis 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 onI 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
Signed-off-by Gal Pressman <[email protected]>--- rdma/sys.c | 9 +++++++++ 1 file changed, 9 insertions(+)rdma/sys.c +0
-0@@ -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
-0mode_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