Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu: Add synchronize_sched_expedited() rcutorture doc + updates

This patch updates the rcutorture documentation to include
updated output format. It also brings the RCU documentation up
to date.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org
Cc: davem@davemloft.net
Cc: dada1@cosmosbay.com
Cc: zbr@ioremap.net
Cc: jeff.chua.linux@gmail.com
Cc: paulus@samba.org
Cc: laijs@cn.fujitsu.com
Cc: jengelh@medozas.de
Cc: r000n@r000n.net
Cc: benh@kernel.crashing.org
Cc: mathieu.desnoyers@polymtl.ca
LKML-Reference: <12459460983193-git-send-email->
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Paul E. McKenney and committed by
Ingo Molnar
240ebbf8 0acc512c

+156 -19
+77
Documentation/RCU/RTFP.txt
··· 743 743 RCU, realtime RCU, sleepable RCU, performance. 744 744 " 745 745 } 746 + 747 + @article{PaulEMcKenney2008RCUOSR 748 + ,author="Paul E. McKenney and Jonathan Walpole" 749 + ,title="Introducing technology into the {Linux} kernel: a case study" 750 + ,Year="2008" 751 + ,journal="SIGOPS Oper. Syst. Rev." 752 + ,volume="42" 753 + ,number="5" 754 + ,pages="4--17" 755 + ,issn="0163-5980" 756 + ,doi={http://doi.acm.org/10.1145/1400097.1400099} 757 + ,publisher="ACM" 758 + ,address="New York, NY, USA" 759 + ,annotation={ 760 + Linux changed RCU to a far greater degree than RCU has changed Linux. 761 + } 762 + } 763 + 764 + @unpublished{PaulEMcKenney2008HierarchicalRCU 765 + ,Author="Paul E. McKenney" 766 + ,Title="Hierarchical {RCU}" 767 + ,month="November" 768 + ,day="3" 769 + ,year="2008" 770 + ,note="Available: 771 + \url{http://lwn.net/Articles/305782/} 772 + [Viewed November 6, 2008]" 773 + ,annotation=" 774 + RCU with combining-tree-based grace-period detection, 775 + permitting it to handle thousands of CPUs. 776 + " 777 + } 778 + 779 + @conference{PaulEMcKenney2009MaliciousURCU 780 + ,Author="Paul E. McKenney" 781 + ,Title="Using a Malicious User-Level {RCU} to Torture {RCU}-Based Algorithms" 782 + ,Booktitle="linux.conf.au 2009" 783 + ,month="January" 784 + ,year="2009" 785 + ,address="Hobart, Australia" 786 + ,note="Available: 787 + \url{http://www.rdrop.com/users/paulmck/RCU/urcutorture.2009.01.22a.pdf} 788 + [Viewed February 2, 2009]" 789 + ,annotation=" 790 + Realtime RCU and torture-testing RCU uses. 791 + " 792 + } 793 + 794 + @unpublished{MathieuDesnoyers2009URCU 795 + ,Author="Mathieu Desnoyers" 796 + ,Title="[{RFC} git tree] Userspace {RCU} (urcu) for {Linux}" 797 + ,month="February" 798 + ,day="5" 799 + ,year="2009" 800 + ,note="Available: 801 + \url{http://lkml.org/lkml/2009/2/5/572} 802 + \url{git://lttng.org/userspace-rcu.git} 803 + [Viewed February 20, 2009]" 804 + ,annotation=" 805 + Mathieu Desnoyers's user-space RCU implementation. 806 + git://lttng.org/userspace-rcu.git 807 + " 808 + } 809 + 810 + @unpublished{PaulEMcKenney2009BloatWatchRCU 811 + ,Author="Paul E. McKenney" 812 + ,Title="{RCU}: The {Bloatwatch} Edition" 813 + ,month="March" 814 + ,day="17" 815 + ,year="2009" 816 + ,note="Available: 817 + \url{http://lwn.net/Articles/323929/} 818 + [Viewed March 20, 2009]" 819 + ,annotation=" 820 + Uniprocessor assumptions allow simplified RCU implementation. 821 + " 822 + }
+25 -9
Documentation/RCU/UP.txt
··· 2 2 3 3 4 4 A common misconception is that, on UP systems, the call_rcu() primitive 5 - may immediately invoke its function, and that the synchronize_rcu() 6 - primitive may return immediately. The basis of this misconception 5 + may immediately invoke its function. The basis of this misconception 7 6 is that since there is only one CPU, it should not be necessary to 8 7 wait for anything else to get done, since there are no other CPUs for 9 8 anything else to be happening on. Although this approach will -sort- -of- 10 9 work a surprising amount of the time, it is a very bad idea in general. 11 - This document presents three examples that demonstrate exactly how bad an 12 - idea this is. 10 + This document presents three examples that demonstrate exactly how bad 11 + an idea this is. 13 12 14 13 15 14 Example 1: softirq Suicide ··· 81 82 82 83 Summary 83 84 84 - Permitting call_rcu() to immediately invoke its arguments or permitting 85 - synchronize_rcu() to immediately return breaks RCU, even on a UP system. 86 - So do not do it! Even on a UP system, the RCU infrastructure -must- 87 - respect grace periods, and -must- invoke callbacks from a known environment 88 - in which no locks are held. 85 + Permitting call_rcu() to immediately invoke its arguments breaks RCU, 86 + even on a UP system. So do not do it! Even on a UP system, the RCU 87 + infrastructure -must- respect grace periods, and -must- invoke callbacks 88 + from a known environment in which no locks are held. 89 + 90 + It -is- safe for synchronize_sched() and synchronize_rcu_bh() to return 91 + immediately on an UP system. It is also safe for synchronize_rcu() 92 + to return immediately on UP systems, except when running preemptable 93 + RCU. 94 + 95 + Quick Quiz #3: Why can't synchronize_rcu() return immediately on 96 + UP systems running preemptable RCU? 89 97 90 98 91 99 Answer to Quick Quiz #1: ··· 123 117 callbacks acquire locks directly. However, a great many RCU 124 118 callbacks do acquire locks -indirectly-, for example, via 125 119 the kfree() primitive. 120 + 121 + Answer to Quick Quiz #3: 122 + Why can't synchronize_rcu() return immediately on UP systems 123 + running preemptable RCU? 124 + 125 + Because some other task might have been preempted in the middle 126 + of an RCU read-side critical section. If synchronize_rcu() 127 + simply immediately returned, it would prematurely signal the 128 + end of the grace period, which would come as a nasty shock to 129 + that other thread when it started running again.
+15 -5
Documentation/RCU/checklist.txt
··· 11 11 structure is updated more than about 10% of the time, then 12 12 you should strongly consider some other approach, unless 13 13 detailed performance measurements show that RCU is nonetheless 14 - the right tool for the job. 14 + the right tool for the job. Yes, you might think of RCU 15 + as simply cutting overhead off of the readers and imposing it 16 + on the writers. That is exactly why normal uses of RCU will 17 + do much more reading than updating. 15 18 16 19 Another exception is where performance is not an issue, and RCU 17 20 provides a simpler implementation. An example of this situation ··· 243 240 instead need to use synchronize_irq() or synchronize_sched(). 244 241 245 242 12. Any lock acquired by an RCU callback must be acquired elsewhere 246 - with irq disabled, e.g., via spin_lock_irqsave(). Failing to 247 - disable irq on a given acquisition of that lock will result in 248 - deadlock as soon as the RCU callback happens to interrupt that 249 - acquisition's critical section. 243 + with softirq disabled, e.g., via spin_lock_irqsave(), 244 + spin_lock_bh(), etc. Failing to disable irq on a given 245 + acquisition of that lock will result in deadlock as soon as the 246 + RCU callback happens to interrupt that acquisition's critical 247 + section. 250 248 251 249 13. RCU callbacks can be and are executed in parallel. In many cases, 252 250 the callback code simply wrappers around kfree(), so that this ··· 314 310 Because these primitives only wait for pre-existing readers, 315 311 it is the caller's responsibility to guarantee safety to 316 312 any subsequent readers. 313 + 314 + 16. The various RCU read-side primitives do -not- contain memory 315 + barriers. The CPU (and in some cases, the compiler) is free 316 + to reorder code into and out of RCU read-side critical sections. 317 + It is the responsibility of the RCU update-side primitives to 318 + deal with this.
+7
Documentation/RCU/rcubarrier.txt
··· 170 170 the timers, and only then invoke rcu_barrier() to wait for any remaining 171 171 RCU callbacks to complete. 172 172 173 + Of course, if you module uses call_rcu_bh(), you will need to invoke 174 + rcu_barrier_bh() before unloading. Similarly, if your module uses 175 + call_rcu_sched(), you will need to invoke rcu_barrier_sched() before 176 + unloading. If your module uses call_rcu(), call_rcu_bh(), -and- 177 + call_rcu_sched(), then you will need to invoke each of rcu_barrier(), 178 + rcu_barrier_bh(), and rcu_barrier_sched(). 179 + 173 180 174 181 Implementing rcu_barrier() 175 182
+21 -2
Documentation/RCU/torture.txt
··· 76 76 "rcu_sync" for rcu_read_lock() with synchronous reclamation, 77 77 "rcu_bh" for the rcu_read_lock_bh() API, "rcu_bh_sync" for 78 78 rcu_read_lock_bh() with synchronous reclamation, "srcu" for 79 - the "srcu_read_lock()" API, and "sched" for the use of 80 - preempt_disable() together with synchronize_sched(). 79 + the "srcu_read_lock()" API, "sched" for the use of 80 + preempt_disable() together with synchronize_sched(), 81 + and "sched_expedited" for the use of preempt_disable() 82 + with synchronize_sched_expedited(). 81 83 82 84 verbose Enable debug printk()s. Default is disabled. 83 85 ··· 163 161 of the "old" and "current" counters for the corresponding CPU. The 164 162 "idx" value maps the "old" and "current" values to the underlying array, 165 163 and is useful for debugging. 164 + 165 + Similarly, sched_expedited RCU provides the following: 166 + 167 + sched_expedited-torture: rtc: d0000000016c1880 ver: 1090796 tfle: 0 rta: 1090796 rtaf: 0 rtf: 1090787 rtmbe: 0 nt: 27713319 168 + sched_expedited-torture: Reader Pipe: 12660320201 95875 0 0 0 0 0 0 0 0 0 169 + sched_expedited-torture: Reader Batch: 12660424885 0 0 0 0 0 0 0 0 0 0 170 + sched_expedited-torture: Free-Block Circulation: 1090795 1090795 1090794 1090793 1090792 1090791 1090790 1090789 1090788 1090787 0 171 + state: -1 / 0:0 3:0 4:0 172 + 173 + As before, the first four lines are similar to those for RCU. 174 + The last line shows the task-migration state. The first number is 175 + -1 if synchronize_sched_expedited() is idle, -2 if in the process of 176 + posting wakeups to the migration kthreads, and N when waiting on CPU N. 177 + Each of the colon-separated fields following the "/" is a CPU:state pair. 178 + Valid states are "0" for idle, "1" for waiting for quiescent state, 179 + "2" for passed through quiescent state, and "3" when a race with a 180 + CPU-hotplug event forces use of the synchronize_sched() primitive. 166 181 167 182 168 183 USAGE
+11 -3
Documentation/RCU/whatisRCU.txt
··· 785 785 rcu_dereference 786 786 list_for_each_entry_rcu 787 787 hlist_for_each_entry_rcu 788 + hlist_nulls_for_each_entry_rcu 788 789 789 790 list_for_each_continue_rcu (to be deprecated in favor of new 790 791 list_for_each_entry_continue_rcu) ··· 808 807 809 808 rcu_read_lock synchronize_net rcu_barrier 810 809 rcu_read_unlock synchronize_rcu 810 + synchronize_rcu_expedited 811 811 call_rcu 812 812 813 813 814 814 bh: Critical sections Grace period Barrier 815 815 816 816 rcu_read_lock_bh call_rcu_bh rcu_barrier_bh 817 - rcu_read_unlock_bh 817 + rcu_read_unlock_bh synchronize_rcu_bh 818 + synchronize_rcu_bh_expedited 818 819 819 820 820 821 sched: Critical sections Grace period Barrier 821 822 822 - [preempt_disable] synchronize_sched rcu_barrier_sched 823 - [and friends] call_rcu_sched 823 + rcu_read_lock_sched synchronize_sched rcu_barrier_sched 824 + rcu_read_unlock_sched call_rcu_sched 825 + [preempt_disable] synchronize_sched_expedited 826 + [and friends] 824 827 825 828 826 829 SRCU: Critical sections Grace period Barrier ··· 832 827 srcu_read_lock synchronize_srcu N/A 833 828 srcu_read_unlock 834 829 830 + SRCU: Initialization/cleanup 831 + init_srcu_struct 832 + cleanup_srcu_struct 835 833 836 834 See the comment headers in the source code (or the docbook generated 837 835 from them) for more information.