SPARSEMEM memory needs?

Ard Biesheuvel ardb at kernel.org
Mon Jun 6 12:10:50 PDT 2022


Hello Joakim,

On Mon, 6 Jun 2022 at 17:20, Joakim Tjernlund
<Joakim.Tjernlund at infinera.com> wrote:
>
> I am trying to reduce RAM used by the kernel and enabled memblock debug and found these(annotated with BT here):
>
> [    0.000000] memblock_alloc_exact_nid_raw: 4194304 bytes align=0x200000 nid=0 from=0x0000000040000000 max_addr=0x0000000000000000 memmap_alloc+0x1c/0x2c
> [    0.000000] memblock_reserve: [0x0000000061c00000-0x0000000061ffffff] memblock_alloc_range_nid+0xc8/0x134
> [    0.000000] ------------[ cut here ]------------
> [    0.000000] Call trace:
> [    0.000000]  vmemmap_alloc_block+0xc4/0xe8
> [    0.000000]  vmemmap_pud_populate+0x24/0xb8
> [    0.000000]  vmemmap_populate+0xa4/0x180
> [    0.000000]  __populate_section_memmap+0x50/0x70
> [    0.000000]  sparse_init_nid+0x164/0x1d4
> [    0.000000]  sparse_init+0xb0/0x224
> [    0.000000]  bootmem_init+0x40/0x80
> [    0.000000]  setup_arch+0x244/0x540
> [    0.000000]  start_kernel+0x60/0x804
> [    0.000000]  __primary_switched+0xa0/0xa8
> [    0.000000] ---[ end trace 0000000000000000 ]---
> [    0.000000] memblock_alloc_try_nid_raw: 2097152 bytes align=0x200000 nid=0 from=0x0000000040000000 max_addr=0x0000000000000000 __earlyonly_bootmem_alloc+0x20/0x28
> [    0.000000] memblock_reserve: [0x0000000061a00000-0x0000000061bfffff] memblock_alloc_range_nid+0xc8/0x134

I'm not sure which backtrace belongs with which memblock debug
message, but something looks wrong here.  vmemmap_pud_populate() does
an allocation of PAGE_SIZE, but your kernel is allocating 2 megabytes
here.

Which kernel version are you using? Do you have any out of tree
changes related to memory management? I assume you are using the
standard 4k page size, right?


> [    0.000000] ------------[ cut here ]------------
> [    0.000000] Call trace:
> [    0.000000]  vmemmap_alloc_block+0xc4/0xe8
> [    0.000000]  vmemmap_alloc_block_buf+0xfc/0x100
> [    0.000000]  vmemmap_populate+0xd0/0x180
> [    0.000000]  __populate_section_memmap+0x50/0x70
> [    0.000000]  sparse_init_nid+0x164/0x1d4
> [    0.000000]  sparse_init+0xb0/0x224
> [    0.000000]  bootmem_init+0x40/0x80
> [    0.000000]  setup_arch+0x244/0x540
> [    0.000000]  start_kernel+0x60/0x804
> [    0.000000]  __primary_switched+0xa0/0xa8
> [    0.000000] ---[ end trace f68728a0d3053b53 ]---
> [    0.000000] memblock_alloc_try_nid_raw: 2097152 bytes align=0x200000 nid=0 from=0x0000000040000000 max_addr=0x0000000000000000 __earlyonly_bootmem_alloc+0x20/0x28
> [    0.000000] memblock_reserve: [0x0000000061800000-0x00000000619fffff] memblock_alloc_range_nid+0xc8/0x134
>
> It seems AARCH64 SPARSEMEM uses some RAM and I wonder if this use can be somewhat reduced?
> Looking at this code I have not yet figured out how these allocations work.
>
> If SPARSEMEM really needs all that RAM, could a simpler memory model like FLATMEM be supported?
>
>  Jocke
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



More information about the linux-arm-kernel mailing list