Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs-writeback: unplug before cond_resched in writeback_sb_inodes

Commit 505a666ee3fc ("writeback: plug writeback in wb_writeback() and
writeback_inodes_wb()") has us holding a plug during writeback_sb_inodes,
which increases the merge rate when relatively contiguous small files
are written by the filesystem. It helps both on flash and spindles.

For an fs_mark workload creating 4K files in parallel across 8 drives,
this commit improves performance ~9% more by unplugging before calling
cond_resched(). cond_resched() doesn't trigger an implicit unplug, so
explicitly getting the IO down to the device before scheduling reduces
latencies for anyone waiting on clean pages.

It also cuts down on how often we use kblockd to unplug, which means
less work bouncing from one workqueue to another.

Many more details about how we got here:

https://lkml.org/lkml/2015/9/11/570

Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Chris Mason and committed by
Linus Torvalds
590dca3a 00ade1f5

+16 -1
+16 -1
fs/fs-writeback.c
··· 1481 1481 wbc_detach_inode(&wbc); 1482 1482 work->nr_pages -= write_chunk - wbc.nr_to_write; 1483 1483 wrote += write_chunk - wbc.nr_to_write; 1484 + 1485 + if (need_resched()) { 1486 + /* 1487 + * We're trying to balance between building up a nice 1488 + * long list of IOs to improve our merge rate, and 1489 + * getting those IOs out quickly for anyone throttling 1490 + * in balance_dirty_pages(). cond_resched() doesn't 1491 + * unplug, so get our IOs out the door before we 1492 + * give up the CPU. 1493 + */ 1494 + blk_flush_plug(current); 1495 + cond_resched(); 1496 + } 1497 + 1498 + 1484 1499 spin_lock(&wb->list_lock); 1485 1500 spin_lock(&inode->i_lock); 1486 1501 if (!(inode->i_state & I_DIRTY_ALL)) ··· 1503 1488 requeue_inode(inode, wb, &wbc); 1504 1489 inode_sync_complete(inode); 1505 1490 spin_unlock(&inode->i_lock); 1506 - cond_resched_lock(&wb->list_lock); 1491 + 1507 1492 /* 1508 1493 * bail out to wb_writeback() often enough to check 1509 1494 * background threshold and other termination conditions.