As decribed, gup_pgd_range is a lockless pagetable walk. So, in order to
monitor against THP split/collapse with the couting method, it's necessary
to bound it with {start,end}_lockless_pgtbl_walk.

There are dummy functions, so it is not going to add any overhead on archs
that don't use this method.

Signed-off-by: Leonardo Bras <leona...@linux.ibm.com>
---
 mm/gup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index 98f13ab37bac..675e4be27082 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2404,6 +2404,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
                        unsigned int gup_flags, struct page **pages)
 {
        unsigned long addr, len, end;
+       struct mm_struct *mm;
        int nr = 0, ret = 0;
 
        if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM)))
@@ -2421,9 +2422,12 @@ int get_user_pages_fast(unsigned long start, int 
nr_pages,
 
        if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) &&
            gup_fast_permitted(start, end)) {
+               mm = current->mm;
+               start_lockless_pgtbl_walk(mm);
                local_irq_disable();
                gup_pgd_range(addr, end, gup_flags, pages, &nr);
                local_irq_enable();
+               end_lockless_pgtbl_walk(mm);
                ret = nr;
        }
 
-- 
2.20.1

Reply via email to