From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: jhs@mojatatu.com, jiri@resnulli.us, victor@mojatatu.com,
Florian Westphal <fw@strlen.de>
Subject: [PATCH net 1/4] selftests/tc-testing: pass mp_pm via initialiser
Date: Wed, 19 Aug 2026 22:42:07 +0200 [thread overview]
Message-ID: <20260819204210.23722-2-fw@strlen.de> (raw)
In-Reply-To: <20260819204210.23722-1-fw@strlen.de>
The script doesn't work for me:
-- ns/SubPlugin.__init__
Executing 1205 tests in parallel and 89 in serial
Using 39 batches and 4 workers
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.14/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
~~~~^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "tools/testing/selftests/tc-testing/tdc.py", line 604, in __mp_runner
(_, tsr) = test_runner(mp_pm, mp_args, tests)
^^^^^
NameError: name 'mp_pm' is not defined
Assisted-by: ollama:gemma4:26b
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tools/testing/selftests/tc-testing/tdc.py | 27 ++++++++++++++++-------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index 511d66c36a2a..19b8a1fd1c71 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -600,6 +600,18 @@ def mp_bins(alltests):
return (serial, parallel)
+mp_pm = None
+mp_args = None
+
+def __mp_init__(pm, args):
+ """
+ This function is called once when each worker process starts.
+ It sets the global variables in the child process's memory space.
+ """
+ global mp_pm, mp_args
+ mp_pm = pm
+ mp_args = args
+
def __mp_runner(tests):
(_, tsr) = test_runner(mp_pm, mp_args, tests)
return tsr._testsuite
@@ -615,14 +627,13 @@ def test_runner_mp(pm, args, alltests):
print("Executing {} tests in parallel and {} in serial".format(len(parallel), len(serial)))
print("Using {} batches and {} workers".format(len(batches), args.mp))
- # We can't pickle these objects so workaround them
- global mp_pm
- mp_pm = pm
-
- global mp_args
- mp_args = args
-
- with Pool(args.mp) as p:
+ # Use the 'initializer' to pass the unpickleable/shared objects
+ # to each worker process exactly once upon startup.
+ with Pool(
+ processes=args.mp,
+ initializer=__mp_init__,
+ initargs=(pm, args)
+ ) as p:
pres = p.map(__mp_runner, batches)
tsr = TestSuiteReport()
--
2.54.0
next prev parent reply other threads:[~2026-08-19 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 20:42 [PATCH net 0/4] net/sched: reset conntrack after packet munging Florian Westphal
2026-08-19 20:42 ` Florian Westphal [this message]
2026-08-19 20:42 ` [PATCH net 2/4] net/sched: act_pedit: drop conntrack on network/transport header changes Florian Westphal
2026-08-19 20:42 ` [PATCH net 3/4] selftests: tc-testing: add act_ct test for ct reset handling Florian Westphal
2026-08-19 20:42 ` [PATCH net 4/4] net/sched: act_nat: discard any conntrack entry post modification Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260819204210.23722-2-fw@strlen.de \
--to=fw@strlen.de \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=victor@mojatatu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox