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
386386 return NULL;
387387 }
388388
389−static void io_flush_signals(void)
389+static bool io_flush_signals(void)
390390 {
391391 if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {
392+ __set_current_state(TASK_RUNNING);
392393 if (current->task_works)
393394 task_work_run();
394395 clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);
396+ return true;
395397 }
398+ return false;
396399 }
397400
398401 static void io_assign_current_work(struct io_worker *worker,
@@ -499,7 +502,8 @@ loop: · 100 unmodified lines
499502 }
500503 __io_worker_idle(wqe, worker);
501504 raw_spin_unlock_irq(&wqe->lock);
502− io_flush_signals();
505+ if (io_flush_signals())
506+ continue;
503507 ret = schedule_timeout(WORKER_IDLE_TIMEOUT);
504508 if (try_to_freeze() || ret)
505509 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