Skip to content

Commit a2bb9a9

Browse files
djwongSomasundaram Krishnasamy
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 Conflicts: fs/xfs/xfs_iwalk.c fs/xfs/xfs_pwork.c fs/xfs/xfs_pwork.h Orabug: 30898016 Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent e0a7240 commit a2bb9a9

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
@@ -2167,3 +2167,37 @@ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
21672167

21682168
atomic_set(&bp->b_lru_ref, lru_ref);
21692169
}
2170+
2171+
/* Estimate the amount of parallelism available for a given device. */
2172+
unsigned int
2173+
xfs_buftarg_guess_threads(
2174+
struct xfs_buftarg *btp)
2175+
{
2176+
int iomin;
2177+
int ioopt;
2178+
2179+
/*
2180+
* The device tells us that it is non-rotational, and we take that to
2181+
* mean there are no moving parts and that the device can handle all
2182+
* the CPUs throwing IO requests at it.
2183+
*/
2184+
if (blk_queue_nonrot(btp->bt_bdev->bd_queue))
2185+
return num_online_cpus();
2186+
2187+
/*
2188+
* The device has a preferred and minimum IO size that suggest a RAID
2189+
* setup, so infer the number of disks and assume that the parallelism
2190+
* is equal to the disk count.
2191+
*/
2192+
iomin = bdev_io_min(btp->bt_bdev);
2193+
ioopt = bdev_io_opt(btp->bt_bdev);
2194+
if (iomin > 0 && ioopt > iomin)
2195+
return ioopt / iomin;
2196+
2197+
/*
2198+
* The device did not indicate that it has any capabilities beyond that
2199+
* of a rotating disk with a single drive head, so we estimate no
2200+
* parallelism at all.
2201+
*/
2202+
return 1;
2203+
}

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ extern xfs_buftarg_t *xfs_alloc_buftarg(struct xfs_mount *,
399399
extern void xfs_free_buftarg(struct xfs_mount *, struct xfs_buftarg *);
400400
extern void xfs_wait_buftarg(xfs_buftarg_t *);
401401
extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int);
402+
unsigned int xfs_buftarg_guess_threads(struct xfs_buftarg *btp);
402403

403404
#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
404405
#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
@@ -1410,3 +1410,42 @@ xfs_dev_is_read_only(
14101410
}
14111411
return 0;
14121412
}
1413+
1414+
/*
1415+
* Estimate the amount of parallelism that is available for metadata operations
1416+
* on this filesystem.
1417+
*/
1418+
unsigned int
1419+
xfs_guess_metadata_threads(
1420+
struct xfs_mount *mp)
1421+
{
1422+
unsigned int threads;
1423+
1424+
/*
1425+
* Estimate the amount of parallelism for metadata operations from the
1426+
* least capable of the two devices that handle metadata. Cap that
1427+
* estimate to the number of AGs to avoid unnecessary lock contention.
1428+
*/
1429+
threads = xfs_buftarg_guess_threads(mp->m_ddev_targp);
1430+
if (mp->m_logdev_targp != mp->m_ddev_targp)
1431+
threads = min(xfs_buftarg_guess_threads(mp->m_logdev_targp),
1432+
threads);
1433+
threads = min(mp->m_sb.sb_agcount, threads);
1434+
1435+
/* If the storage told us it has fancy capabilities, we're done. */
1436+
if (threads > 1)
1437+
goto clamp;
1438+
1439+
/*
1440+
* Metadata storage did not even hint that it has any parallel
1441+
* capability. If the filesystem was formatted with a stripe unit and
1442+
* width, we'll treat that as evidence of a RAID setup and estimate
1443+
* the number of disks.
1444+
*/
1445+
if (mp->m_sb.sb_unit > 0 && mp->m_sb.sb_width > mp->m_sb.sb_unit)
1446+
threads = mp->m_sb.sb_width / mp->m_sb.sb_unit;
1447+
1448+
clamp:
1449+
/* Don't return an estimate larger than the CPU count. */
1450+
return min(num_online_cpus(), threads);
1451+
}

fs/xfs/xfs_mount.h

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

450+
unsigned int xfs_guess_metadata_threads(struct xfs_mount *mp);
450451
#endif /* __XFS_MOUNT_H__ */

0 commit comments

Comments
 (0)