€•ÇŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ"/translations/zh_CN/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/zh_TW/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/pt_BR/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/sp_SP/RCU/rcubarrier”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒtarget”“”)�”}”(hŒ.. _rcu_barrier:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œ rcu-barrier”uh1hµh´Khhh²hh³Œrcu, p_callback);”h]”hŒ/list_del_rcu(p); call_rcu(&p->rcu, p_callback);”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j h³hÃh´KhhÆh²hubhÚ)�”}”(hŒŒSince call_rcu() never blocks, this code can safely be used from within IRQ context. The function p_callback() might be defined as follows::”h]”hŒ‹Since call_rcu() never blocks, this code can safely be used from within IRQ context. The function p_callback() might be defined as follows:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubj )�”}”(hŒ…static void p_callback(struct rcu_head *rp) { struct pstruct *p = container_of(rp, struct pstruct, rcu); kfree(p); }”h]”hŒ…static void p_callback(struct rcu_head *rp) { struct pstruct *p = container_of(rp, struct pstruct, rcu); kfree(p); }”…”�”}”hj,sbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÃh´KhhÆh²hubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒ%Unloading Modules That Use call_rcu()”h]”hŒ%Unloading Modules That Use call_rcu()”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj:h²hh³hÃh´KubhÚ)�”}”(hŒIBut what if the p_callback() function is defined in an unloadable module?”h]”hŒIBut what if the p_callback() function is defined in an unloadable module?”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K hj:h²hubhÚ)�”}”(hŒëIf we unload the module while some RCU callbacks are pending, the CPUs executing these callbacks are going to be severely disappointed when they are later invoked, as fancifully depicted at http://lwn.net/images/ns/kernel/rcu-drop.jpg.”h]”(hŒ¾If we unload the module while some RCU callbacks are pending, the CPUs executing these callbacks are going to be severely disappointed when they are later invoked, as fancifully depicted at ”…”�”}”(hjYh²hh³Nh´Nubhä)�”}”(hŒ,http://lwn.net/images/ns/kernel/rcu-drop.jpg”h]”hŒ,http://lwn.net/images/ns/kernel/rcu-drop.jpg”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”jcuh1hãhjYubhŒ.”…”�”}”(hjYh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K"hj:h²hubhÚ)�”}”(hŒÕWe could try placing a synchronize_rcu() in the module-exit code path, but this is not sufficient. Although synchronize_rcu() does wait for a grace period to elapse, it does not wait for the callbacks to complete.”h]”hŒÕWe could try placing a synchronize_rcu() in the module-exit code path, but this is not sufficient. Although synchronize_rcu() does wait for a grace period to elapse, it does not wait for the callbacks to complete.”…”�”}”(hjzh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K'hj:h²hubhÚ)�”}”(hXpOne might be tempted to try several back-to-back synchronize_rcu() calls, but this is still not guaranteed to work. If there is a very heavy RCU-callback load, then some of the callbacks might be deferred in order to allow other processing to proceed. For but one example, such deferral is required in realtime kernels in order to avoid excessive scheduling latencies.”h]”hXpOne might be tempted to try several back-to-back synchronize_rcu() calls, but this is still not guaranteed to work. If there is a very heavy RCU-callback load, then some of the callbacks might be deferred in order to allow other processing to proceed. For but one example, such deferral is required in realtime kernels in order to avoid excessive scheduling latencies.”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K+hj:h²hubeh}”(h]”Œ#unloading-modules-that-use-call-rcu”ah ]”h"]”Œ%unloading modules that use call_rcu()”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´KubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒ rcu_barrier()”h]”hŒ rcu_barrier()”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjžh²hh³hÃh´K4ubhÚ)�”}”(hX©This situation can be handled by the rcu_barrier() primitive. Rather than waiting for a grace period to elapse, rcu_barrier() waits for all outstanding RCU callbacks to complete. Please note that rcu_barrier() does **not** imply synchronize_rcu(), in particular, if there are no RCU callbacks queued anywhere, rcu_barrier() is within its rights to return immediately, without waiting for anything, let alone a grace period.”h]”(hŒÙThis situation can be handled by the rcu_barrier() primitive. Rather than waiting for a grace period to elapse, rcu_barrier() waits for all outstanding RCU callbacks to complete. Please note that rcu_barrier() does ”…”�”}”(hj¯h²hh³Nh´NubhŒstrong”“”)�”}”(hŒ**not**”h]”hŒnot”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj¯ubhŒÉ imply synchronize_rcu(), in particular, if there are no RCU callbacks queued anywhere, rcu_barrier() is within its rights to return immediately, without waiting for anything, let alone a grace period.”…”�”}”(hj¯h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K6hjžh²hubhÚ)�”}”(hŒ.Pseudo-code using rcu_barrier() is as follows:”h]”hŒ.Pseudo-code using rcu_barrier() is as follows:”…”�”}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K=hjžh²hubhŒ block_quote”“”)�”}”(hŒr1. Prevent any new RCU callbacks from being posted. 2. Execute rcu_barrier(). 3. Allow the module to be unloaded. ”h]”hŒenumerated_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒ0Prevent any new RCU callbacks from being posted.”h]”hÚ)�”}”(hjîh]”hŒ0Prevent any new RCU callbacks from being posted.”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K?hjìubah}”(h]”h ]”h"]”h$]”h&]”uh1jêhjçubjë)�”}”(hŒExecute rcu_barrier().”h]”hÚ)�”}”(hjh]”hŒExecute rcu_barrier().”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K@hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jêhjçubjë)�”}”(hŒ!Allow the module to be unloaded. ”h]”hÚ)�”}”(hŒ Allow the module to be unloaded.”h]”hŒ Allow the module to be unloaded.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KAhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jêhjçubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jåhjáubah}”(h]”h ]”h"]”h$]”h&]”uh1jßh³hÃh´K?hjžh²hubhÚ)�”}”(hXÁThere is also an srcu_barrier() function for SRCU, and you of course must match the flavor of srcu_barrier() with that of call_srcu(). If your module uses multiple srcu_struct structures, then it must also use multiple invocations of srcu_barrier() when unloading that module. For example, if it uses call_rcu(), call_srcu() on srcu_struct_1, and call_srcu() on srcu_struct_2, then the following three lines of code will be required when unloading::”h]”hXÀThere is also an srcu_barrier() function for SRCU, and you of course must match the flavor of srcu_barrier() with that of call_srcu(). If your module uses multiple srcu_struct structures, then it must also use multiple invocations of srcu_barrier() when unloading that module. For example, if it uses call_rcu(), call_srcu() on srcu_struct_1, and call_srcu() on srcu_struct_2, then the following three lines of code will be required when unloading:”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KChjžh²hubj )�”}”(hŒS1 rcu_barrier(); 2 srcu_barrier(&srcu_struct_1); 3 srcu_barrier(&srcu_struct_2);”h]”hŒS1 rcu_barrier(); 2 srcu_barrier(&srcu_struct_1); 3 srcu_barrier(&srcu_struct_2);”…”�”}”hjQsbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÃh´KKhjžh²hubhÚ)�”}”(hŒaIf latency is of the essence, workqueues could be used to run these three functions concurrently.”h]”hŒaIf latency is of the essence, workqueues could be used to run these three functions concurrently.”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KOhjžh²hubhÚ)�”}”(hŒhAn ancient version of the rcutorture module makes use of rcu_barrier() in its exit function as follows::”h]”hŒgAn ancient version of the rcutorture module makes use of rcu_barrier() in its exit function as follows:”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KRhjžh²hubj )�”}”(hX 1 static void 2 rcu_torture_cleanup(void) 3 { 4 int i; 5 6 fullstop = 1; 7 if (shuffler_task != NULL) { 8 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task"); 9 kthread_stop(shuffler_task); 10 } 11 shuffler_task = NULL; 12 13 if (writer_task != NULL) { 14 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task"); 15 kthread_stop(writer_task); 16 } 17 writer_task = NULL; 18 19 if (reader_tasks != NULL) { 20 for (i = 0; i < nrealreaders; i++) { 21 if (reader_tasks[i] != NULL) { 22 VERBOSE_PRINTK_STRING( 23 "Stopping rcu_torture_reader task"); 24 kthread_stop(reader_tasks[i]); 25 } 26 reader_tasks[i] = NULL; 27 } 28 kfree(reader_tasks); 29 reader_tasks = NULL; 30 } 31 rcu_torture_current = NULL; 32 33 if (fakewriter_tasks != NULL) { 34 for (i = 0; i < nfakewriters; i++) { 35 if (fakewriter_tasks[i] != NULL) { 36 VERBOSE_PRINTK_STRING( 37 "Stopping rcu_torture_fakewriter task"); 38 kthread_stop(fakewriter_tasks[i]); 39 } 40 fakewriter_tasks[i] = NULL; 41 } 42 kfree(fakewriter_tasks); 43 fakewriter_tasks = NULL; 44 } 45 46 if (stats_task != NULL) { 47 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task"); 48 kthread_stop(stats_task); 49 } 50 stats_task = NULL; 51 52 /* Wait for all RCU callbacks to fire. */ 53 rcu_barrier(); 54 55 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 56 57 if (cur_ops->cleanup != NULL) 58 cur_ops->cleanup(); 59 if (atomic_read(&n_rcu_torture_error)) 60 rcu_torture_print_module_parms("End of test: FAILURE"); 61 else 62 rcu_torture_print_module_parms("End of test: SUCCESS"); 63 }”h]”hX 1 static void 2 rcu_torture_cleanup(void) 3 { 4 int i; 5 6 fullstop = 1; 7 if (shuffler_task != NULL) { 8 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task"); 9 kthread_stop(shuffler_task); 10 } 11 shuffler_task = NULL; 12 13 if (writer_task != NULL) { 14 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task"); 15 kthread_stop(writer_task); 16 } 17 writer_task = NULL; 18 19 if (reader_tasks != NULL) { 20 for (i = 0; i < nrealreaders; i++) { 21 if (reader_tasks[i] != NULL) { 22 VERBOSE_PRINTK_STRING( 23 "Stopping rcu_torture_reader task"); 24 kthread_stop(reader_tasks[i]); 25 } 26 reader_tasks[i] = NULL; 27 } 28 kfree(reader_tasks); 29 reader_tasks = NULL; 30 } 31 rcu_torture_current = NULL; 32 33 if (fakewriter_tasks != NULL) { 34 for (i = 0; i < nfakewriters; i++) { 35 if (fakewriter_tasks[i] != NULL) { 36 VERBOSE_PRINTK_STRING( 37 "Stopping rcu_torture_fakewriter task"); 38 kthread_stop(fakewriter_tasks[i]); 39 } 40 fakewriter_tasks[i] = NULL; 41 } 42 kfree(fakewriter_tasks); 43 fakewriter_tasks = NULL; 44 } 45 46 if (stats_task != NULL) { 47 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task"); 48 kthread_stop(stats_task); 49 } 50 stats_task = NULL; 51 52 /* Wait for all RCU callbacks to fire. */ 53 rcu_barrier(); 54 55 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 56 57 if (cur_ops->cleanup != NULL) 58 cur_ops->cleanup(); 59 if (atomic_read(&n_rcu_torture_error)) 60 rcu_torture_print_module_parms("End of test: FAILURE"); 61 else 62 rcu_torture_print_module_parms("End of test: SUCCESS"); 63 }”…”�”}”hj{sbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÃh´KUhjžh²hubhÚ)�”}”(hX)Line 6 sets a global variable that prevents any RCU callbacks from re-posting themselves. This will not be necessary in most cases, since RCU callbacks rarely include calls to call_rcu(). However, the rcutorture module is an exception to this rule, and therefore needs to set this global variable.”h]”hX)Line 6 sets a global variable that prevents any RCU callbacks from re-posting themselves. This will not be necessary in most cases, since RCU callbacks rarely include calls to call_rcu(). However, the rcutorture module is an exception to this rule, and therefore needs to set this global variable.”…”�”}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K•hjžh²hubhÚ)�”}”(hŒûLines 7-50 stop all the kernel tasks associated with the rcutorture module. Therefore, once execution reaches line 53, no more rcutorture RCU callbacks will be posted. The rcu_barrier() call on line 53 waits for any pre-existing callbacks to complete.”h]”hŒûLines 7-50 stop all the kernel tasks associated with the rcutorture module. Therefore, once execution reaches line 53, no more rcutorture RCU callbacks will be posted. The rcu_barrier() call on line 53 waits for any pre-existing callbacks to complete.”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K›hjžh²hubhÚ)�”}”(hŒ‰Then lines 55-62 print status and do operation-specific cleanup, and then return, permitting the module-unload operation to be completed.”h]”hŒ‰Then lines 55-62 print status and do operation-specific cleanup, and then return, permitting the module-unload operation to be completed.”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K hjžh²hubh¶)�”}”(hŒ.. _rcubarrier_quiz_1:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒrcubarrier-quiz-1”uh1hµh´K£hjžh²hh³hÃubhŒdefinition_list”“”)�”}”(hhh]”hŒdefinition_list_item”“”)�”}”(hŒSQuick Quiz #1: Is there any other situation where rcu_barrier() might be required? ”h]”(hŒterm”“”)�”}”(hŒQuick Quiz #1:”h]”hŒQuick Quiz #1:”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´K§hjÅubhŒ definition”“”)�”}”(hhh]”hÚ)�”}”(hŒCIs there any other situation where rcu_barrier() might be required?”h]”hŒCIs there any other situation where rcu_barrier() might be required?”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¦hjÛubah}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjÅubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´K§hjÀubah}”(h]”j½ah ]”h"]”Œrcubarrier_quiz_1”ah$]”h&]”uh1j¾hjžh²hh³hÃh´NŒexpect_referenced_by_name”}”jüj³sŒexpect_referenced_by_id”}”j½j³subhÚ)�”}”(hŒ9:ref:`Answer to Quick Quiz #1 `”h]”h)�”}”(hjh]”hŒinline”“”)�”}”(hjh]”hŒAnswer to Quick Quiz #1”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”ŒRCU/rcubarrier”Œ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆŒ reftarget”Œanswer_rcubarrier_quiz_1”uh1hh³hÃh´K©hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K©hjžh²hubhÚ)�”}”(hX0Your module might have additional complications. For example, if your module invokes call_rcu() from timers, you will need to first refrain from posting new timers, cancel (or wait for) all the already-posted timers, and only then invoke rcu_barrier() to wait for any remaining RCU callbacks to complete.”h]”hX0Your module might have additional complications. For example, if your module invokes call_rcu() from timers, you will need to first refrain from posting new timers, cancel (or wait for) all the already-posted timers, and only then invoke rcu_barrier() to wait for any remaining RCU callbacks to complete.”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K«hjžh²hubhÚ)�”}”(hXxOf course, if your module uses call_rcu(), you will need to invoke rcu_barrier() before unloading. Similarly, if your module uses call_srcu(), you will need to invoke srcu_barrier() before unloading, and on the same srcu_struct structure. If your module uses call_rcu() **and** call_srcu(), then (as noted above) you will need to invoke rcu_barrier() **and** srcu_barrier().”h]”(hXOf course, if your module uses call_rcu(), you will need to invoke rcu_barrier() before unloading. Similarly, if your module uses call_srcu(), you will need to invoke srcu_barrier() before unloading, and on the same srcu_struct structure. If your module uses call_rcu() ”…”�”}”(hj?h²hh³Nh´Nubj¸)�”}”(hŒ**and**”h]”hŒand”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj?ubhŒJ call_srcu(), then (as noted above) you will need to invoke rcu_barrier() ”…”�”}”(hj?h²hh³Nh´Nubj¸)�”}”(hŒ**and**”h]”hŒand”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj?ubhŒ srcu_barrier().”…”�”}”(hj?h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K±hjžh²hubeh}”(h]”Œid1”ah ]”h"]”Œ rcu_barrier()”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´K4ubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒImplementing rcu_barrier()”h]”hŒImplementing rcu_barrier()”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjyh²hh³hÃh´KºubhÚ)�”}”(hXkDipankar Sarma's implementation of rcu_barrier() makes use of the fact that RCU callbacks are never reordered once queued on one of the per-CPU queues. His implementation queues an RCU callback on each of the per-CPU callback queues, and then waits until they have all started executing, at which point, all earlier RCU callbacks are guaranteed to have completed.”h]”hXmDipankar Sarma’s implementation of rcu_barrier() makes use of the fact that RCU callbacks are never reordered once queued on one of the per-CPU queues. His implementation queues an RCU callback on each of the per-CPU callback queues, and then waits until they have all started executing, at which point, all earlier RCU callbacks are guaranteed to have completed.”…”�”}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¼hjyh²hubhÚ)�”}”(hŒ`”h]”h)�”}”(hj h]”j )�”}”(hj h]”hŒAnswer to Quick Quiz #2”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hj ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œanswer_rcubarrier_quiz_2”uh1hh³hÃh´Kãhjubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kãhjyh²hubhÚ)�”}”(hŒdThis code was rewritten in 2008 and several times thereafter, but this still gives the general idea.”h]”hŒdThis code was rewritten in 2008 and several times thereafter, but this still gives the general idea.”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kåhjyh²hubhÚ)�”}”(hŒjThe rcu_barrier_func() runs on each CPU, where it invokes call_rcu() to post an RCU callback, as follows::”h]”hŒiThe rcu_barrier_func() runs on each CPU, where it invokes call_rcu() to post an RCU callback, as follows:”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kèhjyh²hubj )�”}”(hX' 1 static void rcu_barrier_func(void *notused) 2 { 3 int cpu = smp_processor_id(); 4 struct rcu_data *rdp = &per_cpu(rcu_data, cpu); 5 struct rcu_head *head; 6 7 head = &rdp->barrier; 8 atomic_inc(&rcu_barrier_cpu_count); 9 call_rcu(head, rcu_barrier_callback); 10 }”h]”hX' 1 static void rcu_barrier_func(void *notused) 2 { 3 int cpu = smp_processor_id(); 4 struct rcu_data *rdp = &per_cpu(rcu_data, cpu); 5 struct rcu_head *head; 6 7 head = &rdp->barrier; 8 atomic_inc(&rcu_barrier_cpu_count); 9 call_rcu(head, rcu_barrier_callback); 10 }”…”�”}”hjMsbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÃh´Këhjyh²hubhÚ)�”}”(hXrLines 3 and 4 locate RCU's internal per-CPU rcu_data structure, which contains the struct rcu_head that needed for the later call to call_rcu(). Line 7 picks up a pointer to this struct rcu_head, and line 8 increments the global counter. This counter will later be decremented by the callback. Line 9 then registers the rcu_barrier_callback() on the current CPU's queue.”h]”hXvLines 3 and 4 locate RCU’s internal per-CPU rcu_data structure, which contains the struct rcu_head that needed for the later call to call_rcu(). Line 7 picks up a pointer to this struct rcu_head, and line 8 increments the global counter. This counter will later be decremented by the callback. Line 9 then registers the rcu_barrier_callback() on the current CPU’s queue.”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Köhjyh²hubhÚ)�”}”(hŒ£The rcu_barrier_callback() function simply atomically decrements the rcu_barrier_cpu_count variable and finalizes the completion when it reaches zero, as follows::”h]”hŒ¢The rcu_barrier_callback() function simply atomically decrements the rcu_barrier_cpu_count variable and finalizes the completion when it reaches zero, as follows:”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kýhjyh²hubj )�”}”(hŒ§1 static void rcu_barrier_callback(struct rcu_head *notused) 2 { 3 if (atomic_dec_and_test(&rcu_barrier_cpu_count)) 4 complete(&rcu_barrier_completion); 5 }”h]”hŒ§1 static void rcu_barrier_callback(struct rcu_head *notused) 2 { 3 if (atomic_dec_and_test(&rcu_barrier_cpu_count)) 4 complete(&rcu_barrier_completion); 5 }”…”�”}”hjwsbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j h³hÃh´Mhjyh²hubh¶)�”}”(hŒ.. _rcubarrier_quiz_3:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒrcubarrier-quiz-3”uh1hµh´Mhjyh²hh³hÃubj¿)�”}”(hhh]”jÄ)�”}”(hX Quick Quiz #3: What happens if CPU 0's rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU's rcu_barrier_func() invocations are delayed for a full grace period? Couldn't this result in rcu_barrier() returning prematurely? ”h]”(jÊ)�”}”(hŒQuick Quiz #3:”h]”hŒQuick Quiz #3:”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´Mhj“ubjÚ)�”}”(hhh]”hÚ)�”}”(hXWhat happens if CPU 0's rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU's rcu_barrier_func() invocations are delayed for a full grace period? Couldn't this result in rcu_barrier() returning prematurely?”h]”hXWhat happens if CPU 0’s rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU’s rcu_barrier_func() invocations are delayed for a full grace period? Couldn’t this result in rcu_barrier() returning prematurely?”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M hj¥ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÙhj“ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´Mhj�ubah}”(h]”j�ah ]”h"]”Œrcubarrier_quiz_3”ah$]”h&]”uh1j¾hjyh²hh³hÃh´Njÿ}”jÆj…sj}”j�j…subhÚ)�”}”(hŒ9:ref:`Answer to Quick Quiz #3 `”h]”h)�”}”(hjÍh]”j )�”}”(hjÍh]”hŒAnswer to Quick Quiz #3”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjÏubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jÜŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œanswer_rcubarrier_quiz_3”uh1hh³hÃh´MhjËubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Mhjyh²hubhÚ)�”}”(hXCThe current rcu_barrier() implementation is more complex, due to the need to avoid disturbing idle CPUs (especially on battery-powered systems) and the need to minimally disturb non-idle CPUs in real-time systems. In addition, a great many optimizations have been applied. However, the code above illustrates the concepts.”h]”hXCThe current rcu_barrier() implementation is more complex, due to the need to avoid disturbing idle CPUs (especially on battery-powered systems) and the need to minimally disturb non-idle CPUs in real-time systems. In addition, a great many optimizations have been applied. However, the code above illustrates the concepts.”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Mhjyh²hubeh}”(h]”Œimplementing-rcu-barrier”ah ]”h"]”Œimplementing rcu_barrier()”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´KºubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒrcu_barrier() Summary”h]”hŒrcu_barrier() Summary”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj h²hh³hÃh´MubhÚ)�”}”(hXThe rcu_barrier() primitive is used relatively infrequently, since most code using RCU is in the core kernel rather than in modules. However, if you are using RCU from an unloadable module, you need to use rcu_barrier() so that your module may be safely unloaded.”h]”hXThe rcu_barrier() primitive is used relatively infrequently, since most code using RCU is in the core kernel rather than in modules. However, if you are using RCU from an unloadable module, you need to use rcu_barrier() so that your module may be safely unloaded.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Mhj h²hubeh}”(h]”Œrcu-barrier-summary”ah ]”h"]”Œrcu_barrier() summary”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´MubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒAnswers to Quick Quizzes”h]”hŒAnswers to Quick Quizzes”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj1h²hh³hÃh´M#ubh¶)�”}”(hŒ.. _answer_rcubarrier_quiz_1:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒanswer-rcubarrier-quiz-1”uh1hµh´M%hj1h²hh³hÃubj¿)�”}”(hhh]”(jÄ)�”}”(hŒSQuick Quiz #1: Is there any other situation where rcu_barrier() might be required? ”h]”(jÊ)�”}”(hŒQuick Quiz #1:”h]”hŒQuick Quiz #1:”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´M)hjPubjÚ)�”}”(hhh]”hÚ)�”}”(hŒCIs there any other situation where rcu_barrier() might be required?”h]”hŒCIs there any other situation where rcu_barrier() might be required?”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M(hjbubah}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjPubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´M)hjMubjÄ)�”}”(hXÝAnswer: Interestingly enough, rcu_barrier() was not originally implemented for module unloading. Nikita Danilov was using RCU in a filesystem, which resulted in a similar situation at filesystem-unmount time. Dipankar Sarma coded up rcu_barrier() in response, so that Nikita could invoke it during the filesystem-unmount process. Much later, yours truly hit the RCU module-unload problem when implementing rcutorture, and found that rcu_barrier() solves this problem as well. ”h]”(jÊ)�”}”(hŒAnswer:”h]”hŒAnswer:”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´M5hjubjÚ)�”}”(hhh]”(hÚ)�”}”(hXAInterestingly enough, rcu_barrier() was not originally implemented for module unloading. Nikita Danilov was using RCU in a filesystem, which resulted in a similar situation at filesystem-unmount time. Dipankar Sarma coded up rcu_barrier() in response, so that Nikita could invoke it during the filesystem-unmount process.”h]”hXAInterestingly enough, rcu_barrier() was not originally implemented for module unloading. Nikita Danilov was using RCU in a filesystem, which resulted in a similar situation at filesystem-unmount time. Dipankar Sarma coded up rcu_barrier() in response, so that Nikita could invoke it during the filesystem-unmount process.”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M,hj‘ubhÚ)�”}”(hŒ‘Much later, yours truly hit the RCU module-unload problem when implementing rcutorture, and found that rcu_barrier() solves this problem as well.”h]”hŒ‘Much later, yours truly hit the RCU module-unload problem when implementing rcutorture, and found that rcu_barrier() solves this problem as well.”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M3hj‘ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´M5hjMh²hubeh}”(h]”jLah ]”h"]”Œanswer_rcubarrier_quiz_1”ah$]”h&]”uh1j¾hj1h²hh³hÃh´Njÿ}”jÀjBsj}”jLjBsubhÚ)�”}”(hŒ0:ref:`Back to Quick Quiz #1 `”h]”h)�”}”(hjÇh]”j )�”}”(hjÇh]”hŒBack to Quick Quiz #1”…”�”}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjÉubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jÖŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œrcubarrier_quiz_1”uh1hh³hÃh´M7hjÅubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M7hj1h²hubh¶)�”}”(hŒ.. _answer_rcubarrier_quiz_2:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒanswer-rcubarrier-quiz-2”uh1hµh´M9hj1h²hh³hÃubj¿)�”}”(hhh]”(jÄ)�”}”(hŒzQuick Quiz #2: Why doesn't line 8 initialize rcu_barrier_cpu_count to zero, thereby avoiding the need for lines 9 and 10? ”h]”(jÊ)�”}”(hŒQuick Quiz #2:”h]”hŒQuick Quiz #2:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´M=hjüubjÚ)�”}”(hhh]”hÚ)�”}”(hŒjWhy doesn't line 8 initialize rcu_barrier_cpu_count to zero, thereby avoiding the need for lines 9 and 10?”h]”hŒlWhy doesn’t line 8 initialize rcu_barrier_cpu_count to zero, thereby avoiding the need for lines 9 and 10?”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M<hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjüubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´M=hjùubjÄ)�”}”(hX1Answer: Suppose that the on_each_cpu() function shown on line 8 was delayed, so that CPU 0's rcu_barrier_func() executed and the corresponding grace period elapsed, all before CPU 1's rcu_barrier_func() started executing. This would result in rcu_barrier_cpu_count being decremented to zero, so that line 11's wait_for_completion() would return immediately, failing to wait for CPU 1's callbacks to be invoked. Note that this was not a problem when the rcu_barrier() code was first added back in 2005. This is because on_each_cpu() disables preemption, which acted as an RCU read-side critical section, thus preventing CPU 0's grace period from completing until on_each_cpu() had dealt with all of the CPUs. However, with the RCU flavor consolidation around v4.20, this possibility was once again ruled out, because the consolidated RCU once again waits on nonpreemptible regions of code. Nevertheless, that extra count might still be a good idea. Relying on these sort of accidents of implementation can result in later surprise bugs when the implementation changes. ”h]”(jÊ)�”}”(hŒAnswer:”h]”hŒAnswer:”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´MThj+ubjÚ)�”}”(hhh]”(hÚ)�”}”(hX“Suppose that the on_each_cpu() function shown on line 8 was delayed, so that CPU 0's rcu_barrier_func() executed and the corresponding grace period elapsed, all before CPU 1's rcu_barrier_func() started executing. This would result in rcu_barrier_cpu_count being decremented to zero, so that line 11's wait_for_completion() would return immediately, failing to wait for CPU 1's callbacks to be invoked.”h]”hX›Suppose that the on_each_cpu() function shown on line 8 was delayed, so that CPU 0’s rcu_barrier_func() executed and the corresponding grace period elapsed, all before CPU 1’s rcu_barrier_func() started executing. This would result in rcu_barrier_cpu_count being decremented to zero, so that line 11’s wait_for_completion() would return immediately, failing to wait for CPU 1’s callbacks to be invoked.”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M@hj=ubhÚ)�”}”(hX)Note that this was not a problem when the rcu_barrier() code was first added back in 2005. This is because on_each_cpu() disables preemption, which acted as an RCU read-side critical section, thus preventing CPU 0's grace period from completing until on_each_cpu() had dealt with all of the CPUs.”h]”hX+Note that this was not a problem when the rcu_barrier() code was first added back in 2005. This is because on_each_cpu() disables preemption, which acted as an RCU read-side critical section, thus preventing CPU 0’s grace period from completing until on_each_cpu() had dealt with all of the CPUs.”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MHhj=ubhÚ)�”}”(hŒ´However, with the RCU flavor consolidation around v4.20, this possibility was once again ruled out, because the consolidated RCU once again waits on nonpreemptible regions of code.”h]”hŒ´However, with the RCU flavor consolidation around v4.20, this possibility was once again ruled out, because the consolidated RCU once again waits on nonpreemptible regions of code.”…”�”}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MNhj=ubhÚ)�”}”(hŒ²Nevertheless, that extra count might still be a good idea. Relying on these sort of accidents of implementation can result in later surprise bugs when the implementation changes.”h]”hŒ²Nevertheless, that extra count might still be a good idea. Relying on these sort of accidents of implementation can result in later surprise bugs when the implementation changes.”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MRhj=ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÙhj+ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´MThjùh²hubeh}”(h]”jøah ]”h"]”Œanswer_rcubarrier_quiz_2”ah$]”h&]”uh1j¾hj1h²hh³hÃh´Njÿ}”jˆjîsj}”jøjîsubhÚ)�”}”(hŒ0:ref:`Back to Quick Quiz #2 `”h]”h)�”}”(hj�h]”j )�”}”(hj�h]”hŒBack to Quick Quiz #2”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hj‘ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jžŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œrcubarrier_quiz_2”uh1hh³hÃh´MVhj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MVhj1h²hubh¶)�”}”(hŒ.. _answer_rcubarrier_quiz_3:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒanswer-rcubarrier-quiz-3”uh1hµh´MXhj1h²hh³hÃubj¿)�”}”(hhh]”(jÄ)�”}”(hX Quick Quiz #3: What happens if CPU 0's rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU's rcu_barrier_func() invocations are delayed for a full grace period? Couldn't this result in rcu_barrier() returning prematurely? ”h]”(jÊ)�”}”(hŒQuick Quiz #3:”h]”hŒQuick Quiz #3:”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´M_hjÄubjÚ)�”}”(hhh]”hÚ)�”}”(hXWhat happens if CPU 0's rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU's rcu_barrier_func() invocations are delayed for a full grace period? Couldn't this result in rcu_barrier() returning prematurely?”h]”hXWhat happens if CPU 0’s rcu_barrier_func() executes immediately (thus incrementing rcu_barrier_cpu_count to the value one), but the other CPU’s rcu_barrier_func() invocations are delayed for a full grace period? Couldn’t this result in rcu_barrier() returning prematurely?”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´M[hjÖubah}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjÄubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´M_hjÁubjÄ)�”}”(hXÙAnswer: This cannot happen. The reason is that on_each_cpu() has its last argument, the wait flag, set to "1". This flag is passed through to smp_call_function() and further to smp_call_function_on_cpu(), causing this latter to spin until the cross-CPU invocation of rcu_barrier_func() has completed. This by itself would prevent a grace period from completing on non-CONFIG_PREEMPTION kernels, since each CPU must undergo a context switch (or other quiescent state) before the grace period can complete. However, this is of no use in CONFIG_PREEMPTION kernels. Therefore, on_each_cpu() disables preemption across its call to smp_call_function() and also across the local call to rcu_barrier_func(). Because recent RCU implementations treat preemption-disabled regions of code as RCU read-side critical sections, this prevents grace periods from completing. This means that all CPUs have executed rcu_barrier_func() before the first rcu_barrier_callback() can possibly execute, in turn preventing rcu_barrier_cpu_count from prematurely reaching zero. But if on_each_cpu() ever decides to forgo disabling preemption, as might well happen due to real-time latency considerations, initializing rcu_barrier_cpu_count to one will save the day. ”h]”(jÊ)�”}”(hŒAnswer:”h]”hŒAnswer:”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÉh³hÃh´MwhjóubjÚ)�”}”(hhh]”(hÚ)�”}”(hX)This cannot happen. The reason is that on_each_cpu() has its last argument, the wait flag, set to "1". This flag is passed through to smp_call_function() and further to smp_call_function_on_cpu(), causing this latter to spin until the cross-CPU invocation of rcu_barrier_func() has completed. This by itself would prevent a grace period from completing on non-CONFIG_PREEMPTION kernels, since each CPU must undergo a context switch (or other quiescent state) before the grace period can complete. However, this is of no use in CONFIG_PREEMPTION kernels.”h]”hX-This cannot happen. The reason is that on_each_cpu() has its last argument, the wait flag, set to “1â€�. This flag is passed through to smp_call_function() and further to smp_call_function_on_cpu(), causing this latter to spin until the cross-CPU invocation of rcu_barrier_func() has completed. This by itself would prevent a grace period from completing on non-CONFIG_PREEMPTION kernels, since each CPU must undergo a context switch (or other quiescent state) before the grace period can complete. However, this is of no use in CONFIG_PREEMPTION kernels.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MbhjubhÚ)�”}”(hXèTherefore, on_each_cpu() disables preemption across its call to smp_call_function() and also across the local call to rcu_barrier_func(). Because recent RCU implementations treat preemption-disabled regions of code as RCU read-side critical sections, this prevents grace periods from completing. This means that all CPUs have executed rcu_barrier_func() before the first rcu_barrier_callback() can possibly execute, in turn preventing rcu_barrier_cpu_count from prematurely reaching zero.”h]”hXèTherefore, on_each_cpu() disables preemption across its call to smp_call_function() and also across the local call to rcu_barrier_func(). Because recent RCU implementations treat preemption-disabled regions of code as RCU read-side critical sections, this prevents grace periods from completing. This means that all CPUs have executed rcu_barrier_func() before the first rcu_barrier_callback() can possibly execute, in turn preventing rcu_barrier_cpu_count from prematurely reaching zero.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´MlhjubhÚ)�”}”(hŒ»But if on_each_cpu() ever decides to forgo disabling preemption, as might well happen due to real-time latency considerations, initializing rcu_barrier_cpu_count to one will save the day.”h]”hŒ»But if on_each_cpu() ever decides to forgo disabling preemption, as might well happen due to real-time latency considerations, initializing rcu_barrier_cpu_count to one will save the day.”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Muhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÙhjóubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÃh´MwhjÁh²hubeh}”(h]”jÀah ]”h"]”Œanswer_rcubarrier_quiz_3”ah$]”h&]”uh1j¾hj1h²hh³hÃh´Njÿ}”jBj¶sj}”jÀj¶subhÚ)�”}”(hŒ0:ref:`Back to Quick Quiz #3 `”h]”h)�”}”(hjIh]”j )�”}”(hjIh]”hŒBack to Quick Quiz #3”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjKubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jXŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œrcubarrier_quiz_3”uh1hh³hÃh´MyhjGubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Myhj1h²hubeh}”(h]”Œanswers-to-quick-quizzes”ah ]”h"]”Œanswers to quick quizzes”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´M#ubeh}”(h]”(Œrcu-and-unloadable-modules”hÂeh ]”h"]”(Œrcu and unloadable modules”Œ rcu_barrier”eh$]”h&]”uh1hÄhhh²hh³hÃh´Kjÿ}”j~h·sj}”hÂh·subeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÃuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÉNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j¦Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÃŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”(hÂ]”h·aj½]”j³ajÌ]”jÂaj�]”j…ajL]”jBajø]”jîajÀ]”j¶auŒnameids”}”(j~hÂj}jzj›j˜jvjsjüj½jjjjÌjÆj�j.j+jujrjÀjLjˆjøjBjÀuŒ nametypes”}”(j~ˆj}‰j›‰jv‰jüˆj‰jˆjƈj.‰ju‰jÀˆjˆˆjBˆuh}”(hÂhÆjzhÆj˜j:jsjžj½jÀjjyjÌjÍj�j�j+j jrj1jLjMjøjùjÀjÁuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j´Ks…”R”Œparse_messages”]”Œtransform_messages”]”(hŒsystem_message”“”)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ1Hyperlink target "rcu-barrier" is not referenced.”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhjubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÃŒline”Kuh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ7Hyperlink target "rcubarrier-quiz-1" is not referenced.”…”�”}”hj1sbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhj.ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”K£uh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ7Hyperlink target "rcubarrier-quiz-2" is not referenced.”…”�”}”hjKsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhjHubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”KÝuh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ7Hyperlink target "rcubarrier-quiz-3" is not referenced.”…”�”}”hjesbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhjbubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”Muh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ>Hyperlink target "answer-rcubarrier-quiz-1" is not referenced.”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhj|ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”M%uh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ>Hyperlink target "answer-rcubarrier-quiz-2" is not referenced.”…”�”}”hj™sbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhj–ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”M9uh1jubj)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ>Hyperlink target "answer-rcubarrier-quiz-3" is not referenced.”…”�”}”hj³sbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhj°ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j+Œsource”hÃŒline”MXuh1jubeŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.