• Michal Hocko's avatar
    page_cgroup: reduce allocation overhead for page_cgroup array for CONFIG_SPARSEMEM · dde79e00
    Michal Hocko authored
    Currently we are allocating a single page_cgroup array per memory section
    (stored in mem_section->base) when CONFIG_SPARSEMEM is selected.  This is
    correct but memory inefficient solution because the allocated memory
    (unless we fall back to vmalloc) is not kmalloc friendly:
    
            - 32b - 16384 entries (20B per entry) fit into 327680B so the
              524288B slab cache is used
            - 32b with PAE - 131072 entries with 2621440B fit into 4194304B
            - 64b - 32768 entries (40B per entry) fit into 2097152 cache
    
    This is ~37% wasted space per memory section and it sumps up for the whole
    memory.  On a x86_64 machine it is something like 6MB per 1GB of RAM.
    
    We can reduce the internal fragmentation by using alloc_pages_exact which
    allocates PAGE_SIZE aligned blocks so we will get down to <4kB wasted
    memory per section which is much better.
    
    We still need a fallback to vmalloc because we have no guarantees that we
    will have a continuous memory of that size (order-10) later on during the
    hotplug events.
    
    [hannes@cmpxchg.org: do not define unused free_page_cgroup() without memory hotplug]
    Signed-off-by: default avatarMichal Hocko <mhocko@suse.cz>
    Cc: Dave Hansen <dave@linux.vnet.ibm.com>
    Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Balbir Singh <balbir@in.ibm.com>
    Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    dde79e00
page_cgroup.c 11.8 KB