Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Sun, 29 Nov 2026 10:38
Re: [PATCH net-next v5 13/14] selftests: dpll: add concurrency stress tests
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 10:38
Date: Sun, 29 Nov 2026 10:38
111 lines
12533 bytes
12533 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In tools/testing/selftests/drivers/dpll/dpll_stress.sh, cleanup()
checks a pid and signals it in two separate steps: `pid_running "$pid"โฆ
--
selftests: dpll: add concurrency stress tests
This adds test_concurrent_workers and test_many_devices to the dpll stress
selftest. The workers run in subshells and remove their in-flight device
from their own exit traps. The cleanup handler signals the recorded
workers, then removes whatever they left behind, using clock-id ranges
reserved per worker. dpllsim_delete_device() now also treats a part of a
device that disappears concurrently as removed.
> diff --git a/tools/testing/selftests/drivers/dpll/dpll_stress.sh b/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> index 1596c3f1e70b5..20b3132e8a3db 100755
> --- a/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> +++ b/tools/testing/selftests/drivers/dpll/dpll_stress.sh
[ ... ]
> +# Return 0 while the process is a running child of this shell. bash
> +# reaps a background child as soon as it exits and only keeps its status
> +# for a later wait, so the pid of a worker that is gone can be handed
> +# out again. A process that reused it has another parent, which is how
> +# it is told apart, and it must never be signalled. A child that has
> +# exited but was not reaped yet is a zombie, state Z in
> +# /proc/<pid>/stat, and counts as gone, or a wait on it would spin until
> +# the forced kill.
> +pid_running()
> +{
> + local stat state ppid
> +
> + # The state and the parent pid follow the parenthesized command
> + # name, which may contain spaces and parentheses. The ".*" is
> + # greedy, so the expression strips everything up to the last ") "
> + # of the line, and a ")" inside the name is harmless.
> + stat=$(sed 's/^.*) //' "/proc/$1/stat" 2>/dev/null) || return 1
> + read -r state ppid _ <<< "$stat"
> + [ "$ppid" = "$$" ] && [ "$state" != "Z" ]
> +}
[ ... ]
> cleanup()
> {
> # A second signal must not abort the teardown half way.
> trap '' INT TERM
>
> - local dev
> + local pid dev base
> + local pids=() shell_jobs=()
> +
> + # A worker forked right before the signal arrived may not be
> + # recorded yet, so the jobs of the shell are taken as well.
> + mapfile -t shell_jobs < <(jobs -p)
> + mapfile -t pids < <(printf '%s\n' "${BACKGROUND_PIDS[@]}" \
> + "${shell_jobs[@]}" | grep . | sort -u)
> + # Only a process that is still a running child of this shell is
> + # signalled, see pid_running, a recorded pid may have been reused
> + # since its worker finished.
> + for pid in "${pids[@]}"; do
> + pid_running "$pid" && kill "$pid" 2>/dev/null
> + done
[Severity: Low]
Is the check in pid_running() enough to keep a reused pid from being
signalled here?
The check and the kill are two separate steps. pid_running() reads
/proc/<pid>/stat through a forked sed. After it returns, the worker can
still exit, and bash's SIGCHLD handler can reap it before the kill builtin
runs. With a numeric argument, kill calls kill(2) directly and does not
consult the job table. So if the kernel hands the pid to another process
in that gap, the TERM goes to that process.
The same window exists for the forced kill further down:
> + pids_gone "${pids[@]}"
> + for pid in "${pids[@]}"; do
> + pid_running "$pid" && kill -KILL "$pid" 2>/dev/null
> + done
In practice the pid allocator would have to wrap through all of pid_max
inside that short window, so this is very unlikely to happen. The check
does close the main case, a pid that was recycled long after its worker
finished.
However, the commit message says the handler "signals a pid only while
that is still a child of the script". The pid_running() comment also says
a process that reused the pid "must never be signalled". Both describe a
stronger guarantee than the code gives.
Would it make sense to signal by jobspec instead? bash checks liveness
there with SIGCHLD blocked. Otherwise, the comment and the commit message
could say that the check narrows the window rather than closing it.
> + # Give the workers a few seconds to run their exit traps, then
> + # force the survivors and give those a few seconds to die. A
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125090522.3777494-1-poros%40redhat.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads