aboutsummaryrefslogtreecommitdiffstats
path: root/mm/backing-dev.c
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2010-08-29 13:22:30 -0400
committerWu Fengguang <fengguang.wu@intel.com>2011-07-10 01:09:01 -0400
commite98be2d599207c6b31e9bb340d52a231b2f3662d (patch)
tree3ae28e7d621a6e2ddf8e7462f8d282901c113d5c /mm/backing-dev.c
parentf7d2b1ecd0c714adefc7d3a942ef87beb828a763 (diff)
writeback: bdi write bandwidth estimation
The estimation value will start from 100MB/s and adapt to the real bandwidth in seconds. It tries to update the bandwidth only when disk is fully utilized. Any inactive period of more than one second will be skipped. The estimated bandwidth will be reflecting how fast the device can writeout when _fully utilized_, and won't drop to 0 when it goes idle. The value will remain constant at disk idle time. At busy write time, if not considering fluctuations, it will also remain high unless be knocked down by possible concurrent reads that compete for the disk time and bandwidth with async writes. The estimation is not done purely in the flusher because there is no guarantee for write_cache_pages() to return timely to update bandwidth. The bdi->avg_write_bandwidth smoothing is very effective for filtering out sudden spikes, however may be a little biased in long term. The overheads are low because the bdi bandwidth update only occurs at 200ms intervals. The 200ms update interval is suitable, because it's not possible to get the real bandwidth for the instance at all, due to large fluctuations. The NFS commits can be as large as seconds worth of data. One XFS completion may be as large as half second worth of data if we are going to increase the write chunk to half second worth of data. In ext4, fluctuations with time period of around 5 seconds is observed. And there is another pattern of irregular periods of up to 20 seconds on SSD tests. That's why we are not only doing the estimation at 200ms intervals, but also averaging them over a period of 3 seconds and then go further to do another level of smoothing in avg_write_bandwidth. CC: Li Shaohua <shaohua.li@intel.com> CC: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Diffstat (limited to 'mm/backing-dev.c')
-rw-r--r--mm/backing-dev.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 83f18a1d9d10..a76cdd160277 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -638,6 +638,11 @@ static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
638 setup_timer(&wb->wakeup_timer, wakeup_timer_fn, (unsigned long)bdi); 638 setup_timer(&wb->wakeup_timer, wakeup_timer_fn, (unsigned long)bdi);
639} 639}
640 640
641/*
642 * Initial write bandwidth: 100 MB/s
643 */
644#define INIT_BW (100 << (20 - PAGE_SHIFT))
645
641int bdi_init(struct backing_dev_info *bdi) 646int bdi_init(struct backing_dev_info *bdi)
642{ 647{
643 int i, err; 648 int i, err;
@@ -660,6 +665,13 @@ int bdi_init(struct backing_dev_info *bdi)
660 } 665 }
661 666
662 bdi->dirty_exceeded = 0; 667 bdi->dirty_exceeded = 0;
668
669 bdi->bw_time_stamp = jiffies;
670 bdi->written_stamp = 0;
671
672 bdi->write_bandwidth = INIT_BW;
673 bdi->avg_write_bandwidth = INIT_BW;
674
663 err = prop_local_init_percpu(&bdi->completions); 675 err = prop_local_init_percpu(&bdi->completions);
664 676
665 if (err) { 677 if (err) {