Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: poros@redhat.com
Cc: netdev@vger.kernel.org, ivecera@redhat.com, jiri@nvidia.com,
	corbet@lwn.net, skhan@linuxfoundation.org, shuah@kernel.org,
	rdunlap@infradead.org, jani.nikula@intel.com,
	vadim.fedorenko@linux.dev, arkadiusz.kubalewski@intel.com,
	jiri@resnulli.us, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v5 13/14] selftests: dpll: add concurrency stress tests
Date: Sun, 29 Nov 2026 10:38:58 +0000	[thread overview]
Message-ID: <179594873859.3146.5615694504477947742@kernel.org> (raw)
In-Reply-To: <20261125090522.3777494-14-poros@redhat.com>

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

  reply	other threads:[~2026-11-29 10:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  9:05 [PATCH net-next v5 00/14] dpll: add a simulated DPLL device driver Petr Oros
2026-11-25  9:05 ` [PATCH net-next v5 01/14] dpll: dpllsim: Add " Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 02/14] selftests: dpll: add test library and device lifecycle tests Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 03/14] dpll: dpllsim: Add configurable pins Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 04/14] selftests: dpll: add pin enumeration and property tests Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 05/14] dpll: dpllsim: Add support to set input pin state Petr Oros
2026-11-25  9:05 ` [PATCH net-next v5 06/14] selftests: dpll: add pin state tests Petr Oros
2026-11-27 13:39   ` Ivan Vecera
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 07/14] dpll: dpllsim: Add support to get/set priority on input pins Petr Oros
2026-11-27 13:39   ` Ivan Vecera
2026-11-25  9:05 ` [PATCH net-next v5 08/14] selftests: dpll: add pin priority test Petr Oros
2026-11-27 13:40   ` Ivan Vecera
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 09/14] dpll: dpllsim: Add support to set frequency on pins Petr Oros
2026-11-27 13:40   ` Ivan Vecera
2026-11-25  9:05 ` [PATCH net-next v5 10/14] selftests: dpll: add pin frequency test Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 11/14] dpll: dpllsim: Add support to adjust phase Petr Oros
2026-11-25  9:05 ` [PATCH net-next v5 12/14] selftests: dpll: add pin phase adjust test Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko
2026-11-25  9:05 ` [PATCH net-next v5 13/14] selftests: dpll: add concurrency stress tests Petr Oros
2026-11-29 10:38   ` netdev-bot+sashiko [this message]
2026-11-25  9:05 ` [PATCH net-next v5 14/14] selftests: dpll: add reference leak tests Petr Oros
2026-11-29 10:39   ` netdev-bot+sashiko

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=179594873859.3146.5615694504477947742@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=ivecera@redhat.com \
    --cc=jani.nikula@intel.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=vadim.fedorenko@linux.dev \
    /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