All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Pavel Emelianov <xemul@openvz.org>,
	Paul Menage <menage@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH] memcg: fix oops in oom handling
Date: Mon, 14 Apr 2008 15:24:20 +0800	[thread overview]
Message-ID: <480306A4.8080700@cn.fujitsu.com> (raw)
In-Reply-To: <20080414161428.27f3ee59.kamezawa.hiroyu@jp.fujitsu.com>

KAMEZAWA Hiroyuki wrote:
> On Mon, 14 Apr 2008 14:52:00 +0800
> Li Zefan <lizf@cn.fujitsu.com> wrote:
>> It's reproducable in a x86_64 box, but doesn't happen in x86_32.
>>
>> This is because tsk->sighand is not guarded by RCU, so we have to
>> hold tasklist_lock, just as what out_of_memory() does.
>>
> 
> Good catch! and patch seems good.
> 
> Paul, I have one confirmation. Lock hierarchy of
> 	cgroup_lock()
> 	->	read_lock(&tasklist_lock)
> 
> is ok ? (I think this is ok.)
> 

I think so, because we used to have this in cgroup:

mutex_lock(&cgroup_mutex);
  -> attach_task_by_pid()
       -> read_lock(&tasklist_lock)

But afte some time, some uses of tasklist_lock is replaced by rcu.

> Thanks,
> -Kame
> 
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu>
>> ---
>>  mm/oom_kill.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index f255eda..beb592f 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -423,7 +423,7 @@ void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask)
>>  	struct task_struct *p;
>>  
>>  	cgroup_lock();
>> -	rcu_read_lock();
>> +	read_lock(&tasklist_lock);
>>  retry:
>>  	p = select_bad_process(&points, mem);
>>  	if (PTR_ERR(p) == -1UL)
>> @@ -436,7 +436,7 @@ retry:
>>  				"Memory cgroup out of memory"))
>>  		goto retry;
>>  out:
>> -	rcu_read_unlock();
>> +	read_unlock(&tasklist_lock);
>>  	cgroup_unlock();
>>  }
>>  #endif
>> -- 1.5.4.rc3 
>>
>>
>>
>>
> 

WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizf@cn.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Pavel Emelianov <xemul@openvz.org>,
	Paul Menage <menage@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH] memcg: fix oops in oom handling
Date: Mon, 14 Apr 2008 15:24:20 +0800	[thread overview]
Message-ID: <480306A4.8080700@cn.fujitsu.com> (raw)
In-Reply-To: <20080414161428.27f3ee59.kamezawa.hiroyu@jp.fujitsu.com>

KAMEZAWA Hiroyuki wrote:
> On Mon, 14 Apr 2008 14:52:00 +0800
> Li Zefan <lizf@cn.fujitsu.com> wrote:
>> It's reproducable in a x86_64 box, but doesn't happen in x86_32.
>>
>> This is because tsk->sighand is not guarded by RCU, so we have to
>> hold tasklist_lock, just as what out_of_memory() does.
>>
> 
> Good catch! and patch seems good.
> 
> Paul, I have one confirmation. Lock hierarchy of
> 	cgroup_lock()
> 	->	read_lock(&tasklist_lock)
> 
> is ok ? (I think this is ok.)
> 

I think so, because we used to have this in cgroup:

mutex_lock(&cgroup_mutex);
  -> attach_task_by_pid()
       -> read_lock(&tasklist_lock)

But afte some time, some uses of tasklist_lock is replaced by rcu.

> Thanks,
> -Kame
> 
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu>
>> ---
>>  mm/oom_kill.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index f255eda..beb592f 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -423,7 +423,7 @@ void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask)
>>  	struct task_struct *p;
>>  
>>  	cgroup_lock();
>> -	rcu_read_lock();
>> +	read_lock(&tasklist_lock);
>>  retry:
>>  	p = select_bad_process(&points, mem);
>>  	if (PTR_ERR(p) == -1UL)
>> @@ -436,7 +436,7 @@ retry:
>>  				"Memory cgroup out of memory"))
>>  		goto retry;
>>  out:
>> -	rcu_read_unlock();
>> +	read_unlock(&tasklist_lock);
>>  	cgroup_unlock();
>>  }
>>  #endif
>> -- 1.5.4.rc3 
>>
>>
>>
>>
> 

--
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:[~2008-04-14  7:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14  6:52 [PATCH] memcg: fix oops in oom handling Li Zefan
2008-04-14  6:52 ` Li Zefan
2008-04-14  7:14 ` KAMEZAWA Hiroyuki
2008-04-14  7:14   ` KAMEZAWA Hiroyuki
2008-04-14  7:24   ` Li Zefan [this message]
2008-04-14  7:24     ` Li Zefan
2008-04-14  7:53   ` Paul Menage
2008-04-14  7:53     ` Paul Menage
2008-04-14  8:07     ` Li Zefan
2008-04-14  8:07       ` Li Zefan
2008-04-14  9:20       ` Li Zefan
2008-04-14  9:20         ` Li Zefan
2008-04-14  7:24 ` KAMEZAWA Hiroyuki
2008-04-14  7:24   ` KAMEZAWA Hiroyuki
2008-04-14  7:48   ` Andrew Morton
2008-04-14  7:48     ` Andrew Morton
2008-04-14  7:55 ` Balbir Singh
2008-04-14  7:55   ` Balbir Singh

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=480306A4.8080700@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=xemul@openvz.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.