Why negative-dentry-limit sysctl parameter is not available in Red Hat Enterprise Linux 8?

Solution Verified - Updated -

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 sysctl dentry-fs-klimit can be used for a similar limitation which has been introduced with kernel-4.18.0-553.62.1.el8_10. via Errata RHSA-2025:11298.

  • RHEL-8 is more capable of handling the negative dentries situation, however the changes between RHEL-7 and RHEL-8 would have required backporting a large number of patches to the RHEL-7 kernel, which would have caused a large disruption in the kernel code. For this reason, the new sysctl parameter negative-dentry-limit was added into the RHEL-7.8 kernel code.

  • Although RHEL-8 can 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 with RHEL-7, a sysctl parameter has also been added to the RHEL-8.10 kernel allowing a similar limitation. In RHEL-8, the parameter is dentry-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