On Mon, 15 May 2023 12:35:32 -0700 Beau Belgrave <beaub@xxxxxxxxxxxxxxxxxxx> wrote: > > static int user_event_mm_fault_in() > > { > > bool unlocked = false; > > > > [..] > > > > out: > > if (!unlocked) > > mmap_read_unlock(mm->mm); > > } > > > > Good catch! > > > > I don't believe that's correct. fixup_user_fault() re-acquires the > mmap lock, and when it does, it lets you know via unlocked getting set > to true. IE: Something COULD have changed in the mmap during this call, > but the lock is still held. > > See comments here: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/gup.c#n1287 Ah you're right. I thought it said "mmap_read_unlock()" before returning, but it's actually doing a "mmap_read_lock()". Note, I just got back home yesterday, so I blame jetlag ;-) OK, this is good as-is. The "unlocked" is only if you want to know if the mm_read_lock() was unlocked in the function. You need to set it if you want it to retry, but you don't need to initialize it if you don't care if it was released. Probably could use a comment there. -- Steve