lkml.org 
[lkml]   [2022]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [shmem] 7a7256d5f5: WARNING:possible_recursive_locking_detected
On Fri, Oct 21, 2022 at 01:30:41PM -0700, Andrew Morton wrote:
> On Fri, 21 Oct 2022 14:09:16 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Fri, Oct 21, 2022 at 12:10:17PM +0800, kernel test robot wrote:
> > > FYI, we noticed WARNING:possible_recursive_locking_detected due to commit (built with gcc-11):
> > >
> > > commit: 7a7256d5f512b6c17957df7f59cf5e281b3ddba3 ("shmem: convert shmem_mfill_atomic_pte() to use a folio")
> > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
> >
> > Ummm. Looks to me like this now occurs because of this part of the
> > change:
> >
> > if (!zeropage) { /* COPY */
> > - page_kaddr = kmap_atomic(page);
> > + page_kaddr = kmap_local_folio(folio, 0);
> > ret = copy_from_user(page_kaddr,
> > (const void __user *)src_addr,
> > PAGE_SIZE);
> > - kunmap_atomic(page_kaddr);
> > + kunmap_local(page_kaddr);
> >
> > Should I be using __copy_from_user_inatomic() here?
>
> Caller __mcopy_atomic() is holding mmap_read_lock(dst_mm) and this
> copy_from_user() calls
> might_fault()->might_lock_read(current->mm->mmap_lock).
>
> And I guess might_lock_read() gets upset because we're holding another
> mm's mmap_lock. Which sounds OK to me, unless a concurrent
> mmap_write_lock() could jam things up.

Well, are we sure that dst_mm and current->mm are necessarily different?
If so, we could tell lockdep that.

> But I cannot see why your patch would suddenly trigger this warning -
> kmap_local_folio() and kmap_atomic() are basically the same thing.

Except for the important call in kmap_atomic_prot() to
pagefault_disable(). I mean, we could open-code that in the uffd code?

\
 
 \ /
  Last update: 2022-10-22 00:36    [W:0.070 / U:1.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site