]> git.ipfire.org Git - thirdparty/linux.git/commit
timekeeping: Reorder struct timekeeper
authorThomas Gleixner <tglx@linutronix.de>
Tue, 15 Oct 2024 10:08:39 +0000 (12:08 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 25 Oct 2024 17:49:13 +0000 (19:49 +0200)
commit6860d28ccb2390b4eeda32ab2ce7eb10f71921e1
tree6e1e71cb973d25dc099d54df1f08f96a66db952e
parentc2a329566a3d5a638061733f232c40379235931d
timekeeping: Reorder struct timekeeper

struct timekeeper is ordered suboptimal vs. cachelines. The layout,
including the preceding seqcount (see struct tk_core in timekeeper.c) is:

 cacheline 0:   seqcount, tkr_mono
 cacheline 1:   tkr_raw, xtime_sec
 cacheline 2:   ktime_sec ... tai_offset, internal variables
 cacheline 3: next_leap_ktime, raw_sec, internal variables
 cacheline 4: internal variables

So any access to via ktime_get*() except for access to CLOCK_MONOTONIC_RAW
will use either cachelines 0 + 1 or cachelines 0 + 2. Access to
CLOCK_MONOTONIC_RAW uses cachelines 0 + 1 + 3.

Reorder the members so that the result is more efficient:

 cacheline 0:   seqcount, tkr_mono
 cacheline 1:   xtime_sec, ktime_sec ... tai_offset
 cacheline 2: tkr_raw, raw_sec
 cacheline 3: internal variables
 cacheline 4: internal variables

That means ktime_get*() will access cacheline 0 + 1 and CLOCK_MONOTONIC_RAW
access will use cachelines 0 + 2.

Update kernel-doc and fix formatting issues while at it. Also fix a typo
in struct tk_read_base kernel-doc.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20241015100839.12702-1-anna-maria@linutronix.de
include/linux/timekeeper_internal.h