linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Jiang Liu <jiang.liu@huawei.com>
Cc: Minchan Kim <minchan@kernel.org>,
	Keping Chen <chenkeping@huawei.com>, Mel Gorman <mgorman@suse.de>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Hugh Dickins <hughd@google.com>, Tony Luck <tony.luck@intel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Jiang Liu <liuj97@gmail.com>
Subject: Re: [PATCH] trivial, memory hotplug: add kswapd_is_running() for better readability
Date: Sat, 16 Jun 2012 19:19:03 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.1206161913370.797@chino.kir.corp.google.com> (raw)
In-Reply-To: <1339663776-196-1-git-send-email-jiang.liu@huawei.com>

On Thu, 14 Jun 2012, Jiang Liu wrote:

> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index c84ec68..36249d5 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -301,6 +301,11 @@ static inline void scan_unevictable_unregister_node(struct node *node)
>  
>  extern int kswapd_run(int nid);
>  extern void kswapd_stop(int nid);
> +static inline bool kswapd_is_running(int nid)
> +{
> +	return !!(NODE_DATA(nid)->kswapd);
> +}
> +
>  #ifdef CONFIG_CGROUP_MEM_RES_CTLR
>  extern int mem_cgroup_swappiness(struct mem_cgroup *mem);
>  #else
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 0d7e3ec..88e479d 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -522,7 +522,8 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages)
>  	init_per_zone_wmark_min();
>  
>  	if (onlined_pages) {
> -		kswapd_run(zone_to_nid(zone));
> +		if (!kswapd_is_running(zone_to_nid(zone)))
> +			kswapd_run(zone_to_nid(zone));
>  		node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
>  	}
>  
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7585101..3dafdbe 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2941,8 +2941,7 @@ int kswapd_run(int nid)
>  	pg_data_t *pgdat = NODE_DATA(nid);
>  	int ret = 0;
>  
> -	if (pgdat->kswapd)
> -		return 0;
> +	BUG_ON(pgdat->kswapd);
>  
>  	pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
>  	if (IS_ERR(pgdat->kswapd)) {

This isn't better, there's no functional change and you've just added a 
second conditional for no reason and an unnecessary kswapd_is_running() 
function.

More concerning is that online_pages() doesn't check the return value of 
kswapd_run().  We should probably fail the memory hotplug operation that 
onlines a new node and doesn't have a kswapd running and cleanup after 
ourselves in online_pages() with some sane error handling.

--
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>

  parent reply	other threads:[~2012-06-17  2:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  3:44 [PATCH] memory hotplug: fix invalid memory access caused by stale kswapd pointer Jiang Liu
2012-06-14  4:02 ` Kamezawa Hiroyuki
2012-06-14  5:31 ` Minchan Kim
2012-06-14  6:24   ` Jiang Liu
2012-06-14  8:49   ` [PATCH] trivial, memory hotplug: add kswapd_is_running() for better readability Jiang Liu
2012-06-14 11:48     ` Kamezawa Hiroyuki
2012-06-14 11:59     ` KOSAKI Motohiro
2012-06-14 15:04     ` Minchan Kim
2012-06-17  2:19     ` David Rientjes [this message]
2012-06-18  1:12       ` Minchan Kim
2012-06-18  8:25         ` KOSAKI Motohiro
2012-06-20  9:01       ` Jiang Liu
2012-06-14  5:41 ` [PATCH] memory hotplug: fix invalid memory access caused by stale kswapd pointer KOSAKI Motohiro
2012-06-15 14:28 ` Mel Gorman
2012-06-17  2:20 ` David Rientjes

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.00.1206161913370.797@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenkeping@huawei.com \
    --cc=hughd@google.com \
    --cc=jiang.liu@huawei.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuj97@gmail.com \
    --cc=mgorman@suse.de \
    --cc=minchan@kernel.org \
    --cc=tony.luck@intel.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