make kthread_worker_fn to be freezable
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC 1/1 make kthread_worker_fn to be freezable
I notice that kthread_worker_fn() call try_to_freeze() function, but it don't make itself to be a freezable kthread, kthread default behavior is not freezable, we should change it if want try_to_freeze() work correctly.
--- kernel/kthread.c | 1 + 1 file changed, 1 insertion(+)
kernel/kthread.c +1 -0
@@ -550,6 +550,7 @@ int kthread_worker_fn(void *worker_ptr)WARN_ON (worker->task); worker->task = current; +set_freezable (); repeat:set_current_state (TASK_INTERRUPTIBLE );/* mb paired w/ kthread_stop */
--
1.9.1
Hello,
Quoted 6 lines · yalin wang
I notice that
kthread_worker_fn()calltry_to_freeze()function, but it don't make itself to be a freezable kthread, kthread default behavior is not freezable, we should change it if wanttry_to_freeze()work correctly.Signed-off-by yalin wang <[email protected]>
Whether a kthread worker should be able to freeze or not is to be determined by the owner of the specific kthread. If the kthread is marked freezable, kthread_worker will freeze. If not, it won't.
Thanks.
Signature · 1 line
tejun
2015-06-01 19:40 GMT+08:00 Tejun Heo <[email protected]>:
Quoted 8 lines
Hello,
Quoted 5 lines · yalin wang
I notice that
kthread_worker_fn()calltry_to_freeze()function, but it don't make itself to be a freezable kthread, kthread default behavior is not freezable, we should change it if wanttry_to_freeze()work correctly.
Quoted 6 lines
Quoted 1 line
Signed-off-by yalin wang <[email protected]>Whether a kthread worker should be able to freeze or not is to be determined by the owner of the specific kthread. If the kthread is marked freezable,
kthread_workerwill freeze. If not, it won't.
this means i need create kthread like this :
struct task_struct *kworker_task = kthread_run(kthread_worker_fn, &worker, "nvme%d", dev->instance);kworker_task->flags &= ~PF_NOFREEZE;
is it safe to do like this ?
i don't see an API to set other thread to be freezable . only set_freezable() , which set the current thread to be freezable .
am i missing something ?
Thanks
Quoted 6 lines · yalin wang
this means i need create kthread like this :
struct
task_struct*kworker_task=kthread_run(kthread_worker_fn, &worker, "nvme%d", dev->instance);kworker_task->flags&= ~PF_NOFREEZE;
is it safe to do like this ?
It's not.
Quoted 2 lines
i don't see an API to set other thread to be freezable . only
set_freezable(), which set the current thread to be freezable .
But you can create a wrapper kthread function which sets freezable and calls kthread_worker_fn().
Thanks.
Signature · 1 line
tejun
2015-06-03 13:20 GMT+08:00 Tejun Heo <[email protected]>:
Quoted 8 lines · yalin wang
Quoted 6 lines
this means i need create kthread like this :
struct
task_struct*kworker_task=kthread_run(kthread_worker_fn, &worker, "nvme%d", dev->instance);kworker_task->flags&= ~PF_NOFREEZE;
is it safe to do like this ?
Quoted 8 lines
It's not.
Quoted 2 lines
i don't see an API to set other thread to be freezable . only
set_freezable(), which set the current thread to be freezable .But you can create a wrapper kthread function which sets freezable and calls
kthread_worker_fn().
oh, got it, i see your meaning,
Thanks a lot !