Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp279673pxb; Thu, 25 Feb 2021 02:14:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAp3gcl67HhrPL8spUQqD+LQ6OWybB5qh5ijgM2cAcBEj63vyZVPW6I6DmMfiQR+tUyRta X-Received: by 2002:a17:907:1607:: with SMTP id hb7mr1895048ejc.265.1614248066306; Thu, 25 Feb 2021 02:14:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614248066; cv=none; d=google.com; s=arc-20160816; b=UI1OLpkp8Yl1boRfgruB29ApPLMWfq7m8qPetqHeT3RJJTdEJV5fxsT+7uJ0GkzJYJ L2mYUl+ARroeNi34OLmpNSf6r89FIbp6vnEVBPnW9ggVJasO7unQtI33TZCI3Ijr9bhf hpHdkViPj2vC3fkWP0xdYORHUsHqepyPusvbBu7P0O1IvfYk9iJbhaS/sJgfRknPOGOG hVz5nBUE5GvmFX4oq/4p1ran3XdEyE5Q675qVnacg10bcMXFRAEi1tk5E0njL8Oq97Uw Pfjzc1WfOHeRSS5+djh/A2Usywh4+WvZpPxPqDWxRA3c8tHHPEPFSA8SGRmLZtUXlBr4 vjIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rxazs9V2Ma+zCFcC2IOgaxGmi9USRsu78FFylUsOefU=; b=J3IW7MnErUfdauetNKAa6NTXTdFwTYOXN4pZoiuay4wpMyQf4nGlvlzVATGBZjzL2j qEj6SgwQjj59jtDFp3itXDo7q4l7mdsD02wD3GBdygMNM46+j6/fbwGyILzJ0BBo3jEe xfzPGlD2YdWjvk+tEiTdUM5wTVS6JqxXMmQeoBk+DrJsI5oYnVAFW20h8NNaWcFMNE3n RjEW31IpgKAaxbabmA+gPAbhfE/IwbuD/4aqkBr4EgSDY2UktQhYbOsZgNIw92bfETPU sotDQWrEo0OKluc+3EaPC/gWE5YPdFOcxfJep4CvWKjwF3iDeSlbqPmVfc2moWTj92ML KnNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LkAnWlAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y23si3335780eds.278.2021.02.25.02.14.04; Thu, 25 Feb 2021 02:14:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LkAnWlAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235197AbhBYKNN (ORCPT + 99 others); Thu, 25 Feb 2021 05:13:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:34228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbhBYJ7B (ORCPT ); Thu, 25 Feb 2021 04:59:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6673D64F20; Thu, 25 Feb 2021 09:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614246915; bh=vB6rxebxntfOVBLahpQwVeHkkIIhS6QSp2wWiPj8TR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LkAnWlAAbZT7JAVPOj8UHjjMjv3nxbu6OjqJ1SZsMW4XwIj1Rss06OkV1GM4IvfqO ukjLdW9BUFVa5lxoFSvhniLfgbj7RrWkuXrKSLx/BKs+dkVKMzZzhI0vjoHCJSd8hb +85eUWYtEd9L9+rWqnbj6ognyPaAHxqEpeU9naMI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , "Matthew Wilcox (Oracle)" , Daniel Vetter , Dan Williams , Nick Desaulniers , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 14/23] mm: simplify follow_pte{,pmd} Date: Thu, 25 Feb 2021 10:53:45 +0100 Message-Id: <20210225092517.211062201@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210225092516.531932232@linuxfoundation.org> References: <20210225092516.531932232@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig commit ff5c19ed4b087073cea38ff0edc80c23d7256943 upstream. Merge __follow_pte_pmd, follow_pte_pmd and follow_pte into a single follow_pte function and just pass two additional NULL arguments for the two previous follow_pte callers. [sfr@canb.auug.org.au: merge fix for "s390/pci: remove races against pte updates"] Link: https://lkml.kernel.org/r/20201111221254.7f6a3658@canb.auug.org.au Link: https://lkml.kernel.org/r/20201029101432.47011-3-hch@lst.de Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) Cc: Daniel Vetter Cc: Dan Williams Cc: Nick Desaulniers Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/dax.c | 9 ++++----- include/linux/mm.h | 6 +++--- mm/memory.c | 35 +++++------------------------------ 3 files changed, 12 insertions(+), 38 deletions(-) --- a/fs/dax.c +++ b/fs/dax.c @@ -810,12 +810,11 @@ static void dax_entry_mkclean(struct add address = pgoff_address(index, vma); /* - * Note because we provide range to follow_pte_pmd it will - * call mmu_notifier_invalidate_range_start() on our behalf - * before taking any lock. + * Note because we provide range to follow_pte it will call + * mmu_notifier_invalidate_range_start() on our behalf before + * taking any lock. */ - if (follow_pte_pmd(vma->vm_mm, address, &range, - &ptep, &pmdp, &ptl)) + if (follow_pte(vma->vm_mm, address, &range, &ptep, &pmdp, &ptl)) continue; /* --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1655,9 +1655,9 @@ void free_pgd_range(struct mmu_gather *t unsigned long end, unsigned long floor, unsigned long ceiling); int copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma); -int follow_pte_pmd(struct mm_struct *mm, unsigned long address, - struct mmu_notifier_range *range, - pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp); +int follow_pte(struct mm_struct *mm, unsigned long address, + struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp, + spinlock_t **ptlp); int follow_pfn(struct vm_area_struct *vma, unsigned long address, unsigned long *pfn); int follow_phys(struct vm_area_struct *vma, unsigned long address, --- a/mm/memory.c +++ b/mm/memory.c @@ -4707,9 +4707,9 @@ int __pmd_alloc(struct mm_struct *mm, pu } #endif /* __PAGETABLE_PMD_FOLDED */ -static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address, - struct mmu_notifier_range *range, - pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp) +int follow_pte(struct mm_struct *mm, unsigned long address, + struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp, + spinlock_t **ptlp) { pgd_t *pgd; p4d_t *p4d; @@ -4774,31 +4774,6 @@ out: return -EINVAL; } -static inline int follow_pte(struct mm_struct *mm, unsigned long address, - pte_t **ptepp, spinlock_t **ptlp) -{ - int res; - - /* (void) is needed to make gcc happy */ - (void) __cond_lock(*ptlp, - !(res = __follow_pte_pmd(mm, address, NULL, - ptepp, NULL, ptlp))); - return res; -} - -int follow_pte_pmd(struct mm_struct *mm, unsigned long address, - struct mmu_notifier_range *range, - pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp) -{ - int res; - - /* (void) is needed to make gcc happy */ - (void) __cond_lock(*ptlp, - !(res = __follow_pte_pmd(mm, address, range, - ptepp, pmdpp, ptlp))); - return res; -} - /** * follow_pfn - look up PFN at a user virtual address * @vma: memory mapping @@ -4819,7 +4794,7 @@ int follow_pfn(struct vm_area_struct *vm if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) return ret; - ret = follow_pte(vma->vm_mm, address, &ptep, &ptl); + ret = follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl); if (ret) return ret; *pfn = pte_pfn(*ptep); @@ -4840,7 +4815,7 @@ int follow_phys(struct vm_area_struct *v if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) goto out; - if (follow_pte(vma->vm_mm, address, &ptep, &ptl)) + if (follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl)) goto out; pte = *ptep;