• A
    writeback: prevent unnecessary bdi threads wakeups · 253c34e9
    Artem Bityutskiy 提交于
    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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
    Reviewed-by: NChristoph Hellwig <hch@lst.de>
    Signed-off-by: NJens Axboe <jaxboe@fusionio.com>
    253c34e9
fs-writeback.c 31.8 KB