vfs: Add sysctl vfs_cache_pressure_denom for bulk file operations
authorYafang Shao <laoar.shao@gmail.com>
Sun, 11 May 2025 08:36:24 +0000 (16:36 +0800)
committerChristian Brauner <brauner@kernel.org>
Thu, 15 May 2025 09:12:59 +0000 (11:12 +0200)
commite7b9cea718eee4585a947b10086ca51ad27ef5d4
tree1f914ef70a868164824f1252d0ce12c4c897dd27
parent8d9117009dd690f647a66912f429c96335069907
vfs: Add sysctl vfs_cache_pressure_denom for bulk file operations

On our HDFS servers with 12 HDDs per server, a HDFS datanode[0] startup
involves scanning all files and caching their metadata (including dentries
and inodes) in memory. Each HDD contains approximately 2 million files,
resulting in a total of ~20 million cached dentries after initialization.

To minimize dentry reclamation, we set vfs_cache_pressure to 1. Despite
this configuration, memory pressure conditions can still trigger
reclamation of up to 50% of cached dentries, reducing the cache from 20
million to approximately 10 million entries. During the subsequent cache
rebuild period, any HDFS datanode restart operation incurs substantial
latency penalties until full cache recovery completes.

To maintain service stability, we need to preserve more dentries during
memory reclamation. The current minimum reclaim ratio (1/100 of total
dentries) remains too aggressive for our workload. This patch introduces
vfs_cache_pressure_denom for more granular cache pressure control. The
configuration [vfs_cache_pressure=1, vfs_cache_pressure_denom=10000]
effectively maintains the full 20 million dentry cache under memory
pressure, preventing datanode restart performance degradation.

Link: https://hadoop.apache.org/docs/r1.2.1/hdfs_design.html#NameNode+and+DataNodes
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Link: https://lore.kernel.org/20250511083624.9305-1-laoar.shao@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Documentation/admin-guide/sysctl/vm.rst
fs/dcache.c