From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757971AbZBXOkx (ORCPT ); Tue, 24 Feb 2009 09:40:53 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756260AbZBXOkp (ORCPT ); Tue, 24 Feb 2009 09:40:45 -0500 Received: from web30107.mail.mud.yahoo.com ([209.191.69.39]:25260 "HELO web30107.mail.mud.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755330AbZBXOko (ORCPT ); Tue, 24 Feb 2009 09:40:44 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=ox7rMSHunSIr2i1Bjx06Gd2XNLJ+xMIdA6vZ6xOZIBm38aiaqDz8b5e9ksayg6iZ1uLEFCHBoexxYTUFDHF+o8N9wAHzX65nACoSaBWNbKq/VKUthxDUuHlENPVXDZlHxfOQVKaP3IfDuUmO55CjV1Wr7x6Wo7rlMyuOUk9xiN8=; Message-ID: <74923.15071.qm@web30107.mail.mud.yahoo.com> X-YMail-OSG: WxIkqBAVM1nnFhWgPxEmig10Z4JU0.TkYBDAqSWd4RnoW7rGco6QgN1pZ77sWG.ryZNx_odRUS.dvEjdomjFG46ixAFalp__QoRGlHzMF8d3Joja8mdk_Wnylve9xq_blQmnlhlGMyjBaX7JCIKtsGczwj.lyySISe.dsjd_GIxNDudr8QqHUAFnMJg4wbd0qCSXxdJE_N0gcNZKT4EXqYWDOpB_How- X-Mailer: YahooMailClassic/5.1.18 YahooMailWebService/0.7.289.1 Date: Tue, 24 Feb 2009 06:40:42 -0800 (PST) From: Parav Pandit Subject: Suspected sock_sendmsg() with MSG_DONTWAIT can block bug. To: Linux kernel MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: [] lock_sock_nested+0x18/0x9e Feb 24 19:26:16 localhost kernel: [] local_bh_disable+0xa/0xb Feb 24 19:26:16 localhost kernel: [] release_sock+0x13/0x94 Feb 24 19:26:16 localhost kernel: [] tcp_sendmsg+0x15/0xa21 Feb 24 19:26:16 localhost kernel: [] irq_exit+0x50/0x72 Feb 24 19:26:16 localhost kernel: [] sock_sendmsg+0xd0/0xeb Feb 24 19:26:16 localhost kernel: [] autoremove_wake_function+0x0/0x35 Feb 24 19:26:16 localhost kernel: [] resched_task+0x3b/0x59 Feb 24 19:26:16 localhost kernel: [] _spin_unlock_irqrestore+0x1c/0x30 Feb 24 19:26:16 localhost kernel: [] try_to_wake_up+0x2e6/0x2f0 Feb 24 19:26:16 localhost kernel: [] autoremove_wake_function+0x15/0x35 Feb 24 19:26:16 localhost kernel: [] __wake_up_common+0x32/0x55 Feb 24 19:26:16 localhost kernel: [] send+0xce/0x110 [test_driver] Feb 24 19:26:16 localhost kernel: [] drv_tx+0xe6/0x110 [test_driver] Feb 24 19:26:16 localhost kernel: [] drv_ctrl_msg+0x7d/0xb0 [test_driver] Feb 24 19:26:16 localhost kernel: [] __init_begin+0x0/0x10 Feb 24 19:26:16 localhost kernel: [] io_thread+0xed/0x1d0 [test_driver] Feb 24 19:26:16 localhost kernel: [] io_thread+0x0/0x1d0 [test_driver] Feb 24 19:26:16 localhost kernel: [] kernel_thread_helper+0x7/0x10 Regards, Parav Pandit