linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
	"kirill@shutemov.name" <kirill@shutemov.name>
Subject: Re: [PATCH 2/3] memcg: oom notifier
Date: Tue, 16 Mar 2010 09:00:27 +0900	[thread overview]
Message-ID: <20100316090027.95a8943d.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20100315145420.07f2bbe5.akpm@linux-foundation.org>

On Mon, 15 Mar 2010 14:54:20 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Fri, 12 Mar 2010 14:34:35 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> 
> > +static int mem_cgroup_oom_register_event(struct cgroup *cgrp,
> > +	struct cftype *cft, struct eventfd_ctx *eventfd, const char *args)
> > +{
> > +	struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +	struct mem_cgroup_eventfd_list *event;
> > +	int type = MEMFILE_TYPE(cft->private);
> > +	int ret = -ENOMEM;
> > +
> > +	BUG_ON(type != _OOM_TYPE);
> > +
> > +	mutex_lock(&memcg_oom_mutex);
> > +
> > +	event = kmalloc(sizeof(*event),	GFP_KERNEL);
> > +	if (!event)
> > +		goto unlock;
> > +
> > +	event->eventfd = eventfd;
> > +	list_add(&event->list, &memcg->oom_notify);
> > +
> > +	/* already in OOM ? */
> > +	if (atomic_read(&memcg->oom_lock))
> > +		eventfd_signal(eventfd, 1);
> > +	ret = 0;
> > +unlock:
> > +	mutex_unlock(&memcg_oom_mutex);
> > +
> > +	return ret;
> > +}
> 
> We can move that kmalloc() outside the lock.  It's more scalable and the
> code's cleaner.
> 
Agreed. Thank you for pointing out.


-Kame


> --- a/mm/memcontrol.c~memcg-oom-notifier-fix
> +++ a/mm/memcontrol.c
> @@ -3603,27 +3603,23 @@ static int mem_cgroup_oom_register_event
>  	struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
>  	struct mem_cgroup_eventfd_list *event;
>  	int type = MEMFILE_TYPE(cft->private);
> -	int ret = -ENOMEM;
>  
>  	BUG_ON(type != _OOM_TYPE);
>  
> -	mutex_lock(&memcg_oom_mutex);
> -
>  	event = kmalloc(sizeof(*event),	GFP_KERNEL);
>  	if (!event)
> -		goto unlock;
> +		return -ENOMEM;
>  
> +	mutex_lock(&memcg_oom_mutex);
>  	event->eventfd = eventfd;
>  	list_add(&event->list, &memcg->oom_notify);
>  
>  	/* already in OOM ? */
>  	if (atomic_read(&memcg->oom_lock))
>  		eventfd_signal(eventfd, 1);
> -	ret = 0;
> -unlock:
>  	mutex_unlock(&memcg_oom_mutex);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  static int mem_cgroup_oom_unregister_event(struct cgroup *cgrp,
> _
> 
> 

--
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:[~2010-03-16  0:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12  5:31 [PATCH 1/3] memcg: oom wakeup filter KAMEZAWA Hiroyuki
2010-03-12  5:34 ` [PATCH 2/3] memcg: oom notifier KAMEZAWA Hiroyuki
2010-03-12  5:37   ` [PATCH 3/3] memcg: oom kill disable and oom status KAMEZAWA Hiroyuki
2010-03-15 22:00     ` Andrew Morton
2010-03-16  0:03       ` KAMEZAWA Hiroyuki
2010-03-15 21:54   ` [PATCH 2/3] memcg: oom notifier Andrew Morton
2010-03-16  0:00     ` KAMEZAWA Hiroyuki [this message]
2010-03-15 21:50 ` [PATCH 1/3] memcg: oom wakeup filter Andrew Morton
2010-03-16  0:01   ` KAMEZAWA Hiroyuki

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=20100316090027.95a8943d.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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