lkml.org 
[lkml]   [2012]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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


\
 
 \ /
  Last update: 2012-02-02 10:23    [from the cache]
©2003-2011 Jasper Spaans