seqcount: Introduce raw_write_seqcount_barrier()
seqcount: Introduce raw_write_seqcount_barrier()

Introduce raw_write_seqcount_barrier(), a new construct that can be
used to provide write barrier semantics in seqcount read loops instead
of the usual consistency guarantee.

raw_write_seqcount_barier() is equivalent to:

	raw_write_seqcount_begin();
	raw_write_seqcount_end();

But avoids issueing two back-to-back smp_wmb() instructions.

This construct works because the read side will 'stall' when observing
odd values. This means that -- referring to the example in the comment
below -- even though there is no (matching) read barrier between the
loads of X and Y, we cannot observe !x && !y, because:

 - if we observe Y == false we must observe the first sequence
   increment, which makes us loop, until

 - we observe !(seq & 1) -- the second sequence increment -- at which
   time we must also observe T == true.

Suggested-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: d1e2fad1f6337a0a3a08db0a5375a8a96150db4c@gmail.com
Cc: e5b39230c99b4d3ebd6aa54f6d823f95134bc39d@parallels.com
Cc: 43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org
Cc: bdc6bcd4e8b34b4b92413d758024aeca6da0e459@gmail.com
Cc: 8f3df7547938bf466547d5e4573831d5224028fc@linaro.org
Cc: 20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com
Cc: bdcdf23be75b976d8e1ad9f82e6b264941889f50@linux.intel.com
Cc: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@ZenIV.linux.org.uk>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Paul E. McKenney <1e0ce936bb9b355d257bf5790d2513c3f28be22b@linux.vnet.ibm.com>
Link: 1f6bc7f98126641984113d37353174139e6ac22f@twins.programming.kicks-ass.net
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs