]> bbs.cooldavid.org Git - net-next-2.6.git/commit - fs/fs-writeback.c
writeback: prevent unnecessary bdi threads wakeups
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 25 Jul 2010 11:29:21 +0000 (14:29 +0300)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:53:56 +0000 (18:53 +0200)
commit253c34e9b10c30d3064be654b5b78fbc1a8b1896
tree1ee077a52fd1036fe26ddfe8cabd5a5315dc1285
parentfff5b85aa4225a7be157f208277a055822039a9e
writeback: prevent unnecessary bdi threads wakeups

Finally, we can get rid of unnecessary wake-ups in bdi threads, which are very
bad for battery-driven devices.

There are two types of activities bdi threads do:
1. process bdi works from the 'bdi->work_list'
2. periodic write-back

So there are 2 sources of wake-up events for bdi threads:

1. 'bdi_queue_work()' - submits bdi works
2. '__mark_inode_dirty()' - adds dirty I/O to bdi's

The former already has bdi wake-up code. The latter does not, and this patch
adds it.

'__mark_inode_dirty()' is hot-path function, but this patch adds another
'spin_lock(&bdi->wb_lock)' there. However, it is taken only in rare cases when
the bdi has no dirty inodes. So adding this spinlock should be fine and should
not affect performance.

This patch makes sure bdi threads and the forker thread do not wake-up if there
is nothing to do. The forker thread will nevertheless wake up at least every
5 min. to check whether it has to kill a bdi thread. This can also be optimized,
but is not worth it.

This patch also tidies up the warning about unregistered bid, and turns it from
an ugly crocodile to a simple 'WARN()' statement.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fs/fs-writeback.c
mm/backing-dev.c