From patchwork Sun Jun 3 05:22:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10445159 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 83FB2602BC for ; Sun, 3 Jun 2018 05:32:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 764C1289D6 for ; Sun, 3 Jun 2018 05:32:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B37128AFB; Sun, 3 Jun 2018 05:32:55 +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 F087128A4D for ; Sun, 3 Jun 2018 05:32:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7F306B0008; Sun, 3 Jun 2018 01:32:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A2EDA6B000A; Sun, 3 Jun 2018 01:32:53 -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 8CFF06B000C; Sun, 3 Jun 2018 01:32:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 47F776B0008 for ; Sun, 3 Jun 2018 01:32:53 -0400 (EDT) Received: by mail-pg0-f71.google.com with SMTP id v133-v6so8259255pgb.10 for ; Sat, 02 Jun 2018 22:32:53 -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=fR5GJLAqXl6mDkqhPdoriq9qT4iE367jPfDXjTs2E/0=; b=o7ydga5FfBTmekZUvFB2+fHc5oGyJ+Jgk2XFwjcjiuQbZnJ0zkvKrSl9MYgUvYqvVa aBwxkf+EbzCIeF014KA0S2/uzUd/Pd69Ukur2K0MYjZX8nevYAUTBCzDNmMyl28k99Q7 07orkBnKPfyOy5sdfw35FxICpDO9mdvwvZE281TCOnt+76FxERDHaC1PxcDcymm4mXDa cWxIoca7uWPyxvzaFJW+JLRuZjahe8Y2VUX+SlYdgLALfuIo4tdsJBJWVEuOkjl7+aDQ l8ul3sfJXaRtaUxAz/6eWVKe8xvKnjjL130Ilpd0LDdUhGQbC1uvtHHkPiYCDgoILQ1H 9bMg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 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: ALKqPweLCGLghc+vBy0wa9Vmys986VW3VZQsGP9IS3m4+shWDhtPG+Xf 2O1eMUxm8DImDV+p+2PSlNfFs6bXjKY2md1RB/NIjeK1RiUMHc+XxgY7vZR5vwljuf+y4i4KgyI zu9ZAy+yMGej09kg5Zqo9X4yFcM0YTf1/lq3ediGhXviE5eZ078K6xosXLNlCP5F3JQ== X-Received: by 2002:a63:6383:: with SMTP id x125-v6mr13125040pgb.277.1528003972957; Sat, 02 Jun 2018 22:32:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJamTkAj3N3JmI0cGMZr3yy3k1i0glkqG+PQBugaS9hDc5JvgGad+u+IWSstgJBJtPQRn9V X-Received: by 2002:a63:6383:: with SMTP id x125-v6mr13125020pgb.277.1528003972029; Sat, 02 Jun 2018 22:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528003972; cv=none; d=google.com; s=arc-20160816; b=X1IqCxAbukw0wLp13JEVozZJxBigRkHzaUiaVZaB2kfO3f8170TNjACbd18QXdYubQ AzNBKU3lxArVmRs4yqSK6EOVjt0eGiX5PO9y3wJNqB6RyL3+0dRmvOCtPoMFnxs4TCJF /dIEwz8C+0k3axO0mi1ARQ2yN2+6ZXg/653TvkQU6WaAq7AKVKMMpJ5dqKFdV/Pz2f7c AUz7CJRG16nYE8my6ejeco9kO/AmMI7FquhTjdzO8Pbnp1VZ9siRBrgfQVKEKNaSEgkj u0GYrCatMamIeNUS9vbMBm67KQmAg4GTEf/aH2gL1k/FFMze45kN4xVgSZA/EsD830xK t/Ww== 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=fR5GJLAqXl6mDkqhPdoriq9qT4iE367jPfDXjTs2E/0=; b=vXc+pvNHSNAcydQrsvOnYFhrps7mRHSs4iZRXuIrKfzFRxD1R/FQ9wmEWzafGy+el/ iQmGCAZwG6yRTXJNSoWSJqT/GaPzhO8aXKgdYYM+c6/kLV8Ey0acXj75d0wQcJeK2hMI 9pBXXgvBhRXeai+VMnjHy9/NBlfe+GzSHB0YzZbyshXTsHINe2AIf8UL6O9lnDNxzcwi hL4CMheYgRACussB/wnst+u6J399msajGcqql/BvS6HyOQgGw/3Yr6y2OfmIh64eLGKk lWdrnZHaQWgjukppWd9ekQcBZCWhb4e/aof01HR1nDV51i2kyWXWAjaPI6ovOMDwRZA0 FnEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id z7-v6si19975247pfn.247.2018.06.02.22.32.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 22:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 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 fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jun 2018 22:32:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,472,1520924400"; d="scan'208";a="53172438" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga002.fm.intel.com with ESMTP; 02 Jun 2018 22:32:51 -0700 Subject: [PATCH v2 02/11] device-dax: Cleanup vm_fault de-reference chains From: Dan Williams To: linux-nvdimm@lists.01.org Cc: hch@lst.de, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, jack@suse.cz Date: Sat, 02 Jun 2018 22:22:54 -0700 Message-ID: <152800337429.17112.14515997163907857953.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152800336321.17112.3300876636370683279.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152800336321.17112.3300876636370683279.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 Define a local 'vma' variable rather than repetitively de-referencing the passed in 'struct vm_fault *' instance. Signed-off-by: Dan Williams --- drivers/dax/device.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index d44d98c54d0f..686de08e120b 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -247,13 +247,14 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) { + struct vm_area_struct *vma = vmf->vma; struct device *dev = &dev_dax->dev; struct dax_region *dax_region; phys_addr_t phys; pfn_t pfn; unsigned int fault_size = PAGE_SIZE; - if (check_vma(dev_dax, vmf->vma, __func__)) + if (check_vma(dev_dax, vma, __func__)) return VM_FAULT_SIGBUS; dax_region = dev_dax->region; @@ -274,13 +275,14 @@ static vm_fault_t __dev_dax_pte_fault(struct dev_dax *dev_dax, pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); - return vmf_insert_mixed(vmf->vma, vmf->address, pfn); + return vmf_insert_mixed(vma, vmf->address, pfn); } 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 vm_area_struct *vma = vmf->vma; struct device *dev = &dev_dax->dev; struct dax_region *dax_region; phys_addr_t phys; @@ -288,7 +290,7 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, pfn_t pfn; unsigned int fault_size = PMD_SIZE; - if (check_vma(dev_dax, vmf->vma, __func__)) + if (check_vma(dev_dax, vma, __func__)) return VM_FAULT_SIGBUS; dax_region = dev_dax->region; @@ -310,11 +312,10 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, return VM_FAULT_FALLBACK; /* if we are outside of the VMA */ - if (pmd_addr < vmf->vma->vm_start || - (pmd_addr + PMD_SIZE) > vmf->vma->vm_end) + if (pmd_addr < vma->vm_start || (pmd_addr + PMD_SIZE) > vma->vm_end) return VM_FAULT_SIGBUS; - pgoff = linear_page_index(vmf->vma, pmd_addr); + pgoff = linear_page_index(vma, pmd_addr); phys = dax_pgoff_to_phys(dev_dax, pgoff, PMD_SIZE); if (phys == -1) { dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", pgoff); @@ -323,7 +324,7 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); - return vmf_insert_pfn_pmd(vmf->vma, vmf->address, vmf->pmd, pfn, + return vmf_insert_pfn_pmd(vma, vmf->address, vmf->pmd, pfn, vmf->flags & FAULT_FLAG_WRITE); } @@ -332,6 +333,7 @@ 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 vm_area_struct *vma = vmf->vma; struct device *dev = &dev_dax->dev; struct dax_region *dax_region; phys_addr_t phys; @@ -340,7 +342,7 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, unsigned int fault_size = PUD_SIZE; - if (check_vma(dev_dax, vmf->vma, __func__)) + if (check_vma(dev_dax, vma, __func__)) return VM_FAULT_SIGBUS; dax_region = dev_dax->region; @@ -362,11 +364,10 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, return VM_FAULT_FALLBACK; /* if we are outside of the VMA */ - if (pud_addr < vmf->vma->vm_start || - (pud_addr + PUD_SIZE) > vmf->vma->vm_end) + if (pud_addr < vma->vm_start || (pud_addr + PUD_SIZE) > vma->vm_end) return VM_FAULT_SIGBUS; - pgoff = linear_page_index(vmf->vma, pud_addr); + pgoff = linear_page_index(vma, pud_addr); phys = dax_pgoff_to_phys(dev_dax, pgoff, PUD_SIZE); if (phys == -1) { dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", pgoff); @@ -375,7 +376,7 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); - return vmf_insert_pfn_pud(vmf->vma, vmf->address, vmf->pud, pfn, + return vmf_insert_pfn_pud(vma, vmf->address, vmf->pud, pfn, vmf->flags & FAULT_FLAG_WRITE); } #else @@ -390,12 +391,13 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, enum page_entry_size pe_size) { int rc, id; - struct file *filp = vmf->vma->vm_file; + struct vm_area_struct *vma = vmf->vma; + struct file *filp = vma->vm_file; struct dev_dax *dev_dax = filp->private_data; dev_dbg(&dev_dax->dev, "%s: %s (%#lx - %#lx) size = %d\n", current->comm, (vmf->flags & FAULT_FLAG_WRITE) ? "write" : "read", - vmf->vma->vm_start, vmf->vma->vm_end, pe_size); + vma->vm_start, vma->vm_end, pe_size); id = dax_read_lock(); switch (pe_size) {