* [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling
@ 2026-03-08 19:21 Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd() Gal Pressman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Gal Pressman @ 2026-03-08 19:21 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, netdev
Cc: Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest, Gal Pressman
Pass the timeout argument correctly in cmd.process().
As Jakub noted, fixing the timeout broke the bpftrace() command in
netpoll_basic.py, so fix it first.
Changelog:
v1->v2: https://lore.kernel.org/all/20260215125149.2106612-1-gal@nvidia.com/
* Add patch #1.
Gal Pressman (2):
selftests: net: pass bpftrace timeout to cmd()
selftests: net: fix timeout passed as positional argument to
communicate()
tools/testing/selftests/net/lib/py/utils.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd()
2026-03-08 19:21 [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Gal Pressman
@ 2026-03-08 19:21 ` Gal Pressman
2026-03-10 2:41 ` Jakub Kicinski
2026-03-08 19:21 ` [PATCH net v2 2/2] selftests: net: fix timeout passed as positional argument to communicate() Gal Pressman
2026-03-10 2:40 ` [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Jakub Kicinski
2 siblings, 1 reply; 7+ messages in thread
From: Gal Pressman @ 2026-03-08 19:21 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, netdev
Cc: Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest, Gal Pressman, Nimrod Oren
The bpftrace() helper configures an interval based exit timer but does
not propagate the timeout to the cmd object, which defaults to 5
seconds. Since the default BPFTRACE_TIMEOUT is 10 seconds, cmd.process()
always raises a TimeoutExpired exception before bpftrace has a chance to
exit gracefully.
Pass timeout+5 to cmd() to allow bpftrace to complete gracefully.
Note: this issue is masked by a bug in the way cmd() passes timeout,
this is fixed in the next commit.
Fixes: 3c561c547c39 ("selftests: drv-net: add helper/wrapper for bpftrace")
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
tools/testing/selftests/net/lib/py/utils.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index 85884f3e827b..ce4fa4aabebe 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -240,8 +240,9 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
cmd_arr += ['-f', 'json', '-q']
if timeout:
expr += ' interval:s:' + str(timeout) + ' { exit(); }'
+ timeout += 5
cmd_arr += ['-e', expr]
- cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False)
+ cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False, timeout=timeout)
if json:
# bpftrace prints objects as lines
ret = {}
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net v2 2/2] selftests: net: fix timeout passed as positional argument to communicate()
2026-03-08 19:21 [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd() Gal Pressman
@ 2026-03-08 19:21 ` Gal Pressman
2026-03-10 2:40 ` [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Jakub Kicinski
2 siblings, 0 replies; 7+ messages in thread
From: Gal Pressman @ 2026-03-08 19:21 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, netdev
Cc: Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest, Gal Pressman, Nimrod Oren
The cited commit refactored the hardcoded timeout=5 into a parameter,
but dropped the keyword from the communicate() call.
Since Popen.communicate()'s first positional argument is 'input' (not
'timeout'), the timeout value is silently treated as stdin input and the
call never enforces a timeout.
Pass timeout as a keyword argument to restore the intended behavior.
Fixes: 1cf270424218 ("net: selftest: add test for netdev netlink queue-get API")
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
tools/testing/selftests/net/lib/py/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index ce4fa4aabebe..4c98ddafdeab 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -88,7 +88,7 @@ class cmd:
os.write(self.ksft_term_fd, b"1")
if terminate:
self.proc.terminate()
- stdout, stderr = self.proc.communicate(timeout)
+ stdout, stderr = self.proc.communicate(timeout=timeout)
self.stdout = stdout.decode("utf-8")
self.stderr = stderr.decode("utf-8")
self.proc.stdout.close()
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling
2026-03-08 19:21 [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd() Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 2/2] selftests: net: fix timeout passed as positional argument to communicate() Gal Pressman
@ 2026-03-10 2:40 ` Jakub Kicinski
2026-03-10 8:52 ` Gal Pressman
2 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2026-03-10 2:40 UTC (permalink / raw)
To: Gal Pressman
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn, netdev,
Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest
On Sun, 8 Mar 2026 21:21:24 +0200 Gal Pressman wrote:
> Pass the timeout argument correctly in cmd.process().
> As Jakub noted, fixing the timeout broke the bpftrace() command in
> netpoll_basic.py, so fix it first.
patchwork says this didn't get selftest-ed which usually means there's
going to be a conflict with net-next. Can you respin this against
net-next?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd()
2026-03-08 19:21 ` [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd() Gal Pressman
@ 2026-03-10 2:41 ` Jakub Kicinski
2026-03-10 8:51 ` Gal Pressman
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2026-03-10 2:41 UTC (permalink / raw)
To: Gal Pressman
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn, netdev,
Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest, Nimrod Oren
On Sun, 8 Mar 2026 21:21:25 +0200 Gal Pressman wrote:
> @@ -240,8 +240,9 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
> cmd_arr += ['-f', 'json', '-q']
> if timeout:
> expr += ' interval:s:' + str(timeout) + ' { exit(); }'
> + timeout += 5
it may be easy to miss that input arg is modified so..
> cmd_arr += ['-e', expr]
> - cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False)
> + cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False, timeout=timeout)
timeout=(timeout + 5)
here instead could potentially be cleaner, but up to you.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd()
2026-03-10 2:41 ` Jakub Kicinski
@ 2026-03-10 8:51 ` Gal Pressman
0 siblings, 0 replies; 7+ messages in thread
From: Gal Pressman @ 2026-03-10 8:51 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn, netdev,
Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest, Nimrod Oren
On 10/03/2026 4:41, Jakub Kicinski wrote:
> On Sun, 8 Mar 2026 21:21:25 +0200 Gal Pressman wrote:
>> @@ -240,8 +240,9 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
>> cmd_arr += ['-f', 'json', '-q']
>> if timeout:
>> expr += ' interval:s:' + str(timeout) + ' { exit(); }'
>> + timeout += 5
>
> it may be easy to miss that input arg is modified so..
>
>> cmd_arr += ['-e', expr]
>> - cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False)
>> + cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False, timeout=timeout)
>
> timeout=(timeout + 5)
>
> here instead could potentially be cleaner, but up to you.
timeout is None by default, so I figured my version looks better than:
timeout=(timeout + 5) if timeout else None
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling
2026-03-10 2:40 ` [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Jakub Kicinski
@ 2026-03-10 8:52 ` Gal Pressman
0 siblings, 0 replies; 7+ messages in thread
From: Gal Pressman @ 2026-03-10 8:52 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn, netdev,
Simon Horman, Shuah Khan, Breno Leitao, David Wei,
linux-kselftest
On 10/03/2026 4:40, Jakub Kicinski wrote:
> On Sun, 8 Mar 2026 21:21:24 +0200 Gal Pressman wrote:
>> Pass the timeout argument correctly in cmd.process().
>> As Jakub noted, fixing the timeout broke the bpftrace() command in
>> netpoll_basic.py, so fix it first.
>
> patchwork says this didn't get selftest-ed which usually means there's
> going to be a conflict with net-next. Can you respin this against
> net-next?
I'm not seeing any conflicts, but sure, will resubmit to net-next.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-10 8:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 19:21 [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 1/2] selftests: net: pass bpftrace timeout to cmd() Gal Pressman
2026-03-10 2:41 ` Jakub Kicinski
2026-03-10 8:51 ` Gal Pressman
2026-03-08 19:21 ` [PATCH net v2 2/2] selftests: net: fix timeout passed as positional argument to communicate() Gal Pressman
2026-03-10 2:40 ` [PATCH net v2 0/2] selftests: net: fix cmd.process() timeout handling Jakub Kicinski
2026-03-10 8:52 ` Gal Pressman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox