]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rdma: Add copy-on-fork to get sys command
authorGal Pressman <galpress@amazon.com>
Thu, 29 Apr 2021 06:48:03 +0000 (09:48 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 3 May 2021 14:43:13 +0000 (14:43 +0000)
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>
Acked-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
rdma/sys.c

index 8fb565d705983a4e20b0021eaaa08e1b056aca60..fd785b253e20069e3741dbeb8d507e1d3735f975 100644 (file)
@@ -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;
 }