On Sat, 7 Oct 2000, Andi Kleen wrote:
> On Sat, Oct 07, 2000 at 04:16:09PM +0200, A.N.Kuznetsov wrote:
> > Hello!
> > > 2.2.17 is broken too.
> > >
> > > I've fixed it in my 2.2.x sources as well.
> > Dave, sendmsg cannot be used from interrupt yet.
> > Even in 2.2 it works sometimes, but surely will crash sometimes (f.e.
> > because of socket lock on interrupt).
> > If some caller needs this, I am sure, it is buggy.
> iirc nbd doesn't need it from an interrupt but just to avoid deadlock
> on low memory situations when you swap over it.
> Of course it is still broken because there are enough other problems
> with swapping over TCP :-)
The deadlock can happen under normal (without swapping) nbd usage:
nbd_do_request -> nbd_send_req -> nbd_xmit -> sock_sendmsg -> ... ->
tcp_do_sendmsg -> sock_wmalloc_err(GFP_KERNEL) -> alloc_skb ->
kmalloc(GFP_KERNEL) -> kmem_cache_grow -> get_free_pages ->
try_to_free_pages -> shrink_mmap -> try_to_free_buffers ->
sync_page_buffers -> ll_rw_block -> make_request -> add_request ->
nbd_do_request -> nbd_send_req -> ...
until there are no more free requests on the request queue and writer
processes stuck on __get_request_wait.