Web lists-archives.com

Re: How do I stop system hangs?




On Thu, Nov 02, 2017 at 01:10:08AM -0400, Borden Rhodes wrote:
What kernel or other settings can I set to let me keep control of my
computer during a runaway process? Basically, how do I tell Linux to
keep just enough resources free so I can drop into a shell terminal
and figure out what's going wrong?

You're in luck. Systemd uses a relatively new feature of the linux kernel which should make this easier: cgroups. Control Groups group related processes into a logical tree with more reliability than previously.

If, for example, a httpd spawns worker processes, they are initially children of the httpd. But if the httpd dies without reaping its children, the children reparent (probably to the init daemon). Under cgroups, however, the children will retain their state as being part of the httpd's cgroup - meaning that even if the http dies, they stay at the same point in the tree.

OK, so that's nice, but how does it help you? Well, systemd exposes an interface to apply quota limits to whole groups [1]. You can, for example, issue:
# systemctl set-property httpd.service CPUWeight=500 MemoryHigh=500M

Hopefully, the linked page should give you some good ideas.


[1] https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html


In context, this evening my computer hung for 30 minutes. The hard
drive activity light went solid and it took about 10 minutes after
hitting CTRL + ALT + F1 for a bash shell to appear. It didn't matter
anyway, though, since the login process timed out if I attempted to
log in.

Unfortunately, there's a 30-minute gap in journalctl, so I can forget
about figuring out what caused the hang or filing a bug report to the
maintainers' satisfaction. Therefore, I'm more interested in keeping
control of my computer in future.

With thanks,


--
For more information, please reread.

Attachment: signature.asc
Description: PGP signature