Skip to content
  • Ying Han's avatar
    memcg: support hierarchical memory.numa_stats · 071aee13
    Ying Han authored
    
    
    The memory.numa_stat file was not hierarchical.  Memory charged to the
    children was not shown in parent's numa_stat.
    
    This change adds the "hierarchical_" stats to the existing stats.  The
    new hierarchical stats include the sum of all children's values in
    addition to the value of the memcg.
    
    Tested: Create cgroup a, a/b and run workload under b.  The values of
    b are included in the "hierarchical_*" under a.
    
    $ cd /sys/fs/cgroup
    $ echo 1 > memory.use_hierarchy
    $ mkdir a a/b
    
    Run workload in a/b:
    $ (echo $BASHPID >> a/b/cgroup.procs && cat /some/file && bash) &
    
    The hierarchical_ fields in parent (a) show use of workload in a/b:
    $ cat a/memory.numa_stat
    total=0 N0=0 N1=0 N2=0 N3=0
    file=0 N0=0 N1=0 N2=0 N3=0
    anon=0 N0=0 N1=0 N2=0 N3=0
    unevictable=0 N0=0 N1=0 N2=0 N3=0
    hierarchical_total=908 N0=552 N1=317 N2=39 N3=0
    hierarchical_file=850 N0=549 N1=301 N2=0 N3=0
    hierarchical_anon=58 N0=3 N1=16 N2=39 N3=0
    hierarchical_unevictable=0 N0=0 N1=0 N2=0 N3=0
    
    $ cat a/b/memory.numa_stat
    total=908 N0=552 N1=317 N2=39 N3=0
    file=850 N0=549 N1=301 N2=0 N3=0
    anon=58 N0=3 N1=16 N2=39 N3=0
    unevictable=0 N0=0 N1=0 N2=0 N3=0
    hierarchical_total=908 N0=552 N1=317 N2=39 N3=0
    hierarchical_file=850 N0=549 N1=301 N2=0 N3=0
    hierarchical_anon=58 N0=3 N1=16 N2=39 N3=0
    hierarchical_unevictable=0 N0=0 N1=0 N2=0 N3=0
    
    Signed-off-by: default avatarYing Han <yinghan@google.com>
    Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    071aee13