remove Xen tmem leftovers
Subsystems (21)
Hi all,
since the remove of the Xen tmem driver in 2019, the cleancache hooks are entirely unused, as are large parts of frontswap. This series against linux-next (with the folio changes included) removes cleancaches, and cuts down frontswap to the bits actually used by zswap.
Diffstat:
Documentation/vm/cleancache.rst | 296 ------------------------------- b/Documentation/vm/frontswap.rst | 31 --- b/Documentation/vm/index.rst | 1 b/MAINTAINERS | 7 b/arch/arm/configs/bcm2835_defconfig | 1 b/arch/arm/configs/qcom_defconfig | 1 b/arch/m68k/configs/amiga_defconfig | 1 b/arch/m68k/configs/apollo_defconfig | 1 b/arch/m68k/configs/atari_defconfig | 1 b/arch/m68k/configs/bvme6000_defconfig | 1 b/arch/m68k/configs/hp300_defconfig | 1 b/arch/m68k/configs/mac_defconfig | 1 b/arch/m68k/configs/multi_defconfig | 1 b/arch/m68k/configs/mvme147_defconfig | 1 b/arch/m68k/configs/mvme16x_defconfig | 1 b/arch/m68k/configs/q40_defconfig | 1 b/arch/m68k/configs/sun3_defconfig | 1 b/arch/m68k/configs/sun3x_defconfig | 1 b/arch/s390/configs/debug_defconfig | 1 b/arch/s390/configs/defconfig | 1 b/block/bdev.c | 5 b/fs/btrfs/extent_io.c | 10 - b/fs/btrfs/super.c | 2 b/fs/ext4/readpage.c | 6 b/fs/ext4/super.c | 3 b/fs/f2fs/data.c | 7 b/fs/mpage.c | 7 b/fs/ntfs3/ntfs_fs.h | 1 b/fs/ocfs2/super.c | 2 b/fs/super.c | 3 b/include/linux/frontswap.h | 35 --- b/include/linux/fs.h | 5 b/include/linux/shmem_fs.h | 3 b/include/linux/swapfile.h | 3 b/mm/Kconfig | 40 ---- b/mm/Makefile | 1 b/mm/filemap.c | 11 - b/mm/frontswap.c | 259 +-------------------------- b/mm/shmem.c | 33 --- b/mm/swapfile.c | 90 ++------- b/mm/truncate.c | 15 - b/mm/zswap.c | 8 include/linux/cleancache.h | 124 ------------ mm/cleancache.c | 315 --------------------------------- 44 files changed, 65 insertions(+), 1274 deletions(-)
PATCH 1/13 mm: remove cleancache
The cleancache subsystem is unused since the removal of Xen tmem driver in commit 814bbf49dcd0 ("xen: remove tmem driver").
--- Documentation/vm/cleancache.rst | 296 ------------------------- Documentation/vm/frontswap.rst | 12 +- Documentation/vm/index.rst | 1 - MAINTAINERS | 7 - arch/arm/configs/bcm2835_defconfig | 1 - arch/arm/configs/qcom_defconfig | 1 - arch/m68k/configs/amiga_defconfig | 1 - arch/m68k/configs/apollo_defconfig | 1 - arch/m68k/configs/atari_defconfig | 1 - arch/m68k/configs/bvme6000_defconfig | 1 - arch/m68k/configs/hp300_defconfig | 1 - arch/m68k/configs/mac_defconfig | 1 - arch/m68k/configs/multi_defconfig | 1 - arch/m68k/configs/mvme147_defconfig | 1 - arch/m68k/configs/mvme16x_defconfig | 1 - arch/m68k/configs/q40_defconfig | 1 - arch/m68k/configs/sun3_defconfig | 1 - arch/m68k/configs/sun3x_defconfig | 1 - arch/s390/configs/debug_defconfig | 1 - arch/s390/configs/defconfig | 1 - block/bdev.c | 5 - fs/btrfs/extent_io.c | 10 - fs/btrfs/super.c | 2 - fs/ext4/readpage.c | 6 - fs/ext4/super.c | 3 - fs/f2fs/data.c | 7 - fs/mpage.c | 7 - fs/ntfs3/ntfs_fs.h | 1 - fs/ocfs2/super.c | 2 - fs/super.c | 3 - include/linux/cleancache.h | 124 ----------- include/linux/fs.h | 5 - mm/Kconfig | 22 -- mm/Makefile | 1 - mm/cleancache.c | 315 --------------------------- mm/filemap.c | 11 - mm/truncate.c | 15 +- 37 files changed, 4 insertions(+), 867 deletions(-) delete mode 100644 Documentation/vm/cleancache.rst delete mode 100644 include/linux/cleancache.h delete mode 100644 mm/cleancache.c
Documentation/vm/cleancache.rst deleted +0 -296
@@ -1,296 +0,0 @@ -.. _cleancache: - -========== -Cleancache -========== - -Motivation -========== - -Cleancache is a new optional feature provided by the VFS layer that -potentially dramatically increases page cache effectiveness for -many workloads in many environments at a negligible cost. - -Cleancache can be thought of as a page-granularity victim cache for clean -pages that the kernel's pageframe replacement algorithm (PFRA) would like -to keep around, but can't since there isn't enough memory. So when the -PFRA "evicts" a page, it first attempts to use cleancache code to -put the data contained in that page into "transcendent memory", memory -that is not directly accessible or addressable by the kernel and is -of unknown and possibly time-varying size. - -Later, when a cleancache-enabled filesystem wishes to access a page -in a file on disk, it first checks cleancache to see if it already -contains it; if it does, the page of data is copied into the kernel -and a disk access is avoided. - -Transcendent memory "drivers" for cleancache are currently implemented -in Xen (using hypervisor memory) and zcache (using in-kernel compressed -memory) and other implementations are in development. - -:ref:`FAQs <faq>` are included below. - -Implementation Overview -======================= - -A cleancache "backend" that provides transcendent memory registers itself -to the kernel's cleancache "frontend" by calling cleancache_register_ops, -passing a pointer to a cleancache_ops structure with funcs set appropriately. -The functions provided must conform to certain semantics as follows: - -Most important, cleancache is "ephemeral". Pages which are copied into -cleancache have an indefinite lifetime which is completely unknowable -by the kernel and so may or may not still be in cleancache at any later time. -Thus, as its name implies, cleancache is not suitable for dirty pages. -Cleancache has complete discretion over what pages to preserve and what -pages to discard and when. - -Mounting a cleancache-enabled filesystem should call "init_fs" to obtain a -pool id which, if positive, must be saved in the filesystem's superblock; -a negative return value indicates failure. A "put_page" will copy a -(presumably about-to-be-evicted) page into cleancache and associate it with -the pool id, a file key, and a page index into the file. (The combination -of a pool id, a file key, and an index is sometimes called a "handle".) -A "get_page" will copy the page, if found, from cleancache into kernel memory. -An "invalidate_page" will ensure the page no longer is present in cleancache; -an "invalidate_inode" will invalidate all pages associated with the specified -file; and, when a filesystem is unmounted, an "invalidate_fs" will invalidate -all pages in all files specified by the given pool id and also surrender -the pool id. - -An "init_shared_fs", like init_fs, obtains a pool id but tells cleancache -to treat the pool as shared using a 128-bit UUID as a key. On systems -that may run multiple kernels (such as hard partitioned or virtualized -systems) that may share a clustered filesystem, and where cleancache -may be shared among those kernels, calls to init_shared_fs that specify the -same UUID will receive the same pool id, thus allowing the pages to -be shared. Note that any security requirements must be imposed outside -of the kernel (e.g. by "tools" that control cleancache). Or a -cleancache implementation can simply disable shared_init by always -returning a negative value. - -If a get_page is successful on a non-shared pool, the page is invalidated -(thus making cleancache an "exclusive" cache). On a shared pool, the page -is NOT invalidated on a successful get_page so that it remains accessible to -other sharers. The kernel is responsible for ensuring coherency between -cleancache (shared or not), the page cache, and the filesystem, using -cleancache invalidate operations as required. - -Note that cleancache must enforce put-put-get coherency and get-get -coherency. For the former, if two puts are made to the same handle but -with different data, say AAA by the first put and BBB by the second, a -subsequent get can never return the stale data (AAA). For get-get coherency, -if a get for a given handle fails, subsequent gets for that handle will -never succeed unless preceded by a successful put with that handle. - -Last, cleancache provides no SMP serialization guarantees; if two -different Linux threads are simultaneously putting and invalidating a page -with the same handle, the results are indeterminate. Callers must -lock the page to ensure serial behavior. - -Cleancache Performance Metrics -============================== - -If properly configured, monitoring of cleancache is done via debugfs in -the `/sys/kernel/debug/cleancache` directory. The effectiveness of cleancache -can be measured (across all filesystems) with: - -``succ_gets`` - number of gets that were successful - -``failed_gets`` - number of gets that failed - -``puts`` - number of puts attempted (all "succeed") - -``invalidates`` - number of invalidates attempted - -A backend implementation may provide additional metrics. - -.. _faq: - -FAQ -=== - -* Where's the value? (Andrew Morton) - -Cleancache provides a significant performance benefit to many workloads -in many environments with negligible overhead by improving the -effectiveness of the pagecache. Clean pagecache pages are -saved in transcendent memory (RAM that is otherwise not directly -addressable to the kernel); fetching those pages later avoids "refaults" -and thus disk reads. - -Cleancache (and its sister code "frontswap") provide interfaces for -this transcendent memory (aka "tmem"), which conceptually lies between -fast kernel-directly-addressable RAM and slower DMA/asynchronous devices. -Disallowing direct kernel or userland reads/writes to tmem -is ideal when data is transformed to a different form and size (such -as with compression) or secretly moved (as might be useful for write- -balancing for some RAM-like devices). Evicted page-cache pages (and -swap pages) are a great use for this kind of slower-than-RAM-but-much- -faster-than-disk transcendent memory, and the cleancache (and frontswap) -"page-object-oriented" specification provides a nice way to read and -write -- and indirectly "name" -- the pages. - -In the virtual case, the whole point of virtualization is to statistically -multiplex physical resources across the varying demands of multiple -virtual machines. This is really hard to do with RAM and efforts to -do it well with no kernel change have essentially failed (except in some -well-publicized special-case workloads). Cleancache -- and frontswap -- -with a fairly small impact on the kernel, provide a huge amount -of flexibility for more dynamic, flexible RAM multiplexing. -Specifically, the Xen Transcendent Memory backend allows otherwise -"fallow" hypervisor-owned RAM to not only be "time-shared" between multiple -virtual machines, but the pages can be compressed and deduplicated to -optimize RAM utilization. And when guest OS's are induced to surrender -underutilized RAM (e.g. with "self-ballooning"), page cache pages -are the first to go, and cleancache allows those pages to be -saved and reclaimed if overall host system memory conditions allow. - -And the identical interface used for cleancache can be used in -physical systems as well. The zcache driver acts as a memory-hungry -device that stores pages of data in a compressed state. And -the proposed "RAMster" driver shares RAM across multiple physical -systems. - -* Why does cleancache have its sticky fingers so deep inside the - filesystems and VFS? (Andrew Morton and Christoph Hellwig) - -The core hooks for cleancache in VFS are in most cases a single line -and the minimum set are placed precisely where needed to maintain -coherency (via cleancache_invalidate operations) between cleancache, -the page cache, and disk. All hooks compile into nothingness if -cleancache is config'ed off and turn into a function-pointer- -compare-to-NULL if config'ed on but no backend claims the ops -functions, or to a compare-struct-element-to-negative if a -backend claims the ops functions but a filesystem doesn't enable -cleancache. - -Some filesystems are built entirely on top of VFS and the hooks -in VFS are sufficient, so don't require an "init_fs" hook; the -initial implementation of cleancache didn't provide this hook. -But for some filesystems (such as btrfs), the VFS hooks are -incomplete and one or more hooks in fs-specific code are required. -And for some other filesystems, such as tmpfs, cleancache may -be counterproductive. So it seemed prudent to require a filesystem -to "opt in" to use cleancache, which requires adding a hook in -each filesystem. Not all filesystems are supported by cleancache -only because they haven't been tested. The existing set should -be sufficient to validate the concept, the opt-in approach means -that untested filesystems are not affected, and the hooks in the -existing filesystems should make it very easy to add more -filesystems in the future. - -The total impact of the hooks to existing fs and mm files is only -about 40 lines added (not counting comments and blank lines). - -* Why not make cleancache asynchronous and batched so it can more - easily interface with real devices with DMA instead of copying each - individual page? (Minchan Kim) - -The one-page-at-a-time copy semantics simplifies the implementation -on both the frontend and backend and also allows the backend to -do fancy things on-the-fly like page compression and -page deduplication. And since the data is "gone" (copied into/out -of the pageframe) before the cleancache get/put call returns, -a great deal of race conditions and potential coherency issues -are avoided. While the interface seems odd for a "real device" -or for real kernel-addressable RAM, it makes perfect sense for -transcendent memory. - -* Why is non-shared cleancache "exclusive"? And where is the - page "invalidated" after a "get"? (Minchan Kim) - -The main reason is to free up space in transcendent memory and -to avoid unnecessary cleancache_invalidate calls. If you want inclusive, -the page can be "put" immediately following the "get". If -put-after-get for inclusive becomes common, the interface could -be easily extended to add a "get_no_invalidate" call. - -The invalidate is done by the cleancache backend implementation. - -* What's the performance impact? - -Performance analysis has been presented at OLS'09 and LCA'10. -Briefly, performance gains can be significant on most workloads, -especially when memory pressure is high (e.g. when RAM is -overcommitted in a virtual workload); and because the hooks are -invoked primarily in place of or in addition to a disk read/write, -overhead is negligible even in worst case workloads. Basically -cleancache replaces I/O with memory-copy-CPU-overhead; on older -single-core systems with slow memory-copy speeds, cleancache -has little value, but in newer multicore machines, especially -consolidated/virtualized machines, it has great value. - -* How do I add cleancache support for filesystem X? (Boaz Harrash) - -Filesystems that are well-behaved and conform to certain -restrictions can utilize cleancache simply by making a call to -cleancache_init_fs at mount time. Unusual, misbehaving, or -poorly layered filesystems must either add additional hooks -and/or undergo extensive additional testing... or should just -not enable the optional cleancache. - -Some points for a filesystem to consider: - - - The FS should be block-device-based (e.g. a ram-based FS such - as tmpfs should not enable cleancache) - - To ensure coherency/correctness, the FS must ensure that all - file removal or truncation operations either go through VFS or - add hooks to do the equivalent cleancache "invalidate" operations - - To ensure coherency/correctness, either inode numbers must - be unique across the lifetime of the on-disk file OR the - FS must provide an "encode_fh" function. - - The FS must call the VFS superblock alloc and deactivate routines - or add hooks to do the equivalent cleancache calls done there. - - To maximize performance, all pages fetched from the FS should - go through the do_mpag_readpage routine or the FS should add - hooks to do the equivalent (cf. btrfs) - - Currently, the FS blocksize must be the same as PAGESIZE. This - is not an architectural restriction, but no backends currently - support anything different. - - A clustered FS should invoke the "shared_init_fs" cleancache - hook to get best performance for some backends. - -* Why not use the KVA of the inode as the key? (Christoph Hellwig) - -If cleancache would use the inode virtual address instead of -inode/filehandle, the pool id could be eliminated. But, this -won't work because cleancache retains pagecache data pages -persistently even when the inode has been pruned from the -inode unused list, and only invalidates the data page if the file -gets removed/truncated. So if cleancache used the inode kva, -there would be potential coherency issues if/when the inode -kva is reused for a different file. Alternately, if cleancache -invalidated the pages when the inode kva was freed, much of the value -of cleancache would be lost because the cache of pages in cleanache -is potentially much larger than the kernel pagecache and is most -useful if the pages survive inode cache removal. - -* Why is a global variable required? - -The cleancache_enabled flag is checked in all of the frequently-used -cleancache hooks. The alternative is a function call to check a static -variable. Since cleancache is enabled dynamically at runtime, systems -that don't enable cleancache would suffer thousands (possibly -tens-of-thousands) of unnecessary function calls per second. So the -global variable allows cleancache to be enabled by default at compile -time, but have insignificant performance impact when cleancache remains -disabled at runtime. - -* Does cleanache work with KVM? - -The memory model of KVM is sufficiently different that a cleancache -backend may have less value for KVM. This remains to be tested, -especially in an overcommitted system. - -* Does cleancache work in userspace? It sounds useful for - memory hungry caches like web browsers. (Jamie Lokier) - -No plans yet, though we agree it sounds useful, at least for -apps that bypass the page cache (e.g. O_DIRECT). - -Last updated: Dan Magenheimer, April 13 2011
Documentation/vm/frontswap.rst +2 -10
@@ -8,12 +8,6 @@ Frontswap provides a "transcendent memory" interface for swap pages. In some environments, dramatic performance savings may be obtained because swapped pages are saved in RAM (or a RAM-like device) instead of a swap disk. -(Note, frontswap -- and :ref:`cleancache` (merged at 3.0) -- are the "frontends" -and the only necessary changes to the core kernel for transcendent memory; -all other supporting code -- the "backends" -- is implemented as drivers. -See the LWN.net article `Transcendent memory in a nutshell`_ -for a detailed overview of frontswap and related kernel parts) - .. _Transcendent memory in a nutshell: https://lwn.net/Articles/454795/ Frontswap is so named because it can be thought of as the opposite of
@@ -87,11 +81,9 @@ This interface is ideal when data is transformed to a different form and size (such as with compression) or secretly moved (as might be useful for write-balancing for some RAM-like devices). Swap pages (and evicted page-cache pages) are a great use for this kind of slower-than-RAM- -but-much-faster-than-disk "pseudo-RAM device" and the frontswap (and -cleancache) interface to transcendent memory provides a nice way to read -and write -- and indirectly "name" -- the pages. +but-much-faster-than-disk "pseudo-RAM device". -Frontswap -- and cleancache -- with a fairly small impact on the kernel, +Frontswap with a fairly small impact on the kernel, provides a huge amount of flexibility for more dynamic, flexible RAM utilization in various system configurations:
Documentation/vm/index.rst +0 -1
@@ -15,7 +15,6 @@ algorithms. If you are looking for advice on simply allocating memory, see the active_mm arch_pgtable_helpers balance - cleancache damon/index free_page_reporting frontswap
MAINTAINERS +0 -7
@@ -4683,13 +4683,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/cla F: include/linux/cfi.h F: kernel/cfi.c -CLEANCACHE API -M: Konrad Rzeszutek Wilk <[email protected]> -L: [email protected] -S: Maintained -F: include/linux/cleancache.h -F: mm/cleancache.c - CLK API M: Russell King <[email protected]> L: [email protected]
arch/arm/configs/bcm2835_defconfig +0 -1
@@ -31,7 +31,6 @@ CONFIG_ARCH_BCM2835=y CONFIG_PREEMPT_VOLUNTARY=y CONFIG_AEABI=y CONFIG_KSM=y -CONFIG_CLEANCACHE=y CONFIG_CMA=y CONFIG_SECCOMP=y CONFIG_KEXEC=y
arch/arm/configs/qcom_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_PCIE_QCOM=y CONFIG_SMP=y CONFIG_PREEMPT=y CONFIG_HIGHMEM=y -CONFIG_CLEANCACHE=y CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_CPU_IDLE=y
arch/m68k/configs/amiga_defconfig +0 -1
@@ -45,7 +45,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/apollo_defconfig +0 -1
@@ -41,7 +41,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/atari_defconfig +0 -1
@@ -48,7 +48,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/bvme6000_defconfig +0 -1
@@ -38,7 +38,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/hp300_defconfig +0 -1
@@ -40,7 +40,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/mac_defconfig +0 -1
@@ -39,7 +39,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/multi_defconfig +0 -1
@@ -59,7 +59,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/mvme147_defconfig +0 -1
@@ -37,7 +37,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/mvme16x_defconfig +0 -1
@@ -38,7 +38,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/q40_defconfig +0 -1
@@ -39,7 +39,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/sun3_defconfig +0 -1
@@ -35,7 +35,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/m68k/configs/sun3x_defconfig +0 -1
@@ -35,7 +35,6 @@ CONFIG_IOSCHED_BFQ=m CONFIG_BINFMT_AOUT=m CONFIG_BINFMT_MISC=m # CONFIG_COMPACTION is not set -CONFIG_CLEANCACHE=y CONFIG_ZPOOL=m CONFIG_NET=y CONFIG_PACKET=y
arch/s390/configs/debug_defconfig +0 -1
@@ -96,7 +96,6 @@ CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y -CONFIG_CLEANCACHE=y CONFIG_FRONTSWAP=y CONFIG_CMA_DEBUG=y CONFIG_CMA_DEBUGFS=y
arch/s390/configs/defconfig +0 -1
@@ -91,7 +91,6 @@ CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y -CONFIG_CLEANCACHE=y CONFIG_FRONTSWAP=y CONFIG_CMA_SYSFS=y CONFIG_CMA_AREAS=7
block/bdev.c +0 -5
@@ -24,7 +24,6 @@#include <linux/pseudo_fs.h> #include <linux/uio.h> #include <linux/namei.h> -#include <linux/cleancache.h> #include <linux/part_stat.h> #include <linux/uaccess.h> #include "../fs/internal.h"
@@ -88,10 +87,6 @@ void invalidate_bdev(struct block_device *bdev)lru_add_drain_all ();/* make sure all lru add caches are flushed */ invalidate_mapping_pages (mapping,0 ,-1 ); } -/* 99% of the time, we don't need to flush the cleancache on the bdev. -* But, for the strange corners, lets be cautious -*/ -cleancache_invalidate_inode (mapping); }EXPORT_SYMBOL (invalidate_bdev);
fs/btrfs/extent_io.c +0 -10
@@ -12,7 +12,6 @@#include <linux/writeback.h> #include <linux/pagevec.h> #include <linux/prefetch.h> -#include <linux/cleancache.h> #include <linux/fsverity.h> #include "misc.h" #include "extent_io.h"
@@ -3583,15 +3582,6 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, goto out; } -if (!PageUptodate (page)) { -if (cleancache_get_page (page) ==0 ) { -BUG_ON (blocksize !=PAGE_SIZE ); -unlock_extent (tree, start, end); -unlock_page (page); - goto out; - } - } -if (page->index == last_byte >>PAGE_SHIFT ) {size_t zero_offset =offset_in_page (last_byte);
fs/btrfs/super.c +0 -2
@@ -23,7 +23,6 @@#include <linux/miscdevice.h> #include <linux/magic.h> #include <linux/slab.h> -#include <linux/cleancache.h> #include <linux/ratelimit.h> #include <linux/crc32c.h> #include <linux/btrfs.h>
@@ -1374,7 +1373,6 @@ static int btrfs_fill_super(struct super_block *sb, goto fail_close; } -cleancache_init_fs (sb); sb->s_flags |=SB_ACTIVE ;return 0 ;
fs/ext4/readpage.c +0 -6
@@ -43,7 +43,6 @@#include <linux/writeback.h> #include <linux/backing-dev.h> #include <linux/pagevec.h> -#include <linux/cleancache.h> #include "ext4.h"
@@ -350,11 +349,6 @@ int ext4_mpage_readpages(struct inode *inode, }else if (fully_mapped) {SetPageMappedToDisk (page); } -if (fully_mapped && blocks_per_page ==1 && - !PageUptodate (page) &&cleancache_get_page (page) ==0 ) { -SetPageUptodate (page); - goto confused; - }/* * This page will go to BIO. Do we need to send this
fs/ext4/super.c +0 -3
@@ -39,7 +39,6 @@#include <linux/log2.h> #include <linux/crc16.h> #include <linux/dax.h> -#include <linux/cleancache.h> #include <linux/uaccess.h> #include <linux/iversion.h> #include <linux/unicode.h>
@@ -3141,8 +3140,6 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,EXT4_BLOCKS_PER_GROUP (sb),EXT4_INODES_PER_GROUP (sb), sbi->s_mount_opt, sbi->s_mount_opt2); - -cleancache_init_fs (sb);return err; }
fs/f2fs/data.c +0 -7
@@ -18,7 +18,6 @@#include <linux/swap.h> #include <linux/prefetch.h> #include <linux/uio.h> -#include <linux/cleancache.h> #include <linux/sched/signal.h> #include <linux/fiemap.h> #include <linux/iomap.h>
@@ -2035,12 +2034,6 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, block_nr = map->m_pblk + block_in_file - map->m_lblk;SetPageMappedToDisk (page); -if (!PageUptodate (page) && (!PageSwapCache (page) && - !cleancache_get_page (page))) { -SetPageUptodate (page); - goto confused; - } -if (!f2fs_is_valid_blkaddr (F2FS_I_SB (inode), block_nr,DATA_GENERIC_ENHANCE_READ )) { ret = -EFSCORRUPTED ;
fs/mpage.c +0 -7
@@ -29,7 +29,6 @@#include <linux/writeback.h> #include <linux/backing-dev.h> #include <linux/pagevec.h> -#include <linux/cleancache.h> #include "internal.h" /*
@@ -284,12 +283,6 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)SetPageMappedToDisk (page); } -if (fully_mapped && blocks_per_page ==1 && !PageUptodate (page) && -cleancache_get_page (page) ==0 ) { -SetPageUptodate (page); - goto confused; - } -/* * This page will go to BIO. Do we need to send this BIO off first? */
fs/ntfs3/ntfs_fs.h +0 -1
@@ -11,7 +11,6 @@#include <linux/blkdev.h> #include <linux/buffer_head.h> -#include <linux/cleancache.h> #include <linux/fs.h> #include <linux/highmem.h> #include <linux/kernel.h>
fs/ocfs2/super.c +0 -2
@@ -25,7 +25,6 @@#include <linux/mount.h> #include <linux/seq_file.h> #include <linux/quotaops.h> -#include <linux/cleancache.h> #include <linux/signal.h> #define CREATE_TRACE_POINTS
@@ -2283,7 +2282,6 @@ static int ocfs2_initialize_super(struct super_block *sb,mlog_errno (status); goto bail; } -cleancache_init_shared_fs (sb); osb->ocfs2_wq =alloc_ordered_workqueue ("ocfs2_wq" ,WQ_MEM_RECLAIM );if (!osb->ocfs2_wq) {
fs/super.c +0 -3
@@ -31,7 +31,6 @@#include <linux/mutex.h> #include <linux/backing-dev.h> #include <linux/rculist_bl.h> -#include <linux/cleancache.h> #include <linux/fscrypt.h> #include <linux/fsnotify.h> #include <linux/lockdep.h>
@@ -260,7 +259,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_time_gran =1000000000 ; s->s_time_min =TIME64_MIN ; s->s_time_max =TIME64_MAX ; - s->cleancache_poolid =CLEANCACHE_NO_POOL ; s->s_shrink.seeks =DEFAULT_SEEKS ; s->s_shrink.scan_objects = super_cache_scan;
@@ -330,7 +328,6 @@ void deactivate_locked_super(struct super_block *s) {struct file_system_type *fs = s->s_type;if (atomic_dec_and_test (&s->s_active)) { -cleancache_invalidate_fs (s);unregister_shrinker (&s->s_shrink); fs->kill_sb (s);
include/linux/cleancache.h deleted +0 -124
124 lines not on this page · raw message
include/linux/fs.h +0 -5
@@ -1535,11 +1535,6 @@ struct super_block {const struct dentry_operations *s_d_op;/* default d_op for dentries */ -/* -* Saved pool identifier for cleancache (-1 means none) -*/ -int cleancache_poolid; -struct shrinker s_shrink;/* per-sb shrinker handle */ /* Number of inodes with nlink == 0 but still referenced */
mm/Kconfig +0 -22
@@ -444,28 +444,6 @@ config USE_PERCPU_NUMA_NODE_ID config HAVE_SETUP_PER_CPU_AREA bool -config CLEANCACHE - bool "Enable cleancache driver to cache clean pages if tmem is present" - help - Cleancache can be thought of as a page-granularity victim cache - for clean pages that the kernel's pageframe replacement algorithm - (PFRA) would like to keep around, but can't since there isn't enough - memory. So when the PFRA "evicts" a page, it first attempts to use - cleancache code to put the data contained in that page into - "transcendent memory", memory that is not directly accessible or - addressable by the kernel and is of unknown and possibly - time-varying size. And when a cleancache-enabled - filesystem wishes to access a page in a file on disk, it first - checks cleancache to see if it already contains it; if it does, - the page is copied into the kernel and a disk access is avoided. - When a transcendent memory driver is available (such as zcache or - Xen transcendent memory), a significant I/O reduction - may be achieved. When none is available, all cleancache calls - are reduced to a single pointer-compare-against-NULL resulting - in a negligible performance hit. - - If unsure, say Y to enable cleancache - config FRONTSWAP bool "Enable frontswap to cache swap pages if tmem is present" depends on SWAP
mm/Makefile +0 -1
@@ -104,7 +104,6 @@ obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o obj-$(CONFIG_DEBUG_RODATA_TEST) += rodata_test.o obj-$(CONFIG_DEBUG_VM_PGTABLE) += debug_vm_pgtable.o obj-$(CONFIG_PAGE_OWNER) += page_owner.o -obj-$(CONFIG_CLEANCACHE) += cleancache.o obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o obj-$(CONFIG_ZPOOL) += zpool.o obj-$(CONFIG_ZBUD) += zbud.o
mm/cleancache.c deleted +0 -315
315 lines not on this page · raw message
mm/filemap.c +0 -11
@@ -35,7 +35,6 @@#include <linux/cpuset.h> #include <linux/hugetlb.h> #include <linux/memcontrol.h> -#include <linux/cleancache.h> #include <linux/shmem_fs.h> #include <linux/rmap.h> #include <linux/delayacct.h>
@@ -151,16 +150,6 @@ static void filemap_unaccount_folio(struct address_space *mapping, {long nr; -/* -* if we're uptodate, flush out into the cleancache, otherwise -* invalidate any existing cleancache entries. We can't leave -* stale data around in the cleancache once our page is gone -*/ -if (folio_test_uptodate (folio) &&folio_test_mappedtodisk (folio)) -cleancache_put_page (&folio->page); -else -cleancache_invalidate_page (mapping, &folio->page); -VM_BUG_ON_FOLIO (folio_mapped (folio), folio);if (!IS_ENABLED (CONFIG_DEBUG_VM ) &&unlikely (folio_mapped (folio))) {int mapcount;
mm/truncate.c +2 -13
@@ -22,7 +22,6 @@#include <linux/buffer_head.h> /* grr. try_to_release_page, do_invalidatepage */ #include <linux/shmem_fs.h> -#include <linux/cleancache.h> #include <linux/rmap.h> #include "internal.h"
@@ -264,7 +263,6 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)*/ folio_zero_range (folio, offset, length); -cleancache_invalidate_page (folio->mapping, &folio->page);if (folio_has_private (folio))do_invalidatepage (&folio->page, offset, length);if (!folio_test_large (folio))
@@ -351,7 +349,7 @@ void truncate_inode_pages_range(struct address_space *mapping,bool partial_end;if (mapping_empty (mapping)) - goto out; +return ;/* * 'start' and 'end' always covers the range of pages to be fully
@@ -443,9 +441,6 @@ void truncate_inode_pages_range(struct address_space *mapping,folio_batch_release (&fbatch); index++; } - -out: -cleancache_invalidate_inode (mapping); }EXPORT_SYMBOL (truncate_inode_pages_range);
@@ -499,10 +494,6 @@ void truncate_inode_pages_final(struct address_space *mapping)xa_unlock_irq (&mapping->i_pages); } -/* -* Cleancache needs notification even if there are no pages or shadow -* entries. -*/ truncate_inode_pages (mapping,0 ); }EXPORT_SYMBOL (truncate_inode_pages_final);
@@ -662,7 +653,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,int did_range_unmap =0 ;if (mapping_empty (mapping)) - goto out; +return 0 ;folio_batch_init (&fbatch); index = start;
@@ -726,8 +717,6 @@ int invalidate_inode_pages2_range(struct address_space *mapping,if (dax_mapping (mapping)) {unmap_mapping_pages (mapping, start, end - start +1 , false); } -out: -cleancache_invalidate_inode (mapping);return ret; }EXPORT_SYMBOL_GPL (invalidate_inode_pages2_range);
Signature · 1 line
2.30.2
Re: [PATCH 01/13] mm: remove cleancache
Quoted 4 lines · Christoph Hellwig
The cleancache subsystem is unused since the removal of Xen tmem driver in commit
814bbf49dcd0("xen: remove tmem driver").Signed-off-by Christoph Hellwig <[email protected]>
Hehe, this is nearly a verbatim copy of the patch I sent in 2019 (I only missed the defconfig parts back then):
https://lore.kernel.org/lkml/[email protected]/
Juergen
Re: [PATCH 01/13] mm: remove cleancache
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Christoph Hellwig
The cleancache subsystem is unused since the removal of Xen tmem driver in commit
814bbf49dcd0("xen: remove tmem driver").
Quoted 8 lines
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>Hehe, this is nearly a verbatim copy of the patch I sent in 2019 (I only missed the defconfig parts back then):
https://lore.kernel.org/lkml/[email protected]/
Reviewed-by Juergen Gross <[email protected]>
I'm perfectly fine with changing the attribution to your here a well.
Re: [PATCH 01/13] mm: remove cleancache
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
The cleancache subsystem is unused since the removal of Xen tmem driver in commit
814bbf49dcd0("xen: remove tmem driver").Signed-off-by Christoph Hellwig <[email protected]>
Quoted 12 lines
arch/m68k/configs/amiga_defconfig | 1 - arch/m68k/configs/apollo_defconfig | 1 - arch/m68k/configs/atari_defconfig | 1 - arch/m68k/configs/bvme6000_defconfig | 1 - arch/m68k/configs/hp300_defconfig | 1 - arch/m68k/configs/mac_defconfig | 1 - arch/m68k/configs/multi_defconfig | 1 - arch/m68k/configs/mvme147_defconfig | 1 - arch/m68k/configs/mvme16x_defconfig | 1 - arch/m68k/configs/q40_defconfig | 1 - arch/m68k/configs/sun3_defconfig | 1 - arch/m68k/configs/sun3x_defconfig | 1 -
Although this would be removed during the next refresh anyway:
Quoted 17 lines
mm/Kconfig +0
-11@@ -444,28 +444,6 @@ config USE_PERCPU_NUMA_NODE_ID config HAVE_SETUP_PER_CPU_AREA bool -config CLEANCACHE - bool "Enable cleancache driver to cache clean pages if tmem is present" - help - Cleancache can be thought of as a page-granularity victim cache - for clean pages that the kernel's pageframe replacement algorithm - (PFRA) would like to keep around, but can't since there isn't enough - memory. So when the PFRA "evicts" a page, it first attempts to use - cleancache code to put the data contained in that page into - "transcendent memory", memory that is not directly accessible or - addressable by the kernel and is of unknown and possibly - time-varying size. And when a cleancache-enabled
mm/Kconfig config USE_PERCPU_NUMA_NODE_ID · line 467
Quoted 10 lines
mm/Kconfig +0
-10- filesystem wishes to access a page in a file on disk, it first - checks cleancache to see if it already contains it; if it does, - the page is copied into the kernel and a disk access is avoided. - When a transcendent memory driver is available (such as zcache or - Xen transcendent memory), a significant I/O reduction - may be achieved. When none is available, all cleancache calls - are reduced to a single pointer-compare-against-NULL resulting - in a negligible performance hit. - - If unsure, say Y to enable cleancache
Ah, the joy of good advice...
mm/Kconfig config USE_PERCPU_NUMA_NODE_ID · line 449
Quoted 4 lines
mm/Kconfig +0
-1- config FRONTSWAP bool "Enable frontswap to cache swap pages if tmem is present" depends on SWAP
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 2/13 frontswap: remove frontswap_writethrough
In reply to Christoph Hellwigfrontswap_writethrough is never called, so remove it.
--- Documentation/vm/frontswap.rst | 6 ------ include/linux/frontswap.h | 1 - mm/frontswap.c | 23 +---------------------- 3 files changed, 1 insertion(+), 29 deletions(-)
Documentation/vm/frontswap.rst +0 -6
@@ -39,12 +39,6 @@ a disk write and, if the data is later read back, a disk read are avoided. If a store returns failure, transcendent memory has rejected the data, and the page can be written to swap as usual. -If a backend chooses, frontswap can be configured as a "writethrough -cache" by calling frontswap_writethrough(). In this mode, the reduction -in swap device writes is lost (and also a non-trivial performance advantage) -in order to allow the backend to arbitrarily "reclaim" space used to -store frontswap pages to more completely manage its memory usage. - Note that if a page is stored and the page already exists in transcendent memory (a "duplicate" store), either the store succeeds and the data is overwritten, or the store fails AND the page is invalidated. This ensures stale data may
include/linux/frontswap.h +0 -1
@@ -26,7 +26,6 @@ struct frontswap_ops {extern void frontswap_register_ops (struct frontswap_ops *ops);extern void frontswap_shrink (unsigned long );extern unsigned long frontswap_curr_pages (void ); -extern void frontswap_writethrough (bool );#define FRONTSWAP_HAS_EXCLUSIVE_GETS extern void frontswap_tmem_exclusive_gets (bool );
mm/frontswap.c +1 -22
@@ -32,16 +32,6 @@ static struct frontswap_ops *frontswap_ops __read_mostly;#define for_each_frontswap_ops (ops) \ for ((ops) = frontswap_ops; (ops); (ops) = (ops)->next) -/* -* If enabled, frontswap_store will return failure even on success. As -* a result, the swap subsystem will always write the page to swap, in -* effect converting frontswap into a writethrough cache. In this mode, -* there is no direct reduction in swap writes, but a frontswap backend -* can unilaterally "reclaim" any pages in use with no data loss, thus -* providing increases control over maximum memory usage due to frontswap. -*/ -static bool frontswap_writethrough_enabled__read_mostly ; -/* * If enabled, the underlying tmem implementation is capable of doing * exclusive gets, so frontswap_load, on a successful tmem_get must
@@ -170,15 +160,6 @@ void frontswap_register_ops(struct frontswap_ops *ops) }EXPORT_SYMBOL (frontswap_register_ops); -/* -* Enable/disable frontswap writethrough (see above). -*/ -void frontswap_writethrough (bool enable) -{ - frontswap_writethrough_enabled = enable; -} -EXPORT_SYMBOL (frontswap_writethrough); -/* * Enable/disable frontswap exclusive gets (see above). */
@@ -283,9 +264,7 @@ int __frontswap_store(struct page *page) }else {inc_frontswap_failed_stores (); } -if (frontswap_writethrough_enabled) -/* report failure so swap also writes to swap device */ - ret =-1 ; +return ret; }EXPORT_SYMBOL (__frontswap_store);
Signature · 1 line
2.30.2
PATCH 3/13 frontswap: remove frontswap_tmem_exclusive_gets
In reply to Christoph Hellwigfrontswap_tmem_exclusive_gets is never called, so remove it.
--- include/linux/frontswap.h | 2 -- mm/frontswap.c | 23 +---------------------- 2 files changed, 1 insertion(+), 24 deletions(-)
include/linux/frontswap.h +0 -2
@@ -26,8 +26,6 @@ struct frontswap_ops {extern void frontswap_register_ops (struct frontswap_ops *ops);extern void frontswap_shrink (unsigned long );extern unsigned long frontswap_curr_pages (void ); -#define FRONTSWAP_HAS_EXCLUSIVE_GETS -extern void frontswap_tmem_exclusive_gets (bool );extern bool __frontswap_test (struct swap_info_struct *,pgoff_t );extern void __frontswap_init (unsigned type,unsigned long *map);
mm/frontswap.c +1 -22
@@ -32,13 +32,6 @@ static struct frontswap_ops *frontswap_ops __read_mostly;#define for_each_frontswap_ops (ops) \ for ((ops) = frontswap_ops; (ops); (ops) = (ops)->next) -/* -* If enabled, the underlying tmem implementation is capable of doing -* exclusive gets, so frontswap_load, on a successful tmem_get must -* mark the page as no longer in frontswap AND mark it dirty. -*/ -static bool frontswap_tmem_exclusive_gets_enabled__read_mostly ; -#ifdef CONFIG_DEBUG_FS /* * Counters available via /sys/kernel/debug/frontswap (if debugfs is
@@ -160,15 +153,6 @@ void frontswap_register_ops(struct frontswap_ops *ops) }EXPORT_SYMBOL (frontswap_register_ops); -/* -* Enable/disable frontswap exclusive gets (see above). -*/ -void frontswap_tmem_exclusive_gets (bool enable) -{ - frontswap_tmem_exclusive_gets_enabled = enable; -} -EXPORT_SYMBOL (frontswap_tmem_exclusive_gets); -/* * Called when a swap device is swapon'd. */
@@ -296,13 +280,8 @@ int __frontswap_load(struct page *page)if (!ret)/* successful load */ break ; } -if (ret ==0 ) { +if (ret ==0 )inc_frontswap_loads (); -if (frontswap_tmem_exclusive_gets_enabled) { -SetPageDirty (page); -__frontswap_clear (sis, offset); - } - }return ret; }EXPORT_SYMBOL (__frontswap_load);
Signature · 1 line
2.30.2
PATCH 4/13 frontswap: remove frontswap_shrink
In reply to Christoph Hellwigfrontswap_shrink is never called, so remove it.
--- Documentation/vm/frontswap.rst | 13 ------ include/linux/frontswap.h | 1 - mm/frontswap.c | 83 ---------------------------------- 3 files changed, 97 deletions(-)
Documentation/vm/frontswap.rst +0 -13
@@ -255,19 +255,6 @@ the old data and ensure that it is no longer accessible. Since the swap subsystem then writes the new data to the read swap device, this is the correct course of action to ensure coherency. -* What is frontswap_shrink for? - -When the (non-frontswap) swap subsystem swaps out a page to a real -swap device, that page is only taking up low-value pre-allocated disk -space. But if frontswap has placed a page in transcendent memory, that -page may be taking up valuable real estate. The frontswap_shrink -routine allows code outside of the swap subsystem to force pages out -of the memory managed by frontswap and back into kernel-addressable memory. -For example, in RAMster, a "suction driver" thread will attempt -to "repatriate" pages sent to a remote machine back to the local machine; -this is driven using the frontswap_shrink mechanism when memory pressure -subsides. - * Why does the frontswap patch create the new include file swapfile.h? The frontswap code depends on some swap-subsystem-internal data
include/linux/frontswap.h +0 -1
@@ -24,7 +24,6 @@ struct frontswap_ops { };extern void frontswap_register_ops (struct frontswap_ops *ops); -extern void frontswap_shrink (unsigned long );extern unsigned long frontswap_curr_pages (void );extern bool __frontswap_test (struct swap_info_struct *,pgoff_t );
mm/frontswap.c +0 -83
89 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 5/13 frontswap: remove frontswap_curr_pages
In reply to Christoph Hellwigfrontswap_curr_pages is never called, so remove it.
--- include/linux/frontswap.h | 1 - mm/frontswap.c | 28 ---------------------------- 2 files changed, 29 deletions(-)
include/linux/frontswap.h +0 -1
@@ -24,7 +24,6 @@ struct frontswap_ops { };extern void frontswap_register_ops (struct frontswap_ops *ops); -extern unsigned long frontswap_curr_pages (void );extern bool __frontswap_test (struct swap_info_struct *,pgoff_t );extern void __frontswap_init (unsigned type,unsigned long *map);
mm/frontswap.c +0 -28
@@ -330,34 +330,6 @@ void __frontswap_invalidate_area(unsigned type) }EXPORT_SYMBOL (__frontswap_invalidate_area); -static unsigned long __frontswap_curr_pages (void ) -{ -unsigned long totalpages =0 ; -struct swap_info_struct *si =NULL ; - -assert_spin_locked (&swap_lock); -plist_for_each_entry (si, &swap_active_head, list) - totalpages +=atomic_read (&si->frontswap_pages); -return totalpages; -} - -/* -* Count and return the number of frontswap pages across all -* swap devices. This is exported so that backend drivers can -* determine current usage without reading debugfs. -*/ -unsigned long frontswap_curr_pages (void ) -{ -unsigned long totalpages =0 ; - -spin_lock (&swap_lock); - totalpages =__frontswap_curr_pages (); -spin_unlock (&swap_lock); - -return totalpages; -} -EXPORT_SYMBOL (frontswap_curr_pages); -static int __init init_frontswap (void ) {#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.30.2
PATCH 6/13 frontswap: simplify frontswap_init
In reply to Christoph HellwigJust use IS_ENABLED() and remove the __frontswap_init indirection. Also remove the unused export.
--- include/linux/frontswap.h | 9 +-------- mm/frontswap.c | 3 +-- mm/swapfile.c | 3 ++- 3 files changed, 4 insertions(+), 11 deletions(-)
include/linux/frontswap.h +1 -8
@@ -26,7 +26,7 @@ struct frontswap_ops {extern void frontswap_register_ops (struct frontswap_ops *ops);extern bool __frontswap_test (struct swap_info_struct *,pgoff_t ); -extern void __frontswap_init (unsigned type,unsigned long *map); +extern void frontswap_init (unsigned type,unsigned long *map);extern int __frontswap_store (struct page *page);extern int __frontswap_load (struct page *page);extern void __frontswap_invalidate_page (unsigned ,pgoff_t );
@@ -107,11 +107,4 @@ static inline void frontswap_invalidate_area(unsigned type) __frontswap_invalidate_area(type); } -static inline void frontswap_init (unsigned type,unsigned long *map) -{ -#ifdef CONFIG_FRONTSWAP -__frontswap_init (type, map); -#endif -} -#endif /* _LINUX_FRONTSWAP_H */
mm/frontswap.c +1 -2
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(frontswap_register_ops);/* * Called when a swap device is swapon'd. */ -void __frontswap_init (unsigned type,unsigned long *map) +void frontswap_init (unsigned type,unsigned long *map) {struct swap_info_struct *sis = swap_info[type];struct frontswap_ops *ops;
@@ -179,7 +179,6 @@ void __frontswap_init(unsigned type, unsigned long *map)for_each_frontswap_ops (ops) ops->init (type); } -EXPORT_SYMBOL (__frontswap_init);bool __frontswap_test (struct swap_info_struct *sis,pgoff_t offset)
mm/swapfile.c +2 -1
@@ -2463,7 +2463,8 @@ static void enable_swap_info(struct swap_info_struct *p, int prio,struct swap_cluster_info *cluster_info, unsigned long *frontswap_map) { - frontswap_init(p->type, frontswap_map); + if (IS_ENABLED(CONFIG_FRONTSWAP)) + frontswap_init(p->type, frontswap_map); spin_lock(&swap_lock);spin_lock (&p->lock);setup_swap_info (p, prio, swap_map, cluster_info);
Signature · 1 line
2.30.2
PATCH 7/13 frontswap: remove the frontswap exports
In reply to Christoph HellwigNone of the frontswap API is called from modular code.
--- mm/frontswap.c | 6 ------ 1 file changed, 6 deletions(-)
mm/frontswap.c +0 -6
@@ -151,7 +151,6 @@ void frontswap_register_ops(struct frontswap_ops *ops) } } } -EXPORT_SYMBOL (frontswap_register_ops);/* * Called when a swap device is swapon'd.
@@ -187,7 +186,6 @@ bool __frontswap_test(struct swap_info_struct *sis,return test_bit (offset, sis->frontswap_map);return false; } -EXPORT_SYMBOL (__frontswap_test);static inline void __frontswap_set (struct swap_info_struct *sis,pgoff_t offset)
@@ -250,7 +248,6 @@ int __frontswap_store(struct page *page)return ret; } -EXPORT_SYMBOL (__frontswap_store);/* * "Get" data from frontswap associated with swaptype and offset that were
@@ -283,7 +280,6 @@ int __frontswap_load(struct page *page)inc_frontswap_loads ();return ret; } -EXPORT_SYMBOL (__frontswap_load);/* * Invalidate any data from frontswap associated with the specified swaptype
@@ -305,7 +301,6 @@ void __frontswap_invalidate_page(unsigned type, pgoff_t offset)__frontswap_clear (sis, offset);inc_frontswap_invalidates (); } -EXPORT_SYMBOL (__frontswap_invalidate_page);/* * Invalidate all data from frontswap associated with all offsets for the
@@ -327,7 +322,6 @@ void __frontswap_invalidate_area(unsigned type)atomic_set (&sis->frontswap_pages,0 );bitmap_zero (sis->frontswap_map, sis->max); } -EXPORT_SYMBOL (__frontswap_invalidate_area);static int __init init_frontswap (void ) {
Signature · 1 line
2.30.2
PATCH 8/13 mm: simplify try_to_unuse
In reply to Christoph HellwigRemove the unused frontswap and pages_to_unuse arguments, and mark the function static now that the caller in frontswap is gone.
--- include/linux/frontswap.h | 7 ---- include/linux/shmem_fs.h | 3 +- include/linux/swapfile.h | 1 - mm/shmem.c | 33 +++------------- mm/swapfile.c | 83 +++++++++++---------------------------- 5 files changed, 30 insertions(+), 97 deletions(-)
include/linux/frontswap.h +0 -7
@@ -7,13 +7,6 @@#include <linux/bitops.h> #include <linux/jump_label.h> -/* -* Return code to denote that requested number of -* frontswap pages are unused(moved to page cache). -* Used in shmem_unuse and try_to_unuse. -*/ -#define FRONTSWAP_PAGES_UNUSED 2 -struct frontswap_ops {void (*init)(unsigned );/* this swap type was just swapon'ed */ int (*store)(unsigned ,pgoff_t ,struct page *);/* store a page */
include/linux/shmem_fs.h +1 -2
@@ -83,8 +83,7 @@ extern void shmem_unlock_mapping(struct address_space *mapping);extern struct page *shmem_read_mapping_page_gfp (struct address_space *mapping,pgoff_t index,gfp_t gfp_mask);extern void shmem_truncate_range (struct inode *inode,loff_t start,loff_t end); -extern int shmem_unuse (unsigned int type,bool frontswap, -unsigned long *fs_pages_to_unuse); +int shmem_unuse (unsigned int type);extern bool shmem_is_huge (struct vm_area_struct *vma,struct inode *inode,pgoff_t index);
include/linux/swapfile.h +0 -1
@@ -9,7 +9,6 @@extern spinlock_t swap_lock;extern struct plist_head swap_active_head;extern struct swap_info_struct *swap_info[]; -extern int try_to_unuse (unsigned int ,bool ,unsigned long );extern unsigned long generic_max_swapfile_size (void );extern unsigned long max_swapfile_size (void );
mm/shmem.c +6 -27
@@ -36,7 +36,6 @@#include <linux/uio.h> #include <linux/khugepaged.h> #include <linux/hugetlb.h> -#include <linux/frontswap.h> #include <linux/fs_parser.h> #include <linux/swapfile.h>
@@ -1146,7 +1145,7 @@ static void shmem_evict_inode(struct inode *inode)static int shmem_find_swap_entries (struct address_space *mapping,pgoff_t start,unsigned int nr_entries,struct page **entries,pgoff_t *indices, -unsigned int type,bool frontswap) +unsigned int type) {XA_STATE (xas, &mapping->i_pages, start);struct page *page;
@@ -1167,9 +1166,6 @@ static int shmem_find_swap_entries(struct address_space *mapping, entry =radix_to_swp_entry (page);if (swp_type (entry) != type)continue ; -if (frontswap && - !frontswap_test (swap_info[type],swp_offset (entry))) -continue ; indices[ret] = xas.xa_index; entries[ret] = page;
@@ -1222,26 +1218,20 @@ static int shmem_unuse_swap_entries(struct inode *inode, struct pagevec pvec,/* * If swap found in inode, free it and move page from swapcache to filecache. */ -static int shmem_unuse_inode (struct inode *inode,unsigned int type, -bool frontswap,unsigned long *fs_pages_to_unuse) +static int shmem_unuse_inode (struct inode *inode,unsigned int type) {struct address_space *mapping = inode->i_mapping;pgoff_t start =0 ;struct pagevec pvec;pgoff_t indices[PAGEVEC_SIZE ]; -bool frontswap_partial = (frontswap && *fs_pages_to_unuse >0 );int ret =0 ;pagevec_init (&pvec); do { unsigned int nr_entries = PAGEVEC_SIZE; - if (frontswap_partial && *fs_pages_to_unuse < PAGEVEC_SIZE) - nr_entries = *fs_pages_to_unuse; - pvec.nr = shmem_find_swap_entries(mapping, start, nr_entries, - pvec.pages, indices, - type, frontswap); + pvec.pages, indices, type); if (pvec.nr == 0) { ret = 0; break;
@@ -1251,14 +1241,6 @@ static int shmem_unuse_inode(struct inode *inode, unsigned int type,if (ret <0 )break ; -if (frontswap_partial) { - *fs_pages_to_unuse -= ret; -if (*fs_pages_to_unuse ==0 ) { - ret =FRONTSWAP_PAGES_UNUSED ; -break ; - } - } - start = indices[pvec.nr -1 ]; }while (true);
@@ -1270,8 +1252,7 @@ static int shmem_unuse_inode(struct inode *inode, unsigned int type,* device 'type' back into memory, so the swap device can be * unused. */ -int shmem_unuse (unsigned int type,bool frontswap, -unsigned long *fs_pages_to_unuse) +int shmem_unuse (unsigned int type) {struct shmem_inode_info *info, *next;int error =0 ;
@@ -1294,8 +1275,7 @@ int shmem_unuse(unsigned int type, bool frontswap,atomic_inc (&info->stop_eviction);mutex_unlock (&shmem_swaplist_mutex); - error =shmem_unuse_inode (&info->vfs_inode, type, frontswap, - fs_pages_to_unuse); + error =shmem_unuse_inode (&info->vfs_inode, type);cond_resched ();mutex_lock (&shmem_swaplist_mutex);
@@ -4009,8 +3989,7 @@ int __init shmem_init(void)return 0 ; } -int shmem_unuse (unsigned int type,bool frontswap, -unsigned long *fs_pages_to_unuse) +int shmem_unuse (unsigned int type,unsigned long *fs_pages_to_unuse) {return 0 ; }
mm/swapfile.c +23 -60
220 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 9/13 frontswap: remove frontswap_test
In reply to Christoph Hellwigfrontswap_test is unused now, remove it.
--- include/linux/frontswap.h | 11 ----------- mm/frontswap.c | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-)
include/linux/frontswap.h +0 -11
@@ -18,7 +18,6 @@ struct frontswap_ops {extern void frontswap_register_ops (struct frontswap_ops *ops); -extern bool __frontswap_test (struct swap_info_struct *,pgoff_t );extern void frontswap_init (unsigned type,unsigned long *map);extern int __frontswap_store (struct page *page);extern int __frontswap_load (struct page *page);
@@ -33,11 +32,6 @@ static inline bool frontswap_enabled(void)return static_branch_unlikely (&frontswap_enabled_key); } -static inline bool frontswap_test (struct swap_info_struct *sis,pgoff_t offset) -{ -return __frontswap_test (sis, offset); -} -static inline void frontswap_map_set (struct swap_info_struct *p,unsigned long *map) {
@@ -56,11 +50,6 @@ static inline bool frontswap_enabled(void)return false; } -static inline bool frontswap_test (struct swap_info_struct *sis,pgoff_t offset) -{ -return false; -} -static inline void frontswap_map_set (struct swap_info_struct *p,unsigned long *map) {
mm/frontswap.c +1 -1
@@ -179,7 +179,7 @@ void frontswap_init(unsigned type, unsigned long *map) ops->init (type); } -bool __frontswap_test (struct swap_info_struct *sis, +static bool __frontswap_test (struct swap_info_struct *sis,pgoff_t offset) {if (sis->frontswap_map)
Signature · 1 line
2.30.2
PATCH 10/13 frontswap: simplify frontswap_register_ops
In reply to Christoph HellwigGiven that frontswap_register_ops must be called from built-in code, there is no need to handle the case of swapfiles coming online before or during it, so delete the code that deals with that case.
--- mm/frontswap.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-)
mm/frontswap.c +0 -41
@@ -99,25 +99,6 @@ static inline void inc_frontswap_invalidates(void) { }*/ void frontswap_register_ops (struct frontswap_ops *ops) { -DECLARE_BITMAP (a,MAX_SWAPFILES ); -DECLARE_BITMAP (b,MAX_SWAPFILES ); -struct swap_info_struct *si; -unsigned int i; - -bitmap_zero (a,MAX_SWAPFILES ); -bitmap_zero (b,MAX_SWAPFILES ); - -spin_lock (&swap_lock); -plist_for_each_entry (si, &swap_active_head, list) { -if (!WARN_ON (!si->frontswap_map)) -__set_bit (si->type, a); - } -spin_unlock (&swap_lock); - -/* the new ops needs to know the currently active swap devices */ -for_each_set_bit (i, a,MAX_SWAPFILES ) - ops->init (i); -/* * Setting frontswap_ops must happen after the ops->init() calls * above; cmpxchg implies smp_mb() which will ensure the init is
@@ -128,28 +109,6 @@ void frontswap_register_ops(struct frontswap_ops *ops) }while (cmpxchg (&frontswap_ops, ops->next, ops) != ops->next);static_branch_inc (&frontswap_enabled_key); - -spin_lock (&swap_lock); -plist_for_each_entry (si, &swap_active_head, list) { -if (si->frontswap_map) -__set_bit (si->type, b); - } -spin_unlock (&swap_lock); - -/* -* On the very unlikely chance that a swap device was added or -* removed between setting the "a" list bits and the ops init -* calls, we re-check and do init or invalidate for any changed -* bits. -*/ -if (unlikely (!bitmap_equal (a, b,MAX_SWAPFILES ))) { -for (i =0 ; i <MAX_SWAPFILES ; i++) { -if (!test_bit (i, a) &&test_bit (i, b)) - ops->init (i); -else if (test_bit (i, a) && !test_bit (i, b)) - ops->invalidate_area (i); - } - } }/*
Signature · 1 line
2.30.2
PATCH 11/13 mm: mark swap_lock and swap_active_head static
In reply to Christoph Hellwigswap_lock and swap_active_head are only used in swapfile.c, so mark them static.
--- include/linux/swapfile.h | 2 -- mm/swapfile.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-)
include/linux/swapfile.h +0 -2
@@ -6,8 +6,6 @@* these were static in swapfile.c but frontswap.c needs them and we don't * want to expose them to the dozens of source files that include swap.h */ -extern spinlock_t swap_lock; -extern struct plist_head swap_active_head;extern struct swap_info_struct *swap_info[];extern unsigned long generic_max_swapfile_size (void );extern unsigned long max_swapfile_size (void );
mm/swapfile.c +2 -2
@@ -49,7 +49,7 @@ static bool swap_count_continued(struct swap_info_struct *, pgoff_t, unsigned char);static void free_swap_count_continuations (struct swap_info_struct *); -DEFINE_SPINLOCK (swap_lock); +static DEFINE_SPINLOCK (swap_lock);static unsigned int nr_swapfiles;atomic_long_t nr_swap_pages;/*
@@ -71,7 +71,7 @@ static const char Unused_offset[] = "Unused swap offset entry ";* all active swap_info_structs * protected with swap_lock, and ordered by priority. */ -PLIST_HEAD (swap_active_head); +static PLIST_HEAD (swap_active_head);/* * all available (active, not full) swap_info_structs
Signature · 1 line
2.30.2
PATCH 12/13 frontswap: remove support for multiple ops
In reply to Christoph HellwigThere is only a single instance of frontswap ops in the kernel, so simplify the frontswap code by removing support for multiple operations.
--- include/linux/frontswap.h | 3 +-- mm/frontswap.c | 50 ++++++++++----------------------------- mm/zswap.c | 8 +++++-- 3 files changed, 19 insertions(+), 42 deletions(-)
include/linux/frontswap.h +1 -2
@@ -13,10 +13,9 @@ struct frontswap_ops {int (*load)(unsigned ,pgoff_t ,struct page *);/* load a page */ void (*invalidate_page)(unsigned ,pgoff_t );/* page no longer needed */ void (*invalidate_area)(unsigned );/* swap type just swapoff'ed */ -struct frontswap_ops *next;/* private pointer to next ops */ }; -extern void frontswap_register_ops (struct frontswap_ops *ops); +int frontswap_register_ops (const struct frontswap_ops *ops);extern void frontswap_init (unsigned type,unsigned long *map);extern int __frontswap_store (struct page *page);
mm/frontswap.c +12 -38
127 lines not on this page · raw message
mm/zswap.c +6 -2
@@ -1378,7 +1378,7 @@ static void zswap_frontswap_init(unsigned type) zswap_trees[type] = tree; } -static struct frontswap_ops zswap_frontswap_ops = { +static const struct frontswap_ops zswap_frontswap_ops = { .store = zswap_frontswap_store, .load = zswap_frontswap_load, .invalidate_page = zswap_frontswap_invalidate_page,
@@ -1475,11 +1475,15 @@ static int __init init_zswap(void)if (!shrink_wq) goto fallback_fail; -frontswap_register_ops (&zswap_frontswap_ops); + ret =frontswap_register_ops (&zswap_frontswap_ops); +if (ret) + goto destroy_wq;if (zswap_debugfs_init ())pr_warn ("debugfs initialization failed\n" );return 0 ; +destroy_wq: +destroy_workqueue (shrink_wq); fallback_fail:if (pool)zswap_pool_destroy (pool);
Signature · 1 line
2.30.2
PATCH 13/13 mm: hide the FRONTSWAP Kconfig symbol
In reply to Christoph HellwigSelect FRONTSWAP from ZSWAP instead of prompting for it.
--- mm/Kconfig | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
mm/Kconfig +3 -15
@@ -445,20 +445,7 @@ config HAVE_SETUP_PER_CPU_AREA bool config FRONTSWAP - bool "Enable frontswap to cache swap pages if tmem is present" - depends on SWAP - help - Frontswap is so named because it can be thought of as the opposite - of a "backing" store for a swap device. The data is stored into - "transcendent memory", memory that is not directly accessible or - addressable by the kernel and is of unknown and possibly - time-varying size. When space in transcendent memory is available, - a significant swap I/O reduction may be achieved. When none is - available, all frontswap calls are reduced to a single pointer- - compare-against-NULL resulting in a negligible performance hit - and swap data is stored as normal on the matching swap device. - - If unsure, say Y to enable frontswap. + bool config CMA bool "Contiguous Memory Allocator"
@@ -523,7 +510,8 @@ config MEM_SOFT_DIRTY config ZSWAP bool "Compressed cache for swap pages (EXPERIMENTAL)" - depends on FRONTSWAP && CRYPTO=y + depends on SWAP && CRYPTO=y + select FRONTSWAP select ZPOOL help A lightweight compressed cache for swap pages. It takes
Signature · 1 line
2.30.2
Quoted 7 lines · Christoph Hellwig
Hi all,
since the remove of the Xen tmem driver in 2019, the cleancache hooks are entirely unused, as are large parts of frontswap. This series against linux-next (with the folio changes included) removes cleancaches, and cuts down frontswap to the bits actually used by zswap.
Just out of curiosity, why was tmem removed from Linux (or even Xen?). Do you have any information?
Happy to see this cleanup.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 2 lines · David Hildenbrand
Just out of curiosity, why was tmem removed from Linux (or even Xen?). Do you have any information?
"The Xen tmem (transcendent memory) driver can be removed, as the
related Xen hypervisor feature never made it past the "experimental" state and will be removed in future Xen versions (>= 4.13).
The xen-selfballoon driver depends on tmem, so it can be removed, too."
Quoted 11 lines · David Hildenbrand
Quoted 7 lines · Christoph Hellwig
Hi all,
since the remove of the Xen tmem driver in 2019, the cleancache hooks are entirely unused, as are large parts of frontswap. This series against linux-next (with the folio changes included) removes cleancaches, and cuts down frontswap to the bits actually used by zswap.
Just out of curiosity, why was tmem removed from Linux (or even Xen?). Do you have any information?
tmem never made it past the "experimental" state in the Xen hypervisor. Its implementation had some significant security flaws, there was no maintainer left, and nobody stepped up to address those issues.
As a result tmem was removed from Xen.
Juergen
Quoted 10 lines · Juergen Gross
Quoted 9 lines · David Hildenbrand
Quoted 7 lines · Christoph Hellwig
Hi all,
since the remove of the Xen tmem driver in 2019, the cleancache hooks are entirely unused, as are large parts of frontswap. This series against linux-next (with the folio changes included) removes cleancaches, and cuts down frontswap to the bits actually used by zswap.
Quoted 8 lines
Quoted 2 lines
Just out of curiosity, why was tmem removed from Linux (or even Xen?). Do you have any information?
tmem never made it past the "experimental" state in the Xen hypervisor. Its implementation had some significant security flaws, there was no maintainer left, and nobody stepped up to address those issues.
As a result tmem was removed from Xen.
Interesting, thanks for sharing. I know tmem mostly from the papers and thought it was an interesting approach in general. There was even papers about a virtio implementation, however, actual code never appeared in the wild :)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 18 lines · David Hildenbrand
Quoted 17 lines · Juergen Gross
Quoted 11 lines · David Hildenbrand
Quoted 7 lines · Christoph Hellwig
Hi all,
since the remove of the Xen tmem driver in 2019, the cleancache hooks are entirely unused, as are large parts of frontswap. This series against linux-next (with the folio changes included) removes cleancaches, and cuts down frontswap to the bits actually used by zswap.
Just out of curiosity, why was tmem removed from Linux (or even Xen?). Do you have any information?
tmem never made it past the "experimental" state in the Xen hypervisor. Its implementation had some significant security flaws, there was no maintainer left, and nobody stepped up to address those issues.
Quoted 6 lines
Quoted 1 line
As a result tmem was removed from Xen.
Interesting, thanks for sharing. I know tmem mostly from the papers and thought it was an interesting approach in general. There was even papers about a virtio implementation, however, actual code never appeared in the wild :)
There is a repo of it .. I can find it if you are interested - but as Juergen mentioned - I didn't have enough steam to finish up the security rework so code removed.