From nobody Sat May 16 10:08:39 2026 X-Original-To: current@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 4gHfsx2NYnz6dKrx for ; Sat, 16 May 2026 10:08:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4gHfsw4MBfz43lJ; Sat, 16 May 2026 10:08:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 64GA8d6t027021; Sat, 16 May 2026 13:08:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 64GA8d6t027021 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 64GA8dLx027020; Sat, 16 May 2026 13:08:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 16 May 2026 13:08:39 +0300 From: Konstantin Belousov To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= Cc: current@freebsd.org Subject: Re: rms_rlock with non-sleepable locks held Message-ID: References: <86lddjelen.fsf@ltc.des.dev> List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86lddjelen.fsf@ltc.des.dev> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.2 X-Spam-Checker-Version: SpamAssassin 4.0.2 (2025-08-27) on tom.home X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4gHfsw4MBfz43lJ X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated On Sat, May 16, 2026 at 11:47:12AM +0200, Dag-Erling Smørgrav wrote: > On recent main with a debugging kernel, I am unable to build anything as > the system slows to a crawl while the console is inundated with stack > traces: > > rms_rlock with the following non-sleepable locks held: > exclusive sleep mutex kqueue (kqueue) r = 0 (0xfffff8013615cc00) locked @ /usr/src/sys/kern/kern_event.c:2588 > stack backtrace: > #0 0xffffffff805d571c at witness_debugger+0x6c > #1 0xffffffff805d7019 at witness_warn+0x4b9 > #2 0xffffffff8055841f at rms_rlock+0x1f > #3 0xffffffff81418f08 at zfs_freebsd_getattr+0xb8 > #4 0xffffffff808c1ede at VOP_GETATTR_APV+0x4e > #5 0xffffffff8065add0 at vn_getsize_locked+0x70 > #6 0xffffffff806610c2 at filt_vfsread+0x82 > #7 0xffffffff805018f4 at knote+0xc4 > #8 0xffffffff80658f2e at vop_open_post+0x3e > #9 0xffffffff808c1572 at VOP_OPEN_APV+0x92 > #10 0xffffffff8066e67b at vn_open_vnode+0x19b > #11 0xffffffff8066de18 at vn_open_cred+0x698 > #12 0xffffffff8066364e at openatfp+0x2be > #13 0xffffffff8066336d at sys_openat+0x3d > #14 0xffffffff822153a2 at filemon_wrapper_openat+0x12 > #15 0xffffffff808a05b8 at amd64_syscall+0x168 > #16 0xffffffff8086f86b at fast_syscall_common+0xf8 > > They vary in how they get to knote() but they're all the same from frame > 7 and up. > > BTW, filt_vfsread() is an excellent argument for VOP_GETSIZE, with > vn_getsize() falling back to a full VOP_GETATTR() only when the vnode's > vop table does not provide it, as the size of a ZFS vnode is very easy > to get: > > size_t zfs_getsize(vnode_t *vp) { return (VTOZ(vp)->z_size); } > > while a full VOP_GETATTR() is several hundred lines of code. I already posted the patch below somewhere, but did not get a response. commit c3a20bdb7caa3628831bf443cfb1e0316e30d3e7 Author: Konstantin Belousov Date: Wed May 13 23:44:45 2026 +0300 vop_read{,_pgcache}_post(): unlock knote around call into filter ZFS vop_getattr() needs a sleepable lock. diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b3a6e8ce2e02..d19776940bc3 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6509,7 +6509,7 @@ vop_read_post(void *ap, int rc) struct vop_read_args *a = ap; if (!rc) { - VFS_KNOTE_LOCKED(a->a_vp, NOTE_READ); + VN_KNOTE_LOCKED(a->a_vp, NOTE_READ); INOTIFY(a->a_vp, IN_ACCESS); } } @@ -6520,7 +6520,7 @@ vop_read_pgcache_post(void *ap, int rc) struct vop_read_pgcache_args *a = ap; if (rc == 0) { - VFS_KNOTE_LOCKED(a->a_vp, NOTE_READ); + VN_KNOTE_UNLOCKED(a->a_vp, NOTE_READ); INOTIFY(a->a_vp, IN_ACCESS); } }