A seqlock has a strong limitation, that readers should correctly work with inconsistent data.
Not every processing algorithm allows inconstistent data. In most cases, such data can only be numbers: integers, booleans, etc. They rarely can be pointers, because a stale pointer may point to the memory which is already freed, so dereferencing such pointer is no-no.
Locks (and rw-locks among them) doesn't have "inconsitent data" limitations, so they can be used in much more cases.
Example of inconstisten data under seqlock
Assume there are two structure's fields protected by the single seqlock. The first field, a
is incremented by each "write", the second field, b
is decremented by each "write". Both fields initially are 0
.
On may assume, that a reader will always find a + b
to be 0
.
But in case of seqlock, this is not true. E.g., between reading a
and b
it could a "write", so a
value will be old, and b
value will be new, and a + b
gives -1
.