From patchwork Thu Jul 5 06:50:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10508277 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 3D09660116 for ; Thu, 5 Jul 2018 07:00:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29FE628E01 for ; Thu, 5 Jul 2018 07:00:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E38328E66; Thu, 5 Jul 2018 07:00:10 +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 8C4A328E01 for ; Thu, 5 Jul 2018 07:00:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 824D86B027B; Thu, 5 Jul 2018 03:00:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7D6C86B027C; Thu, 5 Jul 2018 03:00:07 -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 6EB826B027D; Thu, 5 Jul 2018 03:00:07 -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 2AE246B027B for ; Thu, 5 Jul 2018 03:00:07 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id s3-v6so1419687plp.21 for ; Thu, 05 Jul 2018 00:00:07 -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=sl6QnN38Epn5S0XD53yLL7zvAonxK5ZxsWnWF4J2MK2ohm8mX4/rMDkDHzYzF+fSda B/aw8eQktcdJtWipaYTQqNKZAWB0tH3UYIMppx7X08zdlDPL8TnV18RF+f92IACmuN+a hZvB7QsjjPTBgPdEecpPJk3QJwYPsvRhh7z2/FWAv0usHNU/g+Q6v2nvZBEkj+szEbA9 UrAAjxTogxurnbd0DCh+CADvyRGr3YCLj3e7hasoMKMQoN5SrfyAKS4Q2sXyvyVxMyLY BrQRZUgmMgx0jZcgCks/lqIbOLQXXQAp1hlvojtGMXdDZB8N8RbUlILD83aU6/w/Tpq0 HJ8A== 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: APt69E19erqZqqIxMenn2UYR5VBtCvx4uEBZVZQRsDJ53K1hTOXm2cdC r+WnI3kwt/GExMRjoZTEV3exArbKJQujxSbwGMe7T7Yt7XMvatyP1fKfazwyRMhsRCJe/ZLqphh dMqaenhzPsAhKMJJ4OAg4wjISccxbVvI4jeFybo32fBEbZEtqG+4ljbeBKr8jPn8oVQ== X-Received: by 2002:a62:f0d:: with SMTP id x13-v6mr4028410pfi.123.1530774006846; Thu, 05 Jul 2018 00:00:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdrgv5MvYeq4E1QVaadbEBifR0Q9IV4GfmAcKPEkST2Gvhk1HXirevhbgqNUHhSpsoSScOU X-Received: by 2002:a62:f0d:: with SMTP id x13-v6mr4028345pfi.123.1530774005932; Thu, 05 Jul 2018 00:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530774005; cv=none; d=google.com; s=arc-20160816; b=lwEZJeeuv+zaadrRlJtlf4gtgEIWqh+1IZFTGQlZUD7c1v+DV3aH8v55qoLJFaAszn yCkay2x84W0R3Kvom1jn3Ys+xghQCtHySijjUpalnO9ImIuBclSx1J+8JjVyifiBT86+ 8nm/vrDyH3ikm/fxUFUaQBV64p/s/GwJ7cerIA4ihXOTvNvfx8V5CYl9L/Jp3KBui8/S Xj403cVu0iX0BlmvkEAUgaNRi522CkCx1r+jHkzpQh093sjlV18E6+ZalHI6oLN6jfcY xmrClHjWSY8U9Ft6FRCN4wDQpB785nA0wX9LbNrYaIykTI/jbjbUtxio0IshJfIcGVmt w/6Q== 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=w/SbTJnCi8LOJ6Dw/AQo97gCIuHnjFppbiVaCh82CVyPBECI3IJFkUtrm9kI5F5fLy gBDqKOY3/UeLPGJmCDCaTvcw3dpWHDMqjVXFFH7+7z+CuQZ4Wwyo0DGlQyouMiHiKTdY v0TubHKM1CfuOidhhct96DCbpct/HW4ZpzfwSAF3K/czrPQONa0a/6jw3no0+raGxO1W UVvOqNxknFBWGDJwwemIOZ19246VweAAKY38/u5GnXJ5/gXgvP2zO6azxzjY8t0wPyyx RLMvUu6eCPiZGPTB7sKTydwqtsKO59bN3p5W3rNDsoAk/k8v2IfL6IwALPbHtc4bIiaw N6Cg== 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 d30-v6si5134907pla.64.2018.07.05.00.00.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 00:00:05 -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; 05 Jul 2018 00:00:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="64302407" 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; 05 Jul 2018 00:00:05 -0700 Subject: [PATCH 12/13] 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-nvdimm@lists.01.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 04 Jul 2018 23:50:07 -0700 Message-ID: <153077340620.40830.18398670365019815228.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153077334130.40830.2714147692560185329.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;