Re: [PATCH 2/2] io_uring: use TWA_SIGNAL for task_work if the task isn't running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/20 2:32 PM, Peter Zijlstra wrote:
> On Mon, Aug 10, 2020 at 02:25:48PM -0600, Jens Axboe wrote:
>> On 8/10/20 2:13 PM, Jens Axboe wrote:
>>>> Would it be clearer to write it like so perhaps?
>>>>
>>>> 	/*
>>>> 	 * Optimization; when the task is RUNNING we can do with a
>>>> 	 * cheaper TWA_RESUME notification because,... <reason goes
>>>> 	 * here>. Otherwise do the more expensive, but always correct
>>>> 	 * TWA_SIGNAL.
>>>> 	 */
>>>> 	if (READ_ONCE(tsk->state) == TASK_RUNNING) {
>>>> 		__task_work_notify(tsk, TWA_RESUME);
>>>> 		if (READ_ONCE(tsk->state) == TASK_RUNNING)
>>>> 			return;
>>>> 	}
>>>> 	__task_work_notify(tsk, TWA_SIGNAL);
>>>> 	wake_up_process(tsk);
>>>
>>> Yeah that is easier to read, wasn't a huge fan of the loop since it's
>>> only a single retry kind of condition. I'll adopt this suggestion,
>>> thanks!
>>
>> Re-write it a bit on top of that, just turning it into two separate
>> READ_ONCE, and added appropriate comments. For the SQPOLL case, the
>> wake_up_process() is enough, so we can clean up that if/else.
>>
>> https://git.kernel.dk/cgit/linux-block/commit/?h=io_uring-5.9&id=49bc5c16483945982cf81b0109d7da7cd9ee55ed
> 
> OK, that works for me, thanks!
> 
> Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Thanks for checking (again) - I've added your acked-by.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux