linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Nathan Zimmer <nzimmer@sgi.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Tang Chen <tangchen@cn.fujitsu.com>,
	Wen Congyang <wency@cn.fujitsu.com>,
	Toshi Kani <toshi.kani@hp.com>,
	Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
	Xishi Qiu <qiuxishi@huawei.com>,
	Cody P Schafer <cody@linux.vnet.ibm.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Jiang Liu <liuj97@gmail.com>, Hedi Berriche <hedi@sgi.com>,
	Mike Travis <travis@sgi.com>
Subject: Re: [RFC] Move the memory_notifier out of the memory_hotplug lock
Date: Wed, 5 Feb 2014 12:29:27 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1402051217520.5616@chino.kir.corp.google.com> (raw)
In-Reply-To: <1391617743-150518-1-git-send-email-nzimmer@sgi.com>

On Wed, 5 Feb 2014, Nathan Zimmer wrote:

> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 62a0cd1..a3cbd14 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -985,12 +985,12 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
>  		if (need_zonelists_rebuild)
>  			zone_pcp_reset(zone);
>  		mutex_unlock(&zonelists_mutex);
> +		unlock_memory_hotplug();
>  		printk(KERN_DEBUG "online_pages [mem %#010llx-%#010llx] failed\n",
>  		       (unsigned long long) pfn << PAGE_SHIFT,
>  		       (((unsigned long long) pfn + nr_pages)
>  			    << PAGE_SHIFT) - 1);
>  		memory_notify(MEM_CANCEL_ONLINE, &arg);
> -		unlock_memory_hotplug();
>  		return ret;
>  	}
>  
> @@ -1016,9 +1016,10 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
>  
>  	writeback_set_ratelimit();
>  
> +	unlock_memory_hotplug();
> +
>  	if (onlined_pages)
>  		memory_notify(MEM_ONLINE, &arg);
> -	unlock_memory_hotplug();
>  
>  	return 0;
>  }

That looks a little problematic, what happens if a nid is being brought 
online and a registered callback does something like allocate resources 
for the arg->status_change_nid and the above two hunks of this patch end 
up racing?

Before, a registered callback would be guaranteed to see either a 
MEMORY_CANCEL_ONLINE or MEMORY_ONLINE after it has already done 
MEMORY_GOING_ONLINE.

With your patch, we could race and see one cpu doing MEMORY_GOING_ONLINE, 
another cpu doing MEMORY_GOING_ONLINE, and then MEMORY_ONLINE and 
MEMORY_CANCEL_ONLINE in either order.

So I think this patch will break most registered callbacks that actually 
depend on lock_memory_hotplug(), it's a coarse lock for that reason.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2014-02-05 20:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 16:29 Nathan Zimmer
2014-02-05 20:29 ` David Rientjes [this message]
2014-02-05 23:10   ` Nathan Zimmer
2014-02-05 23:20     ` David Rientjes
2014-02-06 16:09       ` Nathan Zimmer
2014-02-07  9:30         ` Jiang Liu

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=alpine.DEB.2.02.1402051217520.5616@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cody@linux.vnet.ibm.com \
    --cc=hedi@sgi.com \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuj97@gmail.com \
    --cc=nzimmer@sgi.com \
    --cc=qiuxishi@huawei.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tangchen@cn.fujitsu.com \
    --cc=toshi.kani@hp.com \
    --cc=travis@sgi.com \
    --cc=wency@cn.fujitsu.com \
    /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