Re: [GIT PULL v2] timestamp fixes

From: Christian Brauner
Date: Sun Sep 24 2023 - 06:15:44 EST


> As luck would have it, if my calculations are correct, on x86-64 and with

I hope you're aware that you can use pahole to get struct layouts and
that you don't have to manually calculate this...

> CONFIG_FS_POSIX_ACL=y, CONFIG_SECURITY=y (as they are on
> distro kernels), __i_ctime is exactly on split cache lines and maybe even

(Make sure that your kernel doesn't use randomize_layout...)

tv_nsec has always been on a split cacheline. We've optimized struct
file a little bit in the same way before as there were actual
regressions in some workloads

I can put it into one of the vfs.git perf branches that are tested by
LKP to see if there's any actual performance changes.

5.15:
/* --- cacheline 1 boundary (64 bytes) --- */
long unsigned int i_ino; /* 64 8 */
union {
const unsigned int i_nlink; /* 72 4 */
unsigned int __i_nlink; /* 72 4 */
}; /* 72 4 */
/* typedef dev_t -> __kernel_dev_t -> u32 -> __u32 */ unsigned int i_rdev; /* 76 4 */
/* typedef loff_t -> __kernel_loff_t */ long long int i_size; /* 80 8 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 88 8 */
long int tv_nsec; /* 96 8 */
}i_atime; /* 88 16 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 104 8 */
long int tv_nsec; /* 112 8 */
}i_mtime; /* 104 16 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 120 8 */
/* --- cacheline 2 boundary (128 bytes) --- */
long int tv_nsec; /* 128 8 */
}i_ctime; /* 120 16 */
/* typedef spinlock_t */ struct spinlock {

6.6:
/* --- cacheline 1 boundary (64 bytes) --- */
long unsigned int i_ino; /* 64 8 */
union {
const unsigned int i_nlink; /* 72 4 */
unsigned int __i_nlink; /* 72 4 */
}; /* 72 4 */
/* typedef dev_t -> __kernel_dev_t -> u32 -> __u32 */ unsigned int i_rdev; /* 76 4 */
/* typedef loff_t -> __kernel_loff_t */ long long int i_size; /* 80 8 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 88 8 */
long int tv_nsec; /* 96 8 */
}i_atime; /* 88 16 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 104 8 */
long int tv_nsec; /* 112 8 */
}i_mtime; /* 104 16 */
struct timespec64 {
/* typedef time64_t -> __s64 */ long long int tv_sec; /* 120 8 */
/* --- cacheline 2 boundary (128 bytes) --- */
long int tv_nsec; /* 128 8 */
}__i_ctime; /* 120 16 */