Re: [shmem] 7a7256d5f5: WARNING:possible_recursive_locking_detected
From: Ira Weiny
Date: Fri Oct 21 2022 - 20:10:14 EST
On Fri, Oct 21, 2022 at 05:02:57PM -0700, Randy Dunlap wrote:
>
>
> On 10/21/22 17:00, Ira Weiny wrote:
>
> >
> > I was about to get this patch ready to send when I found this:
> >
> > commit b6ebaedb4cb1a18220ae626c3a9e184ee39dd248
> > Author: Andrea Arcangeli <aarcange@xxxxxxxxxx>
> > Date: Fri Sep 4 15:47:08 2015 -0700
> >
> > userfaultfd: avoid mmap_sem read recursion in mcopy_atomic
> >
> > If the rwsem starves writers it wasn't strictly a bug but lockdep
> > doesn't like it and this avoids depending on lowlevel implementation
> > details of the lock.
> >
> > [akpm@xxxxxxxxxxxxxxxxxxxx: delete weird BUILD_BUG_ON()]
> > Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx>
> > Acked-by: Pavel Emelyanov <xemul@xxxxxxxxxxxxx>
> > ...
> >
> > So I wonder if the true fix is something to lockdep?
> >
> > Regardless I'll send the below patch because it will restore things to a
> > working order.
>
>
> with ; added to each + line.
Indeed! I will actually compile it prior to sending an actual patch. I guess
I should have done that below. :-/ Sorry.
Thanks!
Ira
>
> > But I'm CC'ing Andrea for comments.
> >
> > Ira
> >
> >>
> >> Ira
> >>
> >> diff --git a/mm/shmem.c b/mm/shmem.c
> >> index 8280a5cb48df..6c8e99bf5983 100644
> >> --- a/mm/shmem.c
> >> +++ b/mm/shmem.c
> >> @@ -2424,9 +2424,11 @@ int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
> >>
> >> if (!zeropage) { /* COPY */
> >> page_kaddr = kmap_local_folio(folio, 0);
> >> + pagefault_disable()
> >> ret = copy_from_user(page_kaddr,
> >> (const void __user *)src_addr,
> >> PAGE_SIZE);
> >> + pagefault_enable()
> >> kunmap_local(page_kaddr);
> >>
> >> /* fallback to copy_from_user outside mmap_lock */
> >>
> >>
>
> --
> ~Randy
>