diff options
Diffstat (limited to 'include/linux/seqlock.h')
| -rw-r--r-- | include/linux/seqlock.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index c6db9fb33c4..600060e25ec 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h | |||
| @@ -141,7 +141,7 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s) | |||
| 141 | unsigned ret; | 141 | unsigned ret; |
| 142 | 142 | ||
| 143 | repeat: | 143 | repeat: |
| 144 | ret = s->sequence; | 144 | ret = ACCESS_ONCE(s->sequence); |
| 145 | if (unlikely(ret & 1)) { | 145 | if (unlikely(ret & 1)) { |
| 146 | cpu_relax(); | 146 | cpu_relax(); |
| 147 | goto repeat; | 147 | goto repeat; |
| @@ -166,6 +166,27 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s) | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /** | 168 | /** |
| 169 | * raw_seqcount_begin - begin a seq-read critical section | ||
| 170 | * @s: pointer to seqcount_t | ||
| 171 | * Returns: count to be passed to read_seqcount_retry | ||
| 172 | * | ||
| 173 | * raw_seqcount_begin opens a read critical section of the given seqcount. | ||
| 174 | * Validity of the critical section is tested by checking read_seqcount_retry | ||
| 175 | * function. | ||
| 176 | * | ||
| 177 | * Unlike read_seqcount_begin(), this function will not wait for the count | ||
| 178 | * to stabilize. If a writer is active when we begin, we will fail the | ||
| 179 | * read_seqcount_retry() instead of stabilizing at the beginning of the | ||
| 180 | * critical section. | ||
| 181 | */ | ||
| 182 | static inline unsigned raw_seqcount_begin(const seqcount_t *s) | ||
| 183 | { | ||
| 184 | unsigned ret = ACCESS_ONCE(s->sequence); | ||
| 185 | smp_rmb(); | ||
| 186 | return ret & ~1; | ||
| 187 | } | ||
| 188 | |||
| 189 | /** | ||
| 169 | * __read_seqcount_retry - end a seq-read critical section (without barrier) | 190 | * __read_seqcount_retry - end a seq-read critical section (without barrier) |
| 170 | * @s: pointer to seqcount_t | 191 | * @s: pointer to seqcount_t |
| 171 | * @start: count, from read_seqcount_begin | 192 | * @start: count, from read_seqcount_begin |
