The Linux kernel implements the page cache to accelerate I/O operations.
It would be helpful to be able to turn off and on the page cache for research and testing.
How can the Linux page cache be diabled?
Update 1: If it is not possible to turn off the page cache globally, it may be possible to mount Linux file systems in write-through mode. When I understand it right, the mount option dax
of EXT2, EXT4, and XFS does implement write-through mode. Is this a valid option to avoid the page cache (at least for a file system)?
https://www.kernel.org/doc/Documentation/filesystems/dax.txt
Update 2: Obviously, DAX is more or less dead, and the page cache cannot be switched off really well (globally, not at all, and for a single application only in a limited manner). But is there really no way to set a Linux file system (e.g., via mount parameter) to write-through mode?
Update 3: The tool dd
is one of the application examples that allow easily to bypassed the page cache of the Linux kernel via oflag=direct
.
https://man7.org/linux/man-pages/man1/dd.1.html
Update 4: Obviously, file systems that make use of the FUSE (Filesystem in Userspace) module can be used in direct-io mode where the page cache is completely bypassed for reads and writes.
https://www.kernel.org/doc/Documentation/filesystems/fuse-io.txt
Update 5: The mount option -o sync
implements write-through mode and bypasses the page cache for some file systems (ext2, ext3, FAT, VFAT, UFS)