qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 22/23] userfaultfd: avoid mmap_sem read recursio


From: Andrew Morton
Subject: Re: [Qemu-devel] [PATCH 22/23] userfaultfd: avoid mmap_sem read recursion in mcopy_atomic
Date: Fri, 22 May 2015 13:18:22 -0700

On Thu, 14 May 2015 19:31:19 +0200 Andrea Arcangeli <address@hidden> wrote:

> 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.
> 
> ...
>
> @@ -229,13 +246,33 @@ static __always_inline ssize_t __mcopy_atomic(struct 
> mm_struct *dst_mm,
>  
>               if (!zeropage)
>                       err = mcopy_atomic_pte(dst_mm, dst_pmd, dst_vma,
> -                                            dst_addr, src_addr);
> +                                            dst_addr, src_addr, &page);
>               else
>                       err = mfill_zeropage_pte(dst_mm, dst_pmd, dst_vma,
>                                                dst_addr);
>  
>               cond_resched();
>  
> +             if (unlikely(err == -EFAULT)) {
> +                     void *page_kaddr;
> +
> +                     BUILD_BUG_ON(zeropage);

I'm not sure what this is trying to do.  BUILD_BUG_ON(local_variable)?

It goes bang in my build.  I'll just delete it.

> +                     up_read(&dst_mm->mmap_sem);
> +                     BUG_ON(!page);
> +
> +                     page_kaddr = kmap(page);
> +                     err = copy_from_user(page_kaddr,
> +                                          (const void __user *) src_addr,
> +                                          PAGE_SIZE);
> +                     kunmap(page);
> +                     if (unlikely(err)) {
> +                             err = -EFAULT;
> +                             goto out;
> +                     }
> +                     goto retry;
> +             } else
> +                     BUG_ON(page);
> +




reply via email to

[Prev in Thread] Current Thread [Next in Thread]