Page MenuHomeFreeBSD

[MIPS32] Restore translation of freelist to flind for page allocation
ClosedPublic

Authored by mizhka_gmail.com on Dec 3 2017, 3:05 PM.

Details

Summary

Hi,

@landonf reported that boot process of MIPS kernels are broken after rS326346. This commit moved domain iterators from physical layer to vm_page one, but it removed translation for vm_page_alloc_freelist() call. Before commit it expects VM_FREELIST_ parameter, but after commit it expects freelist index.

On small boxes with few MB of RAM, we have only VM_FREELIST_LOWMEM (1) and there is no VM_FREELIST_DEFAULT (0) (https://svnweb.freebsd.org/base/head/sys/mips/include/vmparam.h?revision=326023&view=markup#l163). It results in freelist 1 with flind 0. So boot hangs with output:

FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-CURRENT #3 7cf1f4b027f(user/mizhka/bcm-r326479)-dirty: Sun Dec  3 01:59:46 MSK 2017
    mizhka@halloween:/repo/onion/obj/mipsel/repo/onion/src/mips.mipsel/sys/BCM mips
gcc version 4.2.1 20070831 patched [FreeBSD]
subsystem 1000000
   vm_mem_init(0)... done.
   vm_page_init(0)... done.
subsystem 1800000
   sysctl_register_all(0)... done.
mallocinit(0)... done.

Actually it's infinite loop inside uma_small_alloc in sys/mips/mips/uma_machdep.c . It tried to get page from empty freelist infinitely.

Test Plan

Diagnosed and tested on BCM5357 (Asus RT-N53).
Reported by @landonf

BTW, it seems MIPS is the only consumer of vm_page_alloc_freelist (from sys/mips/mips/uma_machdep.c and sys/mips/mips/pmap.c)

Proposed patch fixes boot:

https://gist.github.com/Cka3o4Huk/625d9f5d21bdb553157d16fc83208074

KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2017 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-CURRENT #45 7cf1f4b027f(user/mizhka/bcm-r326479)-dirty: Sun Dec  3 17:41:04 MSK 2017
    mizhka@halloween:/repo/onion/obj/mipsel/repo/onion/src/mips.mipsel/sys/BCM mips
gcc version 4.2.1 20070831 patched [FreeBSD]
real memory  = 32899072 (32128K bytes)
avail memory = 25907200 (24MB)
arc4random: no preloaded entropy cache
random: entropy device external interface
nexus0: <MIPS32 root nexus>
bhnd_nvram0: <Broadcom> on nexus0
bhnd0: <BCM5357 BCMA bus> at mem 0x18000000-0x180fffff on nexus0
bhnd0: core 5: can't find RID by port number: 0
bhnd0: core 7: can't find RID by port number: 0
bhnd0: core 10: can't find RID by port number: 0
bhnd0: core 11: can't find RID by port number: 0
bhnd0: core 12: can't find RID by port number: 0

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jeff added inline comments.Dec 3 2017, 7:35 PM
sys/vm/vm_phys.c
610–611 ↗(On Diff #36143)

Can we not do this check only once in vm_phys_alloc_freelist_pages?

changes:

  • move check to vm_phys_alloc_freelist_pages
  • assert input parameter freelist instead of uninitialized flind
mizhka_gmail.com marked an inline comment as done.Dec 3 2017, 8:44 PM
jeff accepted this revision.Dec 4 2017, 12:28 AM
This revision is now accepted and ready to land.Dec 4 2017, 12:28 AM
This revision was automatically updated to reflect the committed changes.