๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Sun, 29 Nov 2026 10:39
Re: [PATCH net-next v5 14/14] selftests: dpll: add reference leak tests
#24127
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 10:39
109 lines
11744 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_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
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