mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Parav Pandit <paravpandit@yahoo.com>
To: Linux kernel <linux-kernel@vger.kernel.org>
Subject: Suspected sock_sendmsg() with MSG_DONTWAIT can block bug.
Date: Tue, 24 Feb 2009 06:40:42 -0800 (PST)	[thread overview]
Message-ID: <74923.15071.qm@web30107.mail.mud.yahoo.com> (raw)


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





      

             reply	other threads:[~2009-02-24 14:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24 14:40 Parav Pandit [this message]
2009-02-24 15:54 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74923.15071.qm@web30107.mail.mud.yahoo.com \
    --to=paravpandit@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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