• Andrey Vagin's avatar
    kmemcg: don't allocate extra memory for root memcg_cache_params · 90c7a79c
    Andrey Vagin authored
    The memcg_cache_params structure contains the common part and the union,
    which represents two different types of data: one for root cashes and
    another for child caches.
    
    The size of child data is fixed.  The size of the memcg_caches array is
    calculated in runtime.
    
    Currently the size of memcg_cache_params for root caches is calculated
    incorrectly, because it includes the size of parameters for child caches.
    
    ssize_t size = memcg_caches_array_size(num_groups);
    size *= sizeof(void *);
    
    size += sizeof(struct memcg_cache_params);
    
    v2: Fix a typo in calculations
    Signed-off-by: default avatarAndrey Vagin <avagin@openvz.org>
    Cc: Glauber Costa <glommer@openvz.org>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@suse.cz>
    Cc: Balbir Singh <bsingharora@gmail.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    90c7a79c
memcontrol.c 185 KB