linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fwd: [RFC] make kthread_worker_fn to be freezable
       [not found] <64da06e6.12ce6.14dae8b205f.Coremail.cn_wyl2003@126.com>
@ 2015-06-01 10:05 ` yalin wang
  2015-06-01 11:40   ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: yalin wang @ 2015-06-01 10:05 UTC (permalink / raw)
  To: Andrew Morton, laijs, tj, nacc, penguin-kernel,
	Linux Kernel Mailing List

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.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
---
 kernel/kthread.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 10e489c..b20a21d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Fwd: [RFC] make kthread_worker_fn to be freezable
  2015-06-01 10:05 ` Fwd: [RFC] make kthread_worker_fn to be freezable yalin wang
@ 2015-06-01 11:40   ` Tejun Heo
  2015-06-02  3:13     ` yalin wang
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2015-06-01 11:40 UTC (permalink / raw)
  To: yalin wang
  Cc: Andrew Morton, laijs, nacc, penguin-kernel, Linux Kernel Mailing List

Hello,

On Mon, Jun 01, 2015 at 06:05:58PM +0800, yalin wang wrote:
> 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.
> 
> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>

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.

 Nacked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: [RFC] make kthread_worker_fn to be freezable
  2015-06-01 11:40   ` Tejun Heo
@ 2015-06-02  3:13     ` yalin wang
  2015-06-03  5:20       ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: yalin wang @ 2015-06-02  3:13 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, laijs, nacc, penguin-kernel, Linux Kernel Mailing List

2015-06-01 19:40 GMT+08:00 Tejun Heo <tj@kernel.org>:
> Hello,
>
> On Mon, Jun 01, 2015 at 06:05:58PM +0800, yalin wang wrote:
>> 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.
>>
>> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
>
> 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.
>
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: [RFC] make kthread_worker_fn to be freezable
  2015-06-02  3:13     ` yalin wang
@ 2015-06-03  5:20       ` Tejun Heo
  2015-06-04  8:39         ` yalin wang
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2015-06-03  5:20 UTC (permalink / raw)
  To: yalin wang
  Cc: Andrew Morton, laijs, nacc, penguin-kernel, Linux Kernel Mailing List

On Tue, Jun 02, 2015 at 11:13:44AM +0800, yalin wang wrote:
> 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.

> 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.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: [RFC] make kthread_worker_fn to be freezable
  2015-06-03  5:20       ` Tejun Heo
@ 2015-06-04  8:39         ` yalin wang
  0 siblings, 0 replies; 5+ messages in thread
From: yalin wang @ 2015-06-04  8:39 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, laijs, nacc, penguin-kernel, Linux Kernel Mailing List

2015-06-03 13:20 GMT+08:00 Tejun Heo <tj@kernel.org>:
> On Tue, Jun 02, 2015 at 11:13:44AM +0800, yalin wang wrote:
>> 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.
>
>> 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 !

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-04  8:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <64da06e6.12ce6.14dae8b205f.Coremail.cn_wyl2003@126.com>
2015-06-01 10:05 ` Fwd: [RFC] make kthread_worker_fn to be freezable yalin wang
2015-06-01 11:40   ` Tejun Heo
2015-06-02  3:13     ` yalin wang
2015-06-03  5:20       ` Tejun Heo
2015-06-04  8:39         ` yalin wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).