0
$ grep -iE 'anon' /proc/meminfo
Active(anon):    2962828 kB
Inactive(anon):  1039836 kB
AnonPages:       2599436 kB
AnonHugePages:         0 kB

Q1. Assuming there are zero "huge pages", do you know why there would be a difference between Active(anon) + Inactive(anon) and AnonPages?

Q2. What is the best overall summary of anonymous memory?

I looked at man proc, but it does not tell me very much:

Active(anon) %lu (since Linux 2.6.28) [To be documented.]

Inactive(anon) %lu (since Linux 2.6.28) [To be documented.]

[...]

AnonPages %lu (since Linux 2.6.18):

Non-file backed pages mapped into user-space page tables.


$ uname -r  # My kernel version
5.0.17-200.fc29.x86_64

I see the same dichotomy in zoneinfo:

$ getconf PAGESIZE
4096

$ grep -C0 -i anon /proc/zoneinfo
      nr_inactive_anon 261105
      nr_active_anon 742227
--
      nr_isolated_anon 0
--
      nr_anon_pages 651405
--
      nr_anon_transparent_hugepages 0
--
      nr_zone_inactive_anon 0
      nr_zone_active_anon 0
--
      nr_zone_inactive_anon 59018
      nr_zone_active_anon 329082
--
      nr_zone_inactive_anon 202087
      nr_zone_active_anon 413145
$ grep -C0 -E "Node|zone[^_]" /proc/zoneinfo
Node 0, zone      DMA
--
Node 0, zone    DMA32
--
Node 0, zone   Normal
--
Node 0, zone  Movable
--
Node 0, zone   Device
$ cat /proc/meminfo
MemTotal:        8042664 kB
MemFree:         1697716 kB
MemAvailable:    3108172 kB
Buffers:          186476 kB
Cached:          3046440 kB
SwapCached:        14580 kB
Active:          3830020 kB
Inactive:        1738252 kB
Active(anon):    2965992 kB
Inactive(anon):  1044420 kB
Active(file):     864028 kB
Inactive(file):   693832 kB
Unevictable:      276372 kB
Mlocked:           13560 kB
SwapTotal:       2097148 kB
SwapFree:        1465040 kB
Dirty:              7376 kB
Writeback:             0 kB
AnonPages:       2602632 kB
Mapped:           696488 kB
Shmem:           1670792 kB
KReclaimable:     164272 kB
Slab:             327948 kB
SReclaimable:     164272 kB
SUnreclaim:       163676 kB
KernelStack:       21408 kB
PageTables:        42976 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6118480 kB
Committed_AS:   14143048 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:             3424 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      492084 kB
DirectMap2M:     7774208 kB
DirectMap1G:     1048576 kB
0

Files created in a tmpfs are counted in Active(anon) + Inactive(anon) (and in Shmem), but not in AnonPages. (Unless the file data is paged out to a swap device).

This is explained in Redhat documentation, and it can be verified in a simple test. So it is not surprising to see some difference.

We can see that is not quite the complete explanation...

  • Active(anon): 2965992 kB
  • Inactive(anon): 1044420 kB
  • AnonPages: 2602632 kB
  • Shmem: 1670792 kB

I expect the difference between Active(anon) + Inactive(anon) and AnonPages + Shmem is explained by:

  • Unevictable: 276372 kB

This raises a second question :-). Why is "Unevictable" memory larger than "Mlocked" memory?

  • Mlocked: 13560 kB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.