From: Luis Chamberlain <mcgrof@kernel.org>
To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org
Cc: linux-mm@kvack.org, p.raghav@samsung.com, dave@stgolabs.net,
a.manzanares@samsung.com, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFC 0/2] tmpfs: add the option to disable swap
Date: Mon, 6 Feb 2023 18:52:57 -0800 [thread overview]
Message-ID: <20230207025259.2522793-1-mcgrof@kernel.org> (raw)
Many folks suggest using tmpfs is not great because it can use swap.
That's not a good reason to *not* use tmpfs, what's just missing is just
the option to let you disable it. And so this does that, to enable that
and also let users experiment with it.
Reconfiguring is not supported, so what you set up first is what you can keep
with regards to swap options. Enabling support to disable on the fly and
add swap on the fly *is* possible, but I'm not sure we need that yet.
Matthew -- the first patch just makes it easier to read the second, but it does
beg a few questions in it with regards to semantics about the folio and
the inode after splitting a huge page so review for that would be
greatly appreciated.
To test I've used kdevops [0] 8 vpcu 4 GiB libvirt guest on linux-next.
I'm doing this work as part of future experimentation with tmpfs and the
page cache, but given a common complaint found about tmpfs is the
innability to work without the page cache I figured this might be useful
to others. It would also prove useful if folks ask for patches for future
experimentation we are doing.
To see if you hit swap:
mkswap /dev/nvme2n1
swapon /dev/nvme2n1
free -h
With swap - what we see today
=============================
mount -t tmpfs -o size=5G tmpfs /data-tmpfs/
dd if=/dev/urandom of=/data-tmpfs/5g-rand2 bs=1G count=5
free -h
total used free shared buff/cache available
Mem: 3.7Gi 2.6Gi 1.2Gi 2.2Gi 2.2Gi 1.2Gi
Swap: 99Gi 2.8Gi 97Gi
Without swap
=============
free -h
total used free shared buff/cache available
Mem: 3.7Gi 387Mi 3.4Gi 2.1Mi 57Mi 3.3Gi
Swap: 99Gi 0B 99Gi
mount -t tmpfs -o size=5G -o noswap tmpfs /data-tmpfs/
dd if=/dev/urandom of=/data-tmpfs/5g-rand2 bs=1G count=5
free -h
total used free shared buff/cache available
Mem: 3.7Gi 2.6Gi 1.2Gi 2.3Gi 2.3Gi 1.1Gi
Swap: 99Gi 21Mi 99Gi
The mix and match remount testing
=================================
# Cannot disable swap after it was first enabled:
mount -t tmpfs -o size=5G tmpfs /data-tmpfs/
mount -t tmpfs -o remount -o size=5G -o noswap tmpfs /data-tmpfs/
mount: /data-tmpfs: mount point not mounted or bad option.
dmesg(1) may have more information after failed mount system call.
dmesg -c
tmpfs: Cannot disable swap on remount
# Remount with the same noswap option is OK:
mount -t tmpfs -o size=5G -o noswap tmpfs /data-tmpfs/
mount -t tmpfs -o remount -o size=5G -o noswap tmpfs /data-tmpfs/
dmesg -c
# Trying to enable swap with a remount after it first disabled:
mount -t tmpfs -o size=5G -o noswap tmpfs /data-tmpfs/
mount -t tmpfs -o remount -o size=5G tmpfs /data-tmpfs/
mount: /data-tmpfs: mount point not mounted or bad option.
dmesg(1) may have more information after failed mount system call.
dmesg -c
tmpfs: Cannot enable swap on remount if it was disabled on first mount
[0] https://github.com/linux-kdevops/kdevops
Luis Chamberlain (2):
shmem: set shmem_writepage() variables early
shmem: add support to ignore swap
include/linux/shmem_fs.h | 1 +
mm/shmem.c | 33 ++++++++++++++++++++++++++++++---
2 files changed, 31 insertions(+), 3 deletions(-)
--
2.39.0
next reply other threads:[~2023-02-07 2:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 2:52 Luis Chamberlain [this message]
2023-02-07 2:52 ` [RFC 1/2] shmem: set shmem_writepage() variables early Luis Chamberlain
2023-02-07 3:52 ` Matthew Wilcox
2023-02-08 16:08 ` Luis Chamberlain
2023-02-07 2:52 ` [RFC 2/2] shmem: add support to ignore swap Luis Chamberlain
2023-02-07 4:01 ` Matthew Wilcox
2023-02-08 16:01 ` Luis Chamberlain
2023-02-08 17:45 ` Matthew Wilcox
2023-02-08 20:33 ` Yosry Ahmed
2023-02-23 0:53 ` Luis Chamberlain
2023-02-23 1:04 ` Yosry Ahmed
2023-02-23 1:35 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230207025259.2522793-1-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=a.manzanares@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=p.raghav@samsung.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).