tmpfs is zero bytes (no free space), maybe a zfs bug?

Gleb Kurtsou gleb.kurtsou at
Mon Feb 7 14:07:09 UTC 2011

On (19/01/2011 17:27), Ivan Voras wrote:
> On 19 January 2011 16:02, Kostik Belousov <kostikbel at> wrote:
> >>
> >>
> >> I don't think this is a complete solution but it's a start. If you can,
> >> try it and see if it helps.
> > This is not a start, and actually a step in the wrong direction.
> > Tmpfs is wrong now, but the patch would make the wrongness even bigger.
> >
> > Issue is that the current tmpfs calculation should not depend on the
> > length of the inactive queue or the amount of free pages. This data only
> > measures  the pressure on the pagedaemon, and has absolutely no relation
> > to the amount of data that can be put into anonymous objects before the
> > system comes out of swap.
> >
> > vm_lowmem handler is invoked in two situations:
> > - when KVA cannot satisfy the request for the space allocation;
> > - when pagedaemon have to start the scan.
> > None of the situations has any direct correlation with the fact that
> > tmpfs needs to check, that is "Is there enough swap to keep all my
> > future anonymous memory requests ?".
> >
> > Might be, swap reservation numbers can be useful to the tmpfs reporting.
> > Also might be, tmpfs should reserve the swap explicitely on start, instead
> > of making attempts to guess how much can be allocated at random moment.
> Thank you for your explanation! I'm still not very familiar with VM
> and VFS. Could you also read my report at
> ? I'm curious about the fact that there is lots of 'free' memory here
> in the same situation.
> Do you think that there is something which can be done as a band-aid
> without a major modification to tmpfs?

It's up to user to mount tmpfs filesystems of reasonable size to prevent
resource exhaustion. Anyway, enormously large tmpfs killing all your
process is not the way to go.

Unless there are objections, I'm planning to do the following:

1. By default set tmpfs size to max(all swap/2, all memory/2) and print
warning that filesystem size should be specified manually.
Max(swap/2,mem/2) is used as a band-aid for the case when no swap is setup.

3. Remove "live" filesystem size checks, i.e. do not depend on
free/inact memory.

2. Add support for resizing tmpfs on the fly:
	mount -u -o size=<newsize> /tmpfs

Reserving swap for tmpfs might not be what user expects: generally I use
tmpfs for work dir for building ports, it's unused most of the time.

btw, what linux and opensolaris do when available mem/swap gets low due
to tmpfs and how filesystem size determined at real-time?


More information about the freebsd-stable mailing list