Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4174178imm; Mon, 8 Oct 2018 16:35:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV60kbxcY1JJfuHReg7xkKfk6sjv0mluFNvL5pvnL1wRMEayBfn6vaB3gkTr2Ccr+/qz3SJ1e X-Received: by 2002:a17:902:694a:: with SMTP id k10-v6mr25815793plt.166.1539041712109; Mon, 08 Oct 2018 16:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539041712; cv=none; d=google.com; s=arc-20160816; b=I13r3keclzhUcaaXPfLT2+oMCxd+ryndxNX6cRgqm57e0th6yDNURUsA2Hwoaxl7MC aLZ6Ltg5Cs4Bw3TDP+jOefEW3J1GpnmXVjHKsKb9g2qht6yOWUmPRMc3CfWpw2MPcj10 DFQXAT30wH8PnbD7NhNUaN1aaeMnJkgibOxwrmxxEmyG+8iLtQ4pTxCqSjpKNAhnO7xi ObESO6p3VLWysyi7g+gKF0TM7q+VT8NyowQ42Ob9wnJSohRPqZLIr6fBslzjauJuVc4N cyAhyjgk9s9Vo2thrCFNoS6c2Oc1yxME0W45D4sPSTkB8PdnYL/6AeaheO5My4vWZo7r zTfA== 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; bh=mA5wrM9N2fs8SFERSwjxva0cK8hIoIR1uorEAihoC68=; b=mvgjoYlNHfdw4Sx7RPn1mz4wCQaVzXf6AllXkPZKHu7eUWXH4zjGAPjZlM3o804G5s vAV341b2RM+q4XEKOX5zi/3PjetoM8P159Q0ubuKO3od2MnJ8ANaCx/9EFcrzuNJdcnv ndtrnMOhNHv14PoQbZtjKzH+YpRhTgfhaYahZ3dkuWqsq8xGm8c+4MxSMsH6c5wQVN8d 07RKc+JpSAJ6g+Nf2vh5gzleIwzkKPZfLN7a/dMw/UVLIYL9CrJkghDEbMH7+6F3H+ac NeUIZicKxOeAESFXMiLZe1y8vkLQmbT9ez+RgxL+H8s9uMMmES9ROv2QHbIVKbNRzOwo TBpg== 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 p188-v6si21012124pfg.197.2018.10.08.16.34.56; Mon, 08 Oct 2018 16:35:12 -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 S1725887AbeJIGsm (ORCPT + 99 others); Tue, 9 Oct 2018 02:48:42 -0400 Received: from mga14.intel.com ([192.55.52.115]:46544 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725759AbeJIGsm (ORCPT ); Tue, 9 Oct 2018 02:48:42 -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 fmsmga103.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 Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, dave.jiang@intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, jglisse@redhat.com, alexander.h.duyck@linux.intel.com, logang@deltatee.com, mingo@kernel.org, kirill.shutemov@linux.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 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 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 --- 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);