Messages in this thread | | | Date | Fri, 21 Oct 2022 17:02:57 -0700 | Subject | Re: [shmem] 7a7256d5f5: WARNING:possible_recursive_locking_detected | From | Randy Dunlap <> |
| |
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@redhat.com> > 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@linux-foundation.org: delete weird BUILD_BUG_ON()] > Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> > Acked-by: Pavel Emelyanov <xemul@parallels.com> > ... > > 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.
> 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
| |