Messages in this thread |  | | | Date | Thu, 02 Feb 2012 13:20:18 +0400 | | From | Dmitry Antipov <> | | Subject | Re: Module/kthread/printk question/problem |
| |
On 02/02/2012 11:45 AM, Eric Dumazet wrote:
> Remove the wait_for_completion(), this brings nothing at all, as you > already discovered.
I want to get the module 'locked' until all threads are completed.
> Then you need cooperation from worker threads : they must wait for > kthread_should_stop(), or else your kthread_stop(arg) pass an already > freed "arg" memory block.
I designed the cooperation in another way: after each successful call of X = kthread_run(...), I do get_task_struct(X), and the module exit code is something like:
... wait_for_completion(&done); for (i = 0; i < nrthreads; i++) { kthread_stop(threads[i]); put_task_struct(threads[i]); } kfree(threads); ... The crash is go away, so I believe this is reasonable. Anyway, it would be nice to have a debug option to detect such a suspicious errors.
Thanks, Dmitry
|  |