[kwlug-disc] fun: 10k to a million threads and more?
Giles Malet
gdmalet at gmail.com
Tue May 30 16:55:24 EDT 2023
On 2023-05-30 12:47, Chris Frey wrote:
> Resource temporarily unavailable
>
> This is the case whether I hit a ulimit limit or some other /proc level
> limit. If it told me the resource that was unavailable, that would
> be more helpful, but I don't think EAGAIN gives that information.
Running your little program under strace causes it to fail thusly:
clone(child_stack=0x7ed76facaef0,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
parent_tid=[3237034], tls=0x7ed76fac>
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1,
0) = 0x7ed76eaca000
mprotect(0x7ed76eacb000, 8388608, PROT_READ|PROT_WRITE) = -1 ENOMEM
(Cannot allocate memory)
Nomem being "temporary" that leads to EAGAIN:
write(2, " what(): ", 11 what(): ) = 11
write(2, "Resource temporarily unavailable", 32Resource temporarily
unavailable) = 32
The man page for mprotect says:
ENOMEM Internal kernel structures could not be allocated.
ENOMEM Addresses in the range [addr, addr+len-1] are invalid
for the address space of the process, or specify one or more pages that
are not mapped. (Before kernel 2.4.19, the error EFAULT was incorrectly
produced for these cases.)
ENOMEM Changing the protection of a memory region would result
in the total number of mappings with distinct attributes (e.g., read
versus read/write protection) exceeding the allowed maximum. [...]
My guess then is that it's either the first or last of these three. If
the first I have no idea how one would allocate more kernel structures.
Or how to correct that last actually.
g
More information about the kwlug-disc
mailing list