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

-- 
Jens Axboe




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux