From nobody Sun Apr 09 21:34:34 2023 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 4Pvlk25HkWz44JRC; Sun, 9 Apr 2023 21:34:34 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pvlk23vwJz4Kd4; Sun, 9 Apr 2023 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076074; 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=SWuT3pM91kpNJrcyLMUMyClic6mqMQKD6O6jof1P5RU=; b=TXbG8sb1RkxfGCm3Pd8lDqzJr0qW6K1zPZylEokb9p7B52u/YyWJlpfbhYEw300PbIw/mS S1eDUguInkbm4JIOvfv1O3En855YDWlH9rTJ5l2XvB8mj7XW+C8HeQ9KLj2t2WYbyLV6tV E3kmsgiiHddCfT0RAQ5DIN8aFk0I5qhkk4VvWMzMi71r66RPPEW+xEStV2vBja2/FRyc0E XUH3IIR4+7e62VSXRNR18q/FLAPMf8rt75s34/FwQKy8GYBSHNGvUVKWTL2precdaCBAtb MsM6UEPAtuwc8j7XOvZz19Dfq67YgEZTnjzwerThBT7RNwC9MVUJh171t8wu6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076074; 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=SWuT3pM91kpNJrcyLMUMyClic6mqMQKD6O6jof1P5RU=; b=yrqPR6P1KOW4+2UNnFEjUlup5x7vX0qD9DEmHEHsaI2xUAGKSJGxlJA+dMRRJFh7iN/PNu sqJVpwtV1qPPsRKJpRvaoALC/+j8sI2WRZl5ds0diVi10iEfqn9B18KNXf+2Q14cWkTaX3 Y3RIxxWqohk0q5Gt8I3voo/v7tB5NOjQGqwwGZD6fXtziH4PmxSwQzvoul69OjtjpKhJt5 wBwnoDLv6g/DEbTNl6TcC8n2mQ/YfyZUdBhBuqc3LROqtwUIpxF+16S86bKy9+R6+kDjtM QV0etwF8u4EE/kBSnozYmVBPb93t9ueCdnHGbZK2uJAEqalRO039PiQN+FdRtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681076074; a=rsa-sha256; cv=none; b=Hk2HBjZn3o49/bRZmUwCLFP7LF2Bj4UkMeeAR5XA3B4jFucQiQgFntK/ha/VuWkfZB2PEN 9Ai/fw4TpUiGhDeQj8UhchCQ4LqqSus0kGlaF/nFpCFmz+YmYTcSMnxR2qeSVi1eWz7Qpk L4zRiMRyU+YyswZpa1BhfKoplaVx7YViEDsl8Us6AdIIUtd+mb3XBcGQhjCc/qG/DzuzpY gbiChfZYtL/1Nn84dP3RIKIzcbb010ocuu9nDI2OMJVK+zP6HzdZxP7ptAGOapa164rV/n UcE+Y2nq7urw0R3av6G4pA5voJsHeLypYXVrHNBP2C+Q/in6RHH71dL22vrg9Q== 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 4Pvlk22Df5zPhC; Sun, 9 Apr 2023 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 339LYYko081081; Sun, 9 Apr 2023 21:34:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 339LYYY5081080; Sun, 9 Apr 2023 21:34:34 GMT (envelope-from git) Date: Sun, 9 Apr 2023 21:34:34 GMT Message-Id: <202304092134.339LYYY5081080@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7b6fe2428a97 - main - DEBUG_VFS_LOCKS: use witness if available 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b6fe2428a97921e8df882d0a24b87094c37b468 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7b6fe2428a97921e8df882d0a24b87094c37b468 commit 7b6fe2428a97921e8df882d0a24b87094c37b468 Author: Konstantin Belousov AuthorDate: 2023-04-08 06:15:00 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-09 21:34:12 +0000 DEBUG_VFS_LOCKS: use witness if available The assert_vop_locked messages are ignored, and file/line information is not too useful. Fixing this without changing both witness and VFS asserts KPIs is not possible. Reviewed by: markj (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39464 --- sys/kern/vfs_lookup.c | 1 + sys/kern/vfs_subr.c | 16 +++++++++++++--- sys/sys/vnode.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index e7f1deea0fae..172aa4b4f576 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -162,6 +162,7 @@ nameiinit(void *dummy __unused) vfs_vector_op_register(&crossmp_vnodeops); getnewvnode("crossmp", NULL, &crossmp_vnodeops, &vp_crossmp); vp_crossmp->v_state = VSTATE_CONSTRUCTED; + vp_crossmp->v_irflag |= VIRF_CROSSMP; } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index c2b1f71502cd..7e7315f827a1 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5452,14 +5452,18 @@ assert_vi_unlocked(struct vnode *vp, const char *str) void assert_vop_locked(struct vnode *vp, const char *str) { - int locked; - if (KERNEL_PANICKED() || vp == NULL) return; - locked = VOP_ISLOCKED(vp); +#ifdef WITNESS + if ((vp->v_irflag & VIRF_CROSSMP) == 0) + witness_assert(&vp->v_vnlock->lock_object, LA_LOCKED, + __FILE__, __LINE__); +#else + int locked = VOP_ISLOCKED(vp); if (locked == 0 || locked == LK_EXCLOTHER) vfs_badlock("is not locked but should be", str, vp); +#endif } void @@ -5468,8 +5472,14 @@ assert_vop_unlocked(struct vnode *vp, const char *str) if (KERNEL_PANICKED() || vp == NULL) return; +#ifdef WITNESS + if ((vp->v_irflag & VIRF_CROSSMP) == 0) + witness_assert(&vp->v_vnlock->lock_object, LA_UNLOCKED, + __FILE__, __LINE__); +#else if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) vfs_badlock("is locked but should not be", str, vp); +#endif } void diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 5e3f81de0236..fa889826867e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -228,6 +228,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); never cleared once set */ #define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */ #define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */ +#define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */ #define VI_UNUSED0 0x0001 /* unused */ #define VI_MOUNT 0x0002 /* Mount in progress */