News for hackers. Stuff that matters.
Re:Linux-insides: sequential locks in the Linux kernel by Amanieu on Sunday July 10, 2016 @05:29PM (#12067350)
I wrote an implementation of sequential locks in Rust [1]. It is extensively commented, which makes it a good way to learn how the algorithm works.

[1] https://github.com/Amanieu/seqlock/blob/master/src/lib.rs

Re:Linux-insides: sequential locks in the Linux kernel by gpderetta on Monday July 11, 2016 @09:21AM (#12070827)
On a related note, take a look a Hans Boehm's paper "Can Seqlocks Get Along With Programming Language Memory Models?" [1].

[1] http://www.hpl.hp.com/techreports/2012/HPL-2012-68.html

Re:Linux-insides: sequential locks in the Linux kernel by caf on Monday July 11, 2016 @09:52PM (#12076209)
I enjoyed footnote 3:

  ... in spite of my earlier claims in the previously
  mentioned mailing list discussion.
Re:Linux-insides: sequential locks in the Linux kernel by caf on Monday July 11, 2016 @05:51AM (#12069947)
This is in error: "So, no one reader or writer can't access protected data. " (in reference to read_seqlock_excl()).

Readers using read_seqbegin() can still access the protected data.

Re:Linux-insides: sequential locks in the Linux kernel by tfigment on Sunday July 10, 2016 @12:04PM (#12066020)
Not an expert but RCU is more complex with respect to checking the CPU states for activity to ensure consistency. Sequential locks use spinlocks and a counter and allows for concurrent reads. This link [1] actually answers it specifically (sorry about the quora link).

[1] https://www.quora.com/What-is-difference-between-the-RCU-rea...

Re:Linux-insides: sequential locks in the Linux kernel by r4um on Sunday July 10, 2016 @06:22PM (#12067543)
LWN's coverage is pretty good https://lwn.net/Articles/262464/
Re:Linux-insides: sequential locks in the Linux kernel by sriram_malhar on Sunday July 10, 2016 @11:43AM (#12065944)
Where do these stand with respect to RCU locks? Are they a replacement, or are these used in different situations?
Re:Linux-insides: sequential locks in the Linux kernel by Amanieu on Sunday July 10, 2016 @01:15PM (#12066274)
The main downside of seqlocks is that you usually can't have pointers in them. Since the basic scheme is read, do stuff, check if sequence counter changed, you need to make sure that you don't dereference a potentially invalid pointer in the "do stuff" phase if another thread is concurrently modifying the data.

RCU avoids this issue by essentially delaying freeing of objects until there are no longer any threads accessing it. But it requires very complicated mechanisms to track all active threads, whereas a seqlock is a very simple and self-contained.

In both cases the read-side overhead is tiny: for example on x86, you don't need any memory barrier or atomic instructions.