Re: [RFC v5 PATCH 2/2] mm: mmap: zap pages with read mmap_sem in munmap

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

 




+static int vm_munmap_zap_rlock(unsigned long start, size_t len)
+{
+    int ret;
+    struct mm_struct *mm = current->mm;
+    LIST_HEAD(uf);
+
+    ret = do_munmap_zap_rlock(mm, start, len, &uf);
+    userfaultfd_unmap_complete(mm, &uf);
+    return ret;
+}
+
   int vm_munmap(unsigned long start, size_t len)
   {
       int ret;
A stupid question, since the overhead of vm_munmap_zap_rlock() compared to
vm_munmap() is not significant, why not putting that in vm_munmap() instead of
introducing a new vm_munmap_zap_rlock() ?
Since vm_munmap() is called in other paths too, i.e. drm driver, kvm, etc. I'm
not quite sure if those paths are safe enough to this optimization. And, it
looks they are not the main sources of the latency, so here I introduced
vm_munmap_zap_rlock() for munmap() only.
For my information, what could be unsafe for these paths ?

I'm just not sure if they are safe enough nor not, because I'm not knowledgeable enough to kvm and drm drivers. They might be safe, but I don't know how to prove that.

So, since they might be not the main sources of latency (I haven't seen any hung report due to them), so it sounds safe to not touch them for now.


If someone reports or we see they are the sources of latency too, and the
optimization is proved safe to them, we can definitely extend this to all
vm_munmap() calls

Thanks,
Yang

@@ -2855,10 +2939,9 @@ int vm_munmap(unsigned long start, size_t len)
   SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
   {
       profile_munmap(addr);
-    return vm_munmap(addr, len);
+    return vm_munmap_zap_rlock(addr, len);
   }

-
   /*
    * Emulation of deprecated remap_file_pages() syscall.
    */
@@ -3146,7 +3229,7 @@ void exit_mmap(struct mm_struct *mm)
       tlb_gather_mmu(&tlb, mm, 0, -1);
       /* update_hiwater_rss(mm) here? but nobody should be looking */
       /* Use -1 here to ensure all VMAs in the mm are unmapped */
-    unmap_vmas(&tlb, vma, 0, -1);
+    unmap_vmas(&tlb, vma, 0, -1, false);
       free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING);
       tlb_finish_mmu(&tlb, 0, -1);





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux