Messages in this thread |  | | | Date | Sun, 28 Sep 2008 16:18:35 +0100 (BST) | | From | Hugh Dickins <> | | Subject | Re: Swap on loop device on tmpfs locks up machine |
| |
On Fri, 26 Sep 2008, Vegard Nossum wrote: > > It turns out that swap over loop device on tmpfs will lock up the > machine. That is, all programs become blocked, but I can still do > things like switch VT consoles. > > To reproduce (as root): > > mount -t tmpfs tmpfs /mnt > dd if=/dev/zero of=/mnt/disk > swapoff -a > losetup -f /mnt/disk > mkswap /dev/loop0 # replace loop0 with actual loop device > swapon /dev/loop0 > <memory hog, like continuous malloc()> > > I'm not sure it's really a very good idea to do this in the first > place, but should something give a warning or prevent a user from > doing it?
It's just a "don't do that" in my opinion, and it doesn't seem to have caused much trouble for sysadmins down the years.
It's good to have a loop driver that can make regular files look like block devices, and it's good to have that working on tmpfs; and I'm glad that trying to swapon a tmpfs file directly just happens to fail because tmpfs doesn't support bmap().
But I don't think it's worth adding in some "valid for swap" call to block devices, and saying no when loop or when loop over tmpfs. Trying to swap to loop over tmpfs is a particularly clear example of something that will end badly - unless the tmpfs file is locked in memory? haven't tried that - but I wouldn't recommend swapping to loop over anything (it interposes levels between swap and device which just increase the likelihood of hang).
Just don't do that.
Hugh
|  |