Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: net: py: don't default to shell=True

Overhead of using shell=True is quite significant.
Micro-benchmark of running ethtool --help shows that
non-shell run is 2x faster.

Runtime of the XDP tests also shows improvement:
this patch: 2m34s 2m21s 2m18s 2m18s
before: 2m54s 2m36s 2m34s

Reviewed-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20250830184317.696121-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+9 -2
+9 -2
tools/testing/selftests/net/lib/py/utils.py
··· 26 26 """ 27 27 Execute a command on local or remote host. 28 28 29 + @shell defaults to false, and class will try to split @comm into a list 30 + if it's a string with spaces. 31 + 29 32 Use bkg() instead to run a command in the background. 30 33 """ 31 - def __init__(self, comm, shell=True, fail=True, ns=None, background=False, 34 + def __init__(self, comm, shell=None, fail=True, ns=None, background=False, 32 35 host=None, timeout=5, ksft_wait=None): 33 36 if ns: 34 37 comm = f'ip netns exec {ns} ' + comm ··· 45 42 if host: 46 43 self.proc = host.cmd(comm) 47 44 else: 45 + # If user doesn't explicitly request shell try to avoid it. 46 + if shell is None and isinstance(comm, str) and ' ' in comm: 47 + comm = comm.split() 48 + 48 49 # ksft_wait lets us wait for the background process to fully start, 49 50 # we pass an FD to the child process, and wait for it to write back. 50 51 # Similarly term_fd tells child it's time to exit. ··· 115 108 116 109 with bkg("my_binary", ksft_wait=5): 117 110 """ 118 - def __init__(self, comm, shell=True, fail=None, ns=None, host=None, 111 + def __init__(self, comm, shell=None, fail=None, ns=None, host=None, 119 112 exit_wait=False, ksft_wait=None): 120 113 super().__init__(comm, background=True, 121 114 shell=shell, fail=fail, ns=ns, host=host,