diff options
author | Tejun Heo <tj@kernel.org> | 2015-05-22 18:23:28 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-06-02 10:38:13 -0400 |
commit | e9f07dfd7086a0b7e9ce98bb97b7422861aad40b (patch) | |
tree | a181a76b726416a14efd4a2fdcfe80b1baf255a3 /mm | |
parent | e9770b3487328b7e28803caf6c809292dd7adbf0 (diff) |
writeback: add dirty_throttle_control->dom
Currently all dirty throttle operations use global_wb_domain; however,
cgroup writeback support requires considering per-memcg wb_domain too.
This patch adds dirty_throttle_control->dom and updates functions
which are directly using globabl_wb_domain to use it instead.
As this makes global_update_bandwidth() a misnomer, the function is
renamed to domain_update_bandwidth().
This patch doesn't introduce any behavioral changes.
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')
-rw-r--r-- | mm/page-writeback.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 5b439fc1e95e..38d45d8c71f5 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -126,6 +126,9 @@ struct wb_domain global_wb_domain; | |||
126 | 126 | ||
127 | /* consolidated parameters for balance_dirty_pages() and its subroutines */ | 127 | /* consolidated parameters for balance_dirty_pages() and its subroutines */ |
128 | struct dirty_throttle_control { | 128 | struct dirty_throttle_control { |
129 | #ifdef CONFIG_CGROUP_WRITEBACK | ||
130 | struct wb_domain *dom; | ||
131 | #endif | ||
129 | struct bdi_writeback *wb; | 132 | struct bdi_writeback *wb; |
130 | struct fprop_local_percpu *wb_completions; | 133 | struct fprop_local_percpu *wb_completions; |
131 | 134 | ||
@@ -140,7 +143,7 @@ struct dirty_throttle_control { | |||
140 | unsigned long pos_ratio; | 143 | unsigned long pos_ratio; |
141 | }; | 144 | }; |
142 | 145 | ||
143 | #define GDTC_INIT(__wb) .wb = (__wb), \ | 146 | #define DTC_INIT_COMMON(__wb) .wb = (__wb), \ |
144 | .wb_completions = &(__wb)->completions | 147 | .wb_completions = &(__wb)->completions |
145 | 148 | ||
146 | /* | 149 | /* |
@@ -152,6 +155,14 @@ struct dirty_throttle_control { | |||
152 | 155 | ||
153 | #ifdef CONFIG_CGROUP_WRITEBACK | 156 | #ifdef CONFIG_CGROUP_WRITEBACK |
154 | 157 | ||
158 | #define GDTC_INIT(__wb) .dom = &global_wb_domain, \ | ||
159 | DTC_INIT_COMMON(__wb) | ||
160 | |||
161 | static struct wb_domain *dtc_dom(struct dirty_throttle_control *dtc) | ||
162 | { | ||
163 | return dtc->dom; | ||
164 | } | ||
165 | |||
155 | static void wb_min_max_ratio(struct bdi_writeback *wb, | 166 | static void wb_min_max_ratio(struct bdi_writeback *wb, |
156 | unsigned long *minp, unsigned long *maxp) | 167 | unsigned long *minp, unsigned long *maxp) |
157 | { | 168 | { |
@@ -181,6 +192,13 @@ static void wb_min_max_ratio(struct bdi_writeback *wb, | |||
181 | 192 | ||
182 | #else /* CONFIG_CGROUP_WRITEBACK */ | 193 | #else /* CONFIG_CGROUP_WRITEBACK */ |
183 | 194 | ||
195 | #define GDTC_INIT(__wb) DTC_INIT_COMMON(__wb) | ||
196 | |||
197 | static struct wb_domain *dtc_dom(struct dirty_throttle_control *dtc) | ||
198 | { | ||
199 | return &global_wb_domain; | ||
200 | } | ||
201 | |||
184 | static void wb_min_max_ratio(struct bdi_writeback *wb, | 202 | static void wb_min_max_ratio(struct bdi_writeback *wb, |
185 | unsigned long *minp, unsigned long *maxp) | 203 | unsigned long *minp, unsigned long *maxp) |
186 | { | 204 | { |
@@ -583,7 +601,7 @@ static unsigned long hard_dirty_limit(unsigned long thresh) | |||
583 | */ | 601 | */ |
584 | static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) | 602 | static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) |
585 | { | 603 | { |
586 | struct wb_domain *dom = &global_wb_domain; | 604 | struct wb_domain *dom = dtc_dom(dtc); |
587 | unsigned long thresh = dtc->thresh; | 605 | unsigned long thresh = dtc->thresh; |
588 | u64 wb_thresh; | 606 | u64 wb_thresh; |
589 | long numerator, denominator; | 607 | long numerator, denominator; |
@@ -952,7 +970,7 @@ out: | |||
952 | 970 | ||
953 | static void update_dirty_limit(struct dirty_throttle_control *dtc) | 971 | static void update_dirty_limit(struct dirty_throttle_control *dtc) |
954 | { | 972 | { |
955 | struct wb_domain *dom = &global_wb_domain; | 973 | struct wb_domain *dom = dtc_dom(dtc); |
956 | unsigned long thresh = dtc->thresh; | 974 | unsigned long thresh = dtc->thresh; |
957 | unsigned long limit = dom->dirty_limit; | 975 | unsigned long limit = dom->dirty_limit; |
958 | 976 | ||
@@ -979,10 +997,10 @@ update: | |||
979 | dom->dirty_limit = limit; | 997 | dom->dirty_limit = limit; |
980 | } | 998 | } |
981 | 999 | ||
982 | static void global_update_bandwidth(struct dirty_throttle_control *dtc, | 1000 | static void domain_update_bandwidth(struct dirty_throttle_control *dtc, |
983 | unsigned long now) | 1001 | unsigned long now) |
984 | { | 1002 | { |
985 | struct wb_domain *dom = &global_wb_domain; | 1003 | struct wb_domain *dom = dtc_dom(dtc); |
986 | 1004 | ||
987 | /* | 1005 | /* |
988 | * check locklessly first to optimize away locking for the most time | 1006 | * check locklessly first to optimize away locking for the most time |
@@ -1190,7 +1208,7 @@ static void __wb_update_bandwidth(struct dirty_throttle_control *dtc, | |||
1190 | goto snapshot; | 1208 | goto snapshot; |
1191 | 1209 | ||
1192 | if (update_ratelimit) { | 1210 | if (update_ratelimit) { |
1193 | global_update_bandwidth(dtc, now); | 1211 | domain_update_bandwidth(dtc, now); |
1194 | wb_update_dirty_ratelimit(dtc, dirtied, elapsed); | 1212 | wb_update_dirty_ratelimit(dtc, dirtied, elapsed); |
1195 | } | 1213 | } |
1196 | wb_update_write_bandwidth(wb, elapsed, written); | 1214 | wb_update_write_bandwidth(wb, elapsed, written); |