~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/RCU/UP.rst

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/RCU/UP.rst (Version linux-6.11.5) and /Documentation/RCU/UP.rst (Version policy-sample)


  1 .. _up_doc:                                       
  2                                                   
  3 RCU on Uniprocessor Systems                       
  4 ===========================                       
  5                                                   
  6 A common misconception is that, on UP systems,    
  7 may immediately invoke its function.  The basi    
  8 is that since there is only one CPU, it should    
  9 wait for anything else to get done, since ther    
 10 anything else to be happening on.  Although th    
 11 work a surprising amount of the time, it is a     
 12 This document presents three examples that dem    
 13 an idea this is.                                  
 14                                                   
 15 Example 1: softirq Suicide                        
 16 --------------------------                        
 17                                                   
 18 Suppose that an RCU-based algorithm scans a li    
 19 elements A, B, and C in process context, and c    
 20 this same list in softirq context.  Suppose th    
 21 is referencing element B when it is interrupte    
 22 which deletes element B, and then invokes call    
 23 after a grace period.                             
 24                                                   
 25 Now, if call_rcu() were to directly invoke its    
 26 from softirq, the list scan would find itself     
 27 element B.  This situation can greatly decreas    
 28 your kernel.                                      
 29                                                   
 30 This same problem can occur if call_rcu() is i    
 31 interrupt handler.                                
 32                                                   
 33 Example 2: Function-Call Fatality                 
 34 ---------------------------------                 
 35                                                   
 36 Of course, one could avert the suicide describ    
 37 by having call_rcu() directly invoke its argum    
 38 from process context.  However, this can fail     
 39                                                   
 40 Suppose that an RCU-based algorithm again scan    
 41 elements A, B, and C in process context, but t    
 42 on each element as it is scanned.  Suppose fur    
 43 deletes element B from the list, then passes i    
 44 freeing.  This may be a bit unconventional, bu    
 45 RCU usage, since call_rcu() must wait for a gr    
 46 Therefore, in this case, allowing call_rcu() t    
 47 its arguments would cause it to fail to make t    
 48 underlying RCU, namely that call_rcu() defers     
 49 all RCU read-side critical sections currently     
 50                                                   
 51 Quick Quiz #1:                                    
 52         Why is it *not* legal to invoke synchr    
 53                                                   
 54 :ref:`Answers to Quick Quiz <answer_quick_quiz    
 55                                                   
 56 Example 3: Death by Deadlock                      
 57 ----------------------------                      
 58                                                   
 59 Suppose that call_rcu() is invoked while holdi    
 60 callback function must acquire this same lock.    
 61 call_rcu() were to directly invoke the callbac    
 62 be self-deadlock *even if* this invocation occ    
 63 call_rcu() invocation a full grace period late    
 64                                                   
 65 In some cases, it would possible to restructur    
 66 the call_rcu() is delayed until after the lock    
 67 there are cases where this can be quite ugly:     
 68                                                   
 69 1.      If a number of items need to be passed    
 70         the same critical section, then the co    
 71         a list of them, then traverse the list    
 72         released.                                 
 73                                                   
 74 2.      In some cases, the lock will be held a    
 75         so that delaying the call_rcu() until     
 76         requires that the data item be passed     
 77         It is far better to guarantee that cal    
 78         with no locks held than to have to mod    
 79         arbitrary data items to be passed back    
 80                                                   
 81 If call_rcu() directly invokes the callback, p    
 82 or API changes would be required.                 
 83                                                   
 84 Quick Quiz #2:                                    
 85         What locking restriction must RCU call    
 86                                                   
 87 :ref:`Answers to Quick Quiz <answer_quick_quiz    
 88                                                   
 89 It is important to note that userspace RCU imp    
 90 permit call_rcu() to directly invoke callbacks    
 91 grace period has elapsed since those callbacks    
 92 the case because some userspace environments a    
 93 Nevertheless, people writing userspace RCU imp    
 94 encouraged to avoid invoking callbacks from ca    
 95 the deadlock-avoidance benefits called out abo    
 96                                                   
 97 Summary                                           
 98 -------                                           
 99                                                   
100 Permitting call_rcu() to immediately invoke it    
101 even on a UP system.  So do not do it!  Even o    
102 infrastructure *must* respect grace periods, a    
103 from a known environment in which no locks are    
104                                                   
105 Note that it *is* safe for synchronize_rcu() t    
106 UP systems, including PREEMPT SMP builds runni    
107                                                   
108 Quick Quiz #3:                                    
109         Why can't synchronize_rcu() return imm    
110         preemptible RCU?                          
111                                                   
112 .. _answer_quick_quiz_up:                         
113                                                   
114 Answer to Quick Quiz #1:                          
115         Why is it *not* legal to invoke synchr    
116                                                   
117         Because the calling function is scanni    
118         list, and is therefore within an RCU r    
119         Therefore, the called function has bee    
120         read-side critical section, and is not    
121                                                   
122 Answer to Quick Quiz #2:                          
123         What locking restriction must RCU call    
124                                                   
125         Any lock that is acquired within an RC    
126         elsewhere using an _bh variant of the     
127         For example, if "mylock" is acquired b    
128         a process-context acquisition of this     
129         like spin_lock_bh() to acquire the loc    
130         it is also OK to use _irq variants of     
131         spin_lock_irqsave().                      
132                                                   
133         If the process-context code were to si    
134         then, since RCU callbacks can be invok    
135         the callback might be called from a so    
136         the process-context critical section.     
137         self-deadlock.                            
138                                                   
139         This restriction might seem gratuitous    
140         callbacks acquire locks directly.  How    
141         callbacks do acquire locks *indirectly    
142         the kfree() primitive.                    
143                                                   
144 Answer to Quick Quiz #3:                          
145         Why can't synchronize_rcu() return imm    
146         running preemptible RCU?                  
147                                                   
148         Because some other task might have bee    
149         of an RCU read-side critical section.     
150         simply immediately returned, it would     
151         end of the grace period, which would c    
152         that other thread when it started runn    
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php