Entries in /proc/meminfo

前端 未结 3 1291
礼貌的吻别
礼貌的吻别 2021-01-31 05:03

I can make sense of most of the information contained in /proc/meminfo like total memory, buffers, cache etc. Could you tell me what do the less obvious ones li

3条回答
  •  离开以前
    2021-01-31 05:11

    My understanding is as follows.
    And I agree these numbers are hard to understand and showing inconsistent values.

    • MemTotal

      = MemFree + Active + Inactive + Slab + PageTables + VmallocUsed + X
      (X : alloc_pages() (get_free_pages(), etc))
      

      But recent kernel's vmallocused value could be wrong. This is because it counts VM_xxx regions like VM_IOREMAP, VM_MAP,... other than VM_ALLOC area.

      VM_IOREMAP region can be mapping memory which can be outside of kernel's memory management, so the formula above can be not precise, or completely wrong.

      You can either do:

      • Check /proc/vmallocinfo to sort out all the entries and filter by yourself,
      • Modify fs/proc/mmu.c: get_vmalloc_info() to count regions only when if(vma->flags & VM_ALLOC)
    • Active + Inactive

       = Buffers + Cached + SwapCached + AnonPages
      
    • AnonPages

       = /proc/*/task/*/smaps anonymous area all sum
       (anonymous: no name|[heap]|/dev/zero|/dev/shm/*|[stack])
      

      Although I haven't been able to match these numbers. See here and help me if you have any clue.

    • Total PageCache

       = Buffers + Cached + SwapCached
      
    • Slab

       = SReclaimable + SUnreclaim
      

提交回复
热议问题