From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A59F32097DD18 for ; Mon, 16 Jul 2018 10:11:33 -0700 (PDT) Subject: [PATCH v2 14/14] libnvdimm, namespace: Publish page structure init state / control From: Dan Williams Date: Mon, 16 Jul 2018 10:01:35 -0700 Message-ID: <153176049568.12695.7468849534191505277.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: akpm@linux-foundation.org Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jack@suse.cz, hch@lst.de List-ID: 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 | 49 ++++++++++++++++++++++++++++++++++----------- mm/page_alloc.c | 1 + 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 147c62e2ef2b..15ab96e2a9b5 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,39 @@ 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 (!sysfs_streq(buf, "sync")) + 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_pages_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 +303,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 b9615a59d29d..2c87165594db 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5457,6 +5457,7 @@ void __ref build_all_zonelists(pg_data_t *pgdat) ASYNC_DOMAIN_EXCLUSIVE(memmap_init_domain); ASYNC_DOMAIN_EXCLUSIVE(memmap_pages_domain); +EXPORT_SYMBOL_GPL(memmap_pages_domain); static void __meminit memmap_init_one(unsigned long pfn, unsigned long zone, int nid, enum memmap_context context, struct dev_pagemap *pgmap) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm