Re: [patch 01/11] mm: memcg: consolidate hierarchy iteration primitives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]