From nobody Wed Oct 1 02:16:43 2025 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cbz7w2Sk4z69pBR; Wed, 01 Oct 2025 02:16:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cbz7w1xg4z3Fw8; Wed, 01 Oct 2025 02:16:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759285004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ih/ZapKIkZGBA6kYEF9xkfnv4Q7+o5xYQUsMVFbkzQI=; b=NTKTPIs7esvs4ZZ3jOZK2jNjZbDBpqdD1u9mY/fw9ASHTwGTxDsEW2Kbv/rnv1EfG3hSv+ NlvZQpJ6ap8rWUKopCGpbeFhumiSB5AdTI7Z5uEyCmlPB0cC/0L8kpyWtNhnLaCKRyvpVD v3dwhZLeKwcG6AiO6LWxbVEX9zkKxfarTQ8VbDY3Xdyq4SV7xXJo9nnVUuIDZCu4eq18VS cPptOHXxYXt0SCvuTiFJhF3qdxRBFEGPZ+BctGCQoBmdeE9ZpeBxWf6TDWOejTb8aGwoJR v3xyhuRVruIo3hDDDxgKjw9WDRp0uuPiV1ns9FveITZnZVdODsRaGGhE8wJHRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759285004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ih/ZapKIkZGBA6kYEF9xkfnv4Q7+o5xYQUsMVFbkzQI=; b=urtxtiKf7rhnXUQWT2Mv6IkBbaXoc60d78jg/8HM2ZDkmZbzKPKK+hMhUmGW5s8jasP43W d3/7Fn30J5I1Wl6Iw0MQbzgxAWTCVoRz3+9B1h39037L3x1aAcU+sYvQNaMfCRvj+G1mhn uKuLKtaxssFlfBGI/HhwUfQR/oEUh9lpPiLcHMi2LxvXx2ELa1g2Zi2q7IcSFu8OslGaxv FhmWhPfbbCaowlP7CFBHyE4GHkYuk1ag6x9CjrX5Jh7FYokszVuJYUdAqbxNWcpBt8Pzdn cH9RsO8yo4imCAA9w6Foaw29ojd7ElSo/LfxH/8S1/F6PAtpCPtjdcCD6J3JsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759285004; a=rsa-sha256; cv=none; b=PeMsgdnan1PorYfjXtw52cnuThH4kKf/QaVLz5aM2QDFYeyf4m71m586sSPihwmWrqRnqS WzD3T41rM2tgExuxELUnYGSVFI4sqyk994EtbkDkxVBK+hi/hrWp9NqiY4Ntt/1tzvaTqG KEdczEb0YgO7ZREW7wZif95ZpInwLPuFlvYOwlOBY5jBAmWJ6C3jFJavmw+xb4yDrK7JYs TuV4q7VWyonYoMunSp84AExlQG/bzgGqSmCTK7KAwo6rUnbsk4yrGts85T/VYDL97j/ev+ XABjc7X6NsVJrlfIo+t8Hbnzp2hXbTFap28qhp03qbne0DESwXwUUREX9bWU/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cbz7w1D45z12y0; Wed, 01 Oct 2025 02:16:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5912Ghni075101; Wed, 1 Oct 2025 02:16:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5912Ghpn075098; Wed, 1 Oct 2025 02:16:43 GMT (envelope-from git) Date: Wed, 1 Oct 2025 02:16:43 GMT Message-Id: <202510010216.5912Ghpn075098@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 7838ad85fb1a - stable/14 - witness: Record the first acquired file and line for recursable locks List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7838ad85fb1a75464e53525b4cdb064ca1e97a47 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=7838ad85fb1a75464e53525b4cdb064ca1e97a47 commit 7838ad85fb1a75464e53525b4cdb064ca1e97a47 Author: Zhenlei Huang AuthorDate: 2025-09-17 16:48:54 +0000 Commit: Zhenlei Huang CommitDate: 2025-10-01 02:16:04 +0000 witness: Record the first acquired file and line for recursable locks and the last acquired file and line to witness object. For recursable locks, unfortunately current implementation records only the recurse count and the last acquired file and line, but does not restore the previous acquired file and line on unlock. Hence it is possible to report false acquired file and line, and that may mislead developers and make the report by users a little harder to analyse. Since subsequent recurse locks do not affect how witness order check, record the first acquired file and line so that the logic is much clear. Reported by: bz Reviewed by: kib (previous version), markj See also: https://lists.freebsd.org/archives/freebsd-current/2025-June/007944.html MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52496 (cherry picked from commit 2d85bc89294baa04daf509e81ec3880bff79cc10) (cherry picked from commit 3dc9f96a489cd53710af8205a1f3901c11b760a5) --- sys/kern/subr_witness.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 58066a738cc2..1cc7c3fd75a0 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1516,6 +1516,10 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) else lock_list = PCPU_PTR(spinlocks); + /* Update per-witness last file and line acquire. */ + w->w_file = file; + w->w_line = line; + /* Check to see if we are recursing on a lock we already own. */ instance = find_instance(*lock_list, lock); if (instance != NULL) { @@ -1523,15 +1527,9 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) CTR4(KTR_WITNESS, "%s: pid %d recursed on %s r=%d", __func__, td->td_proc->p_pid, lock->lo_name, instance->li_flags & LI_RECURSEMASK); - instance->li_file = file; - instance->li_line = line; return; } - /* Update per-witness last file and line acquire. */ - w->w_file = file; - w->w_line = line; - /* Find the next open lock instance in the list and fill it. */ lle = *lock_list; if (lle == NULL || lle->ll_count == LOCK_NCHILDREN) {