From: Arnd Bergmann <arnd@arndb.de>
To: Max Vozeler <max@vozeler.com>
Cc: linux-kernel@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@suse.de>,
Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>
Subject: Re: [PATCH 03/20] staging/usbip: convert to kthread
Date: Tue, 1 Mar 2011 23:15:55 +0100 [thread overview]
Message-ID: <201103012315.55188.arnd@arndb.de> (raw)
In-Reply-To: <4D4302AC.3050903@vozeler.com>
On Friday 28 January 2011 18:53:48 Max Vozeler wrote:
> I need to leave now for the next couple of days,
> so this is a bit rushed.
>
> I can take a closer look and do tests in different
> setups during the next week.
>
It seems we both forgot about this. This is what I now added to my tree.
Greg, I'll resubmit a folded version with the original patch.
Arnd
8<------
staging/usbip: fix breakage from BKL removal
wait_event_interruptible() in a kthread needs
to check if the kthread should stop.
Thread creation was racy, calling kthread_run
instead of wake_up on an existing kthread
fixes this.
Reported-by: Max Vozeler <max@vozeler.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index f2c6148..8214c35 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -139,8 +139,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
spin_unlock(&sdev->ud.lock);
- wake_up_process(sdev->ud.tcp_rx);
- wake_up_process(sdev->ud.tcp_tx);
+ sdev->ud.tcp_rx = kthread_run(stub_rx_loop, &sdev->ud, "stub_rx");
+ sdev->ud.tcp_tx = kthread_run(stub_tx_loop, &sdev->ud, "stub_tx");
spin_lock(&sdev->ud.lock);
sdev->ud.status = SDEV_ST_USED;
@@ -339,9 +339,6 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev,
*/
sdev->devid = (busnum << 16) | devnum;
- sdev->ud.tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx");
- sdev->ud.tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx");
-
sdev->ud.side = USBIP_STUB;
sdev->ud.status = SDEV_ST_AVAILABLE;
/* sdev->ud.lock = SPIN_LOCK_UNLOCKED; */
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c
index 2477481..5523f25 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/staging/usbip/stub_tx.c
@@ -365,7 +365,8 @@ int stub_tx_loop(void *data)
wait_event_interruptible(sdev->tx_waitq,
(!list_empty(&sdev->priv_tx) ||
- !list_empty(&sdev->unlink_tx)));
+ !list_empty(&sdev->unlink_tx) ||
+ kthread_should_stop()));
}
return 0;
diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
index 89aecec..f4b287e 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -67,12 +67,13 @@ static int event_handler_loop(void *data)
struct usbip_device *ud = data;
while (!kthread_should_stop()) {
- if (event_handler(ud) < 0)
- break;
-
wait_event_interruptible(ud->eh_waitq,
- usbip_event_happened(ud));
+ usbip_event_happened(ud) ||
+ kthread_should_stop());
usbip_dbg_eh("wakeup\n");
+
+ if (event_handler(ud) < 0)
+ break;
}
return 0;
}
diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c
index 6d065b9..d9ab49d 100644
--- a/drivers/staging/usbip/vhci_tx.c
+++ b/drivers/staging/usbip/vhci_tx.c
@@ -230,7 +230,8 @@ int vhci_tx_loop(void *data)
wait_event_interruptible(vdev->waitq_tx,
(!list_empty(&vdev->priv_tx) ||
- !list_empty(&vdev->unlink_tx)));
+ !list_empty(&vdev->unlink_tx) ||
+ kthread_should_stop()));
usbip_dbg_vhci_tx("pending urbs ?, now wake up\n");
}
next prev parent reply other threads:[~2011-03-01 22:16 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1295993854-4971-1-git-send-email-arnd@arndb.de>
2011-01-25 22:17 ` [PATCH 01/20] drm/i810: remove the BKL Arnd Bergmann
2011-01-25 22:17 ` [PATCH 02/20] drm: remove i830 driver Arnd Bergmann
2011-01-25 22:17 ` [PATCH 03/20] staging/usbip: convert to kthread Arnd Bergmann
2011-01-28 17:53 ` Max Vozeler
2011-01-28 18:48 ` Arnd Bergmann
2011-03-01 22:15 ` Arnd Bergmann [this message]
2011-01-25 22:17 ` [PATCH 04/20] staging/cx25721: serialize access to devlist Arnd Bergmann
2011-01-26 16:23 ` Palash Bandyopadhyay
2011-01-31 21:37 ` Greg KH
2011-01-25 22:17 ` [PATCH 05/20] staging/go7007: remove the BKL Arnd Bergmann
2011-01-25 22:17 ` [PATCH 06/20] staging: Remove autofs3 Arnd Bergmann
2011-01-26 7:41 ` H. Peter Anvin
2011-01-25 22:17 ` [PATCH 07/20] staging: remove smbfs Arnd Bergmann
2011-01-25 22:17 ` [PATCH 08/20] adfs: remove the big kernel lock Arnd Bergmann
2011-01-25 22:20 ` Russell King
2011-01-25 22:17 ` [PATCH 09/20] hpfs: rename big kernel lock to hpfs_lock Arnd Bergmann
2011-01-25 22:17 ` [PATCH 10/20] hpfs: replace BKL with a global mutex Arnd Bergmann
2011-01-26 0:15 ` Andi Kleen
2011-01-26 0:19 ` Andi Kleen
2011-01-26 12:48 ` [PATCH v2] hpfs: remove the BKL Arnd Bergmann
2011-01-26 12:50 ` [PATCH 10/20] hpfs: replace BKL with a global mutex Arnd Bergmann
2011-01-26 16:52 ` Andi Kleen
2011-01-27 5:01 ` Nick Piggin
2011-01-27 10:57 ` Miklos Szeredi
2011-01-25 22:17 ` [PATCH 11/20] hpfs: move to drivers/staging Arnd Bergmann
2011-02-07 16:17 ` Mikulas Patocka
2011-02-07 19:31 ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 12/20] x25: remove the BKL Arnd Bergmann
2011-01-27 10:07 ` Andrew Hendry
2011-01-27 12:17 ` Arnd Bergmann
2011-01-27 12:38 ` [PATCH v2] " Arnd Bergmann
2011-01-27 13:20 ` Eric Dumazet
2011-01-27 13:43 ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 13/20] appletalk: move to staging Arnd Bergmann
2011-01-25 22:17 ` [PATCH 14/20] staging/appletalk: remove the BKL Arnd Bergmann
2011-01-25 22:29 ` David Miller
2011-01-26 12:57 ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 15/20] ufs: " Arnd Bergmann
2011-01-26 2:30 ` Nick Bowler
2011-01-26 12:53 ` Arnd Bergmann
2011-01-27 5:47 ` Nick Piggin
2011-01-27 13:13 ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 16/20] ipx: " Arnd Bergmann
2011-01-25 22:17 ` [PATCH 17/20] tracing: don't trace " Arnd Bergmann
2011-01-25 22:28 ` Frederic Weisbecker
2011-01-25 22:17 ` [PATCH 18/20] rtmutex-tester: remove BKL tests Arnd Bergmann
2011-01-26 15:00 ` [tip:core/locking] rtmutex-tester: Remove " tip-bot for Arnd Bergmann
2011-02-22 20:57 ` [tip:irq/core] rtmutex: tester: " tip-bot for Arnd Bergmann
2011-01-25 22:17 ` [PATCH 19/20] drivers: remove extraneous includes of smp_lock.h Arnd Bergmann
2011-01-25 22:17 ` [PATCH 20/20] BKL: That's all, folks Arnd Bergmann
2011-01-26 6:19 ` Ingo Molnar
2011-01-26 8:47 ` Alan Cox
2011-01-26 11:01 ` Ingo Molnar
2011-01-26 11:22 ` Thomas Gleixner
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=201103012315.55188.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=gregkh@suse.de \
--cc=hirofuchi@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=max@vozeler.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox