Environment
- Red Hat Enterprise Linux 7
Issue
- What is the maximum value of fs.nr_open?
Resolution
The maximum value of fs.nr_open
is limited to sysctl_nr_open_max in kernel, which is 2147483584 on x86_64.
fs/file.c in kernel-3.10.0-957.el7:
#define __const_min(x, y) ((x) < (y) ? (x) : (y))
int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) &
-BITS_PER_LONG;
Note: The value of "Max open files"(ulimit -n) is limited to fs.nr_open value.
Diagnostic Steps
# ulimit -n 2147483584
-bash: ulimit: open files: cannot modify limit: Operation not permitted
# sysctl fs.nr_open
fs.nr_open = 1048576
# sysctl -w fs.nr_open=2147483584
fs.nr_open = 2147483584
# ulimit -n 2147483584
# ulimit -n
2147483584
# sysctl -w fs.nr_open=2147483585
sysctl: setting key "fs.nr_open": Invalid argument
fs.nr_open = 2147483585
#