View previous topic :: View next topic |
Author |
Message |
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
Posted: Wed Apr 24, 2024 9:39 am Post subject: /proc/sysrq-trigger gone after kernel pgo [SOLVED] |
|
|
I recently did a profile guided optimization on my kernel https://wiki.gentoo.org/wiki/Kernel/Optimization#Performance
The kernel did throw an error, but I could ignore it with -Wno-error and everything seemed to work fine afterwards.
Except that for powering down /proc/sysrq-trigger was gone and I have to hold my power button after unmounting all drives to shut my system down.
Upgrading to a newer kernel did not improve this.
Who creates the /proc/sysrq-trigger? the kernel or init system?
Could it be that it is created by the kernel before the init system makes it a procfs?
How can I make sure when I compile my kernel with pgo that sysrq-trigger is present? could it have been optimized out?
And most importantly how can I get /proc/sysrq-trigger back?
Thanks in advance.
Last edited by spykyvenator on Wed Apr 24, 2024 2:09 pm; edited 1 time in total |
|
Back to top |
|
|
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
Posted: Wed Apr 24, 2024 9:58 am Post subject: |
|
|
As I just found out a simple search for sysrq in the kernel solved the issue.
But, why is a kernel module that is needed for shutdown under generic kernel debugging instruments?
I think it is why I disabled it in the first place.
Does this mean there is another way of shutting the system down? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22650
|
Posted: Wed Apr 24, 2024 2:11 pm Post subject: |
|
|
Why are you using sysrq to power off the system? This is an emergency/recovery feature, not a standard thing you should be using regularly. The proper way to shutdown the system is shutdown -h now, and has been for decades. |
|
Back to top |
|
|
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
Posted: Wed Apr 24, 2024 4:02 pm Post subject: |
|
|
Hey Hu,
I am not using sysrq-trigger myself, it is in a bash script that wraps it
#!/bin/sh
RUNLEVEL=0 /sbin/openrc shutdown
shutdown_mode=$(basename "$1") ## CAPTURE "poweroff" or "reboot"
for serv in /etc/rc/*; do
servname=$(basename "$serv")
if [[ ! "$servname" =~ ^tty|^dtinit ]]; then
lk_killsvc "$serv" 0
echo "[ !! ] Terminated $servname"
fi
done
umount /dev/pts
umount /dev/shm
interfaces=$(ip link show | awk -F': ' '{print $2}')
for interface in $interfaces; do
ip link set dev "$interface" down
done
pkill -15 -e 1
pkill -9 -e 1
swapoff -a
echo "u" > /proc/sysrq-trigger
sync
echo "s" > /proc/sysrq-trigger
if test "$shutdown_mode" = "reboot"; then
echo "b" > /proc/sysrq-trigger
else
echo "o" > /proc/sysrq-trigger
fi
I left some echos out to make it a bit shorter
This is a bash script I don't quite remember where I got it from I use it for powering down, it is called by sinit when I send a USR1 signal to it.
But seeing the sysrq-trigger in debugging indeed made me think it really should not be built for this purpose. |
|
Back to top |
|
|
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
Posted: Wed Apr 24, 2024 4:17 pm Post subject: |
|
|
But I am not really sure how I can get a /bin/halt or similar, normally they are generated/provided by the init system if I am not mistaken.
I am looking at the minit shutdown.c, maybe I can get something similar to that. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22650
|
Posted: Wed Apr 24, 2024 5:02 pm Post subject: |
|
|
/sbin/shutdown is provided by sys-apps/sysvinit. What init are you using here? |
|
Back to top |
|
|
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22650
|
Posted: Wed Apr 24, 2024 6:53 pm Post subject: |
|
|
I see. The suckless tools are infamous for being excessively minimal. We somewhat often have people here who have trouble with dwm due to its odd feature patching policy.
I think the proper final step is to call reboot with an argument of LINUX_REBOOT_CMD_POWER_OFF. Your linked shutdown seems to support that, albeit under a nonstandard invocation with -o. |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1919
|
Posted: Wed Apr 24, 2024 7:55 pm Post subject: |
|
|
As an alternate, there is openrc-init which is very much like suckless init (under 500 LOC and single purpose) and geared specifically for openrc without all the headaches.
The bonus is you already have it. It can be made default init via the sysv-utils USE on sys-apps/openrc or else specify openrc-init via init= to the kernel as a test.
I've been using it for years without issue.
Then shutdown is as simple as openrc-shutdown --poweroff now or openrc-shutdown --reboot now |
|
Back to top |
|
|
spykyvenator n00b
Joined: 31 May 2022 Posts: 23
|
Posted: Thu Apr 25, 2024 7:50 am Post subject: |
|
|
Hu, grknight, thank you for your time and the information.
I will make sure to check out openrc-init so that I can remove sysrq-trigger from my kernel.
Have a wonderful day! |
|
Back to top |
|
|
|