Why negative-dentry-limit sysctl parameter is not available in Red Hat Enterprise Linux 8?
Environment
- Red Hat Enterprise Linux 8
Issue
- Why negative-dentry-limit sysctl parameter is not available in Red Hat Enterprise Linux 8 ?
- How Red Hat Enterprise Linux 8 handles negative-dentry-limit situation ?
Resolution
-
In
RHEL-8.10, the sysctldentry-fs-klimitcan be used for a similar limitation which has been introduced withkernel-4.18.0-553.62.1.el8_10.via Errata RHSA-2025:11298. -
RHEL-8is more capable of handling the negative dentries situation, however the changes betweenRHEL-7andRHEL-8would have required backporting a large number of patches to theRHEL-7kernel, which would have caused a large disruption in the kernel code. For this reason, the new sysctl parameternegative-dentry-limitwas added into theRHEL-7.8kernel code. -
Although
RHEL-8can better handle a large number of negative dentries, there are situations where the number becomes so large that performance is affected. In particular unmounts can become slow. Like withRHEL-7, a sysctl parameter has also been added to theRHEL-8.10kernel allowing a similar limitation. InRHEL-8, the parameter isdentry-fs-klimit.
Root Cause
- RHEL 7 Changelog:
# rpm -q kernel --changelog | grep negative-dentry-limit
- [fs] fs/dcache: Add sysctl parameter negative-dentry-limit as a soft limit on negative dentries (Waiman Long) [1489573]
- Snippet from the patchset:
[fs] fs/dcache: Add sysctl parameter negative-dentry-limit as a soft limit on negative dentries
------------>8--------------->8----------------->8-------------->8-------------
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1489573
Upstream Status: RHEL only
The upstream kernel is able to gracefully handle an avalanche of new
negative dentries by invoking memory reclaim to free excess dentries.
RHEL7 kernel, however, is unable to gracefully handle that leading to OOM
in some cases. Kernel memory cgroup in RHEL7 is not able to limit memory
consumed by slab cache either. Backporting the relevant upstream patches
will be too intrusive. So we need some RHEL7 specific solution to handle
this problem.
A new sysctl parameter "negative-dentry-limit" is added to /proc/sys/fs
whose value represents a soft limit on the total number of negative
dentries allowable in a system as a multiple of one-thousandth of the
total system memory available. IOW, each unit represents 0.1% of the
total memory. The allowable range for this new parameter is 0-100
where 0 means no soft limit and 100 means 10% of total system memory.
The actual dentry reclaim to enforce the limit will be done in a
subsequent patch.
------------>8--------------->8----------------->8-------------->8-------------
</snip>
- RHEL 8.10 Changelog:
- fs/dcache: Control # of dentries in list_lru_node (Waiman Long) [RHEL-8578]
- fs/dcache: Add sysctl parameter dentry-fs-klimit to control # of dentries in filesystem (Waiman Long) [RHEL-8578]
- mm/list_lru: Make list_lru_add() return # if items in affected list_lru_node (Waiman Long) [RHEL-8578]
- From the patchset:
This patch enables the control of the maximum number of dentries in a
mounted filesystem as imposed by the dentry-fs-klimit sysctl parameter.
This is done by checking if the internal per list_lru_node limit has been
exceeded whenever a negative dentry is added to a LRU list. If the limit
is breached, a work function will be scheduled to free up to a quarter
of the total number of dentries in that list_lru_node. In this way,
we will keep these LRU lists to within the bound imposed by the limit.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments