X-Git-Url: http://git.cascardo.info/?p=cascardo%2Flinux.git;a=blobdiff_plain;f=include%2Flinux%2Fseqlock.h;h=cc359636cfa32a84364ca5fc3f4380ec71c9dd1c;hp=8cf350325dc682a5d7c8f5638232a48668bb1f05;hb=e7fda6c4c3c1a7d6996dd75fd84670fa0b5d448f;hpb=08d69a25714429850cf9ef71f22d8cdc9189d93f diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 8cf350325dc6..cc359636cfa3 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -116,6 +116,22 @@ repeat: return ret; } +/** + * raw_read_seqcount - Read the raw seqcount + * @s: pointer to seqcount_t + * Returns: count to be passed to read_seqcount_retry + * + * raw_read_seqcount opens a read critical section of the given + * seqcount without any lockdep checking and without checking or + * masking the LSB. Calling code is responsible for handling that. + */ +static inline unsigned raw_read_seqcount(const seqcount_t *s) +{ + unsigned ret = ACCESS_ONCE(s->sequence); + smp_rmb(); + return ret; +} + /** * raw_read_seqcount_begin - start seq-read critical section w/o lockdep * @s: pointer to seqcount_t @@ -217,6 +233,17 @@ static inline void raw_write_seqcount_end(seqcount_t *s) s->sequence++; } +/* + * raw_write_seqcount_latch - redirect readers to even/odd copy + * @s: pointer to seqcount_t + */ +static inline void raw_write_seqcount_latch(seqcount_t *s) +{ + smp_wmb(); /* prior stores before incrementing "sequence" */ + s->sequence++; + smp_wmb(); /* increment "sequence" before following stores */ +} + /* * Sequence counter only version assumes that callers are using their * own mutexing.