lkml.org 
[lkml]   [2010]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 07/16] writeback: do not lose wake-ups in the forker thread
Date
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Currently the forker thread can lose wakeups 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 'bdi_forker_thread()'.
4. 'bdi_forker_thread()' executes
'set_current_state(TASK_INTERRUPTIBLE)' and goes sleep. We
loose a wake-up.

This situation is theoretica, I never hit it, but it is worth
fixing. The fix is to execute
'set_current_state(TASK_INTERRUPTIBLE)' before walking 'bdi_list'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
mm/backing-dev.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 03a3d82..14fe1bb 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -343,6 +343,7 @@ static int bdi_forker_thread(void *ptr)
wb_do_writeback(me, 0);

spin_lock_bh(&bdi_lock);
+ set_current_state(TASK_INTERRUPTIBLE);

/*
* Check if any existing bdi's have dirty data without
@@ -357,8 +358,6 @@ static int bdi_forker_thread(void *ptr)
bdi_add_default_flusher_thread(bdi);
}

- set_current_state(TASK_INTERRUPTIBLE);
-
if (list_empty(&bdi_pending_list)) {
unsigned long wait;

--
1.7.1.1


\
 
 \ /
  Last update: 2010-07-16 14:53    [W:0.143 / U:2.280 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site