From patchwork Mon Jul 16 17:01:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527285 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 45ABF60545 for ; Mon, 16 Jul 2018 17:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34F9428D80 for ; Mon, 16 Jul 2018 17:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 291CF28D8F; Mon, 16 Jul 2018 17:11: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 9161C28D80 for ; Mon, 16 Jul 2018 17:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 485036B027B; Mon, 16 Jul 2018 13:11:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 40C6A6B027C; Mon, 16 Jul 2018 13:11: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 2AEEC6B027D; Mon, 16 Jul 2018 13:11:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id DBA1C6B027B for ; Mon, 16 Jul 2018 13:11:29 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id x15-v6so14376511pll.7 for ; Mon, 16 Jul 2018 10:11:29 -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=FToy+dbWZrTIvFACi5xJ51HBAb7iF3l6xdgS2vcCHY8=; b=iVheq5KsWmfLHh9e9UowFF4JUGxgGqrOI+tZ/MKKJ+32GzudwPfa9llyHJfUbLmyLQ 9ioS48umreAZBR2FbkhLEFJKtB5+MM3GOrkWks0vEj8hbC/AQJR35E4TuH0rvmp4IEAl 4Bk0NmFD8FlBHb7saBgXZxY+gq8Jz9JxCqP2OfhD3ID6DYj8lIQYo6C/vGOdRG/+IxvR JMq+Nm1LZbAmPmlvDew/e3+rrIrjo7SZ2k1yzq1DkYIkaLs6LLEbkJjLwIezg18Vn1x2 8qsin4FNLZORVYtJplrxNwiGMhcmHKQKsStLk9TlfBsYBrKUmamiOnwsuXimsLAZbawg /BOQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 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: AOUpUlFE6Paa38OVfB69Ox8uxMT5/63O4gXXG705dxpiLMhd9JsT/huk H9HVppVA/VRh2SzCux6zlrD5jAsejflEoUrYJ93BDYy/1drOppzXEgiqNiqKAAXRhBKxHx00gC5 J0OK03GuVhaXUzjgCq75x17Bqm6wNRLP9WucjdVnrC3CNoVDeBWXyxfMRX9yBMpmUsw== X-Received: by 2002:a65:5205:: with SMTP id o5-v6mr16142313pgp.108.1531761089574; Mon, 16 Jul 2018 10:11:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmwCdvYawiuEoKhtaaLfYzND4FYEAdR11SxPtU+w2jZ83R/QQMsEvhYLRh/mjrXfksV7J3 X-Received: by 2002:a65:5205:: with SMTP id o5-v6mr16142281pgp.108.1531761088837; Mon, 16 Jul 2018 10:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761088; cv=none; d=google.com; s=arc-20160816; b=QNkreK7UuOJW3IVPjPcs8DD1eP4+V0vb/p9Rc9cFGXtJZZxFgsMV58vVsZigPaoWI4 k+CGcYMEUXsYP1Ncd6T281nHn2x6ss0gLnpndgUrziJHfHecoo6Kpa36ePX1UjQzW0kE mVs5e5Q98bJe24ZyJgVHwVyuueOkUt7bl44glq7CEWv2AnRGizZUNwWP/QeKNStz/Zlq oiudQnrquA3RaG4Dg5hb4qBdDfLD16iFEGF4RBIWyWsbCiBJwMunQ5G990RDP2aVDU80 JHkqYZOtZvhjBBvWi2Kd7JPEKcg2prx4G4HsMtLVars2HkfAqOewLlAXRhNQRmS5niNd jfoA== 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=FToy+dbWZrTIvFACi5xJ51HBAb7iF3l6xdgS2vcCHY8=; b=1IE4riEwH1XXEl0ecl0S3xSa3huIVR1YFkZb3eSTgb6aO68UsvDe/Z4Rvi2CfnEENa IfVdBHlpZhIp1otjG5xjAkjggrK/V/QGNFAyb89VbX4oJ1qNpudVGGUYr5jJDNOrv4Ql aYvf7+AftA1I71I/TumVoWy+mjWiThdGujzGTMrmTJ2YdXCVEcqqLktIZN19dTo3JpDp 4lRkNT7muXhQNdXIQSAOVwJ3NtveSSi54XfFfS/X6TAxQChtQalPPXMnNpraK48JO3OW 9yH8aRnqc9Tp8d+nE/1BCFMYS2GhokoQuPzhoTx3/g805ASOvTtSCB81r3P9yGo2OH4r Yslw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id w65-v6si32146592pfw.95.2018.07.16.10.11.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:11:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="73221304" 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; 16 Jul 2018 10:11:28 -0700 Subject: [PATCH v2 13/14] device-dax: Initialize the memmap in the background From: Dan Williams To: akpm@linux-foundation.org Cc: Dave Jiang , Ross Zwisler , Vishal Verma , hch@lst.de, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Mon, 16 Jul 2018 10:01:30 -0700 Message-ID: <153176049055.12695.8641863597388682690.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153176041838.12695.3365448145295112857.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 Given that the nd_dax shares device data with nd_pfn devices, arrange for the nd_pfn memmap_async_state instance to be registered by the devm_memremap_pages() call in the dax-pmem driver. Then, provide the generic dev_pagemap instance to the device-dax driver so that it can utilize memmap_sync() before dax-mapping pfns. Cc: Dave Jiang Cc: Ross Zwisler Cc: Vishal Verma Signed-off-by: Dan Williams --- drivers/dax/dax-private.h | 2 ++ drivers/dax/device-dax.h | 2 +- drivers/dax/device.c | 16 +++++++++++++++- drivers/dax/pmem.c | 5 ++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index b6fc4f04636d..35bda544b334 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -25,6 +25,7 @@ * @align: allocation and mapping alignment for child dax devices * @res: physical address range of the region * @pfn_flags: identify whether the pfns are paged back or not + * @pgmap: backing page map for the device address range */ struct dax_region { int id; @@ -35,6 +36,7 @@ struct dax_region { unsigned int align; struct resource res; unsigned long pfn_flags; + struct dev_pagemap *pgmap; }; /** diff --git a/drivers/dax/device-dax.h b/drivers/dax/device-dax.h index 688b051750bd..1a2da8072a6e 100644 --- a/drivers/dax/device-dax.h +++ b/drivers/dax/device-dax.h @@ -19,7 +19,7 @@ struct dax_region; void dax_region_put(struct dax_region *dax_region); struct dax_region *alloc_dax_region(struct device *parent, int region_id, struct resource *res, unsigned int align, - void *addr, unsigned long flags); + void *addr, struct dev_pagemap *pgmap, unsigned long flags); struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, int id, struct resource *res, int count); #endif /* __DEVICE_DAX_H__ */ diff --git a/drivers/dax/device.c b/drivers/dax/device.c index de2f8297a210..2802d21a6e26 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -10,6 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ +#include #include #include #include @@ -101,7 +102,7 @@ static void dax_region_unregister(void *region) struct dax_region *alloc_dax_region(struct device *parent, int region_id, struct resource *res, unsigned int align, void *addr, - unsigned long pfn_flags) + struct dev_pagemap *pgmap, unsigned long pfn_flags) { struct dax_region *dax_region; @@ -130,6 +131,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id, dax_region->id = region_id; ida_init(&dax_region->ida); dax_region->align = align; + dax_region->pgmap = pgmap; dax_region->dev = parent; dax_region->base = addr; if (sysfs_create_groups(&parent->kobj, dax_region_attribute_groups)) { @@ -244,6 +246,15 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, return -1; } +static void dax_pfn_sync(struct dax_region *dax_region, pfn_t pfn, + unsigned long size) +{ + struct dev_pagemap *pgmap = dax_region->pgmap; + struct memmap_async_state *async = pgmap->async; + + memmap_sync(pfn, PHYS_PFN(size), async); +} + static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) { struct device *dev = &dev_dax->dev; @@ -273,6 +284,7 @@ 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); + dax_pfn_sync(dax_region, pfn, PAGE_SIZE); rc = vm_insert_mixed(vmf->vma, vmf->address, pfn); @@ -328,6 +340,7 @@ static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) } pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); + dax_pfn_sync(dax_region, pfn, PMD_SIZE); return vmf_insert_pfn_pmd(vmf->vma, vmf->address, vmf->pmd, pfn, vmf->flags & FAULT_FLAG_WRITE); @@ -379,6 +392,7 @@ static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf) } pfn = phys_to_pfn_t(phys, dax_region->pfn_flags); + dax_pfn_sync(dax_region, pfn, PUD_SIZE); return vmf_insert_pfn_pud(vmf->vma, vmf->address, vmf->pud, pfn, vmf->flags & FAULT_FLAG_WRITE); diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index 54cba20c8ba6..a05be7a03d02 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c @@ -11,6 +11,7 @@ * General Public License for more details. */ #include +#include #include #include #include @@ -110,6 +111,7 @@ static int dax_pmem_probe(struct device *dev) return rc; dax_pmem->pgmap.ref = &dax_pmem->ref; + dax_pmem->pgmap.async = &nd_pfn->async; addr = devm_memremap_pages(dev, &dax_pmem->pgmap, dax_pmem_percpu_kill); if (IS_ERR(addr)) return PTR_ERR(addr); @@ -123,7 +125,8 @@ static int dax_pmem_probe(struct device *dev) return -EINVAL; dax_region = alloc_dax_region(dev, region_id, &res, - le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); + le32_to_cpu(pfn_sb->align), addr, &dax_pmem->pgmap, + PFN_DEV|PFN_MAP); if (!dax_region) return -ENOMEM;