Re: [PATCH -mm 1/5] memcg: replace res_counter

KAMEZAWA Hiroyuki
2008-10-21T01:14:58Z

On Mon, 20 Oct 2008 12:53:58 -0700
"Paul Menage" <menage@google.com> wrote:

> Can't we do this in a more generic way, rather than duplicating a lot
> of functionality from res_counter?
>
> You're trying to track:
>
> - mem usage
> - mem limit
> - swap usage
> - swap+mem usage
> - swap+mem limit
>
> And ensuring that:
>
> - mem usage < mem limit
> - swap+mem usage < swap+mem limit
>
> Could we somehow represent this as a pair of resource counters, one
> for mem and one for swap+mem that are linked together?
>

1. It's harmful to increase size of *generic* res_counter. So, modifing
res_counter only for us is not a choice.
2. Operation should be done under a lock. We have to do
-page + swap in atomic, at least.
3. We want to pack all member into a cache-line, multiple res_counter
is no good.
4. I hate res_counter ;)

> Maybe have an "aggregate" pointer in a res_counter that points to
> another res_counter that sums some number of counters; both the mem
> and the swap res_counter objects for a cgroup would point to the
> mem+swap res_counter for their aggregate. Adjusting the usage of a
> counter would also adjust its aggregate (or fail if adjusting the
> aggregate failed).
>
It's complicated.

Thanks,
-Kame