From nobody Wed Sep 17 16:50:20 2025 X-Original-To: dev-commits-src-all@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 4cRlBN2rp0z67j6b; Wed, 17 Sep 2025 16:50:20 +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 4cRlBN2FDSz3h0H; Wed, 17 Sep 2025 16:50:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758127820; 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=fVIUpQmdxIMWrOQfeR9t9ppMCeKHWtUlTrg1OF5KJwA=; b=oBJt9zOJmlfnSODfZA0nGNoHmNCBboQ8nO8cwrQRpOLo8rzLX+VuCMm38wq69yDBaTHWXm O/Z4OkX83lqmEUoK6KDatmCAdzhRXPE+u8FEs8MgoWxs8Ao9mOIT28JH2UbL3aIL6gIbcN 2Nx42T0IEZBqXWLe60wOLgoy6RAz7u9ihdIWk+KRKnevns2aswz4xSP2oFVN2lOn2uPWBT Z+v1d791/0Mpl8HdSVy5RaSArl/WRJpA6HyxGnyR7/gH31344K4TL1i5vPH4noQ7OK0hQY Fiyf6yt3GSulqnvR9UYwbmYCVFAAKlpApt6pRigvDVulURSsoWjbjVpb6PSoUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758127820; 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=fVIUpQmdxIMWrOQfeR9t9ppMCeKHWtUlTrg1OF5KJwA=; b=eJI3YMqQ+LI2+/QobqYAyyQ52LixXIuLmjPaJ4yToh9O96HrGudl8BFJbYnuBIlGRcjdvg pEGDu+Wl/gNg2wM9fVDCGbX3ne5ddzQ2ybn2VN8OS9JlJa7qcmmUVXZKQuK2ZxaXd4KbrB awXwMCMpG7vB2h5RfHuOKkqdMquYZOUEEqHlgp+DmPBlbNTWHIaAhmtxVQuTTKKazxLF7A S/KrfGnxgxr2L6xzqu75qdeDFVydIQ/mHvACI4Cw/97kc3tyDN1lKH905ouM56iDvG6JaH WsWs32VCHPxft1hDDZSZkBiMfEn1TlNgvb/VkGRUfpJQ7A7D14wQes3pJeoImA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758127820; a=rsa-sha256; cv=none; b=Nz/IgRuO8bUPLvq5pbUPYRzbSfxnSGz2jYfmFK8lnY2L1GAprfsnQ24Jy0u3OwNyA3Bcd8 L10TiE3D16rjxv+ztPrSMEncjxq2oZsyoKPDQY0C9he8sFub1n6Wj/Gcoy5CCk6Ys8SSOi S8KMwyCU8pPXkMohezuBMTT6eCS3Vy30bhpMscvAbrcrq4C4KoG5q5Bhj2WdhfiF36hQY6 M3iWaIEedHfRnMGkzOr3FdLQJ4HtzDKjfpA+wohFUl3ol0NxNFLKnlhP9cNu2xkx02wLMs Z6SxZWhe5CQWA3ItM3pC/jJSAcLYff3g+uTZ2nVbPkrK7j1loBIOVNlD/aGgAg== 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 4cRlBN1ddbzbGq; Wed, 17 Sep 2025 16:50:20 +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 58HGoKWB003068; Wed, 17 Sep 2025 16:50:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58HGoKrr003065; Wed, 17 Sep 2025 16:50:20 GMT (envelope-from git) Date: Wed, 17 Sep 2025 16:50:20 GMT Message-Id: <202509171650.58HGoKrr003065@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: 2d85bc89294b - main - witness: Record the first acquired file and line for recursable locks List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 2d85bc89294baa04daf509e81ec3880bff79cc10 Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=2d85bc89294baa04daf509e81ec3880bff79cc10 commit 2d85bc89294baa04daf509e81ec3880bff79cc10 Author: Zhenlei Huang AuthorDate: 2025-09-17 16:48:54 +0000 Commit: Zhenlei Huang CommitDate: 2025-09-17 16:48: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 --- 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) {