Potential deadlock on mbuf
andre at freebsd.org
Tue Apr 3 11:30:01 UTC 2012
On 02.04.2012 18:21, Alexandre Martins wrote:
> I have currently having troubles with a basic socket stress.
> The socket are setup to use non-blocking I/O.
> During this stress-test, the kernel is running mbuf exhaustion, the goal is to
> see system limits.
> If the program make a write on a socket during this mbuf exhaustion, it become
> blocked in "write" system call. The status of the process is "zonelimit" and
> whole network I/O fall in timeout.
> I have found the root cause of the block :
> So, the question is : Why m_uiotombuf is called with a blocking parameter
> (M_WAITOK) even if is for a non-blocking socket ?
> Then, if M_NOWAIT is used, maybe it will be usefull to have an 'ENOMEM' error.
This is a bit of an catch-22 we have here. Trouble is that when
we return with EAGAIN the next select/poll cycle will tell you
that this and possibly other sockets are writeable again, when in
fact they are not due to kernel memory shortage. Then the application
will tightly loop around the "writeable" non-writeable sockets.
It's about the interaction of write with O_NONBLOCK and select/poll
on the socket.
Do you have any references how other OSes behave, in particular
I've added bde@ as our resident standards compliance expert.
Hopefully he can give us some more insight on this issue.
More information about the freebsd-current