[etherlab-dev] uninterruptible sleep in ecrt_release_master()
Hobin Yoon
hobinyoon at gmail.com
Tue Aug 26 14:44:05 CEST 2008
Hello, Florian Pose,
While I was loading and unloading mini module, I found that
/sbin/rmmod hangs(goes to uninterruptible sleep) at a ratio of 1 in
100.
I found the master thread still runs its while loop even after rmmod
thread issued SIGTERM.
There seems to be a race condition between kill_proc() and signal_pending().
So I modified the waiting thread to issue the signal again after
waiting some time until the master thread completes.
I tested insmod/rmmod 50,000 times and it was okay.
My system specs are:
Disto: MontaVista Linux Version 5.0.0, Professional Edition (0702774)
Kernel version: 2.6.18+
CPU: Intel Core2 Quad Q6600
Here is the patch I did.
--- master.c (original copy)
+++ master.c (working copy)
@@ -332,6 +332,7 @@
)
{
unsigned long sleep_jiffies;
+ sleep_jiffies = max(HZ / 100, 1); // 10 ms, at least 1 jiffy
if (!master->thread_id) {
EC_WARN("ec_master_thread_stop: Already finished!\n");
@@ -341,14 +342,17 @@
if (master->debug_level)
EC_DBG("Stopping master thread.\n");
- kill_proc(master->thread_id, SIGTERM, 1);
- wait_for_completion(&master->thread_exit);
+ do
+ {
+ kill_proc(master->thread_id, SIGTERM, 1);
+ wait_for_completion_timeout(&master->thread_exit,
sleep_jiffies);
+ } while (master->thread_id);
+
EC_INFO("Master thread exited.\n");
if (master->fsm_datagram.state != EC_DATAGRAM_SENT) return;
// wait for FSM datagram
- sleep_jiffies = max(HZ / 100, 1); // 10 ms, at least 1 jiffy
schedule_timeout(sleep_jiffies);
}
Best regards,
Hobin Yoon
More information about the etherlab-dev
mailing list