OpenXiangShan / XiangShan-doc

Documentation for XiangShan
https://xiangshan-doc.readthedocs.io
Creative Commons Attribution 4.0 International
338 stars 130 forks source link

做 Linux Kernel 的第 2 步时,报错:Kernel panic - not syncing: Out of memory and no killable processes #9

Open erdevonmatteo11 opened 2 years ago

erdevonmatteo11 commented 2 years ago

按照《Linux Kernel 的构建.md》,做第 2 步,编译过程顺利。也给 NEMU 设置了额外多的 memory size(CONFIG_MSIZE=0x1800000000)。

但是,执行下面命令时,报错信息如下:

$ ./NEMU/build/riscv64-nemu-interpreter -b ./riscv-pk/build/bbl.bin

[src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'clint' at [0x0000000038000000, 0x000000003800ffff] [src/isa/riscv64/init.c,62,init_isa] NEMU will start from pc 0x80000000 [src/monitor/monitor.c,101,load_img] The image is ./riscv-pk/build/bbl.bin [src/device/io/port-io.c,15,add_pio_map] Add port-io map 'uartlite' at [0x00000000000003f8, 0x0000000000000404] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'uartlite' at [0x0000000040600000, 0x000000004060000c] [src/device/io/port-io.c,15,add_pio_map] Add port-io map 'rtc' at [0x0000000000000048, 0x000000000000004f] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'rtc' at [0x00000000a1000048, 0x00000000a100004f] [src/device/io/port-io.c,15,add_pio_map] Add port-io map 'screen' at [0x0000000000000100, 0x0000000000000107] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'screen' at [0x0000000040001000, 0x0000000040001007] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'vmem' at [0x0000000050000000, 0x00000000500752ff] [src/device/io/port-io.c,15,add_pio_map] Add port-io map 'keyboard' at [0x0000000000000060, 0x0000000000000063] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'keyboard' at [0x00000000a1000060, 0x00000000a1000063] [src/device/io/mmio.c,18,add_mmio_map] Add mmio map 'sdhci' at [0x0000000040002000, 0x000000004000207f] [src/device/sdcard.c,120,init_sdcard] Can not find sdcard image: [src/monitor/monitor.c,25,welcome] Debug: OFF [src/monitor/monitor.c,30,welcome] Build time: 14:45:29, Apr 6 2022 Welcome to riscv64-NEMU! For help, type "help" bbl loader freq-mhz = 500 CLINT: set frequency to 500 MHz vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv
rr vvvvvvvvvvvvvvvvvvvvvv
rr vvvvvvvvvvvvvvvvvvvvvvvv rr rrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrr rrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrr rrrrrrrr vvvvvvvvvvvvvvvvvv rrrrrrrr rrrrrrrrrr vvvvvvvvvvvvvv rrrrrrrrrr rrrrrrrrrrrr vvvvvvvvvv rrrrrrrrrrrr rrrrrrrrrrrrrr vvvvvv rrrrrrrrrrrrrr rrrrrrrrrrrrrrrr vv rrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr

   INSTRUCTION SETS WANT TO BE FREE

[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] Linux version 4.18.0-14485-g036ca364c6b2-dirty (yangqi@gdcni-2U-Rack-Server) (gcc version 10.2.0 (g83718316603)) #3 Wed Apr 6 11:22:17 CST 2022 [ 0.000000] bootconsole [early0] enabled [ 0.000000] Initial ramdisk at: 0x(ptrval) (6730127 bytes) [ 0.000000] Zone ranges: [ 0.000000] DMA32 empty [ 0.000000] Normal [mem 0x0000000080200000-0x0000000081ffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x0000000081ffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000081ffffff] [ 0.000000] Cannot allocate SWIOTLB buffer [ 0.000000] elf_hwcap is 0x112d [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 7575 [ 0.000000] Kernel command line: root=/dev/mmcblk0 rootfstype=ext4 ro rootwait earlycon [ 0.000000] Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] Inode-cache hash table entries: 2048 (order: 2, 16384 bytes) [ 0.000000] Sorting ex_table... [ 0.000000] Memory: 18340K/30720K available (3204K kernel code, 218K rwdata, 922K rodata, 6704K init, 773K bss, 12380K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0 [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns [ 0.000000] Console: colour dummy device 80x25 [ 0.000000] console [hvc0] enabled [ 0.000000] console [hvc0] enabled [ 0.000000] bootconsole [early0] disabled [ 0.000000] bootconsole [early0] disabled [ 0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=10000) [ 0.000000] pid_max: default: 32768 minimum: 301 [ 0.000000] Mount-cache hash table entries: 512 (order: 0, 4096 bytes) [ 0.000000] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes) [ 0.020000] devtmpfs: initialized [ 0.020000] random: get_random_u32 called from bucket_table_alloc+0x6e/0x1a6 with crng_init=0 [ 0.020000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.020000] futex hash table entries: 256 (order: 0, 6144 bytes) [ 0.030000] NET: Registered protocol family 16 [ 0.040000] SCSI subsystem initialized [ 0.050000] clocksource: Switched to clocksource riscv_clocksource [ 0.280000] NET: Registered protocol family 2 [ 0.280000] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes) [ 0.280000] TCP established hash table entries: 512 (order: 0, 4096 bytes) [ 0.280000] TCP bind hash table entries: 512 (order: 0, 4096 bytes) [ 0.280000] TCP: Hash tables configured (established 512 bind 512) [ 0.280000] UDP hash table entries: 256 (order: 1, 8192 bytes) [ 0.280000] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes) [ 0.280000] NET: Registered protocol family 1 [ 0.480000] RPC: Registered named UNIX socket transport module. [ 0.480000] RPC: Registered udp transport module. [ 0.480000] RPC: Registered tcp transport module. [ 0.480000] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 10.640000] swapper invoked oom-killer: gfp_mask=0x6200c2(GFP_HIGHUSER), nodemask=(null), order=0, oom_score_adj=0 [ 10.640000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.0-14485-g036ca364c6b2-dirty #3 [ 10.640000] Call Trace: [ 10.640000] [] walk_stackframe+0x0/0xa6 [ 10.640000] [] show_stack+0x2a/0x34 [ 10.640000] [] dump_stack+0x20/0x28 [ 10.640000] [] dump_header.constprop.0+0x4a/0x14a [ 10.640000] [] out_of_memory+0x2de/0x2f4 [ 10.640000] [] alloc_pages_nodemask+0x444/0x874 [ 10.640000] [] pagecache_get_page+0xe6/0x236 [ 10.640000] [] grab_cache_page_write_begin+0x1a/0x2e [ 10.640000] [] simple_write_begin+0x24/0x106 [ 10.640000] [] generic_perform_write+0x7a/0x15a [ 10.640000] [] generic_file_write_iter+0xd4/0x11e [ 10.640000] [] generic_file_write_iter+0xc4/0x160 [ 10.840000] [] vfs_write+0xd2/0x100 [ 10.840000] [] vfs_write+0x74/0x108 [ 10.840000] [] ksys_write+0x3a/0x7a [ 10.840000] [] xwrite+0x30/0x64 [ 10.840000] [] do_copy+0x88/0xd0 [ 10.840000] [] write_buffer+0x26/0x3a [ 10.840000] [] flush_buffer+0x42/0x96 [ 10.840000] [] gunzip+0x21c/0x296 [ 10.840000] [] gunzip+0x12/0x1a [ 10.840000] [] unpack_to_rootfs+0x13e/0x236 [ 10.840000] [] populate_rootfs+0x20/0xaa [ 10.840000] [] do_one_initcall+0x28/0x100 [ 10.840000] [] kernel_init_freeable+0x11e/0x1b8 [ 10.840000] [] kernel_init+0x12/0xe8 [ 10.840000] [] ret_from_exception+0x0/0xc [ 10.840000] Mem-Info: [ 10.840000] active_anon:0 inactive_anon:0 isolated_anon:0 [ 10.840000] active_file:0 inactive_file:0 isolated_file:0 [ 10.840000] unevictable:4110 dirty:0 writeback:0 unstable:0 [ 10.840000] slab_reclaimable:35 slab_unreclaimable:201 [ 10.840000] mapped:0 shmem:0 pagetables:0 bounce:0 [ 10.840000] free:135 free_pcp:0 free_cma:0 [ 10.840000] Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:16440kB isolated(anon):0kB isolated(file):0kB mapped:0kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no [ 10.840000] Normal free:540kB min:540kB low:672kB high:804kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:16440kB writepending:0kB present:30720kB managed:18340kB mlocked:0kB kernel_stack:144kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB [ 10.840000] lowmem_reserve[]: 0 0 0 [ 10.840000] Normal: 14kB (U) 18kB (U) 116kB (U) 032kB 064kB 0128kB 0256kB 1512kB (U) 01024kB 02048kB 0*4096kB = 540kB [ 10.840000] 4123 total pagecache pages [ 10.840000] 0 pages in swap cache [ 10.840000] Swap cache stats: add 0, delete 0, find 0/0 [ 10.840000] Free swap = 0kB [ 10.840000] Total swap = 0kB [ 10.840000] 7680 pages RAM [ 10.840000] 0 pages HighMem/MovableOnly [ 10.840000] 3095 pages reserved [ 10.840000] [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name [ 10.840000] Kernel panic - not syncing: Out of memory and no killable processes... [ 10.840000] [ 10.840000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.0-14485-g036ca364c6b2-dirty #3 [ 10.840000] Call Trace: [ 10.840000] [] walk_stackframe+0x0/0xa6 [ 10.840000] [] show_stack+0x2a/0x34 [ 10.840000] [] dump_stack+0x20/0x28 [ 10.840000] [] panic+0xc0/0x1d0 [ 10.840000] [] out_of_memory+0x2ea/0x2f4 [ 10.840000] [] alloc_pages_nodemask+0x444/0x874 [ 10.840000] [] pagecache_get_page+0xe6/0x236 [ 10.840000] [] grab_cache_page_write_begin+0x1a/0x2e [ 10.840000] [] simple_write_begin+0x24/0x106 [ 10.840000] [] generic_perform_write+0x7a/0x15a [ 10.840000] [] generic_file_write_iter+0xd4/0x11e [ 10.840000] [] generic_file_write_iter+0xc4/0x160 [ 10.840000] [] vfs_write+0xd2/0x100 [ 10.840000] [] vfs_write+0x74/0x108 [ 10.840000] [] ksys_write+0x3a/0x7a [ 10.840000] [] xwrite+0x30/0x64 [ 10.840000] [] do_copy+0x88/0xd0 [ 10.840000] [] write_buffer+0x26/0x3a [ 10.840000] [] flush_buffer+0x42/0x96 [ 10.840000] [] __gunzip+0x21c/0x296 [ 10.840000] [] gunzip+0x12/0x1a [ 10.840000] [] unpack_to_rootfs+0x13e/0x236 [ 10.840000] [] populate_rootfs+0x20/0xaa [ 10.840000] [] do_one_initcall+0x28/0x100 [ 10.840000] [] kernel_init_freeable+0x11e/0x1b8 [ 10.840000] [] kernel_init+0x12/0xe8 [ 10.840000] [] ret_from_exception+0x0/0xc [ 10.840000] ---[ end Kernel panic - not syncing: Out of memory and no killable processes... [ 10.840000] ]--- ^C

AugustusWillisWang commented 2 years ago

可以在 dts 里调整一下 memory 的大小.

https://github.com/OpenXiangShan/riscv-pk/blob/9f1fca4178465714b27a5f2b9202363980e516ec/dts/noop.dtsi#L29

比如改成:

reg = <0x0 0x80000000 0x0 0x80000000>;

BTW,

也给 NEMU 设置了额外多的 memory size(CONFIG_MSIZE=0x1800000000)

这么大真的没问题的吗? 建议改小一点