From patchwork Mon Oct 8 23:34:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10631671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2076E15E2 for ; Mon, 8 Oct 2018 23:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06DA129684 for ; Mon, 8 Oct 2018 23:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9572969A; Mon, 8 Oct 2018 23:34: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=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A0F7829684 for ; Mon, 8 Oct 2018 23:34:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D0C7521A07A92; Mon, 8 Oct 2018 16:34:36 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=alexander.h.duyck@linux.intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 45DBB21DF8098 for ; Mon, 8 Oct 2018 16:34:35 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2018 16:34:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,358,1534834800"; d="scan'208";a="97639761" Received: from ahduyck-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.7.198.166]) by orsmga001.jf.intel.com with ESMTP; 08 Oct 2018 16:34:34 -0700 Subject: [mm PATCH] memremap: Fix reference count for pgmap in devm_memremap_pages From: Alexander Duyck To: linux-mm@kvack.org, akpm@linux-foundation.org, dan.j.williams@intel.com Date: Mon, 08 Oct 2018 16:34:33 -0700 Message-ID: <20181008233404.1909.37302.stgit@localhost.localdomain> In-Reply-To: References: User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, jglisse@redhat.com, alexander.h.duyck@linux.intel.com, mingo@kernel.org, kirill.shutemov@linux.intel.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP In the earlier patch "mm: defer ZONE_DEVICE page initialization to the point where we init pgmap" I had overlooked the reference count that was being held per page on the pgmap. As a result on running the ndctl test "create.sh" we would call into devm_memremap_pages_release and encounter the following percpu reference count error and hang: WARNING: CPU: 30 PID: 0 at lib/percpu-refcount.c:155 percpu_ref_switch_to_atomic_rcu+0xf3/0x120 This patch addresses that by performing an update for all of the device PFNs in a single call. In my testing this seems to resolve the issue while still allowing us to retain the improvements seen in memory initialization. Reported-by: Dan Williams Signed-off-by: Alexander Duyck Tested-by: Dan Williams --- kernel/memremap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/memremap.c b/kernel/memremap.c index 6ec81e0d7a33..9eced2cc9f94 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -218,6 +218,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE], align_start >> PAGE_SHIFT, align_size >> PAGE_SHIFT, pgmap); + percpu_ref_get_many(pgmap->ref, pfn_end(pgmap) - pfn_first(pgmap)); devm_add_action(dev, devm_memremap_pages_release, pgmap);