[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: thoughts about adding tmpfs support to live-helper



On Mon, May 24, 2010 at 08:46:41AM +0200, intrigeri wrote:
> Hi,
> 
> Tzafrir Cohen wrote (23 May 2010 17:44:54 GMT) :
> > If there's not even swap, I figure that the OOM killer will spring
> > into action. Not sure how it acts with tmpfs, though.
> 
> I doubt it. The OOM killer's job is to kill userspace processes when
> the system happens to lack memory.
> 
> In a situation when the mounted (fixed-size) build tmpfs is too small
> to host the needed files, no such thing happens: the scare resource is
> not memory in this case, but storage space. This is why I suggested
> the build would rather abort with a "no space left" error:
> 
>     $ sudo mount -t tmpfs tmpfs -o size=16M /tmp/test
>     $ dd if=/dev/zero of=/tmp/test/file bs=1M
>     dd: writing `/tmp/test/file': No space left on device
>     $ echo $?
>     1
> 
> So this tmpfs-is-too-small situation does not seem critical to me: the
> build will abort with an understandable error that can easily be fixed
> by using a bigger tmpfs.
> 
> OTOH, the opposite situation (i.e. tmpfs is too big) seems more
> critical to me. I believe there is no protection, either in kernel or
> userspace, against {mounting,filling} a tmpfs that does not fit in
> memory (swap included). I tried the following: I mounted a 4GB tmpfs
> on a system with 1GB physical memory + 2GB swap, and ran dd to fill
> a file in it with zeros. The system quickly became totally
> unresponsive, and I had to use sysrq shortcuts to reboot it. I guess
> in that situation, the OOM killer probably killed any userspace
> program it could in order to make room for the tmpfs, which is memory
> allocated by the kernel, and thus probably deserves a higher priority.
> Care must be taken, then, not to allocate too much space to the build
> tmpfs. I'm no low-level system expert though, and I'd be glad to
> stand corrected.

Given that it should include roughtly 5 times the size the the binary
image (or even more), 16MB surely isn't enough. I can't think of a way
to get a reasonable estimate of it in advance. Note, however, that you
can specify say, 'size=20%', which will use 20% of the size of your
physical memory. The default, if no size option is given, is to use up
to 50% of the physical memory.

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen@xorcom.com
+972-50-7952406           mailto:tzafrir.cohen@xorcom.com
http://www.xorcom.com  iax:guest@local.xorcom.com/tzafrir


Reply to: