Re: [PATCH v2 12/25] timekeeping: Add struct tk_data as argument to timekeeping_update()

From: John Stultz
Date: Thu Oct 24 2024 - 17:30:01 EST


On Wed, Oct 9, 2024 at 1:29 AM Anna-Maria Behnsen
<anna-maria@xxxxxxxxxxxxx> wrote:
>
> From: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
>
> Updates of the timekeeper are done in two ways:
>
> 1. Updating timekeeper and afterwards memcpy()'ing the result into
> shadow_timekeeper using timekeeping_update(). Used everywhere for
> updates except in timekeeping_advance(); the sequence counter protected
> region starts before the first change to the timekeeper is done.
>
> 2. Updating shadow_timekeeper and then memcpy()'ing the result into
> timekeeper. Used only by in timekeeping_advance(); The seqence counter
> protected region is only around timekeeping_update() and the memcpy for
> copy from shadow to timekeeper.
>
> The second option is fast path optimized. The sequence counter protected
> region is as short as possible.
>
> As this behaviour is mainly documented by commit messages, but not in code,
> it makes the not easy timekeeping code more complicated to read.
>
> There is no reason why updates to the timekeeper can't use the optimized
> version everywhere. With this, the code will be cleaner, as code is reused
> instead of duplicated.
>
> To be able to access tk_data which contains all required information, add a
> pointer to tk_data as an argument to timekeeping_update(). With that
> convert the comment about holding the lock into a lockdep assert.
>
> No functional change.
>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>

Acked-by: John Stultz <jstultz@xxxxxxxxxx>