大佬教程收集整理的这篇文章主要介绍了linux-kernel – / proc / sys / fs / file-max的缺省值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是:它的默认值是多少?检查我公司的10台服务器给了我7个不同的值,这些值似乎都是随机的.
内核文档只是提到可以更改值 – 但不是如何计算默认值.
你们中的任何人都知道如何确定默认值吗?
/* And dynamically-tunable limits and defaults: */ struct files_stat_struct { unsigned long nr_files; /* read only */ unsigned long nr_free_files; /* read only */ unsigned long max_files; /* tunable THIS IS OUR VALUE */ };
现在在./fs/file_table.c中,files_stat_struct开始使用:
struct files_stat_struct files_stat = { .max_files = NR_FILE /* This constant is 8192 */ };
现在在前一个文件中“./fs/file_table.c”将具有将成为真正工作的功能
void __init files_init(unsigned long mempages) { unsigned long n; filp_cachep = kmem_cache_create("filp",sizeof(struct filE),SLAB_HWCACHE_ALIGN | SLAB_PANIC,null); /* * One file with associated inode and dcache is very roughly 1K. * Per default don't use more than 10% of our memory for files. */ n = (mempages * (PAGE_SIZE / 1024)) / 10; files_stat.max_files = max_t(unsigned long,n,NR_FILE); files_defer_init(); lg_lock_init(files_lglock); percpu_counter_init(&nr_files,0); }
从我在files_init中看到并查看宏max_t,如果文件的10%内存大于8192,将使用这些值,除非8192.
在内核开始执行时使用files_init,当调用kmem_cache_create创建常规文件slab缓存时,需要查看标志SLAB_PANIC.
现在你需要看看./kernel/sysctl.c
{ .procname = "file-max",.data = &files_stat.max_files,.maxlen = sizeof(files_stat.max_files),.mode = 0644,.proc_handler = proc_doulongvec_minmax,},
以上是大佬教程为你收集整理的linux-kernel – / proc / sys / fs / file-max的缺省值全部内容,希望文章能够帮你解决linux-kernel – / proc / sys / fs / file-max的缺省值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。