Hi, On Sat, Apr 9, 2016 at 3:21 PM, Taylor R Campbell <riastr...@netbsd.org> wrote: > Module Name: src > Committed By: riastradh > Date: Sat Apr 9 06:21:17 UTC 2016 > > Modified Files: > src/distrib/sets/lists/comp: mi > src/share/man/man9: Makefile pslist.9 > src/sys/kern: files.kern > Added Files: > src/share/man/man9: psref.9 > src/sys/kern: subr_psref.c > src/sys/sys: psref.h > > Log Message: > Add passive references, intermediate between pserialize and refcount. > > Discussed on tech-kern: > > https://mail-index.netbsd.org/tech-kern/2016/01/24/msg020069.html > > API is still experimental and likely to change. (Obvious changes: > either remove extra arguments everywhere, or shrink psref_target to a > single bit, at the expense of possibly valuable diagnostic checks.) > Should do some real testing before we use this in anger!
I'm trying to apply psref to bridge(4) and it's mostly done (*). However, I have an issue; I got a KASSERT failure in psref_held with the following output (I added thread names to the KASSERTMSG for debugging): panic: kernel diagnostic assertion "(psref->psref_lwp == curlwp)" failed: file "/home/ozaki-r/git/netbsd-src/sys/kern/subr_psref.c", line 466 passive reference transferred from lwp 0xfffffe803fd10420 (softnet/0) to lwp 0xfffffe803fd0a020 (xcall/0) fatal breakpoint trap in supervisor mode trap type 1 code 0 rip ffffffff80114ae5 cs 8 rflags 246 cr2 7f7ff74d1d40 ilevel 4 rsp fffffe8002cafdb0 curlwp 0xfffffe803fd0a020 pid 0.7 lowest kstack 0xfffffe8002cac2c0 Stopped in pid 0.7 (system) at netbsd:breakpoint+0x5: leave db{0}> bt breakpoint() at netbsd:breakpoint+0x5 vpanic() at netbsd:vpanic+0x140 isp_scsi_channel_init() at netbsd:isp_scsi_channel_init psref_held() at netbsd:psref_held+0xf1 psreffed_p_xc() at netbsd:psreffed_p_xc+0x18 xc_thread() at netbsd:xc_thread+0xdc It seems that the assertion depends on a xcall handler runs on a lwp that holds a reference to a target object, however, in reality the xcall handler runs on its own lwp. I think the assertion is invalid and we should get rid of it. Am I correct? Thanks, ozaki-r (*) http://www.netbsd.org/~ozaki-r/psref-bridge.diff