Calculating the size of memory zones in Linux
I would appreciate it if someone could help me do some calculations based on the following conclusion:
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 I tried to calculate the sizes of the DMA, ZONE_NORMAL and ZONE_HIGHMEM zones. However, using page count ranges, I just can't seem to get it right.
For example, based on the range 0x00000010 -> 0x00001000 for DMA, I would say it is 4080 pages, which gives us ~ 16MiB. In the case of x86 zones, this 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
Only 3979 pages, so where are the other 101?
For ZONE_NORMAL, it carries over well from 0x00001000 -> 0x00037bfe to 222502 after you subtract the number of reserved pages.
For ZONE_HIGHMEM, it's not even close to 287993 pages. 0x00037bfe -> 0x00140000 gives me 1082370 - which is a much larger value, even if you subtract pages for memmap from it. However, it matches this: 4228 MB HIGHMEM available.
If you think about it, the ranges look like they should, at least narrowing them down to what is described here:
https://www.kernel.org/doc/gorman/html/understand/understand005.html
The "summary" just looks.
I'm clearly missing something here, so it would be great if someone could have a look at this and advice. :) Let me know if you need details.
Thank!
source to share
No one has answered this question yet
Check out similar questions: