Re: [RFC][PATCH 1/2] memcg: res_counter hierarchy

From: Paul Menage
Date: Wed Jun 04 2008 - 05:00:16 EST


On Tue, Jun 3, 2008 at 10:01 PM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> int ret;
> char *buf, *end;
> @@ -133,13 +145,101 @@ ssize_t res_counter_write(struct res_cou
> if (*end != '\0')
> goto out_free;
> }
> - spin_lock_irqsave(&counter->lock, flags);
> - val = res_counter_member(counter, member);
> - *val = tmp;
> - spin_unlock_irqrestore(&counter->lock, flags);
> - ret = nbytes;
> + if (set_strategy) {
> + ret = set_strategy(res, tmp, member);
> + if (!ret)
> + ret = nbytes;
> + } else {
> + spin_lock_irqsave(&counter->lock, flags);
> + val = res_counter_member(counter, member);
> + *val = tmp;
> + spin_unlock_irqrestore(&counter->lock, flags);
> + ret = nbytes;
> + }

I think that the hierarchy/reclaim handling that you currently have in
the memory controller should be here; the memory controller should
just be able to pass a reference to try_to_free_mem_cgroup_pages() and
have everything else handled by res_counter.

Paul
--
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/