⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 up.txt

📁 Linux Kernel 2.6.9 for OMAP1710
💻 TXT
字号:
RCU on Uniprocessor SystemsA common misconception is that, on UP systems, the call_rcu() primitivemay immediately invoke its function, and that the synchronize_kernelprimitive may return immediately.  The basis of this misconceptionis that since there is only one CPU, it should not be necessary towait for anything else to get done, since there are no other CPUs foranything else to be happening on.  Although this approach will sort ofwork a surprising amount of the time, it is a very bad idea in general.This document presents two examples that demonstrate exactly how bad anidea this is.Example 1: softirq SuicideSuppose that an RCU-based algorithm scans a linked list containingelements A, B, and C in process context, and can delete elements fromthis same list in softirq context.  Suppose that the process-context scanis referencing element B when it is interrupted by softirq processing,which deletes element B, and then invokes call_rcu() to free element Bafter a grace period.Now, if call_rcu() were to directly invoke its arguments, then upon returnfrom softirq, the list scan would find itself referencing a newly freedelement B.  This situation can greatly decrease the life expectancy ofyour kernel.Example 2: Function-Call FatalityOf course, one could avert the suicide described in the preceding exampleby having call_rcu() directly invoke its arguments only if it was calledfrom process context.  However, this can fail in a similar manner.Suppose that an RCU-based algorithm again scans a linked list containingelements A, B, and C in process contexts, but that it invokes a functionon each element as it is scanned.  Suppose further that this functiondeletes element B from the list, then passes it to call_rcu() for deferredfreeing.  This may be a bit unconventional, but it is perfectly legalRCU usage, since call_rcu() must wait for a grace period to elapse.Therefore, in this case, allowing call_rcu() to immediately invokeits arguments would cause it to fail to make the fundamental guaranteeunderlying RCU, namely that call_rcu() defers invoking its arguments untilall RCU read-side critical sections currently executing have completed.Quick Quiz: why is it -not- legal to invoke synchronize_kernel() inthis case?SummaryPermitting call_rcu() to immediately invoke its arguments or permittingsynchronize_kernel() to immediately return breaks RCU, even on a UP system.So do not do it!  Even on a UP system, the RCU infrastructure -must-respect grace periods.Answer to Quick QuizThe calling function is scanning an RCU-protected linked list, andis therefore within an RCU read-side critical section.  Therefore,the called function has been invoked within an RCU read-side criticalsection, and is not permitted to block.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -