From patchwork Wed Jul 4 21:40:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10507615 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 A4BC2603D7 for ; Wed, 4 Jul 2018 21:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B0E528CD3 for ; Wed, 4 Jul 2018 21:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F35C28DAA; Wed, 4 Jul 2018 21:50:30 +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 0BB5228CD3 for ; Wed, 4 Jul 2018 21:50:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D92156B0007; Wed, 4 Jul 2018 17:50:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D414F6B0008; Wed, 4 Jul 2018 17:50:28 -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 C58806B000A; Wed, 4 Jul 2018 17:50:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 868F26B0007 for ; Wed, 4 Jul 2018 17:50:28 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id j22-v6so455328pll.7 for ; Wed, 04 Jul 2018 14:50:28 -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=Vj2TBP4p0z7BfpFNA9H8FsIJVZddv0zUtLEcxhHLkxI=; b=uHlR3d4rCDgIWQRgbdIzzSVanqdrMgFw+I0/RBMFhPv2Atwg7VhkSEfmPqo/gQ5ogC 48+lCeMm0G4GPmwlLbO5pKDUtXClwfrxP2b76tcg+hpB6VO33r4dL2I5fHT1iEVbFP6E RtekIizcLJPLoIddsk4Xsbv/f8rJB3suEM/DdX8xwK4VsiZzHRAXme5QkeABQ/DFFjra DPyQTfLBvRBq+8Lb49reS2J1iyfH7Eh3rXiAvg0W5kx3y0QJK+5+lQ/sWFUle9TFWd+D at2REEQ8t69L+iK6iSmDvda/2jDJnhiTOVey0taVXmRiDw0/2osFcNdpXCI2UYK6aJ/Z 1j/A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 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: APt69E2BuIBwoKuJnbDAnA4G9k/SnbhJ/+N8KxfZFcWQt2qoFFpu/ioh 4+5CAphgzL0VzlSMO/UvtBitYTKONYsHg96o5DlVnTyyNGVw7heM95/Bwr/06ycfCefQ8jNJjUL WYxWi91wb/S9GLpsADL66hFEX32jxWua8ZIP+RB5T8kDfRdisfvl5HWlNpXZplZcbOA== X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr3513858plp.36.1530741028224; Wed, 04 Jul 2018 14:50:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcmlKFcPq0o5u6AHsMOc+xaceYgEkYi9PWt4S8LrcjuA2UYMuubwU2B5OMTWfnKLDWyB5uo X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr3513826plp.36.1530741027283; Wed, 04 Jul 2018 14:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741027; cv=none; d=google.com; s=arc-20160816; b=0URMAFB69smJZccyWxmZtYivgnYL6w4b+fyeG5vTgrHmCq4ggACDBvDXP8CkAlBDCB NGL3tqvZY7Mm7fx4DQrID7dC5Fqsi3yagZcSdvXJhp3RAwtJiI3EzYIJ2ANPG5sYdP/g MgeAwrUnQgkuvoSXRdyGFIMjcYFEZvZjsCzTwEUdX6U408+/QxbVSmQyhrbH+qTlBhod 7e4C+XqBexH9ix/zI0aus0BPuvCAcK26IXlFjZ1alKy6yNnU+9zE9jq7bS7g3ZjuNJQV +lEy8PwjuzHi6j1R2htzCsmVeYzx0X+pVcier6VZDifa6/swC8vwlj/1VGtH184Sle3W 0kLA== 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=Vj2TBP4p0z7BfpFNA9H8FsIJVZddv0zUtLEcxhHLkxI=; b=wcbngoJEiTChrwSEtR0Ukpwszn9zQIGSo8nQwbOtuvpBKJUD53Rv2PRP7G+uuEycpU vvM9+Rhbdd8hP14ILdnpUi2udHptTvWghPyxBVe2q2Kp52oi2Kmrfkr9s5/NqSjgzu0k diIO1lYifc9eLLG+hYEfaMTGcKU+Nm+tq8RBKP+NpXm7vO1e+lEoQXhMi+U77W3vYsId PeEtzz6Eq1cN6g99U46a5wbZ4jrv1EFFth2OPH9go1CR2H20cwfcLFF2pljKEAVDRkCp 1SSFQHaUGW/IUMM0iZt4sgkTq7SPpwX9pyfBkoQ+ljSRJfjlFAIxc1yHmgjKTgnDLOkf OiGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id t4-v6si4137094pgc.572.2018.07.04.14.50.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 14:50:27 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 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 orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 14:50:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,309,1526367600"; d="scan'208";a="54106562" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga007.jf.intel.com with ESMTP; 04 Jul 2018 14:50:26 -0700 Subject: [PATCH v5 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, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Date: Wed, 04 Jul 2018 14:40:29 -0700 Message-ID: <153074042893.27838.11180008652608787099.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153074042316.27838.17319837331947007626.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 de2f8297a210..ad5e7b4a15dc 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 1cd7c1a57a14..feba371169ca 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -752,7 +752,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; @@ -812,7 +812,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;