Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable panic_on_oom and requirements checks/warnings #1626

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Mar 27, 2024

Closes #1619

  • CONFIG_SYSCTL and CONFIG_PROC_SYSCTL added under all linux configs
  • CONFIG_TMPFS removed from all linux configs (to allign with purism config. Other configs need to be alligned across board configs as we already know which is Better manage Heads kernel config requirements #1628)
  • Applies panic_on_oom through procfs if CONFIG_PROC_SYSCTL not disabled, otherwise warns during early boot

Output in case config missing at #1626 (comment)


OLD: no, we cannot apply this directly through coreboot-> linux(heads payload) command line but if we were using kernel 5.8+.

OLD traces:
Had to launch qemu with -m 75M to simulate early crash:

[    1.596940] XZ decompressor ran out of memory
[    1.603890] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -2
[    1.608210] Please append a correct "root=" boot option; here are the available partitions:
[    1.613139] 0100           65536 ram0 
[    1.613171]  (driver?)
[    1.631137] 0101           65536 ram1 
[    1.631149]  (driver?)
[    1.641684] 0102           65536 ram2 
[    1.641696]  (driver?)
[    1.650986] 0103           65536 ram3 
[    1.650999]  (driver?)
[    1.658418] 0104           65536 ram4 
[    1.658429]  (driver?)
[    1.665788] 0105           65536 ram5 
[    1.665802]  (driver?)
[    1.671296] 0106           65536 ram6 
[    1.671302]  (driver?)
[    1.676017] 0107           65536 ram7 
[    1.676023]  (driver?)
[    1.680588] 0108           65536 ram8 
[    1.680595]  (driver?)
[    1.692009] 0109           65536 ram9 
[    1.692020]  (driver?)
[    1.696605] 010a           65536 ram10 
[    1.696611]  (driver?)
[    1.701675] 010b           65536 ram11 
[    1.701680]  (driver?)
[    1.708700] 010c           65536 ram12 
[    1.708716]  (driver?)
[    1.716709] 010d           65536 ram13 
[    1.716730]  (driver?)
[    1.726823] 010e           65536 ram14 
[    1.726838]  (driver?)
[    1.734192] 010f           65536 ram15 
[    1.734201]  (driver?)
[    1.740210] fe00        20971520 vda 
[    1.740271]  driver: virtio_blk
[    1.751133]   fe01            1024 vda1 4be2aae1-73fb-48f5-85bf-63943aacbb74
[    1.751247] 
[    1.756196]   fe02          525312 vda2 db4cd103-ed63-41e8-9011-ff8b93034572
[    1.756206] 
[    1.760006]   fe03         1750016 vda3 18b81207-6197-463e-9054-e73f434f162e
[    1.760012] 
[    1.763761]   fe04        18693120 vda4 2e883aab-009e-4a62-b67b-d4b5441f83ad
[    1.763766] 
[    1.770080] 0b00         1048575 sr0 
[    1.770096]  driver: sr
[    1.773938] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.776359] Kernel Offset: disabled
[    1.778424] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

At -m 25M bootsplash doesn't show. No downside, maybe only on the x230-legacy-boars but anyway, going to be deprecated soon and there is no way someone would put such low memory sticks in their machines.

@JonathonHall-Purism please review!

@JonathonHall-Purism
Copy link
Collaborator

@tlaurion This doesn't work :-/ This has to be done via a sysctl.

I tested on Librem 14 (32 GB RAM), by dd'ing endlessly into a file (ramfs). The OOM killer still gets invoked several times. In this case the system does eventually panic (because it is the kernel actually using tons of memory here, if the OOM killer actually reclaimed significant memory it would not have panicked). That's the same on master too, no change.

Screenshot 2024-03-28 09-27-19

Enabling CONFIG_PROC_SYSCTL and checking /proc/sys/vm/panic_on_oom shows that the command-line parameter has no effect, it's still 0. Presumably userspace tooling (which we don't ship) applies these sysctl command-line parameters.

So I think we have two options:

  • Enable just CONFIG_SYSCTL and use busybox sysctl to set this during /init.
  • Enable CONFIG_PROC_SYSCTL as well and and set it via /proc/sys/vm/panic_on_oom during /init.

@tlaurion
Copy link
Collaborator Author

tlaurion commented Apr 1, 2024

Hmmm.

Agreed, it is not applied, and testing on qemu biased the results because we have TMPFS which restricts memory allocation and inhibited oom killer from kicking in if redoing dd if=/dev/zero of=/tmp/test bs=1M

diff --git a/config/linux-qemu.config b/config/linux-qemu.config
index a5145bb0c76..97e12fd16c3 100644
--- a/config/linux-qemu.config
+++ b/config/linux-qemu.config
@@ -2270,7 +2270,6 @@ CONFIG_RTC_DRV_CMOS=y
 #
 CONFIG_SYNC_FILE=y
 # CONFIG_SW_SYNC is not set
-# CONFIG_UDMABUF is not set
 # CONFIG_DMABUF_MOVE_NOTIFY is not set
 # CONFIG_DMABUF_SELFTESTS is not set
 # CONFIG_DMABUF_HEAPS is not set
@@ -2565,12 +2564,8 @@ CONFIG_PROC_FS=y
 CONFIG_PROC_PID_ARCH_STATUS=y
 CONFIG_KERNFS=y
 CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-# CONFIG_TMPFS_POSIX_ACL is not set
-# CONFIG_TMPFS_XATTR is not set
-# CONFIG_TMPFS_INODE64 is not set
+# CONFIG_TMPFS is not set
 # CONFIG_HUGETLBFS is not set
-CONFIG_MEMFD_CREATE=y
 CONFIG_ARCH_HAS_GIGANTIC_PAGE=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_EFIVAR_FS=m

Otherwise dd op is stopped from exhausting memory completely and simply exits saying that:

~ # dd if=/dev/zero of=/tmp/test bs=1M

dd: error writing '/tmp/test': No space left on device
1950+0 records in
1949+0 records out
2044112896 bytes (1.9GB) copied, 11.423898 seconds, 170.6MB/s

As opposed to being killed by oom_killer without TPMFS:

[   49.730737] dd invoked oom-killer: gfp_mask=0x100cc2(GFP_HIGHUSER), order=0, oom_score_adj=0
[   49.731415] CPU: 0 PID: 473 Comm: dd Not tainted 5.10.5-Heads #0
[   49.731680] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Heads-v0.2.0-2046-g05289c0 01/01/1970
[   49.732242] Call Trace:
[   49.733163]  dump_stack+0x57/0x6a
[   49.733423]  dump_header+0x57/0x182
[   49.733608]  oom_kill_process+0x7b/0xf6
[   49.733799]  out_of_memory+0x24b/0x273
[   49.733975]  __alloc_pages_slowpath.constprop.146+0x578/0x6ca
[   49.734244]  __alloc_pages_nodemask+0x176/0x1d0
[   49.734455]  pagecache_get_page.part.70+0xc3/0x134
[   49.734668]  grab_cache_page_write_begin+0x17/0x2e
[   49.734945]  simple_write_begin+0x1e/0x68
[   49.735136]  generic_perform_write+0xb1/0x18d
[   49.735412]  __generic_file_write_iter+0x103/0x143
[   49.735655]  ? sysvec_apic_timer_interrupt+0x7d/0x89
[   49.735878]  generic_file_write_iter+0x43/0x86
[   49.736077]  new_sync_write+0x7a/0xb2
[   49.738328]  vfs_write+0xd1/0xea
[   49.738521]  ksys_write+0x66/0xae
[   49.738734]  do_syscall_64+0x33/0x40
[   49.741846]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   49.745405] RIP: 0033:0x7f282b534914
[   49.749500] Code: c3 8b 07 85 c0 75 24 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> e9 8c d3 ff ff 41 54 b8 02 00 00 00 49 89 f4 be 00 08 08 00 55
[   49.757072] RSP: 002b:00007ffcf1d88988 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[   49.761582] RAX: ffffffffffffffda RBX: 00007f282b772d88 RCX: 00007f282b534914
[   49.766139] RDX: 0000000000100000 RSI: 00007f282b66f000 RDI: 0000000000000001
[   49.769903] RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
[   49.774070] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f282b66f000
[   49.778245] R13: 0000000000100000 R14: 00007f282b66f000 R15: 0000000000000000
[   49.783399] Mem-Info:
[   49.787740] active_anon:5 inactive_anon:1014 isolated_anon:0
[   49.787740]  active_file:11 inactive_file:0 isolated_file:0
[   49.787740]  unevictable:997548 dirty:0 writeback:0
[   49.787740]  slab_reclaimable:3657 slab_unreclaimable:1023
[   49.787740]  mapped:825 shmem:0 pagetables:68 bounce:0
[   49.787740]  free:3924 free_pcp:195 free_cma:0
[   49.810604] Node 0 active_anon:20kB inactive_anon:4056kB active_file:44kB inactive_file:0kB unevictable:3990192kB isolated(anon):0kB isolated(file):0kB mapped:3300kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB kernel_stack:896kB all_unreclaimable? yes
[   49.823454] DMA32 free:11768kB min:3992kB low:5996kB high:8000kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:1996088kB writepending:0kB present:2096004kB managed:2015024kB mlocked:0kB pagetables:0kB bounce:0kB free_pcp:496kB local_pcp:496kB free_cma:0kB
[   49.837463] lowmem_reserve[]: 0 1977 1977
[   49.843661] Normal free:3928kB min:4032kB low:6056kB high:8080kB reserved_highatomic:0KB active_anon:20kB inactive_anon:4056kB active_file:44kB inactive_file:0kB unevictable:1994104kB writepending:0kB present:2097152kB managed:2024868kB mlocked:0kB pagetables:272kB bounce:0kB free_pcp:284kB local_pcp:284kB free_cma:0kB
[   49.857382] lowmem_reserve[]: 0 0 0
[   49.861905] DMA32: 4*4kB (ME) 5*8kB (UM) 4*16kB (M) 6*32kB (UM) 5*64kB (UM) 5*128kB (UM) 7*256kB (UME) 3*512kB (UM) 5*1024kB (UME) 1*2048kB (M) 0*4096kB = 11768kB
[   49.871297] Normal: 8*4kB (UME) 11*8kB (UME) 8*16kB (ME) 5*32kB (ME) 5*64kB (ME) 1*128kB (E) 2*256kB (ME) 1*512kB (U) 2*1024kB (UM) 0*2048kB 0*4096kB = 3928kB
[   49.879448] 997570 total pagecache pages
[   49.893583] 1048289 pages RAM
[   49.898395] 0 pages HighMem/MovableOnly
[   49.902446] 38316 pages reserved
[   49.906255] Tasks state (memory values in pages):
[   49.910580] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[   49.916286] [    152]     0   152     2675       53    65536        0             0 gpg-agent
[   49.920909] [    169]     0   169      332      200    49152        0             0 init
[   49.925378] [    351]     0   351      322        1    49152        0             0 sh
[   49.929802] [    472]     0   472     2569      576    69632        0             0 whiptail
[   49.934872] [    473]     0   473      574      438    45056        0             0 dd
[   49.939265] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=whiptail,pid=472,uid=0
[   49.957214] Out of memory: Killed process 472 (whiptail) total-vm:10276kB, anon-rss:1028kB, file-rss:1276kB, shmem-rss:0kB, UID:0 pgtables:68kB oom_score_adj:0
[   50.039496] gui-init invoked oom-killer: gfp_mask=0x400dc0(GFP_KERNEL_ACCOUNT|__GFP_ZERO), order=1, oom_score_adj=0
[   50.049607] COMPACTION is disabled!!!
[   50.057367] CPU: 0 PID: 1 Comm: gui-init Not tainted 5.10.5-Heads #0
[   50.062257] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Heads-v0.2.0-2046-g05289c0 01/01/1970
[   50.068427] Call Trace:
[   50.076559]  dump_stack+0x57/0x6a
[   50.082551]  dump_header+0x57/0x182
[   50.088046]  oom_kill_process+0x7b/0xf6
[   50.093033]  out_of_memory+0x24b/0x273
[   50.098865]  __alloc_pages_slowpath.constprop.146+0x578/0x6ca
[   50.103334]  __alloc_pages_nodemask+0x176/0x1d0
[   50.107696]  __get_free_pages+0xc/0x41
[   50.112057]  pgd_alloc+0x28/0x14e
[   50.119853]  mm_init.isra.91+0x15a/0x1dc
[   50.123968]  dup_mm+0x59/0x3f0
[   50.128156]  ? memcg_slab_post_alloc_hook+0x18/0x120
[   50.132753]  copy_process+0x99f/0x13ad
[   50.137797]  kernel_clone+0xa0/0x201
[   50.141864]  ? __clear_close_on_exec.isra.9+0x10/0x1c
[   50.145866]  ? __alloc_fd+0x139/0x14b
[   50.151217]  __do_sys_fork+0x2e/0x4a
[   50.155234]  do_syscall_64+0x33/0x40
[   50.159420]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   50.163894] RIP: 0033:0x7fc4e9981116
[   50.168050] Code: 89 d0 5b 5d 41 5c c3 55 83 cf ff 53 48 81 ec 88 00 00 00 e8 79 14 01 00 48 89 e5 48 89 ef e8 e3 73 00 00 b8 39 00 00 00 0f 05 <48> 89 c3 85 c0 75 45 64 48 8b 14 25 00 00 00 00 b8 ba 00 00 00 0f
[   50.176890] RSP: 002b:00007ffd04c34070 EFLAGS: 00000246 ORIG_RAX: 0000000000000039
[   50.183849] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc4e9981116
[   50.188854] RDX: 00007ffd04c34070 RSI: 00007fc4e99cee20 RDI: 0000000000000000
[   50.193548] RBP: 00007ffd04c34070 R08: 8080808080808080 R09: fefefefefefefeff
[   50.201861] R10: 0000000000000008 R11: 0000000000000246 R12: 000000000223f720
[   50.206630] R13: 000000000223f720 R14: 0000000000000000 R15: 000000000223e0e0
[   50.211088] Mem-Info:
[   50.216091] active_anon:5 inactive_anon:739 isolated_anon:0
[   50.216091]  active_file:11 inactive_file:0 isolated_file:0
[   50.216091]  unevictable:997548 dirty:0 writeback:0
[   50.216091]  slab_reclaimable:3657 slab_unreclaimable:1023
[   50.216091]  mapped:605 shmem:0 pagetables:52 bounce:0
[   50.216091]  free:3924 free_pcp:497 free_cma:0
[   50.247648] Node 0 active_anon:20kB inactive_anon:2956kB active_file:44kB inactive_file:0kB unevictable:3990192kB isolated(anon):0kB isolated(file):0kB mapped:2420kB dirty:0kB writeback:0kB shmem:0kB writeback_tmp:0kB kernel_stack:896kB all_unreclaimable? yes
[   50.258958] DMA32 free:11768kB min:3992kB low:5996kB high:8000kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:1996088kB writepending:0kB present:2096004kB managed:2015024kB mlocked:0kB pagetables:0kB bounce:0kB free_pcp:496kB local_pcp:496kB free_cma:0kB
[   50.272373] lowmem_reserve[]: 0 1977 1977
[   50.276660] Normal free:3928kB min:4032kB low:6056kB high:8080kB reserved_highatomic:0KB active_anon:20kB inactive_anon:2956kB active_file:44kB inactive_file:0kB unevictable:1994104kB writepending:0kB present:2097152kB managed:2024868kB mlocked:0kB pagetables:208kB bounce:0kB free_pcp:1492kB local_pcp:1492kB free_cma:0kB
[   50.290004] lowmem_reserve[]: 0 0 0
[   50.293512] DMA32: 4*4kB (ME) 5*8kB (UM) 4*16kB (M) 6*32kB (UM) 5*64kB (UM) 5*128kB (UM) 7*256kB (UME) 3*512kB (UM) 5*1024kB (UME) 1*2048kB (M) 0*4096kB = 11768kB
[   50.302618] Normal: 8*4kB (UME) 12*8kB (UME) 8*16kB (ME) 5*32kB (ME) 5*64kB (ME) 1*128kB (E) 2*256kB (ME) 1*512kB (U) 2*1024kB (UM) 0*2048kB 0*4096kB = 3936kB
[   50.312360] 997570 total pagecache pages
[   50.317411] 1048289 pages RAM
[   50.321444] 0 pages HighMem/MovableOnly
[   50.326685] 38316 pages reserved
[   50.332266] Tasks state (memory values in pages):
[   50.336721] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[   50.341461] [    152]     0   152     2675       53    65536        0             0 gpg-agent
[   50.349644] [    169]     0   169      332      200    49152        0             0 init
[   50.354041] [    351]     0   351      322        1    49152        0             0 sh
[   50.357825] [    473]     0   473      574      438    45056        0             0 dd
[   50.361910] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=dd,pid=473,uid=0
[   50.376480] Out of memory: Killed process 473 (dd) total-vm:2296kB, anon-rss:980kB, file-rss:772kB, shmem-rss:0kB, UID:0 pgtables:44kB oom_score_adj:0
[   50.387113] oom_reaper: reaped process 473 (dd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Killed

Interestingly enough, newer kernels (5.8+) permit to apply sysctl configs directly from command line without the need of additional tooling nor hacks in init scripts https://serverfault.com/questions/1082967/can-i-change-the-default-sysctl-values-in-grub.

I'm really confused about the kernel output of non-applied parameters nowadays:

~ # dmesg | grep -i oom -A5 -B5
[    0.000000] Linux version 5.10.5-Heads (linux-qemu.config@linuxboot) (x86_64-linux-musl-gcc (GCC) 8.3.0, GNU ld (GNU Binutils) 2.32) #0 SMP 1970-00-00
[    0.000000] Command line: debug vm.panic_on_oom=1 console=ttyS0,115200 console=tty
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000] x86/fpu: x87 FPU will use FXSAVE
[    0.000000] BIOS-provided physical RAM map:
--
[    0.098381] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:1 nr_node_ids:1
[    0.104891] percpu: Embedded 43 pages/cpu s137368 r8192 d30568 u2097152
[    0.105343] pcpu-alloc: s137368 r8192 d30568 u2097152 alloc=1*2097152
[    0.105438] pcpu-alloc: [0] 0 
[    0.107391] Built 1 zonelists, mobility grouping on.  Total pages: 1031887
[    0.107605] Kernel command line: debug vm.panic_on_oom=1 console=ttyS0,115200 console=tty
[    0.123765] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.130026] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.132340] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.386497] Memory: 4030584K/4193156K available (8194K kernel code, 1436K rwdata, 1940K rodata, 936K init, 2116K bss, 162316K reserved, 0K cma-reserved)
[    0.389536] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

As can be seen, not passed down to init as not applied to kernel, but also nothing kernel side saying that parameter was applied either. If we try something else invalid:

~ # dmesg | grep -i oom -B5 -A5
[    0.000000] Linux version 5.10.5-Heads (linux-qemu.config@linuxboot) (x86_64-linux-musl-gcc (GCC) 8.3.0, GNU ld (GNU Binutils) 2.32) #0 SMP 1970-00-00
[    0.000000] Command line: debug oom_panic=1 console=ttyS0,115200 console=tty
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000] x86/fpu: x87 FPU will use FXSAVE
[    0.000000] BIOS-provided physical RAM map:
--
[    0.072478] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:1 nr_node_ids:1
[    0.076134] percpu: Embedded 43 pages/cpu s137368 r8192 d30568 u2097152
[    0.076409] pcpu-alloc: s137368 r8192 d30568 u2097152 alloc=1*2097152
[    0.076459] pcpu-alloc: [0] 0 
[    0.077711] Built 1 zonelists, mobility grouping on.  Total pages: 1031887
[    0.077835] Kernel command line: debug oom_panic=1 console=ttyS0,115200 console=tty
[    0.085389] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.090275] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.091800] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.230064] Memory: 4030584K/4193156K available (8194K kernel code, 1436K rwdata, 1940K rodata, 936K init, 2116K bss, 162316K reserved, 0K cma-reserved)
[    0.232414] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
--
[    4.040933]   with arguments:
[    4.044903]     /init
[    4.047966]   with environment:
[    4.052152]     HOME=/
[    4.058410]     TERM=linux
[    4.062019]     oom_panic=1
[    4.129656] [U] hello world
[    4.351859] DEBUG: Debug output enabled from board CONFIG_DEBUG_OUTPUT=y option (/etc/config)
[    4.369916] TRACE: Under init
[    4.480541] TRACE: /bin/tpmr(32): main
[    4.545608] TRACE: /bin/tpmr(336): tpm2_startsession

Here, we see that the invalid parameter is passed down as an environment variable to be picked up as expected.
Why vm.panic_on_oom=1 doesn't do the same?

@JonathonHall-Purism
Copy link
Collaborator

we have TMPFS which restricts memory allocation

tmpfs doesn't restrict memory allocation in general, it only restricts the amount of memory used by a tmpfs mount. There is still a risk that we could run out of memory another way. Since this doesn't address OOM conditions in general (which scripts aren't written to handle, which is the problem), IMO we should focus on enabling panic on OOM.

Interestingly enough, newer kernels (5.8+) permit to apply sysctl configs directly from command line without the need of additional tooling nor hacks in init scripts https://serverfault.com/questions/1082967/can-i-change-the-default-sysctl-values-in-grub.

That's a neat find, but I think that it would be more maintainable to do this from /init. Duplicating this across a ton of coreboot configs will be hard to maintain.

Here, we see that the invalid parameter is passed down as an environment variable to be picked up as expected. Why vm.panic_on_oom=1 doesn't do the same?

It's documented this way, from https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html:

... if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init ...

The intent AFAIK is just that the userspace tooling that will apply sysctls will go check the kernel command line on its own rather than having to plumb this through init and every layer in between.

@tlaurion
Copy link
Collaborator Author

tlaurion commented Apr 1, 2024

Alright. Agreed with all the above. So gonna make another PR that will warn if kernel config options are not enabled properly and supersedes this one.

I think we are going in the path of having kconfig kernel requirements for Heads: this one would be part of the basics which if not present should scream being missing.

@JonathonHall-Purism
Copy link
Collaborator

I think we are going in the path of having kconfig kernel requirements for Heads: this one would be part of the basics which if not present should scream being missing.

Agree 👍 Opened #1628 with an idea how we might manage that

@tlaurion
Copy link
Collaborator Author

tlaurion commented Apr 1, 2024

(and we cannot simply expect all kernels to be 5.8+ anyways. Talos 2 comes to mind here and bumping kernel versions is not an easy task either until something else is figured out: kconfig all no+punching general requirements + board specifics and having boards similar in such ways)

@tlaurion tlaurion force-pushed the heads_panic_on_oom branch from 89988fa to 045cedf Compare April 1, 2024 20:54
@tlaurion tlaurion changed the title coreboot configs: add vm.panic_on_oom=1 for Heads kernel to panic ins… Enable panic_on_oom requirements Apr 1, 2024
@tlaurion tlaurion changed the title Enable panic_on_oom requirements Enable panic_on_oom and requirements Apr 1, 2024
@tlaurion
Copy link
Collaborator Author

tlaurion commented Apr 1, 2024

Alright. Agreed with all the above. So gonna make another PR that will warn if kernel config options are not enabled properly and supersedes this one.

I think we are going in the path of having kconfig kernel requirements for Heads: this one would be part of the basics which if not present should scream being missing.

@JonathonHall-Purism I went ahead and applied CONFIG_SYSCTL and CONFIG_PROC_SYSCTL under all linux configs and modified init to warn if missing dependencies while applying panic_on_oom through procfs.

No need to create another PR for this, just modified PR name here since branch was on goal name and still valid.

When /proc/sys doesn't exist:

[    4.846132] DEBUG: Debug output enabled from board CONFIG_DEBUG_OUTPUT=y option (/etc/config)
[    4.875673]  *** WARNING: BUG!!! The following requirements to apply runtime kernel tweaks are missing: ***
[    5.902630]  *** WARNING: CONFIG_SYSCTL=y ***
[    6.929369]  *** WARNING: CONFIG_PROC_SYSCTL=y ***
[    7.963290]  *** WARNING: Please open an issue ***

When /proc/sys/vm/panic_on_oom doesn't exist:

[    8.989119]  *** WARNING: BUG!!! Requirements to setup Panic when under Out Of Memory situation through PROC_SYSCTL are missing (panic_on_oom was not enabled) ***
[   10.021618]  *** WARNING: Please open an issue ***

Which are alligned to #1628 future goals

@tlaurion
Copy link
Collaborator Author

tlaurion commented Apr 1, 2024

OP modified. @JonathonHall-Purism ready for review.

@tlaurion tlaurion changed the title Enable panic_on_oom and requirements Enable panic_on_oom and requirements checks/warnings Apr 1, 2024
initrd/init Outdated Show resolved Hide resolved
@tlaurion tlaurion force-pushed the heads_panic_on_oom branch from 045cedf to c73687a Compare April 2, 2024 21:17
@JonathonHall-Purism JonathonHall-Purism merged commit a360703 into linuxboot:master Apr 4, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set vm.panic_on_oom=1 in bootloader
2 participants