From patchwork Fri May 11 16:34:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10394701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A412760236 for ; Fri, 11 May 2018 16:32:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3881628F4E for ; Fri, 11 May 2018 16:32:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CD1128F50; Fri, 11 May 2018 16:32:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B6B8028F4E for ; Fri, 11 May 2018 16:32:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 134D92033D1B6; Fri, 11 May 2018 09:32:17 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=jrdr.linux@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8E1F92097789E for ; Fri, 11 May 2018 09:32:15 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id o76-v6so2968952pfi.5 for ; Fri, 11 May 2018 09:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=TnP2podgky363Lu0RTtk2L3TIj0vxiqXKU86v7jsXmk=; b=SXjQT06DwsLfPSedFd5LF8bIICUS9QSbvqyDr7qdNeCUykgMbLpN9MqsRay92wfvGo orECxg8ebVS9IcHuSiCHPS5CNSbsLKqRR4Tc+iRdLbfOGmVTLdjnan3NfhNSk4HVh2XD oGRg9qZHfQ5LXq665eswtfPpfnjs1tbkgZXD2MyQcVZl8aU4zLAr/Z5djNrfXxpEUtS+ ZhzfI/Dbyjed2NWzh4ATX/vqmYtAJABWuUACXikA7f6FumzHnQyXZ/TEzh2pll8HSY7C 2ARN9pQ+2YKlaWTubFhOxR/2m6kjAy/yGvX8t4EgBbLR0UD/lgEm1vRHOdwN2id/CudT mrwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=TnP2podgky363Lu0RTtk2L3TIj0vxiqXKU86v7jsXmk=; b=NOZJEUgWOE1Fn2iWcd3MQlrpyMgSUkUFKtOxO+irfu2PFWz5e7l31o/u8Qli7qA8PN lpx3ncykk50/ovFldauXP7JingL0A7aqIXEJQOQ+zTnD8eTJcpaIZ2SWKZRr9LoO/CRY 2mrEJDdQ6e3/0Zss0yZ1e4ZX0Qrqy5UItRWXoq5/TOHPdERqbbq/t1eamKZHw8P4PvB8 tDpi3aheOaRj0JfH6yG7pV9zQbPDhD6GXFqsga8VN9Ljp2I1BUSOSBzj7qOFAMwGqyZ1 ALaym/qrVOavbVPKCIbx7MBWavJeJbAI/9JyWvSr7Mtrt1nmmDRINhVdcVL1GaneZQa3 trNQ== X-Gm-Message-State: ALKqPwfSCwXMotc/o0guA4fzusuRqeVYybQncBnInXGuNRBafdAqR/tC IVrtlHB/rT2IYk4yEJGS2As= X-Google-Smtp-Source: AB8JxZog89q/0cKn+v2ADTpkV1vQqR/DXc+qTz0j/EUBmIhbgXkqnIwA8cleIxK0IVZUAGVtKzyzjQ== X-Received: by 2002:a65:6699:: with SMTP id b25-v6mr4892881pgw.191.1526056334928; Fri, 11 May 2018 09:32:14 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.18.121]) by smtp.gmail.com with ESMTPSA id v14-v6sm6519666pfn.105.2018.05.11.09.32.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 09:32:13 -0700 (PDT) Date: Fri, 11 May 2018 22:04:21 +0530 From: Souptick Joarder To: willy@infradead.org, dan.j.williams@intel.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, zi.yan@cs.rutgers.edu, ross.zwisler@linux.intel.com, ying.huang@intel.com, mhocko@suse.com, peterz@infradead.org, aneesh.kumar@linux.vnet.ibm.com, rientjes@google.com Subject: [PATCH v4] dax: Change return type to vm_fault_t Message-ID: <20180511163421.GA32728@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Use new return type vm_fault_t for fault handler. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type. Commit 1c8f422059ae ("mm: change return type to vm_fault_t") Previously vm_insert_mixed() returns err which driver mapped into VM_FAULT_* type. The new function vmf_insert_mixed() will replace this inefficiency by returning VM_FAULT_* type. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Reviewed-by: Ross Zwisler --- v2: Modified the change log v3: Updated the change log and added Ross in review list v4: Addressed David's comment. Changes in huge_memory.c put together in a single patch that it is bisectable in furture drivers/dax/device.c | 26 +++++++++++--------------- include/linux/huge_mm.h | 5 +++-- mm/huge_memory.c | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 2137dbc..a122701 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -243,11 +243,11 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, return -1; } -static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) +static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, + struct vm_fault *vmf) { struct device *dev = &dev_dax->dev; struct dax_region *dax_region; - int rc = VM_FAULT_SIGBUS; phys_addr_t phys; pfn_t pfn; unsigned int fault_size = PAGE_SIZE; @@ -274,17 +274,11 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn); - - if (rc == -ENOMEM) - return VM_FAULT_OOM; - if (rc < 0 && rc != -EBUSY) - return VM_FAULT_SIGBUS; - - return VM_FAULT_NOPAGE; + return vmf_insert_mixed(vmf->vma, vmf->address, pfn); } -static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) +static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, + struct vm_fault *vmf) { unsigned long pmd_addr = vmf->address & PMD_MASK; struct device *dev = &dev_dax->dev; @@ -335,7 +329,8 @@ static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) } #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD -static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) +static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, + struct vm_fault *vmf) { unsigned long pud_addr = vmf->address & PUD_MASK; struct device *dev = &dev_dax->dev; @@ -386,13 +381,14 @@ static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) vmf->flags & FAULT_FLAG_WRITE); } #else -static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) +static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, + struct vm_fault *vmf) { return VM_FAULT_FALLBACK; } #endif /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ -static int dev_dax_huge_fault(struct vm_fault *vmf, +static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, enum page_entry_size pe_size) { int rc, id; @@ -423,7 +419,7 @@ static int dev_dax_huge_fault(struct vm_fault *vmf, return rc; } -static int dev_dax_fault(struct vm_fault *vmf) +static vm_fault_t dev_dax_fault(struct vm_fault *vmf) { return dev_dax_huge_fault(vmf, PE_SIZE_PTE); } diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index a8a1262..d3bbf6b 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -3,6 +3,7 @@ #define _LINUX_HUGE_MM_H #include +#include #include /* only for vma_is_dax() */ @@ -46,9 +47,9 @@ extern bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, pgprot_t newprot, int prot_numa); -int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, pfn_t pfn, bool write); -int vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write); enum transparent_hugepage_flag { TRANSPARENT_HUGEPAGE_FLAG, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 87ab9b8..1fe4705 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -755,7 +755,7 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, spin_unlock(ptl); } -int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, pfn_t pfn, bool write) { pgprot_t pgprot = vma->vm_page_prot; @@ -815,7 +815,7 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, spin_unlock(ptl); } -int vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write) { pgprot_t pgprot = vma->vm_page_prot;