linux/fs/xfs/libxfs
Chi Zhiling 1fe5c2aa39 xfs: Reduce unnecessary searches when searching for the best extents
commit 3ef2268403 upstream.

Recently, we found that the CPU spent a lot of time in
xfs_alloc_ag_vextent_size when the filesystem has millions of fragmented
spaces.

The reason is that we conducted much extra searching for extents that
could not yield a better result, and these searches would cost a lot of
time when there were millions of extents to search through. Even if we
get the same result length, we don't switch our choice to the new one,
so we can definitely terminate the search early.

Since the result length cannot exceed the found length, when the found
length equals the best result length we already have, we can conclude
the search.

We did a test in that filesystem:
[root@localhost ~]# xfs_db -c freesp /dev/vdb
   from      to extents  blocks    pct
      1       1     215     215   0.01
      2       3  994476 1988952  99.99

Before this patch:
 0)               |  xfs_alloc_ag_vextent_size [xfs]() {
 0) * 15597.94 us |  }

After this patch:
 0)               |  xfs_alloc_ag_vextent_size [xfs]() {
 0)   19.176 us    |  }

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-02-27 04:10:43 -08:00
..
xfs_ag.c xfs: update the pag for the last AG at recovery time 2025-02-27 04:10:43 -08:00
xfs_ag.h xfs: update the pag for the last AG at recovery time 2025-02-27 04:10:43 -08:00
xfs_ag_resv.c xfs: inobt can use perags in many more places than it does 2023-02-13 09:14:52 +11:00
xfs_ag_resv.h xfs: move perag structure and setup to libxfs/xfs_ag.[ch] 2021-06-02 10:48:24 +10:00
xfs_alloc.c xfs: Reduce unnecessary searches when searching for the best extents 2025-02-27 04:10:43 -08:00
xfs_alloc.h xfs: don't ifdef around the exact minlen allocations 2025-02-27 04:10:43 -08:00
xfs_alloc_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_alloc_btree.h xfs: use separate btree cursor cache for each btree type 2021-10-19 11:45:16 -07:00
xfs_attr.c xfs: distinguish extra split from real ENOSPC from xfs_attr_node_try_addname 2025-02-27 04:10:42 -08:00
xfs_attr.h xfs: enforce one namespace per attribute 2024-10-22 15:46:23 +02:00
xfs_attr_leaf.c xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split 2025-02-27 04:10:42 -08:00
xfs_attr_leaf.h xfs: return bool from xfs_attr3_leaf_add 2025-02-27 04:10:42 -08:00
xfs_attr_remote.c xfs: fix error returns from xfs_bmapi_write 2024-10-22 15:46:21 +02:00
xfs_attr_remote.h xfs: rename struct xfs_attr_item to xfs_attr_intent 2022-05-22 16:00:26 +10:00
xfs_attr_sf.h xfs: Convert xfs_attr_sf macros to inline functions 2020-09-15 20:52:42 -07:00
xfs_bit.c xfs: fix missing header includes 2019-11-07 13:00:53 -08:00
xfs_bit.h xfs: Use the correct style for SPDX License Identifier 2020-05-13 15:32:45 -07:00
xfs_bmap.c xfs: support lowmode allocations in xfs_bmap_exact_minlen_extent_alloc 2025-02-27 04:10:43 -08:00
xfs_bmap.h xfs: accumulate iextent records when checking bmap 2023-04-11 19:00:24 -07:00
xfs_bmap_btree.c xfs: use deferred frees for btree block freeing 2023-06-29 09:28:23 -07:00
xfs_bmap_btree.h xfs: use separate btree cursor cache for each btree type 2021-10-19 11:45:16 -07:00
xfs_btree.c xfs: update btree keys correctly when _insrec splits an inode root block 2024-12-19 18:11:24 +01:00
xfs_btree.h overflow: Add struct_size_t() helper 2023-05-26 13:52:19 -07:00
xfs_btree_staging.c xfs: force all buffers to be written during btree bulk load 2024-04-03 15:28:48 +02:00
xfs_btree_staging.h xfs: remove unused fields from struct xbtree_ifakeroot 2024-04-03 15:28:47 +02:00
xfs_cksum.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xfs_da_btree.c xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split 2025-02-27 04:10:42 -08:00
xfs_da_btree.h xfs: fix TOCTOU race involving the new logged xattrs control knob 2022-06-15 23:13:32 -07:00
xfs_da_format.h xfs: fix missing check for invalid attr flags 2024-10-22 15:46:22 +02:00
xfs_defer.c xfs: use xfs_defer_pending objects to recover intent items 2024-04-03 15:28:46 +02:00
xfs_defer.h xfs: use xfs_defer_pending objects to recover intent items 2024-04-03 15:28:46 +02:00
xfs_dir2.c xfs: stabilize the dirent name transformation function used for ascii-ci dir hash computation 2023-04-11 19:05:04 -07:00
xfs_dir2.h xfs: stabilize the dirent name transformation function used for ascii-ci dir hash computation 2023-04-11 19:05:04 -07:00
xfs_dir2_block.c xfs: replace inode fork size macros with functions 2022-07-12 11:17:27 -07:00
xfs_dir2_data.c xfs: don't walk off the end of a directory data block 2024-12-27 13:58:45 +01:00
xfs_dir2_leaf.c xfs: fix exception caused by unexpected illegal bestcount in leaf dir 2022-10-20 09:42:56 -07:00
xfs_dir2_node.c xfs: convert bp->b_bn references to xfs_buf_daddr() 2021-08-19 10:07:15 -07:00
xfs_dir2_priv.h xfs: don't walk off the end of a directory data block 2024-12-27 13:58:45 +01:00
xfs_dir2_sf.c xfs: Remove the unneeded result variable 2022-09-19 06:52:14 +10:00
xfs_dquot_buf.c xfs: remove the xfs_dqblk_t typedef 2021-10-14 09:19:33 -07:00
xfs_errortag.h xfs: add debug knob to slow down write for fun 2022-11-28 17:54:49 -08:00
xfs_format.h xfs: convert rt bitmap extent lengths to xfs_rtbxlen_t 2024-04-03 15:28:46 +02:00
xfs_fs.h xfs: allow userspace to rebuild metadata structures 2023-08-10 07:48:11 -07:00
xfs_health.h xfs: Use the correct style for SPDX License Identifier 2020-05-13 15:32:45 -07:00
xfs_ialloc.c xfs: AGI length should be bounds checked 2023-07-03 09:48:17 -07:00
xfs_ialloc.h xfs: convert xfs_ialloc_has_inodes_at_extent to return keyfill scan results 2023-04-11 19:00:15 -07:00
xfs_ialloc_btree.c xfs: use deferred frees for btree block freeing 2023-06-29 09:28:23 -07:00
xfs_ialloc_btree.h xfs: standardize ondisk to incore conversion for inode btrees 2023-04-11 19:00:01 -07:00
xfs_iext_tree.c xfs: prevent metadata files from being inactivated 2021-03-25 16:47:50 -07:00
xfs_inode_buf.c xfs: allow unlinked symlinks and dirs with zero size 2024-10-22 15:46:24 +02:00
xfs_inode_buf.h xfs: kill xfs_sb_version_has_v3inode() 2021-08-19 10:07:14 -07:00
xfs_inode_fork.c xfs: fix a sloppy memory handling bug in xfs_iroot_realloc 2025-02-27 04:10:42 -08:00
xfs_inode_fork.h xfs: _{attr,data}_map_shared should take ILOCK_EXCL until iread_extents is completely done 2023-04-12 15:49:10 +10:00
xfs_log_format.h xfs: fix AGF vs inode cluster buffer deadlock 2023-06-05 04:08:27 +10:00
xfs_log_recover.h xfs: transfer recovered intent item ownership in ->iop_recover 2024-04-03 15:28:47 +02:00
xfs_log_rlimit.c xfs: reduce transaction reservations with reflink 2022-04-28 10:25:42 -07:00
xfs_quota_defs.h xfs: remove unused parameter in macro XFS_DQUOT_LOGRES 2024-12-27 13:58:45 +01:00
xfs_refcount.c xfs: fix xfs_btree_query_range callers to initialize btree rec fully 2023-07-02 09:26:19 -07:00
xfs_refcount.h xfs: replace xfs_btree_has_record with a general keyspace scanner 2023-04-11 19:00:10 -07:00
xfs_refcount_btree.c xfs: use deferred frees for btree block freeing 2023-06-29 09:28:23 -07:00
xfs_refcount_btree.h xfs: use separate btree cursor cache for each btree type 2021-10-19 11:45:16 -07:00
xfs_rmap.c xfs: fix xfs_btree_query_range callers to initialize btree rec fully 2023-07-02 09:26:19 -07:00
xfs_rmap.h xfs: teach scrub to check for sole ownership of metadata objects 2023-04-11 19:00:15 -07:00
xfs_rmap_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_rmap_btree.h xfs: use separate btree cursor cache for each btree type 2021-10-19 11:45:16 -07:00
xfs_rtbitmap.c xfs: assert a valid limit in xfs_rtfind_forw 2025-02-27 04:10:42 -08:00
xfs_rtbitmap.h xfs: remove conditional building of rt geometry validator functions 2024-04-03 15:28:49 +02:00
xfs_sb.c xfs: remove unknown compat feature check in superblock write validation 2024-12-09 10:33:00 +01:00
xfs_sb.h xfs: allow sunit mount option to repair bad primary sb stripe values 2024-06-21 14:38:45 +02:00
xfs_shared.h xfs: tag transactions that contain intent done items 2022-05-04 11:46:21 +10:00
xfs_symlink_remote.c xfs: return from xfs_symlink_verify early on V4 filesystems 2024-12-19 18:11:24 +01:00
xfs_trans_inode.c Revert "xfs: switch to multigrain timestamps" 2023-09-20 18:05:31 +02:00
xfs_trans_resv.c xfs: remove unused parameter in macro XFS_DQUOT_LOGRES 2024-12-27 13:58:45 +01:00
xfs_trans_resv.h xfs: rename xfs_*alloc*_log_count to _block_count 2022-04-28 10:25:59 -07:00
xfs_trans_space.h xfs: compute the maximum height of the rmap btree when reflink enabled 2021-10-19 11:45:16 -07:00
xfs_types.c xfs: Pre-calculate per-AG agino geometry 2022-07-07 19:13:10 +10:00
xfs_types.h xfs: remove conditional building of rt geometry validator functions 2024-04-03 15:28:49 +02:00