๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24127

Re: [PATCH net-next v5 14/14] selftests: dpll: add reference leak tests

#24127
From: 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
Technical Details
Message-ID: <179594874023.3146.370947298957325220@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373458-linux-kernel-netdev=dewy.ru
References: <20261125090522.3777494-15-poros@redhat.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373458-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 14/14] selftests: dpll: add reference leak tests
Date: Sun, 29 Nov 2026 10:39:00 +0000
Organization: Usenet Network
Message-ID: <179594874023.3146.370947298957325220@kernel.org>
References: <20261125090522.3777494-15-poros@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1150689"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7AdkcGGPtqT0Qm+XzkX+bpX/9RQ= sha256:pbq7FGhsZfHt3IwYVRacRbTK6eExznOfJ36Y9jfDYo0=
	sha1:LEJ7PxgZtw0WvwKNC0tEuAI8CBg= sha256:G3HAiS21PNoW1nFiQCpopW/W3kF96WMq0XtbL5uTIyM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C71F5125F94; Sun, 29 Nov 2026 13:39:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id X0xCsq7H13ec;
	Sun, 29 Nov 2026 13:39:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373458-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 108A8125F97; Sun, 29 Nov 2026 13:39:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 81EA326769; Sun, 29 Nov 2026 10:39:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795948748;
	b=2IOJ3YaGI4hqeaU+CXUdF2PnBtWguCSgdADuTaAWRQMBR5UMoti0Qsk0rOPa5ZD6fPIH
	 r5KVSWZLAcdaMWLo3+UdZ3N/zjNKIwoWTLLCdQM7ZZ9Qox7tPO/JR0GdgiJ/zgKDsOAvJ
	 gVLTTeEeNFuiwEHwE/jh9zwDiyE9Ala5TQuCd2JiRVb7XqT/mtDSW0JDPBKJpbPURT+6F
	 I9fvm7OnyUNjsoQq7sgucwZ3MfJ5h8832as5My68zUMEYpXiaEOK4P6nSQal2KN3nXK0J
	 I5Ma3UV+rWHc9pIUbC5NIc4Jvaeaf3HzSD9cLCkok1Yb9JKzmeNZla9K+Yi/pMGxROA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795948748;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=tNwc/8YPjhLumy/F4frMcHxWXg/Gl4BXIxUbZ5WIsC8=;
	b=VhGXzuV+gdLD8MI5PtGM9DNEQiZsit1tw2np8MhDz2oGkBWyDnsfFjt4vh2cGHHrzH6J
	 cKVA8hW0srOcQ03xYzEMznx2rq/y2vWQACxPXTN52p96gFYngpxtmyRu7VqleD/7guc7i
	 0EcbWaFdxA5f3n4Ryudhu6S0SfvYKXQ3/hGZRJ+KJfpqpDnRvUAEOp4kETKtpbBBF/zRN
	 VeJoKEM37qrZR7avDWjuHuy2W7HnqEvzSzpz65jX/y2TlCi2dZljngL+DzTSAjS6JlNf/
	 fS52+crH25XRMIJ1YIYVUmXIsoffALbKEn07bBhNgJvD7sBRXkO8QsJHSooF6QpMWWw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UZHskt1O;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 59CB7606A32A;
	Sun, 29 Nov 2026 10:39:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UZHskt1O
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795948742;
	b=5CdroYRcbfv8JoyKDIDP1MPnjNuB9S+oXNEB98xcADaeUKXZGqr48j5urb4kBrmE0Oc8
	 tMx3U7i2YnEBno0zvnegmJL6mXe/4Ywx6wRdm5mHssvk+BaiNYE0hGjs/dF5hoztn4k9I
	 hcIrSNfGwjBz53P8xlOnRAcuJ2Vp3tnrUi+1E7XYq7Xf100sVr1/tDi4G7SWs9kZOYCal
	 hDQZQ7SGUyMfqCYXjFW3hxVMQb5Qa5H+icrrpPDX2jnIvUCtA6RLUqnEecHE+LFR2I9jc
	 r5raQLq7eIFudP8I1YjdT1/Ugt2ESyeCMe/LQnDSt4+6YESueCuxs0sX1useaqR+HjA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795948742;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=tNwc/8YPjhLumy/F4frMcHxWXg/Gl4BXIxUbZ5WIsC8=;
	b=4+kPnKJrquV6cl49hZKsIWYGHBK/Yq/NtJVNMw4rW3BYaXPtGcEkKDpcYj/RpvOyKDQq
	 +lhhQvA0ZsLa6I+CUF+AxEgBKHWFsgxNPVZq05gMR4kwY11aFlMAiL4I3ZUcc0IEvPjQd
	 QDWDvTp7MMiTALVAsK8C9lWTgSwVfF4WaO3U2+negO30cSZEa+BuWtZIoxcHxEBG9SJxm
	 S1xFXEvlHKaURErHTeu4ZmtDCiAho6mKx9fAFCD7LVrdT6fH8Dud/6QyYh40CnZxdEn+L
	 at1cWqeZbADt6ptiCc0/gxcnxkGt4F66FEwbx+MdtUkdpdvVWmAYX07P1fPIpRaXErQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UZHskt1O;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7804C606A325;
	Sun, 29 Nov 2026 10:39:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A84B21F0092A;
	Sun, 29 Nov 2026 10:39:00 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795948741;
	bh=tNwc/8YPjhLumy/F4frMcHxWXg/Gl4BXIxUbZ5WIsC8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=UZHskt1OcCQBjelNngt3gw386JsvrH5Mg7gcSEVKaUHEDeO3nZ6rWQUP7cjzKZ38o
	 glNhWRk5ZmWcKj0PfKWvU0E65JgMM+7o5EVFofhBuzADoiHOx3Y04Nwjv56L8ILpSd
	 DEXDZPFT1kJBwo/q1F3OIR+rhJjWT4JzPg0yjW+fysNj8glGvCgtbVfuYuUjngvKud
	 LW9evyvdd7+vNp9E9tavcr/NtH1sEPEuvfbJyZ+8Ru5f6P/ieIn16ii7vG4iDlu+Xn
	 EarEfLnqCNh8CZORAgNuZHc9vylf1Qc+Erayca/72oZ+TmV4yB2huUY2yCj5JE/dWL
	 P3cHjAv1VCmNg==
X-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
X-In-Reply-To: <20261125090522.3777494-15-poros@redhat.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list