mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Suspected sock_sendmsg() with MSG_DONTWAIT can block bug.
@ 2009-02-24 14:40 Parav Pandit
  2009-02-24 15:54 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Parav Pandit @ 2009-02-24 14:40 UTC (permalink / raw)
  To: Linux kernel


Hi,
I am running kernel 2.6.23 from www.kernel.org.

Short quick question:
---------------------
If sock_sendmsg() is calls with MSG_DONTWAIT, it should send the packet without blocking the context or fail the call with error value.

Which means sock_sendmsg() with MSG_DONTWAIT can be called from soft-irq/ interrupt ctx.
Is that correct?

Assuming its correct, long question:
-----------------------------------

One function of my kernel module looks like

msg_hdr.flags = MSG_DONTWAIT;
spin_lock(lock)
....
sock_sendmsg(sock, msg_hdr, len);
spin_unlock(lock);

I am getting following warning,
BUG: sleeping function called from invalid context at net/core/sock.c:1586

Indicating it can sleep. Here is the back trace of sock_sendmsg() with MSG_DONTWAIT. Is this bug or expected behavior?

Feb 24 19:26:16 localhost kernel: BUG: sleeping function called from invalid context at net/core/sock.c:1586
Feb 24 19:26:16 localhost kernel: in_atomic():1, irqs_disabled():0
Feb 24 19:26:16 localhost kernel:  [<c06c4115>] lock_sock_nested+0x18/0x9e
Feb 24 19:26:16 localhost kernel:  [<c0432632>] local_bh_disable+0xa/0xb
Feb 24 19:26:16 localhost kernel:  [<c06c407c>] release_sock+0x13/0x94
Feb 24 19:26:16 localhost kernel:  [<c06f7afb>] tcp_sendmsg+0x15/0xa21
Feb 24 19:26:16 localhost kernel:  [<c04323b0>] irq_exit+0x50/0x72
Feb 24 19:26:16 localhost kernel:  [<c06c2379>] sock_sendmsg+0xd0/0xeb
Feb 24 19:26:16 localhost kernel:  [<c043eacc>] autoremove_wake_function+0x0/0x35
Feb 24 19:26:16 localhost kernel:  [<c0425e0d>] resched_task+0x3b/0x59
Feb 24 19:26:16 localhost kernel:  [<c0751efe>] _spin_unlock_irqrestore+0x1c/0x30
Feb 24 19:26:16 localhost kernel:  [<c0427c18>] try_to_wake_up+0x2e6/0x2f0
Feb 24 19:26:16 localhost kernel:  [<c043eae1>] autoremove_wake_function+0x15/0x35
Feb 24 19:26:16 localhost kernel:  [<c0424643>] __wake_up_common+0x32/0x55
Feb 24 19:26:16 localhost kernel:  [<f8f9b53e>] send+0xce/0x110 [test_driver]
Feb 24 19:26:16 localhost kernel:  [<f8f9bc16>] drv_tx+0xe6/0x110 [test_driver]
Feb 24 19:26:16 localhost kernel:  [<f8f9c07d>] drv_ctrl_msg+0x7d/0xb0 [test_driver]
Feb 24 19:26:16 localhost kernel:  [<c08be000>] __init_begin+0x0/0x10
Feb 24 19:26:16 localhost kernel:  [<f8fa64ad>] io_thread+0xed/0x1d0 [test_driver]
Feb 24 19:26:16 localhost kernel:  [<f8fa63c0>] io_thread+0x0/0x1d0 [test_driver]
Feb 24 19:26:16 localhost kernel:  [<c0405d47>] kernel_thread_helper+0x7/0x10

Regards,
Parav Pandit





      

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-24 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24 14:40 Suspected sock_sendmsg() with MSG_DONTWAIT can block bug Parav Pandit
2009-02-24 15:54 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome