On Fri, Oct 28, 2022 at 11:08:55AM +0200, Martin Pieuchot wrote: > On 20/10/22(Thu) 16:17, Martin Pieuchot wrote: > > On 11/09/22(Sun) 12:26, Martin Pieuchot wrote: > > > Diff below adds a minimalist set of assertions to ensure proper locks > > > are held in uvm_mapanon() and uvm_unmap_remove() which are the guts of > > > mmap(2) for anons and munmap(2). > > > > > > Please test it with WITNESS enabled and report back. > > > > New version of the diff that includes a lock/unlock dance in > > uvm_map_teardown(). While grabbing this lock should not be strictly > > necessary because no other reference to the map should exist when the > > reaper is holding it, it helps make progress with asserts. Grabbing > > the lock is easy and it can also save us a lot of time if there is any > > reference counting bugs (like we've discovered w/ vnode and swapping). > > Here's an updated version that adds a lock/unlock dance in > uvm_map_deallocate() to satisfy the assert in uvm_unmap_remove(). > Thanks to tb@ from pointing this out. > > I received many positive feedback and test reports, I'm now asking for > oks.
regress on i386/GENERIC.MP+WITNESS with this diff shows witness: lock order reversal: 1st 0xd6381aa8 vmmaplk (&map->lock) 2nd 0xd76a9790 inode (&ip->i_lock) lock order "&ip->i_lock"(rrwlock) -> "&map->lock"(rwlock) first seen at: #0 rw_enter_read+0x32 #1 vm_map_lock_read_ln+0x15 #2 uvmfault_lookup+0x60 #3 uvm_fault_check+0x14 #4 uvm_fault+0xe4 #5 kpageflttrap+0xe5 #6 trap+0x260 #7 calltrap+0xc #8 copyout+0x42 #9 uiomove+0x135 #10 ffs_read+0x27b #11 VOP_READ+0x3c #12 vn_rdwr+0x85 #13 vmcmd_map_readvn+0x7e #14 exec_process_vmcmds+0x5e #15 sys_execve+0x69e #16 start_init+0x241 #17 proc_trampoline+0x12 lock order "&map->lock"(rwlock) -> "&ip->i_lock"(rrwlock) first seen at: #0 rw_enter+0x57 #1 rrw_enter+0x3d #2 ufs_lock+0x27 #3 VOP_LOCK+0x50 #4 vn_lock+0x91 #5 vn_rdwr+0x64 #6 vndstrategy+0x2bd #7 physio+0x18f #8 vndwrite+0x1a #9 spec_write+0x74 #10 VOP_WRITE+0x3f #11 vn_write+0xde #12 dofilewritev+0xbb #13 sys_pwrite+0x55 #14 syscall+0x2ec #15 Xsyscall_untramp+0xa9