From patchwork Fri Jun 8 23:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10455337 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 AC9196032D for ; Sat, 9 Jun 2018 00:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC0D6294E0 for ; Sat, 9 Jun 2018 00:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0CA2294E3; Sat, 9 Jun 2018 00:00:35 +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 3522229438 for ; Sat, 9 Jun 2018 00:00:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 677476B000A; Fri, 8 Jun 2018 20:00:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FBE56B000C; Fri, 8 Jun 2018 20:00:33 -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 475896B000D; Fri, 8 Jun 2018 20:00:33 -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 0611E6B000C for ; Fri, 8 Jun 2018 20:00:33 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id 89-v6so8181683plc.1 for ; Fri, 08 Jun 2018 17:00:32 -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=U+IsX0Eh+OgfDVgOtjpxA56El/AVbPsO2EO9QFKbuCk6fEm1BEkyu2eZQBM7nr2UQY ER73SHasxTHYdnac8/MN9FywhM6Lv8NOiFp4JB8J9wBosIitJoO7qIcbOxCACWpaism3 8q7gd0j8YdwIWvbYDkHs9puZDuDg4RPtybibsK/K08jmXaPWKw3Ppg/gnYX//Gwrt3tD qF8HNAJ9cOJnYWIjphM4rvQE/YcDCiHVdvxQw93GiLTT8p5zgvlRKQrlTfdKK1PwRNkp E5kfEYeUZ+/EUwEQtfLIipaBlW9Mg1SUdPdDFoZevWSg0JFt/XtlU92gDgCJOU4UWhe5 +g6g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.20 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: APt69E1Ed4Q5SWau/yHTeaFvsWP24VTBtxWbIqTffbYZ6aj6NiixaCeE mjIypJNHfHJA8k9Dg6/ZRVLVsQ6SAs4BMzha1yMv0l4kfQww6o7RSzV/bPEFjc01Kc0uZMNjI5k zeBxNyUVnjpe2Vt8e5IotPQW4VdPHexwXpilzi/xxYrh1PjWOOgZhtIYFxM+aVet0AQ== X-Received: by 2002:a65:6047:: with SMTP id b7-v6mr6948205pgv.241.1528502432681; Fri, 08 Jun 2018 17:00:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKU7ZNLRrLNzlfrjcZnH7GRm77iid3t4AXSoHpUtUkuJpumBlSuR8+2kGrC7Di2CR5KPF4L X-Received: by 2002:a65:6047:: with SMTP id b7-v6mr6948054pgv.241.1528502429717; Fri, 08 Jun 2018 17:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528502429; cv=none; d=google.com; s=arc-20160816; b=oEPJYUV6AkzX6dqqSZhVhN28yRtDmvY8/5bBnT2397m9kK93jNkqbw4ykOGWD0XYoL RifWzu9HU/3lOwmuxZO3ybNqHfAdWjhdysSibBd6Be1VBbLGTfSSQA0TBj3kvoS1cfkK EtbGMfB1WT6458n0TB0jW8irZAQYURMxWgFxaEe/e8Ei+h6wT3ZK9KHItJqMFEbOsq21 MYSyaRnr1TUZ2IEKDZAalANTgI5b5N5c3/iHnjGYJYrmtoZwV1/3r8W4rGntUUQ0VrUT KcSVff9DgAn+Or96pwD39rl7YFlxd4INGzs9WBxhyiXWN95SpChuaxzQIHiRG8NNtXNd MiLg== 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=XCK712G2EOzikAfeltUQFDgT+c9uczQEFQS2gJmzawXz4oNxnfBKK9rhtgT3z1ZObk ge43g+aHaYgvny0cCpGODzlHK+AZ920969A3pn3n77uPF+3OXPdBgcY9/tFMs7JhX+cF /xEYeBoWHK/rIsWukFFCuA5DwcxWXDLXdr1k3AWwOPTnOOsk/2Y+SPWxDQ8JqIJKHfgv 44htHsfntESYW3I6nxK3rUEYW1csBKD6/9dvxaJC99MEDJEGdgN5LkgtrsWcAdEfTlZm ZUqIFANEZbYW8zXIe6GGRaqB5p2XHMSwHz+9UGK7pgl2nllCW8VmwKGhbbwT5LSDLLs9 pAkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id n1-v6si56754736pld.188.2018.06.08.17.00.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 17:00:29 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.20 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 orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 17:00:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,492,1520924400"; d="scan'208";a="65536708" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga002.jf.intel.com with ESMTP; 08 Jun 2018 17:00:29 -0700 Subject: [PATCH v4 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: Fri, 08 Jun 2018 16:50:32 -0700 Message-ID: <152850183221.38390.15042297366983937566.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 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) {