Skip to content

Commit a539e28

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: 30898008 Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent aa90dc5 commit a539e28

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

22052205
atomic_set(&bp->b_lru_ref, lru_ref);
22062206
}
2207+
2208+
/* Estimate the amount of parallelism available for a given device. */
2209+
unsigned int
2210+
xfs_buftarg_guess_threads(
2211+
struct xfs_buftarg *btp)
2212+
{
2213+
int iomin;
2214+
int ioopt;
2215+
2216+
/*
2217+
* The device tells us that it is non-rotational, and we take that to
2218+
* mean there are no moving parts and that the device can handle all
2219+
* the CPUs throwing IO requests at it.
2220+
*/
2221+
if (blk_queue_nonrot(btp->bt_bdev->bd_queue))
2222+
return num_online_cpus();
2223+
2224+
/*
2225+
* The device has a preferred and minimum IO size that suggest a RAID
2226+
* setup, so infer the number of disks and assume that the parallelism
2227+
* is equal to the disk count.
2228+
*/
2229+
iomin = bdev_io_min(btp->bt_bdev);
2230+
ioopt = bdev_io_opt(btp->bt_bdev);
2231+
if (iomin > 0 && ioopt > iomin)
2232+
return ioopt / iomin;
2233+
2234+
/*
2235+
* The device did not indicate that it has any capabilities beyond that
2236+
* of a rotating disk with a single drive head, so we estimate no
2237+
* parallelism at all.
2238+
*/
2239+
return 1;
2240+
}

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)