mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
To: Dan Williams <dan.j.williams@intel.com>, <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>, <linux-nvdimm@ml01.01.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
	Ben Hutchings <ben@decadent.org.uk>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH 0/2] fix devm_memremap_pages() mem hotplug locking
Date: Mon, 13 Feb 2017 10:25:57 +0900	[thread overview]
Message-ID: <58A10B25.6030508@jp.fujitsu.com> (raw)
In-Reply-To: <148693885124.16345.14319993365448440148.stgit@dwillia2-desk3.amr.corp.intel.com>

Hi Dan,

On Sun, 12 Feb 2017 14:34:11 -0800 Dan Williams wrote:
> Ben notes that commit f931ab479dd2 "mm: fix devm_memremap_pages crash,
> use mem_hotplug_{begin, done}" is incomplete and broken. Writes to
> mem_hotplug.active_writer need to be coordinated under the device
> hotplug lock. Otherwise, we can potentially corrupt mem_hotplug.refcount
> leading to soft lockups.

I think mem_hotplug_{begin,done} is not suitable to exclude devm_memremap_pages()
because it seems that memory hotplug is not related to this context.
How about using pgmap_lock instead?

Like this:

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 9ecedc2..e9b9cfa 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -246,9 +246,9 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
  	/* pages are dead and unused, undo the arch mapping */
  	align_start = res->start & ~(SECTION_SIZE - 1);
  	align_size = ALIGN(resource_size(res), SECTION_SIZE);
-	mem_hotplug_begin();
+	mutex_lock(&pgmap_lock);
  	arch_remove_memory(align_start, align_size);
-	mem_hotplug_done();
+	mutex_unlock(&pgmap_lock);
  	untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
  	pgmap_radix_release(res);
  	dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc,
@@ -360,9 +360,9 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
  	if (error)
  		goto err_pfn_remap;
  
-	mem_hotplug_begin();
+	mutex_lock(&pgmap_lock);
  	error = arch_add_memory(nid, align_start, align_size, true);
-	mem_hotplug_done();
+	mutex_unlock(&pgmap_lock);
  	if (error)
  		goto err_add_memory;
  
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-13  1:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-12 22:34 Dan Williams
2017-02-12 22:34 ` [PATCH 1/2] mm, devm_memremap_pages: hold device_hotplug lock over mem_hotplug_{begin, done} Dan Williams
2017-02-12 22:34 ` [PATCH 2/2] mm: validate device_hotplug is held for memory hotplug Dan Williams
2017-02-13  1:25 ` Masayoshi Mizuma [this message]
2017-02-13  1:35   ` [PATCH 0/2] fix devm_memremap_pages() mem hotplug locking Dan Williams
2017-02-15  0:24     ` Masayoshi Mizuma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58A10B25.6030508@jp.fujitsu.com \
    --to=m.mizuma@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=ben@decadent.org.uk \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@ml01.01.org \
    --cc=mhocko@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®