Skip to content

Commit

Permalink
timekeeping: Pass readout base to update_fast_timekeeper()
Browse files Browse the repository at this point in the history
Modify update_fast_timekeeper() to take a struct tk_read_base
pointer as its argument (instead of a struct timekeeper pointer)
and update its kerneldoc comment to reflect that.

That will allow a struct tk_read_base that is not part of a
struct timekeeper to be passed to it in the next patch.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
Rafael J. Wysocki committed Feb 13, 2015
1 parent 3810631 commit affe3e8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)

/**
* update_fast_timekeeper - Update the fast and NMI safe monotonic timekeeper.
* @tk: The timekeeper from which we take the update
* @tkf: The fast timekeeper to update
* @tbase: The time base for the fast timekeeper (mono/raw)
* @tkr: Timekeeping readout base from which we take the update
*
* We want to use this from any context including NMI and tracing /
* instrumenting the timekeeping code itself.
Expand All @@ -244,11 +242,11 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)
* smp_wmb(); <- Ensure that the last base[1] update is visible
* tkf->seq++;
* smp_wmb(); <- Ensure that the seqcount update is visible
* update(tkf->base[0], tk);
* update(tkf->base[0], tkr);
* smp_wmb(); <- Ensure that the base[0] update is visible
* tkf->seq++;
* smp_wmb(); <- Ensure that the seqcount update is visible
* update(tkf->base[1], tk);
* update(tkf->base[1], tkr);
*
* The reader side does:
*
Expand All @@ -269,15 +267,15 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)
* slightly wrong timestamp (a few nanoseconds). See
* @ktime_get_mono_fast_ns.
*/
static void update_fast_timekeeper(struct timekeeper *tk)
static void update_fast_timekeeper(struct tk_read_base *tkr)
{
struct tk_read_base *base = tk_fast_mono.base;

/* Force readers off to base[1] */
raw_write_seqcount_latch(&tk_fast_mono.seq);

/* Update base[0] */
memcpy(base, &tk->tkr, sizeof(*base));
memcpy(base, tkr, sizeof(*base));

/* Force readers back to base[0] */
raw_write_seqcount_latch(&tk_fast_mono.seq);
Expand Down Expand Up @@ -462,7 +460,7 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action)
memcpy(&shadow_timekeeper, &tk_core.timekeeper,
sizeof(tk_core.timekeeper));

update_fast_timekeeper(tk);
update_fast_timekeeper(&tk->tkr);
}

/**
Expand Down

0 comments on commit affe3e8

Please sign in to comment.