lkml.org 
[lkml]   [2020]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: wait_on_page_bit_common(TASK_KILLABLE, EXCLUSIVE) can miss wakeup?
On 06/30, Oleg Nesterov wrote:
>
> may be someting like this

or this ...

for (;;) {
int intr = 0;

spin_lock_irq(&q->lock);
if (signal_pending_state(state, current)) {
/* see the comment in prepare_to_wait_event() */
list_del_init(&wait->entry);
intr = 1;
} else {
if (likely(list_empty(&wait->entry))) {
__add_wait_queue_entry_tail(q, wait);
SetPageWaiters(page);
}
set_current_state(state);
}
spin_unlock_irq(&q->lock);

bit_is_set = test_bit(bit_nr, &page->flags);
if (behavior == DROP)
put_page(page);

if (!bit_is_set) {
if (behavior != EXCLUSIVE)
break;
if (!test_and_set_bit_lock(bit_nr, &page->flags))
break;
}

if (intr) {
ret = -EINTR;
break;
}

io_schedule();

if (behavior == DROP) {
/*
* We can no longer safely access page->flags:
* even if CONFIG_MEMORY_HOTREMOVE is not enabled,
* there is a risk of waiting forever on a page reused
* for something that keeps it locked indefinitely.
* But best check for -EINTR before breaking.
*/
if (signal_pending_state(state, current))
ret = -EINTR;
break;
}
}

Oleg.

\
 
 \ /
  Last update: 2020-06-30 13:52    [W:0.074 / U:0.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site