Re: [PATCH 00/14] MIPS: memblock: Switch arch code to NO_BOOTMEM

From: Serge Semin
Date: Thu Jan 25 2018 - 15:17:41 EST


Hello Alexander,

On Thu, Jan 25, 2018 at 06:58:07PM +0100, Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx> wrote:
> Hello Serge,
>
> On 17/01/18 23:22, Serge Semin wrote:
> > The patchset is applied on top of kernel 4.15-rc8 and can be found
> > submitted at my repo:
> > https://github.com/fancer/Linux-kernel-MIPS-memblock-project
>
> I've tested the Linux from your repo on Octeon2 and it looks good to me.
> I've only tested startup though. Therefore,
>
> Tested-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx>
>

Great! Thank you very much for doing this. I'll include the info about all the
tested platforms to the cover letter of the next patchset.

> I've noticed one positive effect I cannot explain -- with almost the same
> physical memory map I observe almost 2 megabytes more available memory
> after startup:
>
> without patches:
>
> root@(none):~ >free
> total used free shared buff/cache available
> Mem: 955040 16264 839948 80068 98828 810068
> Swap: 0 0 0
>
> memory map:
>
> memory: 0000000001090dc0 @ 0000000009000000 (usable after init)
> memory: 0000000005400000 @ 0000000002b00000 (usable)
> memory: 0000000000c00000 @ 0000000008200000 (usable)
> memory: 0000000004800000 @ 000000000a100000 (usable)
> memory: 000000001fc00000 @ 0000000020000000 (usable)
> memory: 0000000010000000 @ 0000000040000000 (usable)
> memory: 000000000190a9d0 @ 0000000001100000 (usable)
>
> ----------------------------------------
>
> with patches:
>
> root@(none):~ >free
> total used free shared buff/cache available
> Mem: 955028 14292 841884 80068 98852 811996
> Swap: 0 0 0
>
> memory map:
>
> memory: 0000000001090e00 @ 0000000009000000 (usable after init)
> memory: 0000000005400000 @ 0000000002b00000 (usable)
> memory: 0000000000c00000 @ 0000000008200000 (usable)
> memory: 0000000004800000 @ 000000000a100000 (usable)
> memory: 000000001fc00000 @ 0000000020000000 (usable)
> memory: 0000000010000000 @ 0000000040000000 (usable)
> memory: 000000000190c9d0 @ 0000000001100000 (usable)
>

That's interesting. My suggestion is that the old code used to reserve all
the memory below kernel _end symbol. So if the kernel isn't loaded right at
the start of the lowest memory range, then there is going to be a wasted
memory between the range start and the _text kernel symbol:
[PATCH 04/14] MIPS: memblock: Discard bootmem initialization
My code reserves only the memory occupied by the kernel within [_text, _end]:
[PATCH 05/14] MIPS: memblock: Add reserved memory regions to memblock

There might be some other reason of the lesser memory consumption though.
Hopefully I didn't forget to reserve some necessary memory ranges.)

Regards,
-Sergey

>
> > Signed-off-by: Serge Semin <fancer.lancer@xxxxxxxxx>
> >
> > Serge Semin (14):
> > MIPS: memblock: Add RESERVED_NOMAP memory flag
> > MIPS: memblock: Surely map BSS kernel memory section
> > MIPS: memblock: Reserve initrd memory in memblock
> > MIPS: memblock: Discard bootmem initialization
> > MIPS: memblock: Add reserved memory regions to memblock
> > MIPS: memblock: Reserve kdump/crash regions in memblock
> > MIPS: memblock: Mark present sparsemem sections
> > MIPS: memblock: Simplify DMA contiguous reservation
> > MIPS: memblock: Allow memblock regions resize
> > MIPS: memblock: Perform early low memory test
> > MIPS: memblock: Print out kernel virtual mem layout
> > MIPS: memblock: Discard bootmem from Loongson3 code
> > MIPS: memblock: Discard bootmem from SGI IP27 code
> > MIPS: memblock: Deactivate bootmem allocator
>
> --
> Best regards,
> Alexander Sverdlin.