linux-stable/fs/xfs/libxfs
Dave Chinner ddbca70cc4 xfs: allocate xattr buffer on demand
When doing file lookups and checking for permissions, we end up in
xfs_get_acl() to see if there are any ACLs on the inode. This
requires and xattr lookup, and to do that we have to supply a buffer
large enough to hold an maximum sized xattr.

On workloads were we are accessing a wide range of cache cold files
under memory pressure (e.g. NFS fileservers) we end up spending a
lot of time allocating the buffer. The buffer is 64k in length, so
is a contiguous multi-page allocation, and if that then fails we
fall back to vmalloc(). Hence the allocation here is /expensive/
when we are looking up hundreds of thousands of files a second.

Initial numbers from a bpf trace show average time in xfs_get_acl()
is ~32us, with ~19us of that in the memory allocation. Note these
are average times, so there are going to be affected by the worst
case allocations more than the common fast case...

To avoid this, we could just do a "null"  lookup to see if the ACL
xattr exists and then only do the allocation if it exists. This,
however, optimises the path for the "no ACL present" case at the
expense of the "acl present" case. i.e. we can halve the time in
xfs_get_acl() for the no acl case (i.e down to ~10-15us), but that
then increases the ACL case by 30% (i.e. up to 40-45us).

To solve this and speed up both cases, drive the xattr buffer
allocation into the attribute code once we know what the actual
xattr length is. For the no-xattr case, we avoid the allocation
completely, speeding up that case. For the common ACL case, we'll
end up with a fast heap allocation (because it'll be smaller than a
page), and only for the rarer "we have a remote xattr" will we have
a multi-page allocation occur. Hence the common ACL case will be
much faster, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-08-30 22:43:57 -07:00
..
xfs_ag.c xfs: account for log space when formatting new AGs 2019-06-28 19:30:21 -07:00
xfs_ag.h xfs: add a new ioctl to describe allocation group geometry 2019-04-14 18:15:57 -07:00
xfs_ag_resv.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_ag_resv.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_alloc.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_alloc.h xfs: const-ify xfs_owner_info arguments 2018-12-12 08:47:16 -08:00
xfs_alloc_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_alloc_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr.c xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_attr.h xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_attr_leaf.c xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_attr_leaf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_remote.c xfs: make attr lookup returns consistent 2019-08-30 22:43:57 -07:00
xfs_attr_remote.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_sf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bit.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_bit.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bmap.c xfs: remove unnecessary int returns from deferred bmap functions 2019-08-28 08:31:02 -07:00
xfs_bmap.h xfs: remove unnecessary int returns from deferred bmap functions 2019-08-28 08:31:02 -07:00
xfs_bmap_btree.c xfs: fix sign handling problem in xfs_bmbt_diff_two_keys 2019-08-28 08:31:01 -07:00
xfs_bmap_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_btree.c xfs: remove all *_ITER_ABORT values 2019-08-29 21:22:41 -07:00
xfs_btree.h xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07: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 fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_da_btree.h xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_da_format.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_da_format.h xfs: factor xfs_da3_blkinfo verification into common helper 2019-02-11 16:07:01 -08:00
xfs_defer.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_defer.h xfs: streamline defer op type handling 2018-12-12 08:47:16 -08:00
xfs_dir2.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_dir2.h xfs: check directory name validity 2019-02-11 16:06:40 -08:00
xfs_dir2_block.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_dir2_data.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_dir2_leaf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_dir2_node.c xfs: reverse search directory freespace indexes 2019-08-30 22:43:57 -07:00
xfs_dir2_priv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_dir2_sf.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_dquot_buf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_errortag.h xfs: cache unlinked pointers in an rhashtable 2019-02-11 16:07:01 -08:00
xfs_format.h xfs: move xfs_ino_geometry to xfs_shared.h 2019-06-28 19:25:35 -07:00
xfs_fs.h xfs: allow single bulkstat of special inodes 2019-07-04 07:52:24 -07:00
xfs_health.h xfs: introduce new v5 bulkstat structure 2019-07-03 20:36:26 -07:00
xfs_ialloc.c xfs: fix maxicount division by zero error 2019-08-28 08:31:01 -07:00
xfs_ialloc.h xfs: refactor inode geometry setup routines 2019-06-12 08:37:40 -07:00
xfs_ialloc_btree.c xfs: create simplified inode walk function 2019-07-02 09:40:05 -07:00
xfs_ialloc_btree.h xfs: create simplified inode walk function 2019-07-02 09:40:05 -07:00
xfs_iext_tree.c xfs: remove unnecessary parameter from xfs_iext_inc_seq 2019-08-28 08:31:01 -07:00
xfs_inode_buf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_inode_buf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_inode_fork.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_inode_fork.h xfs: update fork seq counter on data fork changes 2019-02-11 16:07:00 -08:00
xfs_log_format.h xfs: refactor unmount record write 2018-07-23 09:08:01 -07:00
xfs_log_recover.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_log_rlimit.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_quota_defs.h xfs: change some error-less functions to void types 2019-05-01 20:26:30 -07:00
xfs_refcount.c xfs: remove unnecessary int returns from deferred refcount functions 2019-08-28 08:31:02 -07:00
xfs_refcount.h xfs: remove unnecessary int returns from deferred refcount functions 2019-08-28 08:31:02 -07:00
xfs_refcount_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_refcount_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rmap.c xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07:00
xfs_rmap.h xfs: reinitialize rm_flags when unpacking an offset into an rmap irec 2019-08-28 08:31:02 -07:00
xfs_rmap_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_rmap_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rtbitmap.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_sb.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_sb.h xfs: change some error-less functions to void types 2019-05-01 20:26:30 -07:00
xfs_shared.h xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07:00
xfs_symlink_remote.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_trans_inode.c xfs: sync up xfs_trans_inode with userspace 2019-07-15 08:10:34 -07:00
xfs_trans_resv.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_trans_resv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_trans_space.h xfs: separate inode geometry 2019-06-12 08:37:40 -07:00
xfs_types.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_types.h xfs: add kmem allocation trace points 2019-08-26 17:43:14 -07:00