Setting oom_adj so that the ssh process gets killed first
Alkis Georgopoulos <[email protected]> Sun, 12 Dec 2010 23:57:42 +0200
| Newsgroups | gmane.linux.terminal-server.devel |
|---|---|
| Message-ID | <1292191062.3906.14.camel@alkis> |
Sometimes RAM is exhausted on thin clients, usually due to X pixmaps,
and the kernel chooses a process to kill based on
their /proc/pid/oom_score.
`man proc` explains the two files involved: oom_adj, where the priority
is set, and oom_score, where the score is read.
So if a firefox or an openoffice running on the server use a lot of
pixmaps and exhaust the client RAM, what process should die?
The kernel usually kills X, leaving the user processes still running on
the server and the client in an unstable state.
I think the correct process to be killed would be the
ssh -Y -t -S $LDM_SOCKET -l $LDM_USERNAME $LDM_SERVER...
line in X95-run-x-session.
To tell the kernel to kill that process instead of X, we can add this to
the ssh call:
-o 'PermitLocalCommand=yes' -o 'LocalCommand=echo 15 > /proc/$PPID/oom_adj'
I tried that manually and it worked well for me, i.e. no user processes
were left on the server and the client was in a stable state after X was
automatically restarted.
Would anyone mind if I committed something based on that?
(or someone could commit it himself, better for me :))
Here's a small script to generate a page with a lot of images so that
you can reproduce firefox exhausting all the RAM:
echo '<html><body>' > index.htm
i=100
while [ $i -lt 300 ]; do
echo $i
echo "<img src='800x$i.jpg'><br>" >> index.htm
convert -size 800x$i radial-gradient:yellow 800x$i.jpg
i=$(($i+1))
done
echo '</body></html>' >> index.htm
Run `top` and `xrestop` locally to see the memory usage, and increase
the images number if necessary.
Alkis
------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages,
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev
_____________________________________________________________________
Ltsp-developer mailing list. To un-subscribe, or change prefs, goto:
https://lists.sourceforge.net/lists/listinfo/ltsp-developer
For additional LTSP help, try #ltsp channel on irc.freenode.net