From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Leonardo Bras Subject: [PATCH v6 02/11] mm/gup: Use functions to track lockless pgtbl walks on gup_pgd_range Date: Thu, 6 Feb 2020 00:08:51 -0300 Message-ID: <20200206030900.147032-3-leonardo@linux.ibm.com> In-Reply-To: <20200206030900.147032-1-leonardo@linux.ibm.com> References: <20200206030900.147032-1-leonardo@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Arnd Bergmann , Andrew Morton , "Aneesh Kumar K.V" , Nicholas Piggin , Christophe Leroy , Steven Price , Robin Murphy , Leonardo Bras , Mahesh Salgaonkar , Balbir Singh , Reza Arbab , Thomas Gleixner , Allison Randal , Greg Kroah-Hartman , Mike Rapoport , Michal Suchanek Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org List-ID: Message-ID: <20200206030851.YQqX8F9xrIX4WA55C5yV-a0r95y-8eC9h08i3KJ8Mz8@z> As described, gup_pgd_range is a lockless pagetable walk. So, in order to track against THP split/collapse, it disables/enables irq around it. To make use of the new tracking functions, it replaces irq disable/enable by {begin,end}_lockless_pgtbl_walk(). As local_irq_{save,restore} is present inside {begin,end}_lockless_pgtbl_walk, there should be no change in the workings. Signed-off-by: Leonardo Bras --- mm/gup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 1b521e0ac1de..04e6f46993b6 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2369,7 +2369,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, struct page **pages) { unsigned long len, end; - unsigned long flags; + unsigned long irq_mask; int nr = 0; start = untagged_addr(start) & PAGE_MASK; @@ -2395,9 +2395,9 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) { - local_irq_save(flags); + irq_mask = begin_lockless_pgtbl_walk(); gup_pgd_range(start, end, write ? FOLL_WRITE : 0, pages, &nr); - local_irq_restore(flags); + end_lockless_pgtbl_walk(irq_mask); } return nr; @@ -2450,9 +2450,9 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) { - local_irq_disable(); + begin_lockless_pgtbl_walk(); gup_pgd_range(addr, end, gup_flags, pages, &nr); - local_irq_enable(); + end_lockless_pgtbl_walk(IRQS_ENABLED); ret = nr; } -- 2.24.1