linux-yocto/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>
2025-02-27 04:10:43 -08:00
..
xfs_ag_resv.c
xfs_ag_resv.h
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_alloc_btree.c
xfs_alloc_btree.h
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_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_attr_sf.h
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_bit.c
xfs_bit.h
xfs_bmap_btree.c
xfs_bmap_btree.h
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_btree_staging.c
xfs_btree_staging.h
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
xfs_cksum.h
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_da_format.h xfs: fix missing check for invalid attr flags 2024-10-22 15:46:22 +02:00
xfs_defer.c
xfs_defer.h
xfs_dir2_block.c
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_dir2_node.c
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_dir2.c
xfs_dir2.h
xfs_dquot_buf.c
xfs_errortag.h
xfs_format.h
xfs_fs.h
xfs_health.h
xfs_ialloc_btree.c
xfs_ialloc_btree.h
xfs_ialloc.c
xfs_ialloc.h
xfs_iext_tree.c
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_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_log_format.h
xfs_log_recover.h
xfs_log_rlimit.c
xfs_quota_defs.h xfs: remove unused parameter in macro XFS_DQUOT_LOGRES 2024-12-27 13:58:45 +01:00
xfs_refcount_btree.c
xfs_refcount_btree.h
xfs_refcount.c
xfs_refcount.h
xfs_rmap_btree.c
xfs_rmap_btree.h
xfs_rmap.c
xfs_rmap.h
xfs_rtbitmap.c xfs: assert a valid limit in xfs_rtfind_forw 2025-02-27 04:10:42 -08:00
xfs_rtbitmap.h
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_shared.h
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
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_trans_space.h
xfs_types.c
xfs_types.h