Commit 80793c3
seqlock: Introduce seqcount_latch_t
Latch sequence counters are a multiversion concurrency control mechanism
where the seqcount_t counter even/odd value is used to switch between
two copies of protected data. This allows the seqcount_t read path to
safely interrupt its write side critical section (e.g. from NMIs).
Initially, latch sequence counters were implemented as a single write
function above plain seqcount_t: raw_write_seqcount_latch(). The read
side was expected to use plain seqcount_t raw_read_seqcount().
A specialized latch read function, raw_read_seqcount_latch(), was later
added. It became the standardized way for latch read paths. Due to the
dependent load, it has one read memory barrier less than the plain
seqcount_t raw_read_seqcount() API.
Only raw_write_seqcount_latch() and raw_read_seqcount_latch() should be
used with latch sequence counters. Having *unique* read and write path
APIs means that latch sequence counters are actually a data type of
their own -- just inappropriately overloading plain seqcount_t.
Introduce seqcount_latch_t. This adds type-safety and ensures that only
the correct latch-safe APIs are to be used.
Not to break bisection, let the latch APIs also accept plain seqcount_t
or seqcount_raw_spinlock_t. After converting all call sites to
seqcount_latch_t, only that new data type will be allowed.
References: 9b0fd80 ("seqcount: Add raw_write_seqcount_latch()")
References: 7fc2632 ("seqlock: Introduce raw_read_seqcount_latch()")
References: aadd6e5 ("time/sched_clock: Use raw_read_seqcount_latch()")
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200827114044.11173-4-a.darwish@linutronix.de1 parent 6446a51 commit 80793c3
2 files changed
+91
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
142 | 160 | | |
143 | 161 | | |
144 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
| 590 | + | |
| 591 | + | |
593 | 592 | | |
594 | | - | |
595 | | - | |
596 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
597 | 596 | | |
598 | | - | |
599 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
600 | 627 | | |
601 | 628 | | |
602 | | - | |
603 | | - | |
| 629 | + | |
| 630 | + | |
604 | 631 | | |
605 | | - | |
606 | | - | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
607 | 643 | | |
608 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
609 | 653 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 654 | + | |
613 | 655 | | |
614 | 656 | | |
615 | 657 | | |
616 | | - | |
617 | | - | |
| 658 | + | |
| 659 | + | |
618 | 660 | | |
619 | 661 | | |
620 | 662 | | |
| |||
633 | 675 | | |
634 | 676 | | |
635 | 677 | | |
636 | | - | |
| 678 | + | |
637 | 679 | | |
638 | 680 | | |
639 | 681 | | |
| |||
643 | 685 | | |
644 | 686 | | |
645 | 687 | | |
646 | | - | |
| 688 | + | |
647 | 689 | | |
648 | 690 | | |
649 | 691 | | |
650 | 692 | | |
651 | 693 | | |
652 | | - | |
| 694 | + | |
653 | 695 | | |
654 | 696 | | |
655 | 697 | | |
| |||
668 | 710 | | |
669 | 711 | | |
670 | 712 | | |
671 | | - | |
672 | | - | |
| 713 | + | |
| 714 | + | |
673 | 715 | | |
674 | 716 | | |
675 | 717 | | |
| |||
693 | 735 | | |
694 | 736 | | |
695 | 737 | | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
704 | 746 | | |
705 | 747 | | |
706 | 748 | | |
| |||
0 commit comments