lkml.org 
[lkml]   [2012]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC 2/5] memcg: rework mem_cgroup_iter to use cgroup iterators
    On Tue, Nov 13, 2012 at 04:30:36PM +0100, Michal Hocko wrote:
    > @@ -1063,8 +1063,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
    > struct mem_cgroup *prev,
    > struct mem_cgroup_reclaim_cookie *reclaim)
    > {
    > - struct mem_cgroup *memcg = NULL;
    > - int id = 0;
    > + struct mem_cgroup *memcg = NULL,
    > + *last_visited = NULL;

    Nitpick but please don't do this.

    > + /*
    > + * Root is not visited by cgroup iterators so it needs a special
    > + * treatment.
    > + */
    > + if (!last_visited) {
    > + css = &root->css;
    > + } else {
    > + struct cgroup *next_cgroup;
    > +
    > + next_cgroup = cgroup_next_descendant_pre(
    > + last_visited->css.cgroup,
    > + root->css.cgroup);
    > + if (next_cgroup)
    > + css = cgroup_subsys_state(next_cgroup,
    > + mem_cgroup_subsys_id);

    Hmmm... wouldn't it be better to move the reclaim logic into a
    function and do the following?

    reclaim(root);
    for_each_descendent_pre()
    reclaim(descendant);

    If this is a problem, I'd be happy to add a iterator which includes
    the top node. I'd prefer controllers not using the next functions
    directly.

    Thanks.

    --
    tejun


    \
     
     \ /
      Last update: 2012-11-13 18:01    [W:4.029 / U:0.044 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site