From patchwork Mon Jun 4 23:11:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10447437 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 220EC600CA for ; Mon, 4 Jun 2018 23:21:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14DC528871 for ; Mon, 4 Jun 2018 23:21:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0920629210; Mon, 4 Jun 2018 23:21:51 +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 863F228871 for ; Mon, 4 Jun 2018 23:21:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 631D16B000A; Mon, 4 Jun 2018 19:21:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5DEF16B000C; Mon, 4 Jun 2018 19:21:49 -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 47FDC6B000D; Mon, 4 Jun 2018 19:21:49 -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 07C4B6B000A for ; Mon, 4 Jun 2018 19:21:49 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id x23-v6so210369pfm.7 for ; Mon, 04 Jun 2018 16:21:48 -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=WhAID+jW7wkVQKRIlpe/BgXiUiuyMStwsylXW5b+wxrPwjymBT0h0vO3ZjSCABhm93 noZNIZ25cuPRrqSeU35F6P633g5UKpkmJT2IZcOt1CS1MuisHI3OBFCJX7jcjX0ez0EC VsFNdhw/ebkOO0XCfzzTAneJUq3UwM554M5pMbEv2eAq67jDwa9j0PIdk+Gd+fzMfPE8 1Fi7XHEfrLsna0woFMC41Z27FcfDAqBu5jSF/QI8nnrhRKvlW1ArA8EPB5NvLW6O0G3s mSp2GFE/eFz0FregkMEokxQhEyxcx5DnMWQuQSDRf6HA6HgMiof5kS1Vaf/XR0nJl6MF hAow== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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: ALKqPweGCnZzbhCooyIKLeDFo23O7L6fR9Ujv1ViWM5jNzA2eA91fGec 8U3Z4DOBdwxOWplusuOA3tydxTuRnff1hdNj0kB0lx4pXeR6z6atPerlE6xXt1VZpuOjtYMJTfY t9VUUPHvmtFzk4kDQ7P8TA+gOKKbynlBHpAO3e3h/ymecaSQtdu13Fxpt2IZj+tNeGQ== X-Received: by 2002:a17:902:8f84:: with SMTP id z4-v6mr24067681plo.194.1528154508720; Mon, 04 Jun 2018 16:21:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKGdDNnvp/HCYJjTdd7Vu/1uZQTqX6KZt8j3Qmub7Wz30vm+NqPyjzseTMB/oNZCOOnXApE X-Received: by 2002:a17:902:8f84:: with SMTP id z4-v6mr24067648plo.194.1528154507887; Mon, 04 Jun 2018 16:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528154507; cv=none; d=google.com; s=arc-20160816; b=I4u2xXbPlREcZ/8bodcgZ3sVVoxT9cxxf3L4HRQikpaaIz2u288AuVcjOIoQnMUaWl vjTNDVDJvr+q394BWtkUREYw/7g2n1AinXF7yBH8lJhOcELVmE60jD0HTQYtNT8E0GOg Hy8Xu6MzSuyjK+HeWL4WThE/2Uh5GBb8IHQs1pFGKbMB6vPLw+7F1IxyPg0Y1Q1V5k3f 08sOMWFrlXy5NZsKHVhD/UgNPSjZkD2sT79GvKOP29EKjCm+UCZWFK21gEhQkNFI6yZ+ 4jq6LwWLGWE3oalr3Q0YdUn1QVLrbsQ1mMy2oB7OuaFrvqkGOBCK0bSFJR7hoZWAjEjB KzVQ== 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=cVXUKBdpWqwaEdHZ2rXVuSh88sWiFSKbdJZ5gRtNPnehWBd4VuB2Bak67Ckmg0z/em RMJggMCsV/C+LQHuaMDF7sdCZUqozUHo4syaewuox4yAeEnISODCFPfAV/plXKW4iCh4 sckg+aUnW9jAga53u/A5EoY6eSdh6UDSzzGCCmmZXurX9mRJemOEJg7DNTvYKtGeU9AI J8iXdj5A7jcFNOVLgZb+nRUtirXHiIZqOckyzjxgHyMrT7xdCuX7n9ddB4Ui72U9wVTC 0lZ950KV8rfmw6wZMa5lvXAhDD/k/OQHADG2L9MaJ2OB3U0xD1U2FOUs6MIRKh7jQ6Vu LU9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id g7-v6si45854736plt.149.2018.06.04.16.21.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 16:21:47 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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 fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2018 16:21:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,477,1520924400"; d="scan'208";a="45261129" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga008.fm.intel.com with ESMTP; 04 Jun 2018 16:21:47 -0700 Subject: [PATCH v3 02/12] 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: Mon, 04 Jun 2018 16:11:50 -0700 Message-ID: <152815391047.39010.14943806463373398992.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152815389835.39010.13253559944508110923.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152815389835.39010.13253559944508110923.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) {