From nobody Wed Oct 1 02:14:55 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 4cbz5q62vmz69nmy; Wed, 01 Oct 2025 02:14:55 +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 4cbz5q56DRz3FK1; Wed, 01 Oct 2025 02:14:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759284895; 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=ZSEsbWYcQNh5lF0KRfjyKzkVeUN7rmWt7oGINRhvHU4=; b=hZ/kQM1F91fe9CkRwTfZWprIWE4uwuAY0BJSBmei2mPhzyKpGLwljYUNG+uqD019QURuKm NoKtUMBeFhLPr/urhhmclZLgdjrn7UZ7oq7gIyaL/7lOSfllwAu11sekYGF2e9U6E4s2YI hZ2fCQkbocLbdakdzhAXQgU1S6KdSwhoCMHLW4B9ml7nXca/JcUzJ5gjCYDCoRDt0r0/3t XmOTolv58aWh5MY7M3pWGVbaah3QuNnixfZ+bBVNxrRyfBcs8PHG+fILO7k1KC7h6lBUXg GogJCCtcxcHYPkOKiXRrd1OWFY2RxyKU0fu76d9caiLGaAkuqDnu03439mF0nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759284895; 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=ZSEsbWYcQNh5lF0KRfjyKzkVeUN7rmWt7oGINRhvHU4=; b=b22UkyF6vdUc/xSUh7pKP5uc1Qxu97eq5T+5l6HD+XDa8y8issG4fSU5B0ku4usJra4KGA 4d8Jv4JruZUlVXPctfX4vHQAikeG12xJCtq5t5q8lIJ50uJm4N07D8D3v3oCYZMbtQ4D8X Ft+Y/sK/23Ow+JeuBTCNDF2qmoFMKRNA4f4Z2PzVNzC0/LrErLff9mJLFd2F0AsRx8Gg5Y XhFYIcenf8+CzRXo9dDl4yWAdtgQ5hu/bzyZNOEZi2GujqZ6Y+wC/yUUGgHLgsFiuxcyI0 qWaz+ZGIdh/rTVvNkPteZ7JQVy37tfjvaLd2zxhyKz1ChOgtUVbLXKRtJRaJ4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759284895; a=rsa-sha256; cv=none; b=Eb1mS7W32G4kDuMIYBNgmRnQDws6Xxdu4AS+YVNBcPpzGxvkuYhO1clME6JVCogCPp2Ucx KSVjVMVHsNm0Dgj5aEvlAxGuFd1rjqLjMd7M8XWx+28QzJLN/wT1ha31God+LFxw/e4/5i PAa3XGdMuVgcseX+KhYsbJdS9JStyd98vVBJHp/HfRxR1K5reutlgWKNLh1Ps9W7+momLw RVZzBx2v3Y9ekMK93CZOTa3xF+NRHvN+o7rucL7CwUHD3elAHl3ueRb3qpfXTcQAx27nIk 5xZwH2skJaYzQTb2IMe2c2DaeIDxywXs6/H06ane3ykOhcgL8R3OgfxGJexWiw== 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 4cbz5q4gsCz12kY; Wed, 01 Oct 2025 02:14:55 +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 5912EtnI074458; Wed, 1 Oct 2025 02:14:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5912Etf5074455; Wed, 1 Oct 2025 02:14:55 GMT (envelope-from git) Date: Wed, 1 Oct 2025 02:14:55 GMT Message-Id: <202510010214.5912Etf5074455@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: 3dc9f96a489c - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 3dc9f96a489cd53710af8205a1f3901c11b760a5 Auto-Submitted: auto-generated The branch stable/15 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=3dc9f96a489cd53710af8205a1f3901c11b760a5 commit 3dc9f96a489cd53710af8205a1f3901c11b760a5 Author: Zhenlei Huang AuthorDate: 2025-09-17 16:48:54 +0000 Commit: Zhenlei Huang CommitDate: 2025-10-01 02:13:54 +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) --- 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 a65c3ca128d9..c937f6a82757 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1515,6 +1515,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) { @@ -1522,15 +1526,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) {