diff mbox series

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

Message ID 20210428114231.96944-3-galpress@amazon.com (mailing list archive)
State Superseded
Headers show
Series Add copy-on-fork to get sys command | expand

Commit Message

Gal Pressman April 28, 2021, 11:42 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 | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Leon Romanovsky April 28, 2021, noon UTC | #1
On Wed, Apr 28, 2021 at 02:42:31PM +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

I don't think that we need to print them on separate lines.
$ rdma sys
netns shared copy-on-fork on
> 
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  rdma/sys.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/rdma/sys.c b/rdma/sys.c
> index 8fb565d70598..dd9c6da33e2a 100644
> --- a/rdma/sys.c
> +++ b/rdma/sys.c
> @@ -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);

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);



> +
>  	return MNL_CB_OK;
>  }
>  
> -- 
> 2.31.1
>
Gal Pressman April 29, 2021, 6:40 a.m. UTC | #2
On 28/04/2021 15:00, Leon Romanovsky wrote:
> On Wed, Apr 28, 2021 at 02:42:31PM +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
> 
> I don't think that we need to print them on separate lines.
> $ rdma sys
> netns shared copy-on-fork on

Ack.

>> Signed-off-by: Gal Pressman <galpress@amazon.com>
>> ---
>>  rdma/sys.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/rdma/sys.c b/rdma/sys.c
>> index 8fb565d70598..dd9c6da33e2a 100644
>> --- a/rdma/sys.c
>> +++ b/rdma/sys.c
>> @@ -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);
> 
> 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);

Ack (changed cow -> cof).

Thanks
diff mbox series

Patch

diff --git a/rdma/sys.c b/rdma/sys.c
index 8fb565d70598..dd9c6da33e2a 100644
--- a/rdma/sys.c
+++ b/rdma/sys.c
@@ -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;
 }