lkml.org 
[lkml]   [2018]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Re: [PATCHv3 2/6] tty/ldsem: Update waiter->task before waking up reader
From
Date
On 9/11/18 8:41 AM, Sergey Senozhatsky wrote:
> On (09/11/18 14:04), Sergey Senozhatsky wrote:
>>> for (;;) {
>>> set_current_state(TASK_UNINTERRUPTIBLE);
>>
>> I think that set_current_state() also executes memory barrier. Just
>> because it accesses task state.
>>
>>> - if (!waiter.task)
>>> + if (!READ_ONCE(waiter.task))
>>> break;
>>> if (!timeout)
>>> break;
>
> This READ_ONCE(waiter.task) looks interesting. Maybe could be moved
> to a loop condition
>
> while (!READ_ONCE(waiter.task)) {
> ...
> }

We can't reorder event check and set_current_state(),
because this will lead to missing of wakeup:

Documentation/memory-barriers.txt

Also, it looks like READ_ONCE() is not need. In case of compiler
had optimized this, then all wait_event() in kernel w/o READ_ONCE
would have not worked like expected, wouldn't they?

Kirill

\
 
 \ /
  Last update: 2018-09-11 13:05    [W:0.061 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site