From 077ddf6c4071b98a99937803d4b471446fb40275 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 30 Aug 2019 15:44:39 -0700 Subject: xfs: increase the default parallelism levels of pwork clients Increase the default parallelism level for pwork clients so that we can take advantage of computers with a lot of CPUs and a lot of hardware. 8x raid0 spinning rust running quotacheck: 1 39s 2 29s 4 26s 8 24s 24 (nr_cpus) 24s 4x raid0 sata ssds running quotacheck: 1 12s 2 12s 4 12s 8 13s 24 (nr_cpus) 14s 4x raid0 nvme ssds running quotacheck: 1 18s 2 18s 4 19s 8 20s 20 (nr_cpus) 20s So, mixed results... Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_pwork.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_pwork.c b/fs/xfs/xfs_pwork.c index 4bcc3e61056c..9589995a5137 100644 --- a/fs/xfs/xfs_pwork.c +++ b/fs/xfs/xfs_pwork.c @@ -127,10 +127,45 @@ xfs_pwork_guess_datadev_parallelism( struct xfs_mount *mp) { struct xfs_buftarg *btp = mp->m_ddev_targp; + unsigned int threads; + unsigned int max_threads; + int iomin; + int ioopt; /* - * For now we'll go with the most conservative setting possible, - * which is two threads for an SSD and 1 thread everywhere else. + * For metadata activities we probably can't scale further than the + * number of AGs and the number of online CPUs; and we must abide the + * workqueue maximum thread count. */ - return blk_queue_nonrot(btp->bt_bdev->bd_queue) ? 2 : 1; + max_threads = min(mp->m_sb.sb_agcount, + min_t(unsigned int, num_online_cpus(), WQ_MAX_ACTIVE)); + + if (blk_queue_nonrot(btp->bt_bdev->bd_queue)) { + threads = max_threads; + goto out; + } + + /* + * For filesystems on rotational storage with configured stripe width + * and stripe units, we assume that there's a multidisk setup (e.g. + * RAID) and that we can parallelise according to the setup's geometry. + * First we try the values in the superblock and then we resort to + * probing the block layer. + */ + if (mp->m_sb.sb_width && mp->m_sb.sb_unit) { + threads = mp->m_sb.sb_width / mp->m_sb.sb_unit; + goto out; + } + + iomin = bdev_io_min(btp->bt_bdev); + ioopt = bdev_io_opt(btp->bt_bdev); + if (iomin > 0 && ioopt > 0) { + threads = ioopt / iomin; + goto out; + } + + /* Unexciting rotating disks get one thread. */ + threads = 1; +out: + return clamp(threads, 1U, max_threads); } -- cgit v1.2.3