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: <20110913054033.GC2929@redhat.com>
Date:	Tue, 13 Sep 2011 07:40:33 +0200
From:	Johannes Weiner <jweiner@...hat.com>
To:	"Kirill A. Shutemov" <kirill@...temov.name>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Daisuke Nishimura <nishimura@....nes.nec.co.jp>,
	Balbir Singh <bsingharora@...il.com>,
	Ying Han <yinghan@...gle.com>, Michal Hocko <mhocko@...e.cz>,
	Greg Thelen <gthelen@...gle.com>,
	Michel Lespinasse <walken@...gle.com>,
	Rik van Riel <riel@...hat.com>,
	Minchan Kim <minchan.kim@...il.com>,
	Christoph Hellwig <hch@...radead.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: Re: [patch 01/11] mm: memcg: consolidate hierarchy iteration
 primitives

On Tue, Sep 13, 2011 at 01:37:46AM +0300, Kirill A. Shutemov wrote:
> On Mon, Sep 12, 2011 at 12:57:18PM +0200, Johannes Weiner wrote:
> > -static struct mem_cgroup *mem_cgroup_get_next(struct mem_cgroup *iter,
> > -					struct mem_cgroup *root,
> > -					bool cond)
> > -{
> > -	int nextid = css_id(&iter->css) + 1;
> > -	int found;
> > -	int hierarchy_used;
> > -	struct cgroup_subsys_state *css;
> > +	if (prev && !remember)
> > +		id = css_id(&prev->css);
> >  
> > -	hierarchy_used = iter->use_hierarchy;
> > +	if (prev && prev != root)
> > +		css_put(&prev->css);
> >  
> > -	css_put(&iter->css);
> > -	/* If no ROOT, walk all, ignore hierarchy */
> > -	if (!cond || (root && !hierarchy_used))
> > -		return NULL;
> > +	if (!root->use_hierarchy && root != root_mem_cgroup) {
> > +		if (prev)
> > +			return NULL;
> > +		return root;
> > +	}
> >  
> > -	if (!root)
> > -		root = root_mem_cgroup;
> > +	while (!mem) {
> > +		struct cgroup_subsys_state *css;
> >  
> > -	do {
> > -		iter = NULL;
> > -		rcu_read_lock();
> > +		if (remember)
> > +			id = root->last_scanned_child;
> >  
> > -		css = css_get_next(&mem_cgroup_subsys, nextid,
> > -				&root->css, &found);
> > -		if (css && css_tryget(css))
> > -			iter = container_of(css, struct mem_cgroup, css);
> > +		rcu_read_lock();
> > +		css = css_get_next(&mem_cgroup_subsys, id + 1, &root->css, &id);
> > +		if (css) {
> > +			if (css == &root->css || css_tryget(css))
> 
> When does css != &root->css here?

It does not grab an extra reference to the passed hierarchy root, as
all callsites must already hold one to guarantee it's not going away.

> > +static void mem_cgroup_iter_break(struct mem_cgroup *root,
> > +				  struct mem_cgroup *prev)
> > +{
> > +	if (!root)
> > +		root = root_mem_cgroup;
> > +	if (prev && prev != root)
> > +		css_put(&prev->css);
> > +}
--
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