lkml.org 
[lkml]   [2020]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject回复: [PATCH] io-wq: set task TASK INTERRUPTI BLE state before schedule timeout
Date


________________________________________
发件人: Jens Axboe <axboe@kernel.dk>
发送时间: 2020年10月27日 21:35
收件人: Zhang, Qiang
抄送: io-uring@vger.kernel.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] io-wq: set task TASK_INTERRUPTIBLE state before schedule_timeout

On 10/26/20 9:09 PM, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
>
> In 'io_wqe_worker' thread, if the work which in 'wqe->work_list' be
> finished, the 'wqe->work_list' is empty, and after that the
> '__io_worker_idle' func return false, the task state is TASK_RUNNING,
> need to be set TASK_INTERRUPTIBLE before call schedule_timeout func.
>
>I don't think that's safe - what if someone added work right before you
>call schedule_timeout_interruptible? Something ala:
>
>
>io_wq_enqueue()
> set_current_state(TASK_INTERRUPTIBLE();
> schedule_timeout(WORKER_IDLE_TIMEOUT);
>
>then we'll have work added and the task state set to running, but the
>worker itself just sets us to non-running and will hence wait
>WORKER_IDLE_TIMEOUT before the work is processed.
>
>The current situation will do one extra loop for this case, as the
>schedule_timeout() just ends up being a nop and we go around again

although the worker task state is running, due to the call schedule_timeout, the
current worker still possible to be switched out.
if set current worker task is no-running, the current worker be switched out, but
the schedule will call io_wq_worker_sleeping func to wake up free worker task, if
wqe->free_list is not empty.

>checking for work. Since we already unused the mm, the next iteration
>will go to sleep properly unless new work came in.
>
>--
>Jens Axboe

\
 
 \ /
  Last update: 2020-10-28 22:59    [W:0.060 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site