History

io-wq: ensure task is running before processing task_work

Mark the current task as running if we need to run task_work from the io-wq threads as part of work handling. If that is the case, then return as such so that the caller can appropriately loop back and reset if it was part of a going-to-sleep flush.

Jens Axboe committed 5 years ago

Commit 00ddff41 parent 4db4b1a1 file · +6 −2Browse files

Unified · Split

fs/io-wq.c+6−2
@@ -386,13 +386,16 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe) · 385 unmodified lines
386 return NULL;386 return NULL;
387}387}
388 388
389static void io_flush_signals(void)389static bool io_flush_signals(void)
390{390{
391 if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {391 if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {
392 __set_current_state(TASK_RUNNING);
392 if (current->task_works)393 if (current->task_works)
393 task_work_run();394 task_work_run();
394 clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);395 clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);
396 return true;
395 }397 }
398 return false;
396}399}
397 400
398static void io_assign_current_work(struct io_worker *worker,401static void io_assign_current_work(struct io_worker *worker,
@@ -499,7 +502,8 @@ loop: · 100 unmodified lines
499 }502 }
500 __io_worker_idle(wqe, worker);503 __io_worker_idle(wqe, worker);
501 raw_spin_unlock_irq(&wqe->lock);504 raw_spin_unlock_irq(&wqe->lock);
502 io_flush_signals();505 if (io_flush_signals())
506 continue;
503 ret = schedule_timeout(WORKER_IDLE_TIMEOUT);507 ret = schedule_timeout(WORKER_IDLE_TIMEOUT);
504 if (try_to_freeze() || ret)508 if (try_to_freeze() || ret)
505 continue;509 continue;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t