diff options
author | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2014-07-16 17:05:21 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 18:01:54 -0400 |
commit | 9b0fd802e8c0545148324916055e7b40d97963fa (patch) | |
tree | ed3332e022543a236e187cd976a657433d35c786 | |
parent | 0ea5a520f73ca31abc4c10b6d5bc14a884a0641b (diff) |
seqcount: Add raw_write_seqcount_latch()
For NMI safe access to clock monotonic we use the seqcount LSB as
index of a timekeeper array. The update sequence looks like this:
smp_wmb(); <- prior stores to a[1]
seq++;
smp_wmb(); <- seq increment before update of a[0]
update(a[0]);
smp_wmb(); <- update of a[0]
seq++;
smp_wmb(); <- seq increment before update of a[1]
update(a[1]);
To avoid open coded barriers, provide a helper function.
[ tglx: Split out of a combo patch against the first implementation of
the NMI safe accessor ]
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | include/linux/seqlock.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index dcc64b9bfc41..cce6e7453592 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h | |||
@@ -236,6 +236,17 @@ static inline void raw_write_seqcount_end(seqcount_t *s) | |||
236 | } | 236 | } |
237 | 237 | ||
238 | /* | 238 | /* |
239 | * raw_write_seqcount_latch - redirect readers to even/odd copy | ||
240 | * @s: pointer to seqcount_t | ||
241 | */ | ||
242 | static inline void raw_write_seqcount_latch(seqcount_t *s) | ||
243 | { | ||
244 | smp_wmb(); /* prior stores before incrementing "sequence" */ | ||
245 | s->sequence++; | ||
246 | smp_wmb(); /* increment "sequence" before following stores */ | ||
247 | } | ||
248 | |||
249 | /* | ||
239 | * Sequence counter only version assumes that callers are using their | 250 | * Sequence counter only version assumes that callers are using their |
240 | * own mutexing. | 251 | * own mutexing. |
241 | */ | 252 | */ |