diff options
author | Tejun Heo <tj@kernel.org> | 2015-05-22 18:23:25 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-06-02 10:38:13 -0400 |
commit | b1cbc6d40c85639d405fee37c7bb688c3bf468d6 (patch) | |
tree | 3fade9185da49c4ba9d54fd77f5501d514b8b447 /mm/page-writeback.c | |
parent | 970fb01ad3a773b5612a9bba6b366abcefc18eaf (diff) |
writeback: make __wb_calc_thresh() take dirty_throttle_control
wb_calc_thresh() calculates wb_thresh by scaling thresh according to
the wb's portion in the system-wide write bandwidth. cgroup writeback
support would need to calculate wb_thresh against memcg domain too.
This patch renames wb_calc_thresh() to __wb_calc_thresh() and makes it
take dirty_throttle_control so that the function can later be updated
to calculate against different domains according to
dirty_throttle_control.
wb_calc_thresh() is now a thin wrapper around __wb_calc_thresh().
v2: The original version was incorrectly scaling dtc->dirty instead of
dtc->thresh. This was due to the extremely confusing function and
variable names. Added a rename patch and fixed this one.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Greg Thelen <gthelen@google.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'mm/page-writeback.c')
-rw-r--r-- | mm/page-writeback.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 3ec922309178..2352c69bff12 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -557,9 +557,8 @@ static unsigned long hard_dirty_limit(unsigned long thresh) | |||
557 | } | 557 | } |
558 | 558 | ||
559 | /** | 559 | /** |
560 | * wb_calc_thresh - @wb's share of dirty throttling threshold | 560 | * __wb_calc_thresh - @wb's share of dirty throttling threshold |
561 | * @wb: bdi_writeback to query | 561 | * @dtc: dirty_throttle_context of interest |
562 | * @dirty: global dirty limit in pages | ||
563 | * | 562 | * |
564 | * Returns @wb's dirty limit in pages. The term "dirty" in the context of | 563 | * Returns @wb's dirty limit in pages. The term "dirty" in the context of |
565 | * dirty balancing includes all PG_dirty, PG_writeback and NFS unstable pages. | 564 | * dirty balancing includes all PG_dirty, PG_writeback and NFS unstable pages. |
@@ -578,9 +577,10 @@ static unsigned long hard_dirty_limit(unsigned long thresh) | |||
578 | * The wb's share of dirty limit will be adapting to its throughput and | 577 | * The wb's share of dirty limit will be adapting to its throughput and |
579 | * bounded by the bdi->min_ratio and/or bdi->max_ratio parameters, if set. | 578 | * bounded by the bdi->min_ratio and/or bdi->max_ratio parameters, if set. |
580 | */ | 579 | */ |
581 | unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh) | 580 | static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) |
582 | { | 581 | { |
583 | struct wb_domain *dom = &global_wb_domain; | 582 | struct wb_domain *dom = &global_wb_domain; |
583 | unsigned long thresh = dtc->thresh; | ||
584 | u64 wb_thresh; | 584 | u64 wb_thresh; |
585 | long numerator, denominator; | 585 | long numerator, denominator; |
586 | unsigned long wb_min_ratio, wb_max_ratio; | 586 | unsigned long wb_min_ratio, wb_max_ratio; |
@@ -588,14 +588,14 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh) | |||
588 | /* | 588 | /* |
589 | * Calculate this BDI's share of the thresh ratio. | 589 | * Calculate this BDI's share of the thresh ratio. |
590 | */ | 590 | */ |
591 | fprop_fraction_percpu(&dom->completions, &wb->completions, | 591 | fprop_fraction_percpu(&dom->completions, &dtc->wb->completions, |
592 | &numerator, &denominator); | 592 | &numerator, &denominator); |
593 | 593 | ||
594 | wb_thresh = (thresh * (100 - bdi_min_ratio)) / 100; | 594 | wb_thresh = (thresh * (100 - bdi_min_ratio)) / 100; |
595 | wb_thresh *= numerator; | 595 | wb_thresh *= numerator; |
596 | do_div(wb_thresh, denominator); | 596 | do_div(wb_thresh, denominator); |
597 | 597 | ||
598 | wb_min_max_ratio(wb, &wb_min_ratio, &wb_max_ratio); | 598 | wb_min_max_ratio(dtc->wb, &wb_min_ratio, &wb_max_ratio); |
599 | 599 | ||
600 | wb_thresh += (thresh * wb_min_ratio) / 100; | 600 | wb_thresh += (thresh * wb_min_ratio) / 100; |
601 | if (wb_thresh > (thresh * wb_max_ratio) / 100) | 601 | if (wb_thresh > (thresh * wb_max_ratio) / 100) |
@@ -604,6 +604,13 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh) | |||
604 | return wb_thresh; | 604 | return wb_thresh; |
605 | } | 605 | } |
606 | 606 | ||
607 | unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh) | ||
608 | { | ||
609 | struct dirty_throttle_control gdtc = { GDTC_INIT(wb), | ||
610 | .thresh = thresh }; | ||
611 | return __wb_calc_thresh(&gdtc); | ||
612 | } | ||
613 | |||
607 | /* | 614 | /* |
608 | * setpoint - dirty 3 | 615 | * setpoint - dirty 3 |
609 | * f(dirty) := 1.0 + (----------------) | 616 | * f(dirty) := 1.0 + (----------------) |
@@ -1323,7 +1330,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) | |||
1323 | * wb_position_ratio() will let the dirtier task progress | 1330 | * wb_position_ratio() will let the dirtier task progress |
1324 | * at some rate <= (write_bw / 2) for bringing down wb_dirty. | 1331 | * at some rate <= (write_bw / 2) for bringing down wb_dirty. |
1325 | */ | 1332 | */ |
1326 | dtc->wb_thresh = wb_calc_thresh(dtc->wb, dtc->thresh); | 1333 | dtc->wb_thresh = __wb_calc_thresh(dtc); |
1327 | dtc->wb_bg_thresh = dtc->thresh ? | 1334 | dtc->wb_bg_thresh = dtc->thresh ? |
1328 | div_u64((u64)dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0; | 1335 | div_u64((u64)dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0; |
1329 | 1336 | ||