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: 10394703 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 F18A460236 for ; Fri, 11 May 2018 16:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8016728F4E for ; Fri, 11 May 2018 16:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74FB028F51; Fri, 11 May 2018 16:32:19 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E76BB28F4E for ; Fri, 11 May 2018 16:32:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EF6C6B0671; Fri, 11 May 2018 12:32:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 078356B0672; Fri, 11 May 2018 12:32:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5C296B0673; Fri, 11 May 2018 12:32:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 9F5536B0671 for ; Fri, 11 May 2018 12:32:17 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id p189-v6so3195184pfp.2 for ; Fri, 11 May 2018 09:32:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=TnP2podgky363Lu0RTtk2L3TIj0vxiqXKU86v7jsXmk=; b=UDpRbIrgiDOE/ReAlfJl3FkHnJJoP0EDA1kia2lS6DNBUav80I4OiPBgzU7wc16yKN NxtnX3XXuhOsZt4OIAveKxA5uxxv5sjJIXXemWMqv5WJT0zoXhtJjPqZbly674XJ/58Q tm50RSz7HUrm5lR+L6W9Srpw3ZYvsoQo5gGbOg1PT9JL7LdnqXc0I5F3PVt7CYTRAcQx C/rq4m3aPIvCa5RUc9azH7fFyh3elo+u1L3Ii7KajDdscy+5AJkSW3v4d1tiDYGYgTU1 ZhNZrhMBxWPH9qkAbVLmXSm1xCevAHyl/DnjsZdydx//66aXaHFs6XNomIdX3hM7MimS qGNQ== X-Gm-Message-State: ALKqPwdvD+OlxwWIzbR6HMPhocGFkFR7LAY45uTNIH7iwfSY1JYubKoB LzK0BG67mDKwSHfrk0usNp0elphbA5ByFsswJf940H7psQGnboYA5FQSyC8MWSNmjzQK2DClJW8 PnzEop863Y/d7uH4qRKfCA7vmHyqAnpmdzX5KWvq1AFwCorSkHqp3lDaYZrJcSaYBxEbbBZII5G XzeaBaJfXGShpPq5u4csdVJPNRZB6+wLwjHT23hQDMvT/3tUTKxWTasqOyEfyVfsipMC8wzszGm MXPoeLesMngzhRZNy4G/MTJlLDEeRi5bCbgUTyRJE1w1PuPHjpau7wXdbHktMynq9CAK8A8HdCg fhLb3ZtIqtaecXYM1Fa+G6IRLiOw4jIkJymB3EX6asyToR11kTmMV34aF0ciZc7LSHakQLwq8c6 E X-Received: by 2002:a17:902:8f97:: with SMTP id z23-v6mr6246445plo.329.1526056337316; Fri, 11 May 2018 09:32:17 -0700 (PDT) X-Received: by 2002:a17:902:8f97:: with SMTP id z23-v6mr6246364plo.329.1526056336075; Fri, 11 May 2018 09:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526056336; cv=none; d=google.com; s=arc-20160816; b=HVbs9liVQ1KseDDPJxKr0QDhShcUFqseOc2t0fx5uszVv/ujrcHEONBCQzpF24khbB LV8F0YjYXdOdwlHwYLb9nVILdTzVQAaL2Uj7ErC0IhW2r/0JcmbggPhBvFx1u+7M4bdW /6S6FAVfBQL7USyq/J3JQwCkrRIwiuuXoX1oPy1abfALNjznzim9ULq5Cs39XcXSse2l hcM2hhqDZutNb/AJW8qBfCPJPS3bIo4W9UKFLWVzI7JyN16Nw/GR6jNb0Wgq1oL2glMt m8ZgxTbPuQmAz0AJB8a1AvQm/0TE+qAoRlow6zupZcM0Gad5hmdrTr624oQyVf0QAJcr /HIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=TnP2podgky363Lu0RTtk2L3TIj0vxiqXKU86v7jsXmk=; b=yuUllwo1hZ36b+eBDsLTp9m4aXmkV5uegSTdksrk7oeZ5CiEc4QoUyqP6/T4Cg0Z+P HOOqsQY1fIVjTxY/qpGAb8sHG3hCx0hTRKdFg7oJfISb0c5zmUu+X7F5/EtRk8AVSGM6 7QJJzLqQwEDwDD6qogbGsu5+cwC4+jyozcR/ZuTH/fOdra2MlAMMTa4cEPljhAbyWQ1J /UJDEHxxM0SUJVSxYtOrG+NFcyIh3WOuO8B10cE3l+8l0swEtSSNgWivgio+tSeH/QaM wX4+3bUgFmvLJRgc3YkWqQMkcesgDRc+3rJvq4BKJk3gMVM84Ab2EwZyBO/YyeEQhpz6 EDLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SXjQT06D; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g187-v6sor844250pgc.365.2018.05.11.09.32.15 for (Google Transport Security); Fri, 11 May 2018 09:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SXjQT06D; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-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 Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;