Unnecessarily bad cache behavior for ext4_getattr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It looks from profiles like ext4_getattr() is fairly expensive,
because it unnecessarily accesses the extended inode information and
causes extra cache misses.

On an empty kernel allmodconfig build (which is a lot of "stat()"
calls by Make, and a lot of silly string stuff in user space due to
all the make variable games we play), ext4_getattr() was something
like 1% of the time according to the profile I gathered. It might be
bogus - maybe the cacheline ends up being accessed later anyway, but
it _looked_ like it was the whole "i_extra_isize" access that missed
in the cache.

That's all for gathering the STATX_BTIME information, that the caller
doesn't even *want*.

How about a patch like the attached?

                 Linus
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 516faa280ced..617dc8835f5f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5700,7 +5700,7 @@ int ext4_getattr(const struct path *path, struct kstat *stat,
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	unsigned int flags;
 
-	if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) {
+	if ((query_flags & STATX_BTIME) && EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) {
 		stat->result_mask |= STATX_BTIME;
 		stat->btime.tv_sec = ei->i_crtime.tv_sec;
 		stat->btime.tv_nsec = ei->i_crtime.tv_nsec;

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux