[systemd-devel] cgroup use case for preventing a system lock up if say a browser exhausts memory

Colin Guthrie gmane at colin.guthr.ie
Mon Nov 12 03:35:21 PST 2012


'Twas brillig, and Kai Hendry at 12/11/12 04:54 did gyre and gimble:
> Hi there,
> 
> I hope this is the right forum for a systemd question, to address a
> particular problem I'm trying to solve.
> 
> Problem is I've found Firefox (for example, this probably can be
> extrapolated to any browser) to lock up machines when memory is
> exhausted. Ideally when the browser hits a certain limit (only 5% of
> free RAM left), Firefox is killed and restarted, to solve my
> particular kiosk use case.
> https://github.com/Webconverger/webc/issues/83
> 
> I've looked and tested varying unsatisfactory solutions and since I'm
> an Archlinux user who has been put onto systemd (tbh I'm impressed), I
> was eager to know if systemd can help.
> 
> I can't help but notice how busy my `mount` looks now: http://ix.io/3nt

Yeah, topic discussed/flamed to death here to be honest! The "answer"
this is to make the tools more intelligent - e.g. tools like "df" and
similar to avoid showing the same device multiple times if it's mounted
multiple times in different paths etc.

> I've done a quick couple of searches trying to find how to use cgroups
> for controlling limits with systemd and I'm still in the dark. I was
> half expecting a service file example to have a resource limit stanza.
> 
> Am I looking in the right place? Many thanks,

Well, I suspect systemd can help eventually here, but likely "not yet".
The reason is that Firefox is just one process that runs in the user
session, not the system. systemd is designed in such a way to eventually
replace the home-grown "user session" implementations (e.g.
gnome-session etc.) as the problems faced and the solutions for them are
all rather similar.

When launching firefox becomes a "user unit", then it will be contained
within it's own cgroup and can have resource limits imposed with
relative ease.

When this happens I think you'll have a good framework to implement the
needed safeguards.

See Auke's work on systemd for the user session for some more background
(including his talk at this years Plumbers conference).

HTHs

Col



-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list