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 14/14] selftests: dpll: add reference leak tests
Date: Sun, 29 Nov 2026 10:39:00 +0000	[thread overview]
Message-ID: <179594874023.3146.370947298957325220@kernel.org> (raw)
In-Reply-To: <20261125090522.3777494-15-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_lib.sh,
  __dpll_ref_tracker_note_changed() updates the snapshot with `sed -i…

--

selftests: dpll: add reference leak tests

This adds library helpers to the dpll selftests that snapshot the
ref_tracker debugfs entries before a test creates its devices. They then
report entries that appear later and still hold references. A probe test
checks that the tracker works, and it runs first in dpll_stress.sh and in
the new dpll_reftrack.sh.

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_lib.sh b/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> index 6f07837a7d9de..06402b3194a11 100644
> --- a/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> +++ b/tools/testing/selftests/drivers/dpll/dpll_lib.sh

[ ... ]

> @@ -799,3 +817,366 @@ dpllsim_setup_standard_device()

[ ... ]

> +dpll_ref_tracker_snapshot_file()
> +{
> +	local file pid
> +
> +	find "$DPLL_RUN_DIR" -maxdepth 1 \
> +	     -name "${DPLL_REF_SNAPSHOT_PREFIX##*/}.*" -mmin +1440 -delete \
> +	     2>/dev/null
> +	for file in "$DPLL_REF_SNAPSHOT_PREFIX".*; do
> +		[ -f "$file" ] || continue
> +		pid=${file#"$DPLL_REF_SNAPSHOT_PREFIX".}
> +		pid=${pid%%.*}
> +		[[ "$pid" =~ ^[0-9]+$ ]] || continue
> +		[ -d "/proc/$pid" ] || rm -f "$file"
> +	done
> +	mktemp "$DPLL_REF_SNAPSHOT_PREFIX.$$.XXXXXX"
> +}

[ ... ]

> +__dpll_ref_tracker_note_changed()
> +{
> +	local file=$1
> +	local entry name content hash changed=""
> +
> +	for entry in "$DPLL_REF_TRACKER_DIR"/dpll_device@* \
> +		     "$DPLL_REF_TRACKER_DIR"/dpll_pin@*; do
> +		[ -f "$entry" ] || continue
> +		name=$(basename "$entry")
> +		grep -q "^$name " "$file" || continue
> +		content=$(cat "$entry" 2>/dev/null) || continue
> +		hash=$(__dpll_ref_tracker_hash "$content")
> +		grep -qx "$name $hash" "$file" && continue
> +		sed -i "s/^$name .*/$name $hash/" "$file"

[Severity: Low]
Can this sed -i leave a stray file behind in /run/dpll-selftest?

GNU sed -i writes the new content to its own temporary file, named
sedXXXXXX, in the directory of the input file, here DPLL_RUN_DIR. It then
renames that file over the snapshot. If sed is killed before the rename,
the temporary file stays, since GNU sed only removes it on its internal
error path and not when it gets a signal.

A signal to the whole process group while sed runs is enough. That can be
a Ctrl-C, or the kselftest runner timeout: runner.sh runs the inner
/usr/bin/timeout without --foreground, so it signals the whole group.

The stale file sweeps in dpll_ref_tracker_snapshot_file() only match
refsnap.*:

	find "$DPLL_RUN_DIR" -maxdepth 1 \
	     -name "${DPLL_REF_SNAPSHOT_PREFIX##*/}.*" -mmin +1440 -delete

	for file in "$DPLL_REF_SNAPSHOT_PREFIX".*; do

so a leftover sedXXXXXX file is never removed by later runs.

This path is only reached from dpll_ref_tracker_check_leaks() when an
entry already in the snapshot changed its content, so the window is
narrow.

Would it work to write the updated snapshot to a file from
mktemp "$DPLL_REF_SNAPSHOT_PREFIX.$$.XXXXXX" and mv it over the snapshot,
or to rebuild the snapshot with a shell redirect? Then every temporary
file would carry the prefix that the sweep matches.

> +		changed="$changed $name"
> +	done
> +
> +	[ -n "$changed" ] && log_info \
> +		"references of another driver changed (ignored):$changed"
> +	return 0
> +}

[ ... ]

-- 
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
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 [this message]

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=179594874023.3146.370947298957325220@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