Skip to content

Commit 55a694d

Browse files
htejunaxboe
authored andcommitted
writeback, cgroup: Adjust WB_FRN_TIME_CUT_DIV to accelerate foreign inode switching
WB_FRN_TIME_CUT_DIV is used to tell the foreign inode detection logic to ignore short writeback rounds to prevent getting confused by a burst of short writebacks. The parameter is currently 2 meaning that anything smaller than half of the running average writback duration will be ignored. This is unnecessarily aggressive. The detection logic uses 16 history slots and is already reasonably protected against some short bursts confusing it and the current parameter can lead to tens of seconds of missed detection depending on the writeback pattern. Let's change the parameter to 8, so that it only ignores writeback with are smaller than 12.5% of the current running average. v2: Add comment explaining what's going on with the foreign detection parameters. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b8e24a9 commit 55a694d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

fs/fs-writeback.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,28 @@ static void wb_wait_for_completion(struct backing_dev_info *bdi,
224224

225225
#ifdef CONFIG_CGROUP_WRITEBACK
226226

227-
/* parameters for foreign inode detection, see wb_detach_inode() */
227+
/*
228+
* Parameters for foreign inode detection, see wbc_detach_inode() to see
229+
* how they're used.
230+
*
231+
* These paramters are inherently heuristical as the detection target
232+
* itself is fuzzy. All we want to do is detaching an inode from the
233+
* current owner if it's being written to by some other cgroups too much.
234+
*
235+
* The current cgroup writeback is built on the assumption that multiple
236+
* cgroups writing to the same inode concurrently is very rare and a mode
237+
* of operation which isn't well supported. As such, the goal is not
238+
* taking too long when a different cgroup takes over an inode while
239+
* avoiding too aggressive flip-flops from occasional foreign writes.
240+
*
241+
* We record, very roughly, 2s worth of IO time history and if more than
242+
* half of that is foreign, trigger the switch. The recording is quantized
243+
* to 16 slots. To avoid tiny writes from swinging the decision too much,
244+
* writes smaller than 1/8 of avg size are ignored.
245+
*/
228246
#define WB_FRN_TIME_SHIFT 13 /* 1s = 2^13, upto 8 secs w/ 16bit */
229247
#define WB_FRN_TIME_AVG_SHIFT 3 /* avg = avg * 7/8 + new * 1/8 */
230-
#define WB_FRN_TIME_CUT_DIV 2 /* ignore rounds < avg / 2 */
248+
#define WB_FRN_TIME_CUT_DIV 8 /* ignore rounds < avg / 8 */
231249
#define WB_FRN_TIME_PERIOD (2 * (1 << WB_FRN_TIME_SHIFT)) /* 2s */
232250

233251
#define WB_FRN_HIST_SLOTS 16 /* inode->i_wb_frn_history is 16bit */

0 commit comments

Comments
 (0)