OpenVZ Forum - RDF feed
type: channel
items: Re: [PATCH 05/10] memcg: Slab accounting.

Re: [PATCH 05/10] memcg: Slab accounting.
type: item
description: On 02/28/2012 08:31 PM, Suleiman Souhlal wrote: > On Tue, Feb 28, 2012 at 5:24 AM, Glauber Costa<glommer@parallels.com> wrote: >> On 02/27/2012 07:58 PM, Suleiman Souhlal wrote: >>> >>> Introduce per-cgroup kmem_caches for memcg slab accounting, that >>> get created the first time we do an allocation of that type in the >>> cgroup. >>> If we are not permitted to sleep in that allocation, the cache >>> gets created asynchronously. >> >> And then we allocate from the root cgroup? > > Yes, the allocation will go to the root cgroup (or not get accounted > at all if you don't have CONFIG_CGROUP_MEM_RES_CTLR_KMEM_ACCT_ROOT). > Once the workqueue runs and creates the memcg cache, all the > allocations of that type will start using it. > >>> The cgroup cache gets used in subsequent allocations, and permits >>> accounting of slab on a per-page basis. >>> >>> The per-cgroup kmem_caches get looked up at slab allocation time, >>> in a MAX_KMEM_CACHE_TYPES-sized array in the memcg structure, based >>> on the original kmem_cache's id, which gets allocated when the original >>> cache gets created. >>> >>> Allocations that cannot be attributed to a cgroup get charged to >>> the root cgroup. >>> >>> Each cgroup kmem_cache has a refcount that dictates the lifetime >>> of the cache: We destroy a cgroup cache when its cgroup has been >>> destroyed and there are no more active objects in the cache. >> >> >> Since we already track the number of pages in the slab, why do we need a >> refcnt? > > I must be missing something, but I don't see a counter of the number > of active pages in the cache in the code. :-( That's fine. Remember I did my work on the slub, so the internals of the slab are to me fuzzy at the very best. If you make sure that this refcnt never leaves slab.c, it should be okay. (since for the slub, it definitely is not needed - we do track the # of pages). One thing we could do is both provide "slab_nr_pages()" (or a better more generic name) as I did in my series, and then…
creator: Glauber Costa
date: 2012-02-29T17:00:33-00:00