Skip to content

Commit 2e065f1

Browse files
biger410Brian Maly
authored andcommitted
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 <[email protected]> (cherry picked from commit 4aa9d5eb8af0b92657a696dfaf8404f7b8edf9e9) cherry-pick-repo=kernel/git/djwong/xfs-linux.git Signed-off-by: Brian Maly <[email protected]> Conflicts: fs/xfs/xfs_iwalk.c fs/xfs/xfs_pwork.c fs/xfs/xfs_pwork.h Orabug: 30944736 Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 885fc2b commit 2e065f1

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

fs/xfs/xfs_buf.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,3 +2008,37 @@ xfs_buf_terminate(void)
20082008
{
20092009
kmem_zone_destroy(xfs_buf_zone);
20102010
}
2011+
2012+
/* Estimate the amount of parallelism available for a given device. */
2013+
unsigned int
2014+
xfs_buftarg_guess_threads(
2015+
struct xfs_buftarg *btp)
2016+
{
2017+
int iomin;
2018+
int ioopt;
2019+
2020+
/*
2021+
* The device tells us that it is non-rotational, and we take that to
2022+
* mean there are no moving parts and that the device can handle all
2023+
* the CPUs throwing IO requests at it.
2024+
*/
2025+
if (blk_queue_nonrot(btp->bt_bdev->bd_queue))
2026+
return num_online_cpus();
2027+
2028+
/*
2029+
* The device has a preferred and minimum IO size that suggest a RAID
2030+
* setup, so infer the number of disks and assume that the parallelism
2031+
* is equal to the disk count.
2032+
*/
2033+
iomin = bdev_io_min(btp->bt_bdev);
2034+
ioopt = bdev_io_opt(btp->bt_bdev);
2035+
if (iomin > 0 && ioopt > iomin)
2036+
return ioopt / iomin;
2037+
2038+
/*
2039+
* The device did not indicate that it has any capabilities beyond that
2040+
* of a rotating disk with a single drive head, so we estimate no
2041+
* parallelism at all.
2042+
*/
2043+
return 1;
2044+
}

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ extern xfs_buftarg_t *xfs_alloc_buftarg(struct xfs_mount *,
413413
extern void xfs_free_buftarg(struct xfs_mount *, struct xfs_buftarg *);
414414
extern void xfs_wait_buftarg(xfs_buftarg_t *);
415415
extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int);
416+
unsigned int xfs_buftarg_guess_threads(struct xfs_buftarg *btp);
416417

417418
#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
418419
#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)

fs/xfs/xfs_mount.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,3 +1314,42 @@ xfs_dev_is_read_only(
13141314
}
13151315
return 0;
13161316
}
1317+
1318+
/*
1319+
* Estimate the amount of parallelism that is available for metadata operations
1320+
* on this filesystem.
1321+
*/
1322+
unsigned int
1323+
xfs_guess_metadata_threads(
1324+
struct xfs_mount *mp)
1325+
{
1326+
unsigned int threads;
1327+
1328+
/*
1329+
* Estimate the amount of parallelism for metadata operations from the
1330+
* least capable of the two devices that handle metadata. Cap that
1331+
* estimate to the number of AGs to avoid unnecessary lock contention.
1332+
*/
1333+
threads = xfs_buftarg_guess_threads(mp->m_ddev_targp);
1334+
if (mp->m_logdev_targp != mp->m_ddev_targp)
1335+
threads = min(xfs_buftarg_guess_threads(mp->m_logdev_targp),
1336+
threads);
1337+
threads = min(mp->m_sb.sb_agcount, threads);
1338+
1339+
/* If the storage told us it has fancy capabilities, we're done. */
1340+
if (threads > 1)
1341+
goto clamp;
1342+
1343+
/*
1344+
* Metadata storage did not even hint that it has any parallel
1345+
* capability. If the filesystem was formatted with a stripe unit and
1346+
* width, we'll treat that as evidence of a RAID setup and estimate
1347+
* the number of disks.
1348+
*/
1349+
if (mp->m_sb.sb_unit > 0 && mp->m_sb.sb_width > mp->m_sb.sb_unit)
1350+
threads = mp->m_sb.sb_width / mp->m_sb.sb_unit;
1351+
1352+
clamp:
1353+
/* Don't return an estimate larger than the CPU count. */
1354+
return min(num_online_cpus(), threads);
1355+
}

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,5 @@ int xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
380380
struct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp,
381381
int error_class, int error);
382382

383+
unsigned int xfs_guess_metadata_threads(struct xfs_mount *mp);
383384
#endif /* __XFS_MOUNT_H__ */

0 commit comments

Comments
 (0)