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: 10631673 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 C6DD217E3 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 B82AB29684 for ; Mon, 8 Oct 2018 23:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABAF62969A; Mon, 8 Oct 2018 23:34:38 +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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4736229684 for ; Mon, 8 Oct 2018 23:34:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F0AE6B0003; Mon, 8 Oct 2018 19:34:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 19FD16B0005; Mon, 8 Oct 2018 19:34:37 -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 0903E6B0006; Mon, 8 Oct 2018 19:34:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id BB73D6B0003 for ; Mon, 8 Oct 2018 19:34:36 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id d22-v6so18819004pfn.3 for ; Mon, 08 Oct 2018 16:34:36 -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=mA5wrM9N2fs8SFERSwjxva0cK8hIoIR1uorEAihoC68=; b=Oc+Y5FISSilcuK7fopgZKVsDcMaymyTtlib32zo4ZTC5X+PqWBdYX385uk4pwbPV8i PiTJ0oLhoHv/c1Do6TKQwUkVHWZ/WPqU+ezTiKxnNSYXNlgry7Nwpw8BliYZKSYTTNDl 8LJM9GNFyqOsR+9YNdEUa6GVe1N/yba2jAixBhfcdKanikylamNrWe/5yrbS0v6Z0jE4 0L5iLoK/dwDUmQWRZEITPiCNTL54jEjBZGGszLlpQRXuwwsAF1p2cSjjc4nEjhAxjns0 kJ99JT8epBX2MzHHw1Xmh4elLZpM7uQiZHkoNKgDkeEEUn61r8RggHlJpGjR1kRPSURS P37g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfoiytnfqBJDejmTaNTwhAJmzDwbpjvvNjAxkDMOBYXpllprfn7ZL uh5xNsq4RIDfMGEgi1ekif+G3xiCCueez7hCXgnLFzf7Tx16PgSMG7jxnuml/45+t+eh6QkBrH9 BgLpzGGp+PzGRAvMD9YauTIRgdJCZeI6mIuFjvzYMtKjado4mXMH/K9bWFyL2QxdNXg== X-Received: by 2002:a17:902:6848:: with SMTP id f8-v6mr26345290pln.27.1539041676397; Mon, 08 Oct 2018 16:34:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV63lhkqsUs3BKRWHsZx51CSaR5eh21fJWG40SUusdQEkEmld86dEZ5QojoTrwx2K49W8Hjiu X-Received: by 2002:a17:902:6848:: with SMTP id f8-v6mr26345235pln.27.1539041675589; Mon, 08 Oct 2018 16:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539041675; cv=none; d=google.com; s=arc-20160816; b=XvL/2I0TQDyuyCHORDvFUBUuRqkxLwpU3jPCByxeEsNfOksZBrHTrpsx7Cf2DVDPyX YladnffvmqOtNlmqXBjRfYYHPY56J/lcADPWL/XUWTh9FVjmUEXIRrFtgZM0H8dbnFfe 4sgvM2q7Y0szG9D/vDIDwkNVuX/JSuZ76xgOcPA/Rgj3FRu4nwTIZt/lgSJ4I36R+cCd T76GzN0ay6s4gzuCvf9GmBRDA4/Q1kJKRBqIDHEwEc3zkIGI5bIe2LAceK2sfZ20MjCK mmTDH0leaSiNMne0OZGhsqb7K02hMc3cmwthOtj7NJw8DUfPfViSDGy3D+ngl+sB3Zck 67+A== 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; bh=mA5wrM9N2fs8SFERSwjxva0cK8hIoIR1uorEAihoC68=; b=Qg63v9kX+D/ze8jzeB8XndOXwupFgJRLEbkadqD+GKaBh3xpHwjb/ssutjNv5aVhGD 3YkY0JJW2IetIJlAj2x3PumZ7R+pFsk85Ehq9xzb8vBPsfzv/8tKKf98gaPi4yVBGNV0 DPz9LUddYkxuYmNeaJbIqbqrHtBl/uzCUlyx9r0W2A962y/RkIupW1hsUloPclPuuXR0 Mv9orl4DLtqx7OoXv8+wZKx0GDtETohM2525vvBK4khyMhyISJNPs/XHkG1BL70Tqp1m 0ec7c+mRadvbRNPWSpZyG5e6VZKsrYoNK15/5GEZgdTuhGgp8lCvr23avzhH2nXAEEZW PsRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id k63-v6si18389639pge.175.2018.10.08.16.34.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 16:34:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (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 orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.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 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 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);