Re: [RFC][PATCH 2/5] add softlimit to res_counter

From: KAMEZAWA Hiroyuki
Date: Thu Mar 12 2009 - 00:00:22 EST


On Thu, 12 Mar 2009 09:24:44 +0530
Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> wrote:

>
> > +int res_counter_set_softlimit(struct res_counter *cnt, unsigned long long val)
> > +{
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&cnt->lock, flags);
> > + cnt->softlimit = val;
> > + spin_unlock_irqrestore(&cnt->lock, flags);
> > + return 0;
> > +}
> > +
> > +bool res_counter_check_under_softlimit(struct res_counter *cnt)
> > +{
> > + struct res_counter *c;
> > + unsigned long flags;
> > + bool ret = true;
> > +
> > + local_irq_save(flags);
> > + for (c = cnt; ret && c != NULL; c = c->parent) {
> > + spin_lock(&c->lock);
> > + if (c->softlimit < c->usage)
> > + ret = false;
>
> So if a child was under the soft limit and the parent is *not*, we
> _override_ ret and return false?
>
yes. If you don't want this behavior I'll rename this to
res_counter_check_under_softlimit_hierarchical().


> > + spin_unlock(&c->lock);
> > + }
> > + local_irq_restore(flags);
> > + return ret;
> > +}
>
> Why is the check_under_softlimit hierarchical?

At checking whether a mem_cgroup is a candidate for softlimit-reclaim,
we need to check all parents.

> BTW, this patch is buggy. See above.
>

Not buggy. Just meets my requiremnt.


Thanks,
-Kame

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/