Re: [PATCH] mm/memblock:use a more appropriate order calculation when free memblock pages

From: Anders Roxell
Date: Sat Dec 05 2020 - 13:23:37 EST


On Sat, 5 Dec 2020 at 18:09, Anders Roxell <anders.roxell@xxxxxxxxxx> wrote:
>
> On Fri, 4 Dec 2020 at 18:44, Jon Hunter <jonathanh@xxxxxxxxxx> wrote:
> >
> >
> > On 04/12/2020 16:07, Marek Szyprowski wrote:
> > > Hi All,
> > >
> > > On 04.12.2020 14:42, Qian Cai wrote:
> > >> On Thu, 2020-12-03 at 23:23 +0800, carver4lio@xxxxxxx wrote:
> > >>> From: Hailong Liu <liu.hailong6@xxxxxxxxxx>
> > >>>
> > >>> When system in the booting stage, pages span from [start, end] of a memblock
> > >>> are freed to buddy in a order as large as possible (less than MAX_ORDER) at
> > >>> first, then decrease gradually to a proper order(less than end) in a loop.
> > >>>
> > >>> However, *min(MAX_ORDER - 1UL, __ffs(start))* can not get the largest order
> > >>> in some cases.
> > >>> Instead, *__ffs(end - start)* may be more appropriate and meaningful.
> > >>>
> > >>> Signed-off-by: Hailong Liu <liu.hailong6@xxxxxxxxxx>
> > >> Reverting this commit on the top of today's linux-next fixed boot crashes on
> > >> multiple NUMA systems.
> > >
> > > I confirm. Reverting commit 4df001639c84 ("mm/memblock: use a more
> > > appropriate order calculation when free memblock pages") on top of linux
> > > next-20201204 fixed booting of my ARM32bit test systems.
> >
> >
> > FWIW, I also confirm that this is causing several 32-bit Tegra platforms
> > to crash on boot and reverting this fixes the problem.
>
> I had the same experience on an arm64 system.

This is the log that I see:

[ 0.000000][ T0] percpu: Embedded 507 pages/cpu s2036568 r8192
d31912 u2076672
[ 0.000000][ T0] Detected VIPT I-cache on CPU0
[ 0.000000][ T0] CPU features: detected: ARM erratum 845719
[ 0.000000][ T0] CPU features: GIC system register CPU interface
present but disabled by higher exception level
[ 0.000000][ T0] CPU features: kernel page table isolation
forced OFF by kpti command line option
[ 0.000000][ T0] Built 1 zonelists, mobility grouping on. Total
pages: 516096
[ 0.000000][ T0] Policy zone: DMA
[ 0.000000][ T0] Kernel command line: root=/dev/root
rootfstype=9p rootflags=trans=virtio console=ttyAMA0,38400n8
earlycon=pl011,0x9000000 initcall_debug softlockup_panic=0
security=none kpti=no
[ 0.000000][ T0] Dentry cache hash table entries: 262144 (order:
9, 2097152 bytes, linear)
[ 0.000000][ T0] Inode-cache hash table entries: 131072 (order:
8, 1048576 bytes, linear)
[ 0.000000][ T0] mem auto-init: stack:off, heap alloc:on, heap free:on
[ 0.000000][ T0] mem auto-init: clearing system memory may take
some time...
[ 0.000000][ T0] page:(____ptrval____) refcount:0 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0x40010
[ 0.000000][ T0] flags: 0x1fffe0000000000()
[ 0.000000][ T0] raw: 01fffe0000000000 fffffc0000000408
fffffc0000000408 0000000000000000
[ 0.000000][ T0] raw: 0000000000000000 0000000000000000
00000000ffffffff 0000000000000000
[ 0.000000][ T0] page dumped because: VM_BUG_ON_PAGE(pfn & ((1
<< order) - 1))
[ 0.000000][ T0] ------------[ cut here ]------------
[ 0.000000][ T0] kernel BUG at mm/page_alloc.c:1015!
[ 0.000000][ T0] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[ 0.000000][ T0] Modules linked in:
[ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted
5.10.0-rc6-next-20201204-00010-g7f8e9106f747-dirty #1
[ 0.000000][ T0] Hardware name: linux,dummy-virt (DT)
[ 0.000000][ T0] pstate: 40400085 (nZcv daIf +PAN -UAO -TCO BTYPE=--)
[ 0.000000][ T0] pc : __free_one_page+0x14c/0x700
[ 0.000000][ T0] lr : __free_one_page+0x14c/0x700
[ 0.000000][ T0] sp : ffff800013fd7c10
[ 0.000000][ T0] x29: ffff800013fd7c10 x28: 0000000000000000
[ 0.000000][ T0] x27: 0000000000000200 x26: 0000000000000001
[ 0.000000][ T0] x25: 0000000000000000 x24: 0000000000000009
[ 0.000000][ T0] x23: ffff00007dbfbd40 x22: fffffc0000000400
[ 0.000000][ T0] x21: 0000000000040010 x20: 0000000000000009
[ 0.000000][ T0] x19: 00000000000001ff x18: 0000000000000000
[ 0.000000][ T0] x17: 0000000000000000 x16: 0000000000000000
[ 0.000000][ T0] x15: 0000000000000000 x14: 0000000000000000
[ 0.000000][ T0] x13: 0000000000000000 x12: ffff70000281852d
[ 0.000000][ T0] x11: 1ffff0000281852c x10: ffff70000281852c
[ 0.000000][ T0] x9 : dfff800000000000 x8 : ffff8000140c2960
[ 0.000000][ T0] x7 : 0000000000000001 x6 : 00008ffffd7e7ad4
[ 0.000000][ T0] x5 : 0000000000000000 x4 : 0000000000000000
[ 0.000000][ T0] x3 : ffff80001400ab00 x2 : 0000000000000000
[ 0.000000][ T0] x1 : 0000000000000000 x0 : 0000000000000000
[ 0.000000][ T0] Call trace:
[ 0.000000][ T0] __free_one_page+0x14c/0x700
[ 0.000000][ T0] free_one_page+0xf0/0x120
[ 0.000000][ T0] __free_pages_ok+0x720/0x780
[ 0.000000][ T0] __free_pages_core+0x240/0x280
[ 0.000000][ T0] memblock_free_pages+0x40/0x50
[ 0.000000][ T0] free_low_memory_core_early+0x230/0x2f0
[ 0.000000][ T0] memblock_free_all+0x28/0x58
[ 0.000000][ T0] mem_init+0xf0/0x10c
[ 0.000000][ T0] mm_init+0xb4/0xe8
[ 0.000000][ T0] start_kernel+0x1e0/0x520
[ 0.000000][ T0] Code: 913a8021 aa1603e0 91030021 97fe7ec6 (d4210000)
[ 0.000000][ T0] random: get_random_bytes called from
oops_exit+0x50/0xa0 with crng_init=0
[ 0.000000][ T0] ---[ end trace 0000000000000000 ]---
[ 0.000000][ T0] Kernel panic - not syncing: Oops - BUG: Fatal exception
[ 0.000000][ T0] ---[ end Kernel panic - not syncing: Oops -
BUG: Fatal exception ]---

Cheers,
Anders