问题原文
原帖链接 · Valeriy Maslov · CC BY-SA 3.0
I have some multithread apps on my server machine based on FreeBSD 7.2, so because of this I need to increase kern.threads.max_threads_per_proc to 4000 (default value is 1500). I changed it using "sysctl kern.threads.max_threads_per_proc=4096" and it looks like ok, but after reboot this option has default value again. I also tried to use /boot/loader.conf but it's still returning to default value.
This is what contains in loader.conf:
kern.maxdsiz=1073741824
kern.maxtsiz=1073741824
kern.maxssiz=268435456
kern.maxproc=10000
kern.maxprocperuid=9000
kern.threads.max_threads_per_proc=4000
And even with this settings "sysctl kern.threads.max_threads_per_proc" shows defalut value (1500) after reboot.
Please, tell me how can I change this permanently?
已采纳解答
原帖链接 · Valeriy Maslov · CC BY-SA 3.0
Well, first of all thank you for all your answers. They are all right of course, but the reason of my problem was a bit deeper, inside kernel source code :)
I try to eplain my solution step by step, what I found.
So, like @citrin said kern.threads.max_threads_per_proc is needed to be set in sysctl.conf. But this doesn't help to change value more than 1500 (this is kernel max and defaul by the way). So, this is because there is another limit in system which overrides any of user defined values. I didn't know exactly where it is, so I tried to found something in kernel sources.
I found this value inside kernel sources: /usr/src/sys/kern/kern_thread.c. It contains code like this:
int max_threads_per_proc = 1500;
SYSCTL_INT(_kern_threads, OID_AUTO, max_threads_per_proc, CTLFLAG_RW,
&max_threads_per_proc, 0, "Limit on threads per proc");
I changed that value to 5000 and build new kernel with GENERIC configuration and installed it. There was a little surprise for me cause I had thread limit setted 4096 inside sysctl.conf, but the working value was 5000, like in sources.
Although kernel values somehow overrides user defined, so, this still causes questions, but right now my problem is solved, thread limit was permanently increased.
Thanks for your answers again.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
