From patchwork Mon Jul 16 17:01:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527293 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 5A848601D2 for ; Mon, 16 Jul 2018 17:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 464E428D80 for ; Mon, 16 Jul 2018 17:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AB2528D8F; Mon, 16 Jul 2018 17:11:37 +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 BCD8B28D80 for ; Mon, 16 Jul 2018 17:11:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62E576B027D; Mon, 16 Jul 2018 13:11:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5938B6B027E; Mon, 16 Jul 2018 13:11:35 -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 3C0116B0280; Mon, 16 Jul 2018 13:11:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id E0C2B6B027D for ; Mon, 16 Jul 2018 13:11:34 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id d22-v6so7330095pls.4 for ; Mon, 16 Jul 2018 10:11:34 -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=km39zmqn61dXIJ8mTMNgmGoDI5aDFgE98SuQ+shybe4=; b=OzRbJwXRb8e+Rsd004lp2seZj3wuojc+u5lRuL192PWGvw6jSwOb7DTEPUJqkpWshN UaTUuY4wDxopabMAN0fH+dA3XEm9/hhr7OL6EJOJnI3IOEa5s4XL/Ezy2OF72MFPJP02 8yMTvhvS2CIpDpDol8FcdRzUQYtl15uL+dslIEE/lBgcDwWfhVHXFyAaisDsYcYs2dtT QsCcBCNlgyMBd2+PkZFfhraK/ita9nLyeWKT/fj3ibijGcP+TfPZ1DgOBqdnbswyvEEF h61FJiLFAPcXYGmiUGQphogaZrLMSgk8Zpc359M+MS+KoNnAZLRji/RdykkofQNpaS96 nq4g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.65 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: AOUpUlFnvmqXUE8tVBWhpeMG6qE5aNZQ6xtcIdUYOGhDJfyIZXPfTLWy CwpUOfFW1cwMiB6AH4oQh5YG64dJDOmx4+6W0QkvxjrWZjW4hhdGZlGfdtPg2dt7TbtZAV8PZdA tTeC+giVugYmgSAOkT5CuNxUl976EwEDY/4MvmbZ47A4mZC71jaf9iIg1RJfWYN9dWA== X-Received: by 2002:a65:55c6:: with SMTP id k6-v6mr16157101pgs.6.1531761094596; Mon, 16 Jul 2018 10:11:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcywKgDGr0kmVK0w8LW/SfptO/kMfyaMKfDC7i5H1lfnY6Zxdt1RnaCWO7vR09TUg/mfCbs X-Received: by 2002:a65:55c6:: with SMTP id k6-v6mr16157065pgs.6.1531761093869; Mon, 16 Jul 2018 10:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761093; cv=none; d=google.com; s=arc-20160816; b=Wj6MJ6gsL/7oXP3Z81aQ61GbT7upU7xKwUKKxYQP+J6ub7fImCGZoOmr8Lc2GgGJk0 jebP1E6OAm3U8MEs9GpR3/Vp3gc3Fmr/vdDFeZBy/MIbX/mIwlFaElhx6PwNullIU0Mr ZDhma9GMPnQQviPcqcJAWn7+vivceWgLKT9OsXGqvvizFaVZ1C75dpAxmttn5ImBqKPl kdQnT9osTYVgPs/OoR11aai0TXgjJnwKROGGqottyy9NMBBr7+SYnPw6JXwP5xCtF22A ZQZKSgf/YOhRdC1sXkGx10ORQwgA4dn/KdkcaLfGuk80hNZ+9uc6cvgox75BQhFvVEXb dllg== 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=km39zmqn61dXIJ8mTMNgmGoDI5aDFgE98SuQ+shybe4=; b=SdPgaRecdrlfXIRCCLgm9UEYbRt1MtsYr9cGvUd70C2bvMblK1L/xeyU5z48swyRPa NdC3W4YoLc8TP7Le8Jzjxu8CLi4QaXxYAUEzRSgV8sppU0Yg3g9/35IYK5QVB8ldNrBY /aHbDWhJ7yGqkRX+RxctotWpROeQV5JHJagiMmKCdG6TQrpp0RwbgfjcR6zdbBAv4cg/ lUmtwKuMQCwlZ9zbgm5S4C/5bIOSZbH/ilwx5snBRTrcKpt/Fwv+B1BYVVLv8Epdly+G 64sacr6svkLI5pEfBJNHVNCcfP+K5JzYZBCsxuCZv0Q/ZBycEMfrvYqyC9lj/OrU16P5 cdpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga03.intel.com (mga03.intel.com. [134.134.136.65]) by mx.google.com with ESMTPS id m14-v6si6351177pgc.368.2018.07.16.10.11.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) client-ip=134.134.136.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.65 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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:11:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="75224321" 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; 16 Jul 2018 10:11:33 -0700 Subject: [PATCH v2 14/14] 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-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org 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> 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 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)