From patchwork Tue May 22 14:39:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10418755 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 AECA660224 for ; Tue, 22 May 2018 14:49:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA5928D05 for ; Tue, 22 May 2018 14:49:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 946E128D13; Tue, 22 May 2018 14:49:43 +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 1574228D05 for ; Tue, 22 May 2018 14:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85ED26B0006; Tue, 22 May 2018 10:49:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 80DEE6B0007; Tue, 22 May 2018 10:49:41 -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 724B26B0008; Tue, 22 May 2018 10:49:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 33DA76B0006 for ; Tue, 22 May 2018 10:49:41 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id s16-v6so11353824pfm.1 for ; Tue, 22 May 2018 07:49:41 -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=s/CeKMSySu7+8Pz1olFbE8RW6dKQgLH3qignsfkH19dIE8CXI7CkV2FMKZ2vYrfBQV AeKFiYH2/6c8Jf57pp/obd6UyrsDjW5QbIjwsnHRw5GoR3TIAvcczUvXLTsXIvYWIQR6 LgzxWlHQAvLDzl97eCVK7bcRfrX9sMRk2A4kBqNihLDJoxLXyAnSiniK+SHAe86/+oY2 pdpKJtoRPKGom3gn9tJKJECO+gs5DCMSp/EALP/dGFEWEJYy56AuALuw4O/mc/Dj6wOa 4dVZ/ROZS8paULaARsaUdhrI0wHatiwK6kBPA5WzZ+fShwMyrzb0a/MSohuCuYypPBo0 9KZw== 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: ALKqPwdJnPAKFG4qpjshuWPWE77tuP6uxpE/V0LeLTv9YyIvPLi8OPCm bMZTbqvC64rObwVyGyXP0lg+cKF5t652EXt+gufi6WHFhqiz9Vt7+yR9aIb3vux0sKEgac7Cgf+ uByhLfAPxWO6wYdeYQINrZtnJND4bMgQmXTXJw0riSZN9jDP83253/uhQ4um2CWqKNQ== X-Received: by 2002:a65:5042:: with SMTP id k2-v6mr19069296pgo.122.1527000580885; Tue, 22 May 2018 07:49:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpLThyAlTJ8yT/m7R/PxIC/fg3qICzNoMW8ND0vH0cnxxo4gHfC2rconISgCCQeZ6GZYZHH X-Received: by 2002:a65:5042:: with SMTP id k2-v6mr19069254pgo.122.1527000579927; Tue, 22 May 2018 07:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527000579; cv=none; d=google.com; s=arc-20160816; b=zYouC7R8dDpLNuXyXc+hzTvTCk+x2hXluSmaxgBJYSCU3a+UB48f2IqIeaujTmV3ss 1Z8PEuUOACBLANw54inSH3tYC67JaEYGyJmC5JWIUER8x7xks5w4yFHWAiovTBPB/uXO e1JTwHUmO4V37wkk0qfqmuz8ZMXCrzixXAOOqhwftMqqfumgrh409VUvCt+JOpudbmuW L3A6atzNBAl3a9xI1j+t6QeIIAV3lawH51Iewu6mXbHhNoxmtc49sYr4p4jJgrQ/LL60 ovaxTo7y9XRMol1mOyhf0TK8sAMWVGA+qh8fg6pkHgPhU9h/Q1yTt34IDST1QsNUYErV PRMg== 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=Yuiio2zaagFlhahyygCdzfb2SARtjJSHiNFewOiO5ru5zuvjRRj9Or9m3SFYAgH3ny /BYm78uS1hO9OFvH5vawM+v2oA6FP7N8rl6j5jl7QctO93pBrgg09Gpdhu6OrGUAuBTI 1IiKJJauqOILo0fa6QW17JdwK/Z7U1bY0TaC5mhzDHL+0nEbUdep5ESreF1l7WDQqd+8 Fhet26MeDWNY0OPp/APaFO5HJ3eO2Ovp8CUUYnlTqT55bMweIUO7FfIzeMdJa40VZvQS /20z6NVdbqLzvFycahW7PUhg6mAmij7l8nDbGCHlrg/yCFX/lGZVPXweND1nCYWz69d5 IuTg== 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 t125-v6si12692571pgc.118.2018.05.22.07.49.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:49:39 -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 orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 07:49:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="226336357" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005.jf.intel.com with ESMTP; 22 May 2018 07:49:39 -0700 Subject: [PATCH 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, tony.luck@intel.com Date: Tue, 22 May 2018 07:39:42 -0700 Message-ID: <152699998238.24093.9051943906273306897.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 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) {