lkml.org 
[lkml]   [2011]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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);
> > +}


\
 
 \ /
  Last update: 2011-09-13 07:43    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site