I am aware that /proc/sys/fs/file-max defines the maximum number of open file descriptors and can be set on runtime or during boot.
However: what is its default value? Checking 10 servers in my company gives me 7 different values, which all seem kind of random.
The kernel documentation just keeps mentioning that the value can be changed – but not how the default value is calculated.
Does anyone of you know how the default value is determined?
Best Answer
The
file-max
limit that you see underproc fs
is one value in struct in"./include/linux/fs.h"
the struct is:Now in
./fs/file_table.c
thefiles_stat_struct
is begin used:Now in the previous file
"./fs/file_table.c"
will have the function that will make the real jobFrom What I can see in the
files_init
and looking the macromax_t
, If 10% of memory for files is more then 8192, that values will be used, Unless 8192.files_init is used when kernel is begin executed and you need to see the flag SLAB_PANIC when
kmem_cache_create
is called for create the general file slab cache.Now you need to look
./kernel/sysctl.c
The file-max is 10% of memory, If your system has different memory size, I think that is normal.