• KAMEZAWA Hiroyuki's avatar
    memcg: add memory.vmscan_stat · 82f9d486
    KAMEZAWA Hiroyuki authored
    The commit log of 0ae5e89c ("memcg: count the soft_limit reclaim
    in...") says it adds scanning stats to memory.stat file.  But it doesn't
    because we considered we needed to make a concensus for such new APIs.
    
    This patch is a trial to add memory.scan_stat. This shows
      - the number of scanned pages(total, anon, file)
      - the number of rotated pages(total, anon, file)
      - the number of freed pages(total, anon, file)
      - the number of elaplsed time (including sleep/pause time)
    
      for both of direct/soft reclaim.
    
    The biggest difference with oringinal Ying's one is that this file
    can be reset by some write, as
    
      # echo 0 ...../memory.scan_stat
    
    Example of output is here. This is a result after make -j 6 kernel
    under 300M limit.
    
      [kamezawa@bluextal ~]$ cat /cgroup/memory/A/memory.scan_stat
      [kamezawa@bluextal ~]$ cat /cgroup/memory/A/memory.vmscan_stat
      scanned_pages_by_limit 9471864
      scanned_anon_pages_by_limit 6640629
      scanned_file_pages_by_limit 2831235
      rotated_pages_by_limit 4243974
      rotated_anon_pages_by_limit 3971968
      rotated_file_pages_by_limit 272006
      freed_pages_by_limit 2318492
      freed_anon_pages_by_limit 962052
      freed_file_pages_by_limit 1356440
      elapsed_ns_by_limit 351386416101
      scanned_pages_by_system 0
      scanned_anon_pages_by_system 0
      scanned_file_pages_by_system 0
      rotated_pages_by_system 0
      rotated_anon_pages_by_system 0
      rotated_file_pages_by_system 0
      freed_pages_by_system 0
      freed_anon_pages_by_system 0
      freed_file_pages_by_system 0
      elapsed_ns_by_system 0
      scanned_pages_by_limit_under_hierarchy 9471864
      scanned_anon_pages_by_limit_under_hierarchy 6640629
      scanned_file_pages_by_limit_under_hierarchy 2831235
      rotated_pages_by_limit_under_hierarchy 4243974
      rotated_anon_pages_by_limit_under_hierarchy 3971968
      rotated_file_pages_by_limit_under_hierarchy 272006
      freed_pages_by_limit_under_hierarchy 2318492
      freed_anon_pages_by_limit_under_hierarchy 962052
      freed_file_pages_by_limit_under_hierarchy 1356440
      elapsed_ns_by_limit_under_hierarchy 351386416101
      scanned_pages_by_system_under_hierarchy 0
      scanned_anon_pages_by_system_under_hierarchy 0
      scanned_file_pages_by_system_under_hierarchy 0
      rotated_pages_by_system_under_hierarchy 0
      rotated_anon_pages_by_system_under_hierarchy 0
      rotated_file_pages_by_system_under_hierarchy 0
      freed_pages_by_system_under_hierarchy 0
      freed_anon_pages_by_system_under_hierarchy 0
      freed_file_pages_by_system_under_hierarchy 0
      elapsed_ns_by_system_under_hierarchy 0
    
    total_xxxx is for hierarchy management.
    
    This will be useful for further memcg developments and need to be
    developped before we do some complicated rework on LRU/softlimit
    management.
    
    This patch adds a new struct memcg_scanrecord into scan_control struct.
    sc->nr_scanned at el is not designed for exporting information.  For
    example, nr_scanned is reset frequentrly and incremented +2 at scanning
    mapped pages.
    
    To avoid complexity, I added a new param in scan_control which is for
    exporting scanning score.
    Signed-off-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
    Cc: Michal Hocko <mhocko@suse.cz>
    Cc: Ying Han <yinghan@google.com>
    Cc: Andrew Bresticker <abrestic@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    82f9d486
memcontrol.c 146 KB