Artem Bityutskiy 6467716a37 writeback: optimize periodic bdi thread wakeups
Whe the first inode for a bdi is marked dirty, we wake up the bdi thread which
should take care of the periodic background write-out. However, the write-out
will actually start only 'dirty_writeback_interval' centisecs later, so we can
delay the wake-up.

This change was requested by Nick Piggin who pointed out that if we delay the
wake-up, we weed out 2 unnecessary contex switches, which matters because
'__mark_inode_dirty()' is a hot-path function.

This patch introduces a new function - 'bdi_wakeup_thread_delayed()', which
sets up a timer to wake-up the bdi thread and returns. So the wake-up is
delayed.

We also delete the timer in bdi threads just before writing-back. And
synchronously delete it when unregistering bdi. At the unregister point the bdi
does not have any users, so no one can arm it again.

Since now we take 'bdi->wb_lock' in the timer, which can execute in softirq
context, we have to use 'spin_lock_bh()' for 'bdi->wb_lock'. This patch makes
this change as well.

This patch also moves the 'bdi_wb_init()' function down in the file to avoid
forward-declaration of 'bdi_wakeup_thread_delayed()'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
2010-08-07 18:53:56 +02:00
..
2010-05-27 09:12:41 -07:00
2010-05-19 22:41:57 -04:00
2010-04-30 14:52:51 -05:00
2010-06-04 17:16:30 -04:00
2010-05-27 22:15:33 -04:00
2010-05-27 22:15:33 -04:00
2010-05-21 18:31:16 -04:00
2010-05-11 17:43:58 +02:00
2010-05-21 18:31:16 -04:00
2010-05-21 18:31:17 -04:00
2010-05-18 08:57:00 +10:00
2010-05-21 18:31:17 -04:00
2010-06-10 19:08:34 +02:00
2010-05-27 09:12:56 -07:00
2010-05-21 18:31:17 -04:00
2010-06-29 10:38:22 -07:00
2010-06-01 12:42:12 +02:00