[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/17] mm: PT lock: export double_pt_lock/unlock
From: |
Andrea Arcangeli |
Subject: |
[Qemu-devel] [PATCH 09/17] mm: PT lock: export double_pt_lock/unlock |
Date: |
Fri, 3 Oct 2014 19:07:59 +0200 |
Those two helpers are needed by remap_anon_pages.
Signed-off-by: Andrea Arcangeli <address@hidden>
---
include/linux/mm.h | 4 ++++
mm/fremap.c | 29 +++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index bf3df07..71dbe03 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1408,6 +1408,10 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm,
pud_t *pud, unsigned long a
}
#endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
+/* mm/fremap.c */
+extern void double_pt_lock(spinlock_t *ptl1, spinlock_t *ptl2);
+extern void double_pt_unlock(spinlock_t *ptl1, spinlock_t *ptl2);
+
#if USE_SPLIT_PTE_PTLOCKS
#if ALLOC_SPLIT_PTLOCKS
void __init ptlock_cache_init(void);
diff --git a/mm/fremap.c b/mm/fremap.c
index 72b8fa3..1e509f7 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -281,3 +281,32 @@ out_freed:
return err;
}
+
+void double_pt_lock(spinlock_t *ptl1,
+ spinlock_t *ptl2)
+ __acquires(ptl1)
+ __acquires(ptl2)
+{
+ spinlock_t *ptl_tmp;
+
+ if (ptl1 > ptl2) {
+ /* exchange ptl1 and ptl2 */
+ ptl_tmp = ptl1;
+ ptl1 = ptl2;
+ ptl2 = ptl_tmp;
+ }
+ /* lock in virtual address order to avoid lock inversion */
+ spin_lock(ptl1);
+ if (ptl1 != ptl2)
+ spin_lock_nested(ptl2, SINGLE_DEPTH_NESTING);
+}
+
+void double_pt_unlock(spinlock_t *ptl1,
+ spinlock_t *ptl2)
+ __releases(ptl1)
+ __releases(ptl2)
+{
+ spin_unlock(ptl1);
+ if (ptl1 != ptl2)
+ spin_unlock(ptl2);
+}
- [Qemu-devel] [PATCH 01/17] mm: gup: add FOLL_TRIED, (continued)
- [Qemu-devel] [PATCH 01/17] mm: gup: add FOLL_TRIED, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 06/17] kvm: Faults which trigger IO release the mmap_sem, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 04/17] mm: gup: make get_user_pages_fast and __get_user_pages_fast latency conscious, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 11/17] mm: swp_entry_swapcount, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 15/17] userfaultfd: make userfaultfd_write non blocking, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 13/17] waitqueue: add nr wake parameter to __wake_up_locked_key, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 09/17] mm: PT lock: export double_pt_lock/unlock,
Andrea Arcangeli <=
- [Qemu-devel] [PATCH 07/17] mm: madvise MADV_USERFAULT: prepare vm_flags to allow more than 32bits, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andrea Arcangeli, 2014/10/03
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Linus Torvalds, 2014/10/03
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Dr. David Alan Gilbert, 2014/10/06
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andrea Arcangeli, 2014/10/06
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Linus Torvalds, 2014/10/07
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andrea Arcangeli, 2014/10/07
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andrea Arcangeli, 2014/10/07
- Re: [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andy Lutomirski, 2014/10/07