[PATCH] use schedule_timeout_interruptible() in bdi_writeback_thread

From: KAMEZAWA Hiroyuki
Date: Thu Sep 01 2011 - 04:02:13 EST


Use schedule_timeout_interruptible() rather than

set_current_state(TASK_INTERRUPTIBLE);
do some work
schedule_timeout()

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
---
fs/fs-writeback.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 04cf3b9..c538bda 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -936,22 +936,18 @@ int bdi_writeback_thread(void *data)
if (pages_written)
wb->last_active = jiffies;

- set_current_state(TASK_INTERRUPTIBLE);
- if (!list_empty(&bdi->work_list) || kthread_should_stop()) {
- __set_current_state(TASK_RUNNING);
+ if (!list_empty(&bdi->work_list) || kthread_should_stop())
continue;
- }

+ /*
+ * If we have nothing to do, we can go sleep without any
+ * timeout and save power. When a work is queued or
+ * something is made dirty - we will be woken up.
+ */
+ timeout = MAX_SCHEDULE_TIMEOUT;
if (wb_has_dirty_io(wb) && dirty_writeback_interval)
- schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
- else {
- /*
- * We have nothing to do, so can go sleep without any
- * timeout and save power. When a work is queued or
- * something is made dirty - we will be woken up.
- */
- schedule();
- }
+ timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
+ schedule_timeout_interruptible(timeout);

try_to_freeze();
}
--
1.7.4.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/