From patchwork Thu Mar 2 23:27:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13158043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB2AC6FA8E for ; Thu, 2 Mar 2023 23:28:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 199066B0078; Thu, 2 Mar 2023 18:28:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 147BB6B007B; Thu, 2 Mar 2023 18:28:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F042A6B007E; Thu, 2 Mar 2023 18:28:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DD02E6B007B for ; Thu, 2 Mar 2023 18:28:06 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ABEE5140792 for ; Thu, 2 Mar 2023 23:28:06 +0000 (UTC) X-FDA: 80525548572.14.ACCF5FD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 240C040009 for ; Thu, 2 Mar 2023 23:28:04 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="K/eQSla3"; spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677799685; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=skC96Wt8xxhIMwjo9L+gt44Hnic6JkSNTvyHUyToP4E=; b=acjIYc2l8qdgWaXvoKeH82cWlljyPq5FQeeSHimhwDalmyLVeyxXuuouIXe1CLx2BNrvSZ TKw9R1j+wj2wFOYmMFfwjlRl5/k4gkIrbDwvfI2+nhOqMK5nc598KUp2BcrBdK2h3K2XJG MMTA9ZglORrb1KXhaw0Kqi+nxvXKXZU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="K/eQSla3"; spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677799685; a=rsa-sha256; cv=none; b=a9s39dOPpYUemD1fsGBVIXljm+Yjjs2pkrc5N3gbhZTw7xeRKmweg5LFc9ge1Dr/Pc1OmY osgCcqMSLwdaFtiEcyhyQ7FbSoy2a+WBKJEzUivSM3r9bL8aqvMsyzwrwoOK6ZbyoSL2Tl Z/TPxAbUttTwlnqJtDhU6fv7aW9fYjI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=skC96Wt8xxhIMwjo9L+gt44Hnic6JkSNTvyHUyToP4E=; b=K/eQSla3MTHn7M0Rb9rcMYDVlA e37q4SAkKhrm7U/RKwrVlRksYjpLSQ7cyFhGajl9HtpsHsUn6N0cRNl0Qv09F6TFF8NJALHGbqV9Y MKle2ZzppMMuer2n5cLdK6TEumXDYu//CEasZglQ4GBDSIpbcgf9zrLrspyNLR57fU9TjiN84RzjX DJKtgrXnUJH4f9ErONxxluGJkBZMTUgr6znqZikMJYzDqfZ43mgtSToV2ADG2RhlMqjD5DNDGVY4q QwjsemBTEGNoJzgAOOd9LwEPm7jsyyl3cLget4EvACCEKtoo27Ivb7ie0zI+m3cji7ZAqVl11QKp8 lTov+nwA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXsL9-003j3Q-Dq; Thu, 02 Mar 2023 23:27:59 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org Cc: linux-mm@kvack.org, p.raghav@samsung.com, da.gomez@samsung.com, a.manzanares@samsung.com, dave@stgolabs.net, yosryahmed@google.com, keescook@chromium.org, mcgrof@kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] shmem: update documentation Date: Thu, 2 Mar 2023 15:27:57 -0800 Message-Id: <20230302232758.888157-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230302232758.888157-1-mcgrof@kernel.org> References: <20230302232758.888157-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 240C040009 X-Stat-Signature: agibmbxuo9gnkt7hc9h81k9icahos8sg X-Rspam-User: X-HE-Tag: 1677799684-825232 X-HE-Meta: U2FsdGVkX19y7jj9Glkpqno5rtNf9YBudny9ech8gEXOSkP+vtdRbxL8y0hDF/ZJM3EsHs62OPwfPhdb2bYAVkYyxUIl9bDBL60CEWgPa+NfEyQsyEhwh/98z5oaU4iRsFMqNSOg/PG+LMaVJshfs4VFPdrPtfZH0QZ9C0HwU2fQPcwyfTUceil/g3oJDo7QySNaz1q+V1wKOAEMHZj2N3C/NHUl+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p+Dia57COCIOfET10FaZbqknxGzvaWv5H+WXx4RCp2PvGf2f8Z9HrBofvOFkaganocvWu1vhUH6ZQq/g0a7geaPm9RqClGtu4VhDp0tcHtstKAR6kjMsgQzyUmHgn+e X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: David Hildenbrand Reviewed-by: Christian Brauner --- 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. + +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