Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If fs.file-max is not set in /etc/sysctl.conf on RHEL 5 or its derivatives, how does the kernel determine the default value? Is there a formula used to set the fs.file-max value based on the amount of system RAM? I checked a number of random RHEL servers running the same OS level, but with different hardware configurations, and cat /proc/sys/fs/file-max shows different values on each system.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'll answer my own question: the Linux 2.6 kernel sets the open file limit to 10% of the available memory.

Source: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=fs/file_table.c

 488 void __init files_init(unsigned long mempages)
 489 { 
 490         int n; 
 491 
 492         filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
 493                         SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
 494 
 495         /*
 496          * One file with associated inode and dcache is very roughly 1K.
 497          * Per default don't use more than 10% of our memory for files. 
 498          */ 
 499 
 500         n = (mempages * (PAGE_SIZE / 1024)) / 10;
 501         files_stat.max_files = n; 
 502         if (files_stat.max_files < NR_FILE)
 503                 files_stat.max_files = NR_FILE;
 504         files_defer_init();
 505         lg_lock_init(files_lglock);
 506         percpu_counter_init(&nr_files, 0);
 507 } 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.