All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: wangbiao <biao.wang@intel.com>
Cc: oneukum@suse.de, netdev@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, mingo@elte.hu, a.p.zijlstra@chello.nl,
	rusty@rustcorp.com.au, william.douglas@intel.com
Subject: Re: [PATCH] usbnet: fix race condition caused spinlock bad magic issue
Date: Mon, 11 Nov 2013 09:23:30 +0100	[thread overview]
Message-ID: <20131111082330.GA12405@gmail.com> (raw)
In-Reply-To: <1384139315.2179.9.camel@wangbiao>


* wangbiao <biao.wang@intel.com> wrote:

> @@ -1448,8 +1448,10 @@ static void usbnet_bh (unsigned long param)
>  
>  	// waiting for all pending urbs to complete?
>  	if (dev->wait) {
> +		wait_queue_head_t *wait_d = dev->wait;
>  		if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
> -			wake_up (dev->wait);
> +			if (wait_d)
> +				wake_up(wait_d);
>  		}
>  
>  	// or are we maybe short a few urbs?

1)

Nit: the scope of 'wait_d' is unnecessarily broad, it could be moved to 
the block that uses it.

2)

Also, the changelog mentions that dev->wait can race - it would be nice to 
add to the changelog what exact synchronization mechanism protects 
usbnet_terminate_urbs() and usbnet_bh() from seeing/modifying that value 
at once - as the code was clearly written without such interaction in 
mind.

> @@ -1602,6 +1604,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
>  	init_timer (&dev->delay);
>  	mutex_init (&dev->phy_mutex);
>  	mutex_init(&dev->interrupt_mutex);
> +	init_waitqueue_head(&unlink_wakeup);

3)

Can that runtime initialization be avoided by using 
DECLARE_WAIT_QUEUE_HEAD()?

Thanks,

	Ingo

      parent reply	other threads:[~2013-11-11  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11  3:08 [PATCH] usbnet: fix race condition caused spinlock bad magic issue wangbiao
2013-11-11  7:44 ` Oliver Neukum
2013-11-11  8:23 ` Ingo Molnar [this message]

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=20131111082330.GA12405@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=biao.wang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.de \
    --cc=rusty@rustcorp.com.au \
    --cc=william.douglas@intel.com \
    /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.