Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Oct 2011 00:46:34 +0300
From:      Gleb Kurtsou <gleb.kurtsou@gmail.com>
To:        Olivier Smedts <olivier@gid0.org>
Cc:        "freebsd-fs@freebsd.org" <freebsd-fs@freebsd.org>, Ivan Voras <ivoras@freebsd.org>
Subject:   Re: is TMPFS still highly experimental?
Message-ID:  <20111018214634.GA55276@tops>
In-Reply-To: <CABzXLYNU%2B397-scL5vGAq1rC%2BDx76ceMMNt9HUag%2Ba7iP8eL_w@mail.gmail.com>
References:  <CAGMYy3ssi%2BkAuufDTHA1z6u7jRrZwRRkCCkcO94GHNGF9Rku_w@mail.gmail.com> <20111002020231.GA70864@icarus.home.lan> <CAGMYy3sCCxOiVqeP4PVbvxnpcyoyQZoL%2Bw3nY8STYnpUNfj6JQ@mail.gmail.com> <j6aorc$hf0$1@dough.gmane.org> <CAGMYy3tbMWU6JU1%2B%2B5XmzjZTrV1=oAgRaaDE3-=MMT73F_ojQQ@mail.gmail.com> <CABzXLYNLhP%2BYFvT5Sw=hKVF6d_Yvmt%2Be_QjH7ghX-2MyzS0wWA@mail.gmail.com> <CAGMYy3s7RrP8oWC%2BJYgSG3hU1EXgKmnf%2BWQRiE2CDu4bHuz3UA@mail.gmail.com> <CABzXLYO-gRt6o6wrevEFwwtTneYiShYD9UbK=j0UUUBzVob5jA@mail.gmail.com> <20111005092603.GA1874@tops> <CABzXLYNU%2B397-scL5vGAq1rC%2BDx76ceMMNt9HUag%2Ba7iP8eL_w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On (18/10/2011 19:46), Olivier Smedts wrote:
> 2011/10/5 Gleb Kurtsou <gleb.kurtsou@gmail.com>:
> > Free RAM is a bit tricky with virtual memory and overcommit support all
> > over the place. There are at least 3 memory hungry subsystems: buffer
> > cache, ZFS ARC, tmpfs.
> >
> > For the first two there is defined maximum size and they can be shrunk
> > in low memory situations. Tmpfs grows as much as it can trying to
> > calculate "free" memory available. Another difference is that tmpfs
> > can't be shrunk in low memory situation.
> >
> > I proposed a patch changing tmpfs memory allocation:
> > - Define maximum file system size (RAM/2 by default)
> > - Don't try to check if free memory available, check free swap
> >  instead and allocate more aggressively, i.e. allocate until
> >  swap or file system limit is reached.
> 
> Patch tested and approved ! I did not test the maximum tmpfs default
> size because I allocated a max size in my fstab.
> 
> %cat /etc/fstab
> none /tmp tmpfs rw,mode=1777,size=2147483648 0 0
You may specify human friendly size, e.g. size=2G.

I'll add live tmpfs resize once decision is made that patch can be
committed.

> 
> %df -h /tmp
> Filesystem    Size    Used   Avail Capacity  Mounted on
> tmpfs         2.0G    124k      2G     0%    /tmp
> 
> Mem: 622M Active, 351M Inact, 6491M Wired, 4940K Cache, 2160K Buf, 385M Free
> Swap: 2048M Total, 36M Used, 2012M Free, 1% Inuse
> 
> (ZFS is using all my wired memory, the ARC is now full, and I deleted
> my nearly-never-touched 8G swap in favor of a 2G swap)
> 
> A little test now :
> %dd if=/dev/zero of=/tmp/test bs=1M count=1500
> 1500+0 records in
> 1500+0 records out
> 1572864000 bytes transferred in 0.763368 secs (2060427243 bytes/sec)
> %df -h /tmp
> Filesystem    Size    Used   Avail Capacity  Mounted on
> tmpfs         2.0G    1.5G    542M    74%    /tmp
> % top
> Mem: 2559M Active, 514M Inact, 4506M Wired, 1656K Cache, 2160K Buf, 274M Free
> Swap: 2048M Total, 39M Used, 2009M Free, 1% Inuse
> 
> So tmpfs made the ZFS ARC cache shrink, without swapping. I did not
> test filling my active memory to see if the max tmpfs size was
> shrinking.
tmpfs size won't change. You'll be able to write to tmpfs until either
filesystem size or swap limit reached. It's for administrator to decide
how large tmpfs can grow. Simply put, there is no way to compete with
ZFS and buffer cache in trying to use all "free" memory, unlike those
tmpfs data can't be freed when needed.

> 
> Cheers !
> 
> >
> > Patch:
> > http://marc.info/?l=freebsd-fs&m=129747367322954&w=2
> > https://github.com/glk/freebsd-head/tree/tmpfs
> >
> > Thanks,
> > Gleb.
> >
> 
> 
> -- 
> Olivier Smedts                                                 _
>                                         ASCII ribbon campaign ( )
> e-mail: olivier@gid0.org        - against HTML email & vCards  X
> www: http://www.gid0.org    - against proprietary attachments / \
> 
>   "Il y a seulement 10 sortes de gens dans le monde :
>   ceux qui comprennent le binaire,
>   et ceux qui ne le comprennent pas."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111018214634.GA55276>