Cannot edit /proc/sys/kernel/threads-max
The repsonse lies in man proc(5)
, here is the interesting part:
/proc/sys/kernel/threads-max (since Linux 2.3.11)
This file specifies the system-wide limit on the number
of threads (tasks) that can be created on the system.
Since Linux 4.1, the value that can be written to
threads-max is bounded. The minimum value that can be
written is 20. The maximum value that can be written
is given by the constant FUTEX_TID_MASK (0x3fffffff).
If a value outside of this range is written to threads-
max, the error EINVAL occurs.
The value written is checked against the available RAM
pages. If the thread structures would occupy too much
(more than 1/8th) of the available RAM pages, threads-
max is reduced accordingly.
I assume your kernel version is > 4.1, so since 200000 (the number you try) is less than 0x3fffffff, the problem looks like the available RAM in not sufficient.
Related videos on Youtube
Comments
-
Anarkopsykotik over 1 year
I am currently building a stress testing tool, and as such I need a pretty massive number of threads. I already went through all settings to raise the limit, but there is one last setting, the upper system-wide limit in
/proc/sys/kernel/threads-max
, that I can't seem to be able to change.I tried
sysctl -w kernel.threads-max=200000
Editing manually with
nano
orecho
echo 200000 > /proc/sys/kernel/threads-max
Editing
/etc/sysctl.conf
and runningsysctl -f
If I run those as
sudo
, I have no error displayed (the new value is even displayed), but when checking again, the value hasn't changed either. When trying to edit the value withgedit
, it spat aninvalid argument"
whatever the value I try, even the original one. I had no problem changing the
pid_max
value.I really have no clue why it refuses my edits, and I haven't been able to find anybody with a similar problem, so I would be very grateful if someone could explain what is happening.
-
quadruplebucky almost 7 years
-
Anarkopsykotik almost 7 yearsThe whole problem is precisely that the simple&obvious method does not work...
-
Knud Larsen almost 7 yearsThe files in /proc/ are virtual, and can as such not be edited. ( Please try
$ du /proc/
to know there isn't anything! ) .... The setting "kernel.threads-max=200000" is elsewhere ... -
Anarkopsykotik over 6 yearsThey can be edited, I have done so for other settings, and also modified that one on other machines (test servers running fedora)
-
-
Anarkopsykotik over 6 yearsIsn't 0x3fffffff more than 2.000.000.000 ? Also, even the original numbers or lower did not work, although it could be indeed related to the limit on available ram.
-
pim over 6 years200,000 is far less than 0x3fffffff, like it is written
-
Anarkopsykotik over 6 yearsWell google is lying to me or its not hexa then ;p But anyway, I am pretty sure it's related to available ram, as tweaking the number seem to work now (did not work last time, so must depend on actually used RAM) but as soon as I get too high, it revert to a default of 96062 (which must be calculated from my physical ram)
-
James McGuigan about 6 yearsUntested, but Wolfram Alpha says 0x3fffffff = 1073741823, so the following should be:
echo kernel.threads-max = 1073741823 >> /etc/sysctl.conf
echo 1073741823 > /proc/sys/kernel/threads-max
(wolframalpha.com/input/?i=0x3fffffff) -
Jonathan almost 5 yearsJames' comment is the only thing that worked for me.