Message ID | 20230302232758.888157-6-mcgrof@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tmpfs: add the option to disable swap | expand |
On 03.03.23 00:27, Luis Chamberlain wrote: > Update the docs to reflect a bit better why some folks prefer tmpfs > over ramfs and clarify a bit more about the difference between brd > ramdisks. > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > --- > Documentation/filesystems/tmpfs.rst | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst > index 0408c245785e..e77ebdacadd0 100644 > --- a/Documentation/filesystems/tmpfs.rst > +++ b/Documentation/filesystems/tmpfs.rst > @@ -13,14 +13,25 @@ everything stored therein is lost. > > tmpfs puts everything into the kernel internal caches and grows and > shrinks to accommodate the files it contains and is able to swap > -unneeded pages out to swap space. It has maximum size limits which can > -be adjusted on the fly via 'mount -o remount ...' > - > -If you compare it to ramfs (which was the template to create tmpfs) > -you gain swapping and limit checking. Another similar thing is the RAM > -disk (/dev/ram*), which simulates a fixed size hard disk in physical > -RAM, where you have to create an ordinary filesystem on top. Ramdisks > -cannot swap and you do not have the possibility to resize them. > +unneeded pages out to swap space. I suppose, in contrast to ramfs, tmpfs also supports THP. Maybe worth adding as well. Reviewed-by: David Hildenbrand <david@redhat.com>
On Thu, Mar 02, 2023 at 03:27:57PM -0800, Luis Chamberlain wrote: > Update the docs to reflect a bit better why some folks prefer tmpfs > over ramfs and clarify a bit more about the difference between brd > ramdisks. > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > --- Looks good, Reviewed-by: Christian Brauner <brauner@kernel.org>
On Mon, Mar 06, 2023 at 03:04:57PM +0100, David Hildenbrand wrote: > On 03.03.23 00:27, Luis Chamberlain wrote: > > Update the docs to reflect a bit better why some folks prefer tmpfs > > over ramfs and clarify a bit more about the difference between brd > > ramdisks. > > > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > > --- > > Documentation/filesystems/tmpfs.rst | 27 +++++++++++++++++++-------- > > 1 file changed, 19 insertions(+), 8 deletions(-) > > > > diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst > > index 0408c245785e..e77ebdacadd0 100644 > > --- a/Documentation/filesystems/tmpfs.rst > > +++ b/Documentation/filesystems/tmpfs.rst > > @@ -13,14 +13,25 @@ everything stored therein is lost. > > tmpfs puts everything into the kernel internal caches and grows and > > shrinks to accommodate the files it contains and is able to swap > > -unneeded pages out to swap space. It has maximum size limits which can > > -be adjusted on the fly via 'mount -o remount ...' > > - > > -If you compare it to ramfs (which was the template to create tmpfs) > > -you gain swapping and limit checking. Another similar thing is the RAM > > -disk (/dev/ram*), which simulates a fixed size hard disk in physical > > -RAM, where you have to create an ordinary filesystem on top. Ramdisks > > -cannot swap and you do not have the possibility to resize them. > > +unneeded pages out to swap space. > > I suppose, in contrast to ramfs, tmpfs also supports THP. Maybe worth adding > as well. Good call, both the mount and the sysfs file (which is registered by THP) lacks any documentation so I'll just add docs for both. Luis
diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst index 0408c245785e..e77ebdacadd0 100644 --- a/Documentation/filesystems/tmpfs.rst +++ b/Documentation/filesystems/tmpfs.rst @@ -13,14 +13,25 @@ everything stored therein is lost. tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains and is able to swap -unneeded pages out to swap space. It has maximum size limits which can -be adjusted on the fly via 'mount -o remount ...' - -If you compare it to ramfs (which was the template to create tmpfs) -you gain swapping and limit checking. Another similar thing is the RAM -disk (/dev/ram*), which simulates a fixed size hard disk in physical -RAM, where you have to create an ordinary filesystem on top. Ramdisks -cannot swap and you do not have the possibility to resize them. +unneeded pages out to swap space. + +tmpfs extends ramfs with a few userspace configurable options listed and +explained further below, some of which can be reconfigured dynamically on the +fly using a remount ('mount -o remount ...') of the filesystem. A tmpfs +filesystem can be resized but it cannot be resized to a size below its current +usage. tmpfs also supports POSIX ACLs, and extended attributes for the +trusted.* and security.* namespaces. ramfs does not use swap and you cannot +modify any parameter for a ramfs filesystem. The size limit of a ramfs +filesystem is how much memory you have available, and so care must be taken if +used so to not run out of memory. + +An alternative to tmpfs and ramfs is to use brd to create RAM disks +(/dev/ram*), which allows you to simulate a block device disk in physical RAM. +To write data you would just then need to create an regular filesystem on top +this ramdisk. As with ramfs, brd ramdisks cannot swap. brd ramdisks are also +configured in size at initialization and you cannot dynamically resize them. +Contrary to brd ramdisks, tmpfs has its own filesystem, it does not rely on the +block layer at all. Since tmpfs lives completely in the page cache and on swap, all tmpfs pages will be shown as "Shmem" in /proc/meminfo and "Shared" in
Update the docs to reflect a bit better why some folks prefer tmpfs over ramfs and clarify a bit more about the difference between brd ramdisks. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> --- Documentation/filesystems/tmpfs.rst | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)