找到你要的答案

Q:Calculating size of memory zones in Linux

Q: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:

https://www.kernel.org/doc/gorman/html/understand/understand005.html

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.

Thanks!

如果有人能帮我根据下面的输出做一些计算,我将不胜感激:

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

好的,所以基本上我试图计算尺寸的DMA,zone_normal和zone_highmem区。然而,它得到正确的比较范围页数我不能。

例如,基于0x00000010范围- >;0x00001000 DMA我会说它有4080页,给我们~ 16mib。在x86区看起来正确的情况下。但当我看着这部分:

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

总共有3979页,剩下的101页在哪里?

对于zone_normal它转换从0x00001000 - >;0x00037bfe 222502当你减去保留的页数。

对于zone_highmem它甚至还没有接近287993页。0x00037bfe - >;0x00140000给我1082370 -即使你减去MemMap从这页的方式更大的价值。然而,它匹配:4228mb highmem可用。

如果你认为它看起来像他们应该的范围,至少通过它所描述的在这里:

https://www.kernel.org/doc/gorman/html/understand/understand005.html

“总结”只是看起来。

我显然错过了这里的东西,所以这将是真棒,如果有人可以看看这和建议。)如果你需要更多的细节,请告诉我。

谢谢!

linux  memory  memory-management  linux-kernel