Calculating size of memory zones in Linux


I would appreciate if someone could help me to do some calculations based on the following output:

init_memory_mapping: 0000000000000000-0000000037bfe000
0000000000 - 0000200000 page 4k
0000200000 - 0037a00000 page 2M
0037a00000 - 0037bfe000 page 4k
kernel direct mapping tables up to 0x37bfdfff @ [mem 0x009fa000-0x009fffff]
RAMDISK: 7d11f000 - 7fff0000
Allocated new RAMDISK: 34d2d000 - 37bfd661
Move RAMDISK from 000000007d11f000 - 000000007ffef660 to 34d2d000 - 37bfd660
ACPI: RSDP 000f9aa0 00014 (v00 ACPIAM)
ACPI: RSDT bf6a0000 0003C (v01 062711 RSDT0931 20110627 MSFT 00000097)
ACPI: FACP bf6a0200 00084 (v01 062711 FACP0931 20110627 MSFT 00000097)
ACPI: DSDT bf6a0440 05835 (v01  1AAAA 1AAAA000 00000000 INTL 20051117)
ACPI: FACS bf6ae000 00040
ACPI: APIC bf6a0390 0006C (v01 062711 APIC0931 20110627 MSFT 00000097)
ACPI: MCFG bf6a0400 0003C (v01 062711 OEMMCFG  20110627 MSFT 00000097)
ACPI: OEMB bf6ae040 00072 (v01 062711 OEMB0931 20110627 MSFT 00000097)
ACPI: HPET bf6aa440 00038 (v01 062711 OEMHPET  20110627 MSFT 00000097)
ACPI: GSCI bf6ae0c0 02024 (v01 062711 GMCHSCI  20110627 MSFT 00000097)
ACPI: Local APIC address 0xfee00000
4228MB HIGHMEM available.
891MB LOWMEM available.
  mapped low ram: 0 - 37bfe000
  low ram: 0 - 37bfe000
Zone PFN ranges:
  DMA      0x00000010 -> 0x00001000
  Normal   0x00001000 -> 0x00037bfe
  HighMem  0x00037bfe -> 0x00140000
Movable zone start PFN for each node
Early memory PFN ranges
    0: 0x00000010 -> 0x0000009b
    0: 0x00000100 -> 0x00040200
    0: 0x00100000 -> 0x00140000
On node 0 totalpages: 524683
free_area_init_node: node 0, pgdat c04f7380, node_mem_map f252c200
  DMA zone: 32 pages used for memmap
  DMA zone: 0 pages reserved
  DMA zone: 3947 pages, LIFO batch:0
  Normal zone: 1752 pages used for memmap
  Normal zone: 222502 pages, LIFO batch:31
  HighMem zone: 8457 pages used for memmap
  HighMem zone: 287993 pages, LIFO batch:31

Ok, so basically I have tried to calculate sizes of DMA, ZONE_NORMAL and ZONE_HIGHMEM zones. However, by compering ranges to number of pages I just cannot get it right.

For instance, based on the range of 0x00000010 -> 0x00001000 for DMA I would say that it consists of 4080 pages which gives us ~16MiB. In case of x86 zones it looks correct. But when I look at this part:

  DMA zone: 32 pages used for memmap
  DMA zone: 0 pages reserved
  DMA zone: 3947 pages, LIFO batch:0

There is 3979 pages in total, so where is the remaining 101?

For ZONE_NORMAL it translates well from 0x00001000 -> 0x00037bfe to 222502 after you subtract number of reserved pages.

For ZONE_HIGHMEM it isn't even close to 287993 pages. 0x00037bfe -> 0x00140000 gives me 1082370 - it's way bigger value even if you subtract pages for memmap from it. However, it matches this: 4228MB HIGHMEM available.

If you think of it, ranges looks as they should, at least compering it to what is described in here:

The 'summary' just looks off.

I am clearly missing something here so it would be awesome if someone could take a look at this and advise. :) Do let me know if you need some more details.


asked on Stack Overflow May 2, 2015 by mike

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0