From patchwork Tue May 22 14:39:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10418749 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 C3C2A60224 for ; Tue, 22 May 2018 14:49:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3B4A28D05 for ; Tue, 22 May 2018 14:49:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A851028D13; Tue, 22 May 2018 14:49:38 +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.9 required=2.0 tests=BAYES_00, 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 2D20D28D05 for ; Tue, 22 May 2018 14:49:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E52766B0005; Tue, 22 May 2018 10:49:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E017E6B0006; Tue, 22 May 2018 10:49:36 -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 D18AE6B0007; Tue, 22 May 2018 10:49:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 923266B0005 for ; Tue, 22 May 2018 10:49:36 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id q15-v6so11231917pff.17 for ; Tue, 22 May 2018 07:49:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=ejfMiBwayMZ+uRBKTE8Al9yMndVM1pES8Us7a8b070w=; b=rGiKnWB8Ai04yKNKfs68Pi5x5cbVBA1Rg2od3GPO+ljVCc8+dFwJ6h5gVfOEmhQPFY qkp6RdTHxWtBBfHkgAXa92x9wYdXxqy2r55hZV5jU1CuSUGAfk7cwcIvgb7qjBhuSlov JdFa+RafPg+juGNxVdKLO+tjQwQCh12b2GXIT8BnyfduhkJAIZfp8pcgzffPTCIyutpO zR9WCNdaGPao/Sq/x2hOwmiPykzOfh8JPdal0eLKPBAzIfwUePmCWX2NovbjzIMcxvtE /Ymg0w/GO8JTZQ9E5BA27OOnyP2gDa2gIqaJYnXd1DTKEDLLodyATAmoPH10e77fGwVY O7DA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ALKqPwfUBCjDQm2LYyqzvnDJCcsB5HUACxsPe02IDxdnPl6TsvzZuy87 DdRIIXxpJU+X1TTF/du00IsCUSDXiYDe3FZDXLd3HDnjCZ9NY9f3vvfzLUtXPxhIQWm0Q/Qx8Av V4gE6MOiLlm18VlyLgp24nVpdxx8Z9cxhmJv1f/yIPiiQoXWJyB5IshQfhPPMh2qz2w== X-Received: by 2002:a65:5ac9:: with SMTP id d9-v6mr19566339pgt.342.1527000576262; Tue, 22 May 2018 07:49:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqh8MHG5O6XB5vxS1kK4ucxDOkSfxw1ftcXjU8q2VY01hzkV+Q6WDROmkntDj0mO+kCTFhi X-Received: by 2002:a65:5ac9:: with SMTP id d9-v6mr19566295pgt.342.1527000575293; Tue, 22 May 2018 07:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527000575; cv=none; d=google.com; s=arc-20160816; b=c6Nz0XdM5Kzi8o9BRepbKwp9RvNQ71zm+Hc9SgKAikqI5CESV6I//k98QziTuYQ2rU IROeTBGrpGTYeqZtyWQsOPe7LRh2ARuHkhRWikcj2oyKdfSHPVowTbD19paKz/v3CklR PF4sPUbA5zWEUw/+tX9smjoT5L8CcPQf3kbzNRg6hNxJnLuyGdHJ1vV7tmVrX92hbq+j Qf6wyzo5OgtxDmdzpkzeJmgr5eAh9N5sUhFbf8fUG4l3xd6l/QwygyYvipvv4+lT1Ja6 0pBVdUPb2v8tyHml1BVhvG7BVN0GVbZ9c5fqHTlQhuEBIg+wUhnDEleOw7WVU+fK4C+C Pk6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=ejfMiBwayMZ+uRBKTE8Al9yMndVM1pES8Us7a8b070w=; b=gigKcxs1ml/okQtF35a0ioG0vBAwSmuEXIwdZI7sGskH4ax8XpxhSUhgdQjK2cf4yZ LthCzKcqDzAk72GEvNiE35EmBGhNraAqbnv9bKn5eYQbDmSTluDC6NkxtVxcvDCOamaa xm3SPH5xMrLwNX8LvDerkkl74ulBWgEy/70pJWYl2LGw2kp2JZRMdj6cHmvCForejo++ GEZeE8DF50BGabsvCAXt7UIKh7kFpDZIsIEAHZLgL2um29UHpI5/ARcrsm9wYXwZ1ayV u7GmogPzrVJfc8Jvcm6QukbzONXebTc/Kqm7ukRU1wd3wZ9vqxaUmRUYJ6C4nxMk3Tc4 ALow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id y5-v6si9955558pgq.276.2018.05.22.07.49.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:49:35 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 07:49:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="52908994" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga003.jf.intel.com with ESMTP; 22 May 2018 07:49:33 -0700 Subject: [PATCH 01/11] device-dax: convert to vmf_insert_mixed and vm_fault_t From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Souptick Joarder , Matthew Wilcox , Ross Zwisler , hch@lst.de, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, tony.luck@intel.com Date: Tue, 22 May 2018 07:39:37 -0700 Message-ID: <152699997725.24093.7806223020674439995.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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 and huge_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() returned an error code 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 Signed-off-by: Dan Williams --- 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 aff2c1594220..d44d98c54d0f 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -244,11 +244,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; @@ -334,7 +328,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; @@ -384,13 +379,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; @@ -420,7 +416,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 a8a126259bc4..d3bbf6bea9e9 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 a3a1815f8e11..6af976472a5d 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;