mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
fix wait_queue rmmod deadlock, wait_queue2, add insrm.sh that was used to test wait_queue lock, which obsoletes workqueue_cheat.sh
This commit is contained in:
@@ -39,8 +39,6 @@ static int kthread_func1(void *data)
|
|||||||
wake_up(&queue);
|
wake_up(&queue);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i = !i;
|
|
||||||
wake_up_interruptible(&queue);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +48,7 @@ static int kthread_func2(void *data)
|
|||||||
while (!kthread_should_stop()) {
|
while (!kthread_should_stop()) {
|
||||||
pr_info("2 %u\n", i);
|
pr_info("2 %u\n", i);
|
||||||
i++;
|
i++;
|
||||||
wait_event_interruptible(queue, atomic_read(&awake));
|
wait_event(queue, atomic_read(&awake));
|
||||||
atomic_set(&awake, 0);
|
atomic_set(&awake, 0);
|
||||||
schedule();
|
schedule();
|
||||||
}
|
}
|
||||||
@@ -69,8 +67,9 @@ static int myinit(void)
|
|||||||
|
|
||||||
static void myexit(void)
|
static void myexit(void)
|
||||||
{
|
{
|
||||||
kthread_stop(kthread1);
|
/* 2 must be stopped before, or else we can deadlock. */
|
||||||
kthread_stop(kthread2);
|
kthread_stop(kthread2);
|
||||||
|
kthread_stop(kthread1);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(myinit)
|
module_init(myinit)
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ static int kthread_wake_func(void *data)
|
|||||||
wake_up(&queue);
|
wake_up(&queue);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i = !i;
|
|
||||||
wake_up_interruptible(&queue);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +71,7 @@ int init_module(void)
|
|||||||
|
|
||||||
void cleanup_module(void)
|
void cleanup_module(void)
|
||||||
{
|
{
|
||||||
kthread_stop(kthread_wake);
|
|
||||||
kthread_stop(kthread_sleep1);
|
|
||||||
kthread_stop(kthread_sleep2);
|
kthread_stop(kthread_sleep2);
|
||||||
|
kthread_stop(kthread_sleep1);
|
||||||
|
kthread_stop(kthread_wake);
|
||||||
}
|
}
|
||||||
|
|||||||
13
rootfs_overlay/insrm.sh
Executable file
13
rootfs_overlay/insrm.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Insert and remove a module n times to check for spurious errors / deadlocks.
|
||||||
|
set -e
|
||||||
|
mod="$1"
|
||||||
|
n="${2:-1}"
|
||||||
|
i=0
|
||||||
|
while [ $i -lt $n ]; do
|
||||||
|
echo "insmod $i"
|
||||||
|
insmod "/$mod.ko"
|
||||||
|
echo "rmmod $i"
|
||||||
|
rmmod "$mod"
|
||||||
|
i=$(($i+1))
|
||||||
|
done
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Got a few kernel crashes after insert / remove, so let's do this a few times.
|
|
||||||
insmod /workqueue_cheat.ko
|
|
||||||
rmmod workqueue_cheat
|
|
||||||
insmod /workqueue_cheat.ko
|
|
||||||
rmmod workqueue_cheat
|
|
||||||
insmod /workqueue_cheat.ko
|
|
||||||
rmmod workqueue_cheat
|
|
||||||
Reference in New Issue
Block a user