All of lore.kernel.org
 help / color / mirror / Atom feed
From: arvid.brodin@enea.com (Arvid Brodin)
To: kernelnewbies@lists.kernelnewbies.org
Subject: inconsistent lock state on call to kmem_cache_zalloc()
Date: Thu, 17 Mar 2011 19:13:24 +0100	[thread overview]
Message-ID: <4D824F44.8090501@enea.com> (raw)

On a call to kmem_cache_zalloc(), I get this:

=================================
[ INFO: inconsistent lock state ]
2.6.37 #116
---------------------------------
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
khubd/133 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (&(&priv->lock)->rlock){?.-...}, at: [<9017a508>] isp1760_urb_enqueue+0x24c/0x3e4
{IN-HARDIRQ-W} state was registered at:
  [<90043476>] lock_acquire+0x3a/0x48
  [<90236210>] _raw_spin_lock_irqsave+0x28/0x50
  [<9017a7ac>] isp1760_irq+0x44/0x3b4
  [<9016ffec>] usb_hcd_irq+0x68/0x70
...

And I cannot understand why. (I'm also unsure about the syntax - what does
"IN-HARDIRQ-W" and "HARDIRQ-ON-W" mean?)

Background:

I have an interrupt routine isp1760_irq() that calls
	spin_lock(&priv->lock)
	...
	spin_unlock(&priv->lock)

I also take this lock in isp1760_urb_enqueue() mentioned in the printout. I
believe this function gets called by the USB core when an urb should be
transferred. isp1760_urb_enqueue() uses

	spin_lock_irqsave(&priv->lock, spinflags);
	...
	spin_unlock_irqrestore(&priv->lock, spinflags);

isp1760_urb_enqueue() also calls kmem_cache_zalloc(); this is what apparently
triggers the printout above (the lock have already been successfully taken).

The call to kmem_cache_zalloc() never returns; the printk() text on the line
after is never displayed and the system locks up. The printk() om the line
before displays.

I also get an additional BUG:

BUG: spinlock lockup on CPU#0, khubd/133, 93dcc138
Call trace:
 [<9001d370>] dump_stack+0x18/0x20
 [<9012e7aa>] do_raw_spin_lock+0x9a/0xc8
 [<9023622a>] _raw_spin_lock_irqsave+0x42/0x50
 [<9017a7ac>] isp1760_irq+0x44/0x3b4
 [<9016ffec>] usb_hcd_irq+0x68/0x70
 [<9004b2fc>] handle_IRQ_event+0x16/0x92
 [<9004cbec>] handle_level_irq+0xb0/0xc8
 [<9001ad28>] demux_eic_irq+0x38/0x50
 [<9001ac36>] do_IRQ+0x36/0x5c
 [<90019428>] irq_level0+0x18/0x60
 [<9006aa96>] kmem_cache_alloc+0x4a/0x90
 [<9017a59c>] isp1760_urb_enqueue+0x2e0/0x3e4
 [<90170e54>] usb_hcd_submit_urb+0x6d4/0x758
 [<90171186>] usb_submit_urb+0x1ce/0x1e0
 [<901718aa>] usb_start_wait_urb+0x32/0x80
 [<90171bc4>] usb_control_msg+0xc0/0xd8
 [<9016d6ac>] hub_port_init+0x218/0x528
 [<9016e672>] hub_thread+0x5aa/0xa38
 [<900358c6>] kthread+0x58/0x62
 [<90027c4a>] do_exit+0x0/0x43e

which seems very weird to me, since it looks like isp1760_irq() gets called
even though I thought I had disabled interrupts with spin_lock_irqsave() in
isp1760_urb_enqueue().

Obviously I have not understood the locking in the kernel. What have I done
wrong here?

Thanks,
Arvid Brodin
Enea Services Stockholm AB

             reply	other threads:[~2011-03-17 18:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 18:13 Arvid Brodin [this message]
2011-03-17 19:26 ` inconsistent lock state on call to kmem_cache_zalloc() Daniel Baluta
2011-03-17 20:59   ` Arvid Brodin
2011-03-17 21:46     ` Daniel Baluta
2011-03-17 22:49       ` Arvid Brodin

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=4D824F44.8090501@enea.com \
    --to=arvid.brodin@enea.com \
    --cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.