Commit c5f7ad233b8805dae06e694538d8095b19f3c560
Committed by
Jens Axboe
1 parent
94eac5e623
Exists in
master
and in
7 other branches
writeback: do not lose wake-ups in the forker thread - 1
Currently the forker thread can lose wake-ups which may lead to unnecessary delays in processing bdi works. E.g., consider the following scenario. 1. 'bdi_forker_thread()' walks the 'bdi_list', finds out there is nothing to do, and is about to finish the loop. 2. A bdi thread decides to exit because it was inactive for long time. 3. 'bdi_queue_work()' adds a work to the bdi which just exited, so it wakes up the forker thread. 4. but 'bdi_forker_thread()' executes 'set_current_state(TASK_INTERRUPTIBLE)' and goes sleep. We lose a wake-up. Losing the wake-up is not fatal, but this means that the bdi work processing will be delayed by up to 5 sec. This race is theoretical, I never hit it, but it is worth fixing. The fix is to execute 'set_current_state(TASK_INTERRUPTIBLE)' _before_ walking 'bdi_list', not after. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Showing 1 changed file with 1 additions and 2 deletions Side-by-side Diff
mm/backing-dev.c
... | ... | @@ -342,6 +342,7 @@ |
342 | 342 | wb_do_writeback(me, 0); |
343 | 343 | |
344 | 344 | spin_lock_bh(&bdi_lock); |
345 | + set_current_state(TASK_INTERRUPTIBLE); | |
345 | 346 | |
346 | 347 | /* |
347 | 348 | * Check if any existing bdi's have dirty data without |
... | ... | @@ -356,8 +357,6 @@ |
356 | 357 | |
357 | 358 | bdi_add_default_flusher_thread(bdi); |
358 | 359 | } |
359 | - | |
360 | - set_current_state(TASK_INTERRUPTIBLE); | |
361 | 360 | |
362 | 361 | if (list_empty(&bdi_pending_list)) { |
363 | 362 | unsigned long wait; |