All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] selftests: tls: size splice_short pipe by page size
@ 2026-06-22 20:28 Nirmoy Das
  2026-06-24 12:51 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Nirmoy Das @ 2026-06-22 20:28 UTC (permalink / raw)
  To: Jakub Kicinski, Sabrina Dubroca, John Fastabend
  Cc: netdev, linux-kernel, Nirmoy Das

splice_short grows its pipe with (MAX_FRAGS + 1) * 0x1000 so it can
queue one short vmsplice() buffer for each fragment before draining the
pipe. That assumes 4K pipe buffers.

On 64K-page kernels the request is rounded to 262144 bytes, which
provides only four pipe buffers. The fifth one-byte vmsplice() blocks in
pipe_wait_writable and the test times out before it reaches the TLS path.

Request enough bytes for the same number of pipe buffers using the
runtime page size, and assert that the kernel granted at least that much.
If an unprivileged run cannot raise the pipe above the system
pipe-max-size limit, skip the test because it cannot exercise the
intended path.

Fixes: 3667e9b442b9 ("selftests: tls: add test for short splice due to full skmsg")
Assisted-by: Codex:gpt-5
Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
---
 tools/testing/selftests/net/tls.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 30a236b8e9f73..e3bf4ade0f770 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -997,6 +997,8 @@ TEST_F(tls, splice_short)
 	char sendbuf[0x100];
 	char sendchar = 'S';
 	int pipefds[2];
+	int pipe_sz;
+	int ret;
 	int i;
 
 	sendchar_iov.iov_base = &sendchar;
@@ -1005,7 +1007,12 @@ TEST_F(tls, splice_short)
 	memset(sendbuf, 's', sizeof(sendbuf));
 
 	ASSERT_GE(pipe2(pipefds, O_NONBLOCK), 0);
-	ASSERT_GE(fcntl(pipefds[0], F_SETPIPE_SZ, (MAX_FRAGS + 1) * 0x1000), 0);
+	pipe_sz = (MAX_FRAGS + 1) * getpagesize();
+	ret = fcntl(pipefds[0], F_SETPIPE_SZ, pipe_sz);
+	if (ret < 0 && errno == EPERM)
+		SKIP(return, "insufficient pipe capacity");
+	ASSERT_GE(ret, 0);
+	ASSERT_GE(ret, pipe_sz);
 
 	for (i = 0; i < MAX_FRAGS; i++)
 		ASSERT_GE(vmsplice(pipefds[1], &sendchar_iov, 1, 0), 0);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] selftests: tls: size splice_short pipe by page size
  2026-06-22 20:28 [PATCH net-next] selftests: tls: size splice_short pipe by page size Nirmoy Das
@ 2026-06-24 12:51 ` Simon Horman
  2026-06-24 13:46   ` Nirmoy Das
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2026-06-24 12:51 UTC (permalink / raw)
  To: Nirmoy Das
  Cc: Jakub Kicinski, Sabrina Dubroca, John Fastabend, netdev,
	linux-kernel

On Mon, Jun 22, 2026 at 01:28:47PM -0700, Nirmoy Das wrote:
> splice_short grows its pipe with (MAX_FRAGS + 1) * 0x1000 so it can
> queue one short vmsplice() buffer for each fragment before draining the
> pipe. That assumes 4K pipe buffers.
> 
> On 64K-page kernels the request is rounded to 262144 bytes, which
> provides only four pipe buffers. The fifth one-byte vmsplice() blocks in
> pipe_wait_writable and the test times out before it reaches the TLS path.
> 
> Request enough bytes for the same number of pipe buffers using the
> runtime page size, and assert that the kernel granted at least that much.
> If an unprivileged run cannot raise the pipe above the system
> pipe-max-size limit, skip the test because it cannot exercise the
> intended path.
> 
> Fixes: 3667e9b442b9 ("selftests: tls: add test for short splice due to full skmsg")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>

The nit below not withstanding, this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  tools/testing/selftests/net/tls.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
> index 30a236b8e9f73..e3bf4ade0f770 100644
> --- a/tools/testing/selftests/net/tls.c
> +++ b/tools/testing/selftests/net/tls.c
> @@ -997,6 +997,8 @@ TEST_F(tls, splice_short)
>  	char sendbuf[0x100];
>  	char sendchar = 'S';
>  	int pipefds[2];
> +	int pipe_sz;
> +	int ret;
>  	int i;
>  
>  	sendchar_iov.iov_base = &sendchar;
> @@ -1005,7 +1007,12 @@ TEST_F(tls, splice_short)
>  	memset(sendbuf, 's', sizeof(sendbuf));
>  
>  	ASSERT_GE(pipe2(pipefds, O_NONBLOCK), 0);
> -	ASSERT_GE(fcntl(pipefds[0], F_SETPIPE_SZ, (MAX_FRAGS + 1) * 0x1000), 0);
> +	pipe_sz = (MAX_FRAGS + 1) * getpagesize();
> +	ret = fcntl(pipefds[0], F_SETPIPE_SZ, pipe_sz);
> +	if (ret < 0 && errno == EPERM)
> +		SKIP(return, "insufficient pipe capacity");
> +	ASSERT_GE(ret, 0);

nit: the line above seems redundant to me given the line below.

> +	ASSERT_GE(ret, pipe_sz);
>  
>  	for (i = 0; i < MAX_FRAGS; i++)
>  		ASSERT_GE(vmsplice(pipefds[1], &sendchar_iov, 1, 0), 0);
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] selftests: tls: size splice_short pipe by page size
  2026-06-24 12:51 ` Simon Horman
@ 2026-06-24 13:46   ` Nirmoy Das
  0 siblings, 0 replies; 3+ messages in thread
From: Nirmoy Das @ 2026-06-24 13:46 UTC (permalink / raw)
  To: Simon Horman
  Cc: Jakub Kicinski, Sabrina Dubroca, John Fastabend, netdev,
	linux-kernel


On 24.06.26 15:51, Simon Horman wrote:
> On Mon, Jun 22, 2026 at 01:28:47PM -0700, Nirmoy Das wrote:
>> splice_short grows its pipe with (MAX_FRAGS + 1) * 0x1000 so it can
>> queue one short vmsplice() buffer for each fragment before draining the
>> pipe. That assumes 4K pipe buffers.
>>
>> On 64K-page kernels the request is rounded to 262144 bytes, which
>> provides only four pipe buffers. The fifth one-byte vmsplice() blocks in
>> pipe_wait_writable and the test times out before it reaches the TLS path.
>>
>> Request enough bytes for the same number of pipe buffers using the
>> runtime page size, and assert that the kernel granted at least that much.
>> If an unprivileged run cannot raise the pipe above the system
>> pipe-max-size limit, skip the test because it cannot exercise the
>> intended path.
>>
>> Fixes: 3667e9b442b9 ("selftests: tls: add test for short splice due to full skmsg")
>> Assisted-by: Codex:gpt-5
>> Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
> The nit below not withstanding, this looks good to me.
>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
>> ---
>>   tools/testing/selftests/net/tls.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
>> index 30a236b8e9f73..e3bf4ade0f770 100644
>> --- a/tools/testing/selftests/net/tls.c
>> +++ b/tools/testing/selftests/net/tls.c
>> @@ -997,6 +997,8 @@ TEST_F(tls, splice_short)
>>   	char sendbuf[0x100];
>>   	char sendchar = 'S';
>>   	int pipefds[2];
>> +	int pipe_sz;
>> +	int ret;
>>   	int i;
>>   
>>   	sendchar_iov.iov_base = &sendchar;
>> @@ -1005,7 +1007,12 @@ TEST_F(tls, splice_short)
>>   	memset(sendbuf, 's', sizeof(sendbuf));
>>   
>>   	ASSERT_GE(pipe2(pipefds, O_NONBLOCK), 0);
>> -	ASSERT_GE(fcntl(pipefds[0], F_SETPIPE_SZ, (MAX_FRAGS + 1) * 0x1000), 0);
>> +	pipe_sz = (MAX_FRAGS + 1) * getpagesize();
>> +	ret = fcntl(pipefds[0], F_SETPIPE_SZ, pipe_sz);
>> +	if (ret < 0 && errno == EPERM)
>> +		SKIP(return, "insufficient pipe capacity");
>> +	ASSERT_GE(ret, 0);
> nit: the line above seems redundant to me given the line below.


Thanks Simon. Sent v2 with the nit addressed.


>
>> +	ASSERT_GE(ret, pipe_sz);
>>   
>>   	for (i = 0; i < MAX_FRAGS; i++)
>>   		ASSERT_GE(vmsplice(pipefds[1], &sendchar_iov, 1, 0), 0);
>> -- 
>> 2.43.0
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-24 13:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 20:28 [PATCH net-next] selftests: tls: size splice_short pipe by page size Nirmoy Das
2026-06-24 12:51 ` Simon Horman
2026-06-24 13:46   ` Nirmoy Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.