Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp295198imm; Thu, 5 Jul 2018 00:01:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcBVqE1ykp5gBkQv1feGCx86CCCYxoqE0ldMEjOgArpM87iYSlTw7GIcWvC+tfuKJqQ/r2J X-Received: by 2002:a62:1e81:: with SMTP id e123-v6mr5083773pfe.188.1530774080051; Thu, 05 Jul 2018 00:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530774080; cv=none; d=google.com; s=arc-20160816; b=hS3DqUXbAaY3ASi2mGjzeT+eciCC1qIE3PgYkt4nZujH/t+zPjd01g+8KYqC5A+Ut2 0nTI4rq/ByevdJAaFHj48RqxBhZ0cOAbO8VeU5u5VVnogYmhwK4cScf0OxEiGF2SuCTu Ghp77x/DcDFy9BloOi5IitQpKcoEWdpruayLSgYghQKvHdDypnSrX/6Oi0zhLyma9rVu W/93i5Kh2X2W5a0p1uQNiGVwS2QssRw2Iq8zd7YBP8tH/ao11UA4pMYsSJD31SBf7BIe uhBAYT2MDZDDJ2phV0+fkiPYsUSmEwE9NiOC3OeYgqHczKSDSY98/ne66Xk6D8Elx6NS z9Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=B1zYGOdfM52oJ3dpwUbiA6dKKRxXPJCpr3P8OihlQN8=; b=JJ0TvvqnZINx6uvEXqazzD+6ja99RXv6fCLCKM1OePK3ig9Mhrv+uxhKwhVTv/W1w1 UGSQwL/8DecGkiuQhH6O1iTx4/L3kfr85eZVhxvCFiDAlnk/uswxCGpiyr9/Q8wrhvQR MdRm6KBAyaz3ZfuxinxCHyEeJhoOHT/0ysYEaP6l7SOdkUVnmKfAYx4BHcaTxK7o9yTN a2sDhiiSVyzR/7XPgu+4kkL9W9L/vSeq726rf+e0AUxR3yVwMIbSV4YRX0j1gNdwz+Nv zIbwEokjxD9hj7PY8r0HwL+6Yp3S4UsdG1jJS+l0zzpaP5W938GusFfTScMugmnVCRCg rrkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si5948826pfd.76.2018.07.05.00.01.05; Thu, 05 Jul 2018 00:01:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753672AbeGEHAN (ORCPT + 99 others); Thu, 5 Jul 2018 03:00:13 -0400 Received: from mga12.intel.com ([192.55.52.136]:30789 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753648AbeGEHAL (ORCPT ); Thu, 5 Jul 2018 03:00:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jul 2018 00:00:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="70215986" 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; 05 Jul 2018 00:00:10 -0700 Subject: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control From: Dan Williams To: akpm@linux-foundation.org Cc: Ross Zwisler , Vishal Verma , Dave Jiang , Johannes Thumshirn , Jeff Moyer , hch@lst.de, linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 04 Jul 2018 23:50:13 -0700 Message-ID: <153077341292.40830.11333232703318633087.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applications may want to know that page structure initialization is complete rather than be subject to delays at first DAX fault. Also, page structure initialization consumes CPU resources impacting application performance, so a environment may want to wait before considering the system fully initialized. Provide a sysfs attribute to display the current state, and when written with 'sync' complete memmap initialization. Cc: Ross Zwisler Cc: Vishal Verma Cc: Dave Jiang Cc: Johannes Thumshirn Cc: Jeff Moyer Signed-off-by: Dan Williams --- drivers/nvdimm/pfn_devs.c | 53 +++++++++++++++++++++++++++++++++++---------- mm/page_alloc.c | 1 + 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 147c62e2ef2b..00f1792d070c 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -1,15 +1,6 @@ -/* - * Copyright(c) 2013-2016 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2013-2018 Intel Corporation. All rights reserved. */ +#include #include #include #include @@ -103,6 +94,43 @@ static ssize_t mode_store(struct device *dev, } static DEVICE_ATTR_RW(mode); +static ssize_t memmap_state_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); + struct memmap_async_state *async = &nd_pfn->async; + + return sprintf(buf, "%s\n", bitmap_weight(async->active, + NR_MEMMAP_THREADS) ? "active" : "idle"); +} + +static ssize_t memmap_state_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + int i; + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); + struct memmap_async_state *async = &nd_pfn->async; + + if (strcmp(buf, "sync") == 0) + /* pass */; + else if (strcmp(buf, "sync\n") == 0) + /* pass */; + else + return -EINVAL; + + for (i = 0; i < NR_MEMMAP_THREADS; i++) { + struct memmap_init_pages *thread = &async->page_init[i]; + + if (!test_bit(i, async->active)) + continue; + async_synchronize_cookie_domain(thread->cookie, + &memmap_init_domain); + } + + return len; +} +static DEVICE_ATTR_RW(memmap_state); + static ssize_t align_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -279,6 +307,7 @@ static struct attribute *nd_pfn_attributes[] = { &dev_attr_resource.attr, &dev_attr_size.attr, &dev_attr_supported_alignments.attr, + &dev_attr_memmap_state.attr, NULL, }; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d1466dd82bc2..90414c1d2ca8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5456,6 +5456,7 @@ void __ref build_all_zonelists(pg_data_t *pgdat) } ASYNC_DOMAIN_EXCLUSIVE(memmap_init_domain); +EXPORT_SYMBOL_GPL(memmap_init_domain); static void __meminit memmap_init_one(unsigned long pfn, unsigned long zone, int nid, enum memmap_context context, struct dev_pagemap *pgmap)