lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100316090027.95a8943d.kamezawa.hiroyu@jp.fujitsu.com>
Date:	Tue, 16 Mar 2010 09:00:27 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
	"nishimura@....nes.nec.co.jp" <nishimura@....nes.nec.co.jp>,
	"kirill@...temov.name" <kirill@...temov.name>
Subject: Re: [PATCH 2/3] memcg: oom notifier

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

> On Fri, 12 Mar 2010 14:34:35 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@...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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ