From patchwork Fri Jun 8 23:50:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10455335 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 2343E60234 for ; Sat, 9 Jun 2018 00:00:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21A8A294E0 for ; Sat, 9 Jun 2018 00:00:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20312294F7; Sat, 9 Jun 2018 00:00:32 +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 92B51294E0 for ; Sat, 9 Jun 2018 00:00:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 871136B0007; Fri, 8 Jun 2018 20:00:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7F8696B0008; Fri, 8 Jun 2018 20:00:30 -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 69A126B000A; Fri, 8 Jun 2018 20:00:30 -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 2776E6B0007 for ; Fri, 8 Jun 2018 20:00:30 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id j25-v6so5852990pfi.9 for ; Fri, 08 Jun 2018 17:00:30 -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=BiDU5Su1oG5jzkYO2+yUMxxD1WcFggJXIuluzpqcB5LLaKF8KShEHgXBqRyrUIWfIv iGU0gaLvRubudtK2X2j1uu8mkrGxH9TGl08O6xvaGjBttBgATcnRIUVdsEWZQhPLWagg fMVfXq8vc5hwVqiaVUXrLIHUk/SNI8AplYDRITSynHKoie+yhRsJixXoy0n3gEINOJIo e3uIdaNwI8NeGWQG8GGammtc29U/Dpad3rLqSk/Og8GiSW1SjOiyb6QAzpcj7oPWqyCX W7S4kmwM5U89rIyIhpEG/Vv+W6tnUy48mg7MpxwUlAZ+9/s5WFIDQB9w6udflKqqiJkN he/Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 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: APt69E2VZULilO/OlU6K0JlAD5HKOFHSg+Gc1KozbO8WNmFPdUEsRXtW RH2vvLS/q8OWJsYQLpbSvMdrdu+CZOHz9S6Cq6EFTel03YQzWMRAyFRdt7cWcNdQvTyuzoH7vfL rQfVZ2qpCAfVVOyM0wGzcK/e4pTEvcH6Eft1cHs74lNBsXPJOs0HrcFkJJe+OAoBXzA== X-Received: by 2002:aa7:8254:: with SMTP id e20-v6mr8073532pfn.140.1528502428342; Fri, 08 Jun 2018 17:00:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJrHbZW8xeuAJn3MWdrL5J5Itbbqql1g38weQvAXM9GSmdY6o5Y8JZ1ATAFzITwzie2e9zV X-Received: by 2002:aa7:8254:: with SMTP id e20-v6mr8073325pfn.140.1528502425037; Fri, 08 Jun 2018 17:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528502425; cv=none; d=google.com; s=arc-20160816; b=mCoqkMNM7j+0VmNqtgafzJS3Bg/Lw9PIYMvoFzd8QS6YyHabEVT4CKOxg/fWO4paol gwPcJ2+ZYQAYMqq5bMrhy/Gqsb0dUkDjmMfDHy0/kZwJeVIJ3MUcFNNhoDTyisvVSCDn 6IRn++mmO1D8qj2ndXvgqy23h2HLpJ0D4+uIMFEgWDciM949txI+toB/RX+93+gc8Ii8 wYEjbS2IwJWvJ8S0U0lAyMg8rABs0GjmEw4jL4FEluTzEu7j2buf2hkPBA/S5IaJPEzO bzm475IXzecwQ5kwl6wSzihp4gbxZ3QqahmTFfYIoRwF5fApdJX4BhgjSTmXMlfdpK43 +RYQ== 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=Ci1dq1NmpoSDwyAr0Pqr/qH/ajSPurj2blGsOeZQkIVXrMD3hK0rWwsEFIxSI87lUn 3Ebc2tQvalujJig2N/VREupPcwth6tRX3FupEf77NNj8KuRoAfmJgGOs6WY332E+hycK Oe1xmRM2tIDxHogAdfYzEo2aoIUU6CwYYnImOSBOLBFjwjp/aEDVtyIywuLQaDLAuCC5 pMQSy7xR2kA562P1jVt06sxAwLi0wp0n0xDszrRWavIJYXbUcVM0T2gTOc+xyCmGHlA1 1e8X37MXie6HPb695Sz2+Z6iMbEUh5NNpwe51/PhcH2fLGkKf6ys9Yta5m8TPjDn2E9r J9jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id w1-v6si41660798ply.425.2018.06.08.17.00.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 17:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 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 orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 17:00:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,492,1520924400"; d="scan'208";a="63046926" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga001.jf.intel.com with ESMTP; 08 Jun 2018 17:00:24 -0700 Subject: [PATCH v4 01/12] 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, jack@suse.cz Date: Fri, 08 Jun 2018 16:50:27 -0700 Message-ID: <152850182710.38390.3268302707914085883.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152850182079.38390.8280340535691965744.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152850182079.38390.8280340535691965744.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;