Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/proc/sysrq-trigger gone after kernel pgo [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Wed Apr 24, 2024 9:39 am    Post subject: /proc/sysrq-trigger gone after kernel pgo [SOLVED] Reply with quote

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
View user's profile Send private message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Wed Apr 24, 2024 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22636

PostPosted: Wed Apr 24, 2024 2:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Wed Apr 24, 2024 4:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Wed Apr 24, 2024 4:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22636

PostPosted: Wed Apr 24, 2024 5:02 pm    Post subject: Reply with quote

/sbin/shutdown is provided by sys-apps/sysvinit. What init are you using here?
Back to top
View user's profile Send private message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Wed Apr 24, 2024 5:07 pm    Post subject: Reply with quote

sinit https://core.suckless.org/sinit/
it is not in the gentoo repository
this is the shutdown executable I was talking about: https://github.com/jlesage/minit/blob/master/shutdown.c
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22636

PostPosted: Wed Apr 24, 2024 6:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1912

PostPosted: Wed Apr 24, 2024 7:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
spykyvenator
n00b
n00b


Joined: 31 May 2022
Posts: 23

PostPosted: Thu Apr 25, 2024 7:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum