Preempt_rt-based rcu real-time optimization method
By forcing the use of SRCU in the Linux 5.10 Preempt_RT kernel, balancing the RCU reclamation mechanism, disabling Stall detection, and replacing blocking write operations, the RCU lock-in real-time defects were resolved, achieving a full replacement and optimization of RCU and SRCU, thus improving the system's real-time performance and stability.
Patent Information
- Application Number
- CN202610155115.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-04
- Publication Date
- 2026-05-15
- Estimated Expiration
- 2046-02-04
AI Technical Summary
In the Linux 5.10 Preempt_RT kernel environment, the real-time defects of RCU locks lead to read critical section preemption restrictions, grace period IPI interference, excessive CPU usage due to callback reclamation, redundant Stall detection overhead, and write operation blocking, which seriously affect the deterministic response of high-priority RT tasks and system stability.
By forcing the use of SRCU, balancing the RCU reclamation mechanism, disabling RCU Stall detection, and replacing blocking RCU write operations, end-to-end optimization is achieved, including RCU and SRCU structure mapping, precise control of rcu_preempt thread priority, callback loop count limit and breakpoint continuation, and asynchronous transformation of blocking write operations.
It improves the real-time performance of the system in real-time scenarios, reduces IPI interference, eliminates read critical section preemption restrictions, balances RCU callback reclamation and RT task resource consumption, reduces Stall detection redundancy overhead, avoids write operation blocking, ensures that the latency of high-priority RT tasks is within the hard real-time requirement range, and has no RCU-related anomalies during long-term operation.
Smart Images

Figure CN121636208B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of operating system technology, and in particular to a real-time optimization method for RCU based on Preempt_RT. Background Technology
[0002] With the rapid development of hard real-time scenarios such as industrial control, automotive electronics, and telecommunications equipment, stringent requirements have been placed on the response latency of embedded systems (typically needing to be controlled at the microsecond level). As a Long Term Support (LTS) version, the Linux 5.10 kernel is widely used in these scenarios due to its stability advantages, and the introduction of the Preempt_RT patch further enhances its full preemption capability, making it the mainstream infrastructure for hard real-time systems.
[0003] RCU (Read-Copy-Update) locks, as a core synchronization mechanism in the kernel, effectively improve the performance of concurrent access to shared data due to their "lock-free reads and delayed write reclamation" characteristics. However, in the 5.10 Preempt_RT kernel environment, the traditional RCU mechanism has a significant compatibility contradiction with hard real-time requirements: on the one hand, the core goal of Preempt_RT is to achieve "full preemption" to reduce task response latency; on the other hand, the inherent design of RCU (such as non-preemptible windows remaining in the critical section, inter-core synchronization during grace periods, callback priority conflicts, etc.) directly undermines the scheduling determinism of real-time tasks, leading to excessive RT task response latency and even triggering system stability issues.
[0004] Currently, the 5.10 Preempt_RT kernel has become the underlying dependency of many industrial-grade real-time products. If the real-time defects of the RCU lock cannot be resolved, it will severely limit the application of the 5.10 Preempt_RT kernel in high-requirement real-time scenarios. Therefore, a targeted optimization technology solution is urgently needed to balance the concurrent performance of RCU with the hard real-time requirements of the system.
[0005] Existing optimization techniques for RCU locks are mostly geared towards ordinary non-real-time kernels (such as the standard 5.10 kernel), and do not fully adapt to the full preemptive characteristics of the Preempt_RT kernel. When applied to hard real-time scenarios, they have the following core shortcomings:
[0006] 1. The read critical section has a non-preemptible window: Although the existing RCU-preempt variant has been modified by Preempt_RT, it still temporarily disables "RCU-specific preemption". High-priority RT tasks cannot preempt the CPU in the RCU read critical section. If the read critical section takes more than 5μs (hard real-time threshold), it will directly cause the RT task response latency to exceed the standard. In addition, some schemes allow the read critical section to call sleepable functions, which further lengthens the non-preemptible window.
[0007] 2. Severe interference between grace period and IPI: In the existing technology, RCU write operations rely on global grace period synchronization, which requires coordination of all CPU states through inter-processor interrupts (IPI). However, IPI processing will directly interrupt high-priority RT tasks, and the grace period duration is affected by the reading critical section of low-priority tasks, which poses a risk of infinite extension, causing write threads to be blocked and indirectly affecting RT tasks that depend on them.
[0008] 3. Imbalance in callback execution priority: RCU callbacks are handled by low-priority kernel threads (such as rcu_preempt) by default, which can easily lead to callback accumulation and recycling delays. If the priority of this thread is blindly increased, it will preempt core RT tasks (such as the SCHED_FIFO task with a priority of 99), creating an irreconcilable contradiction between "recycling efficiency" and "real-time performance".
[0009] 4. Redundant Stall Detection Overhead: Existing technologies enable RCU Stall detection by default. Its periodic checks and exception handling (such as high-priority IPI wake-up and forced scheduling) will consume additional CPU resources. Moreover, the detection logic is not adapted to RT scenarios and is prone to being accidentally triggered and interrupting critical RT tasks.
[0010] 5. High risk of blocking during write operations: Existing solutions often use blocking write operations such as synchronize_rcu, which require the write thread to wait for the grace period to end. During this period, the thread cannot respond to real-time requirements, which directly reduces the determinism of the system's real-time scheduling. Summary of the Invention
[0011] To address the aforementioned issues, this invention provides a real-time optimization method for RCU based on Preempt_RT, which solves the problems of read critical section preemption restrictions, severe IPI interference during grace period, excessive CPU usage during callback reclamation, redundant Stall detection overhead, and write operation blocking in existing RCU mechanisms, which severely restrict the deterministic response of high-priority RT tasks and the stability of the system.
[0012] This invention is implemented as follows:
[0013] A real-time optimization method for RCU based on Preempt_RT addresses five aspects: RCU read critical section preemption restrictions, grace period IPI interference, callback reclamation, redundancy of Stall detection overhead, and write operation blocking. It improves the real-time performance of the system in real-time scenarios through a full-link optimization scheme that includes forcing the use of SRCU, balancing the RCU reclamation mechanism, disabling RCU Stall detection, and replacing blocking RCU write operations. Specifically, forcing the use of SRCU is implemented in step S1, balancing the RCU reclamation mechanism in step S2, disabling RCU Stall detection in step S3, and replacing blocking RCU write operations in step S4.
[0014] Step S1, Force the use of SRCU: Map RCU and SRCU structures, and use the kprobe mechanism to hook multiple core functions to achieve a full replacement of RCU to SRCU;
[0015] Step S2, Balance the RCU reclamation mechanism: Add the set_srcu_prio function and the srcu_callback_limit function to the rcu_hook_to_scru.ko module;
[0016] Step S3, disable RCU Stall detection: adjust the global variables rcu_cpu_stall_timeout and rcu_cpu_stall_suppress;
[0017] Step S4, replace blocking RCU write operations: add the rcu_async_callback function, use the kprobe mechanism to register the hook of synchronize_rcu, and set the pre-intercept function to synchronize_rcu_hook.
[0018] The mapping between the RCU and SRCU structures in step S1 includes the following steps:
[0019] Write the rcu_hook_to_scru.ko module, and initialize the srcu_struct structure group in the module. The group has a length of 10240 and is named global_srcu.
[0020] Write the global_srcu_init function in the module to initialize the data in the 10240 global_srcu structure groups one by one;
[0021] Write a global_srcu_mapping function in the module to convert the existing rcu structure that calls call_rcu in the system into an srcu structure within the module, and the conversion is one-to-one.
[0022] Specifically, in step S1, hooking multiple core functions using the kprobe mechanism involves registering call_rcu, synchronize_rcu, rcu_read_unlock, and rcu_read_lock in the kprobe structure of rcu_kprobes, and entering the call_rcu_hook, synchronize_rcu_hook, rcu_read_unlock_hook, and rcu_read_lock_hook functions respectively before execution.
[0023] The full replacement of RCU to SRCU in step S1 includes:
[0024] Following the kprobe framework, write the call_rcu_hook function body, use global_srcu_mapping within the function body to convert the RCU into an in-module SRCU, and execute the call_srcu function to replace the call_rcu function call;
[0025] Following the kprobe framework, write the synchronize_rcu_hook function body, and execute the synchronize_srcu function within the function body to replace the synchronize_rcu function call;
[0026] Following the kprobe framework, write the rcu_read_unlock_hook function body, and execute the srcu_read_unlock function within the function body to replace the rcu_read_unlock function call;
[0027] Following the kprobe framework, write the rcu_read_lock_hook function body, and execute the srcu_read_lock function within the function body to replace the rcu_read_lock function call.
[0028] The step S2 of adding the set_srcu_prio function includes the following steps: traversing all processes using the for_each_process function, obtaining the process structure rcu_task with the process name rcu_preempt by matching with comm, setting the priority of rcu_task to 50, and setting the scheduler to SCHED_FIFO.
[0029] The step S2 of adding the srcu_callback_limit function includes the following steps: using the kprobe mechanism, hooking the rcu_process_callbacks function; before executing the rcu_process_callbacks function, executing the rcu_process_callbacks_pre function; moving the body of the rcu_process_callbacks function into the rcu_process_callbacks_pre function; replacing the conditional statement of the while loop; when the while loop executes more than twice, exiting the while loop; saving the current execution point; restoring it upon the next entry to achieve breakpoint continuation; if it returns 1, it means skipping the original rcu_process_callbacks function and not executing it.
[0030] In step S3, the disable_rcu_stall function is added to the rcu_hook_to_scru.ko module, setting the global variable rcu_cpu_stall_timeout to 0 and the global variable rcu_cpu_stall_suppress to 1.
[0031] In step S4, the rcu_async_callback function is added to wake up the write threads that are waiting after the grace period ends, and wake_up_interruptible is used to wake up the waiting queue of rcu.
[0032] The step S4 of adding the synchronize_rcu_hook function includes the following steps: initializing the waiting queue wq, calling call_rcu, setting the callback function to rcu_async_callback, using wait_event_interruptible to wait for the rcu_async_callback function to wake up, and if it returns 1, it means that the original synchronize_rcu function is skipped and not executed.
[0033] The beneficial effects of this invention are:
[0034] This invention presents a Preempt_RT-based RCU real-time optimization method. Through a full-link optimization scheme of "full SRCU replacement + balanced recycling mechanism + Stall detection disabling + asynchronous write operations," the core implementation includes one-to-one mapping and replacement of RCU and SRCU, precise control of rcu_preempt thread priority, callback loop count limits and breakpoint continuation, non-blocking transformation of blocking write operations, and redundancy detection and trimming. It is fully compatible with the Phytium architecture and the 5.10-RT kernel features. After implementation, IPI interference faced by RT tasks is significantly reduced, read critical sections achieve no preemption restrictions, callback recycling and RT task CPU resource usage achieve dynamic balance, write operations are non-blocking with no loss of grace period synchronization semantics, and system redundancy overhead is greatly reduced. Tested on the Phytium E2000Q platform, the latency of high-priority RT tasks is controlled within the hard real-time requirement range, and no RCU-related anomalies occur during long-term operation. The solution is implemented as a fully external module without modifying the kernel source code and is compatible with Phytium 5.10-RT. With excellent kernel compatibility, the system's real-time performance in real-time scenarios is improved while ensuring stability. Attached Figure Description
[0035] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0036] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0037] This invention addresses the real-time performance defects caused by RCU locks in the 5.10 Preempt_RT kernel by proposing a precisely optimized technical solution. The core objectives include:
[0038] 1. Eliminate the preemption restriction of RCU read critical section, and realize that there is no non-preemptible window for read operation by replacing the entire SRCU, ensuring that high-priority RT tasks can preempt the CPU at any time, and ensuring that read operation does not interfere with real-time performance;
[0039] 2. To balance the efficiency of RCU callback recycling with the resource consumption of RT tasks, precise control of the rcu_preempt thread priority, limitation of the number of callback loop executions and support for breakpoint continuation are implemented to avoid callback accumulation or preemption of core RT tasks.
[0040] 3. Reduce RCU Stall detection redundancy overhead by disabling the Stall detection mechanism to improve the scheduling determinism and resource utilization of the RT system;
[0041] 4. Reduce the interference between RCU grace period and IPI real-time performance by modifying the blocking write operation to be asynchronous to avoid blocking of the write thread, shorten the grace period, and prevent inter-core synchronization from interrupting the core RT task.
[0042] The core idea of this invention is "variant adaptation + critical section optimization + asynchronous garbage collection + priority management + redundancy overhead reduction", which builds a full-link optimization system for the 5.10 Preempt_RT kernel features, as detailed below:
[0043] 1. Variant selection priority: SRCU (Sleep RCU) is preferred as the core synchronization variant, taking advantage of its feature that allows full preemption and sleep in the read critical section to eliminate non-preemptible windows from the root; for lightweight scenarios, the RCU-preempt-RT variant is optimized to weaken its preemption restrictions.
[0044] 2. Precise control of callback thread priority: Adjust the scheduling strategy and priority of RCU callback processing threads (such as rcu_preempt) to make them use SCHED_FIFO scheduling, with a priority lower than core RT tasks (such as level 99) but higher than ordinary tasks, balancing recycling efficiency and real-time performance.
[0045] 3. Redundancy reduction: While ensuring code robustness, disable RCU Stall detection or adjust its detection threshold to reduce unnecessary IPI and timed check overhead; optimize grace period synchronization logic to reduce the frequency of inter-core IPI triggering.
[0046] 4. Asynchronous write operations: Replace blocking synchronized_rcu / synchronized_srcu with non-blocking call_rcu / call_srcu to avoid the grace period for write threads, realize asynchronous recycling of old data, and improve the real-time responsiveness of write operations.
[0047] The present invention uses the Phytium E2000Q device and the Phytium 5.10-RT open source kernel. The specific operation steps are as follows.
[0048] like Figure 1The diagram shows a flowchart of the RCU real-time performance optimization method based on Preempt_RT of the present invention. Addressing five aspects—RCU read critical section preemption restrictions, grace period IPI interference, callback reclamation, redundancy in Stall detection overhead, and write operation blocking—a full-link optimization scheme is employed, including forcing the use of SRCU, balancing the RCU reclamation mechanism, disabling RCU Stall detection, and replacing blocking RCU write operations. This improves the system's real-time performance in real-time scenarios. Forcing the use of SRCU is implemented in step S1, balancing the RCU reclamation mechanism in step S2, disabling RCU Stall detection in step S3, and replacing blocking RCU write operations in step S4. The specific steps include steps S1 to S4 below.
[0049] Step S1, Force the use of SRCU: Map the RCU and SRCU structures, and use the kprobe mechanism to hook multiple core functions to achieve a full replacement of RCU to SRCU.
[0050] The mapping between the RCU and SRCU structures in step S1 includes the following steps:
[0051] (1) Write the rcu_hook_to_scru.ko module, and initialize the srcu_struct structure group in the module. The length is 10240 and the name is global_srcu.
[0052] (2) Write the global_srcu_init function in the module to initialize the data in the 10240 global_srcu structure groups one by one;
[0053] (3) Write the global_srcu_mapping function in the module to convert the original rcu structure that calls call_rcu in the system into the srcu structure in the module, and the conversion is one-to-one.
[0054] In step S1, the kprobe mechanism is used to hook multiple core functions. In the module initialization function, the kprobe mechanism is used to register hooks that replace SRCU with RCU, namely rcu_kprobes. In the kprobe structure of rcu_kprobes, call_rcu, synchronize_rcu, rcu_read_unlock, and rcu_read_lock are registered respectively. Before execution, the call_rcu_hook function, synchronize_rcu_hook function, rcu_read_unlock_hook function, and rcu_read_lock_hook function are entered respectively.
[0055] The full replacement of RCU to SRCU in step S1 includes:
[0056] (1) Following the kprobe framework, write the call_rcu_hook function body, use global_srcu_mapping in the function body to convert the rcu into the srcu in the module, and execute the call_srcu function to replace the call_rcu function call;
[0057] (2) Following the kprobe framework, write the synchronize_rcu_hook function body, and execute the synchronize_srcu function within the function body to replace the synchronize_rcu function call;
[0058] (3) Following the kprobe framework, write the rcu_read_unlock_hook function body, and execute the srcu_read_unlock function within the function body to replace the rcu_read_unlock function call;
[0059] (4) Following the kprobe framework, write the rcu_read_lock_hook function body, execute the srcu_read_lock function within the function body, and replace the rcu_read_lock function call.
[0060] Step S2, Balance the RCU reclamation mechanism: Add the set_srcu_prio function and the srcu_callback_limit function to the rcu_hook_to_scru.ko module.
[0061] Adding the set_srcu_prio function in step S2 includes the following steps: In the rcu_hook_to_scru.ko module, add the set_srcu_prio function, which iterates through all processes using the for_each_process function, obtains the process structure rcu_task with the process name rcu_preempt by matching it with comm, sets the priority of rcu_task to 50, and sets the scheduler to SCHED_FIFO.
[0062] Step S2, adding the `srcu_callback_limit` function, includes the following steps: using the kprobe mechanism, hooking the `rcu_process_callbacks` function; before executing `rcu_process_callbacks`, executing the `rcu_process_callbacks_pre` function; moving the body of the `rcu_process_callbacks` function into the `rcu_process_callbacks_pre` function; replacing the conditional statement of the while loop; when the while loop executes more than twice, exiting the while loop, saving the current execution point, and restoring it upon the next entry to achieve breakpoint continuation; if it returns 1, it means skipping the original `rcu_process_callbacks` function and not executing it.
[0063] Step S3, disable RCU Stall detection: adjust the global variables rcu_cpu_stall_timeout and rcu_cpu_stall_suppress.
[0064] Specifically, in the rcu_hook_to_scru.ko module, add the disable_rcu_stall function, set the global variable rcu_cpu_stall_timeout to 0, and set the global variable rcu_cpu_stall_suppress to 1.
[0065] Step S4, replace blocking RCU write operations: add the rcu_async_callback function, use the kprobe mechanism to register the hook of synchronize_rcu, and set the pre-intercept function to synchronize_rcu_hook.
[0066] In step S4, the rcu_async_callback function is added to the rcu_hook_to_scru.ko module to wake up the write threads waiting after the grace period ends. The wake_up_interruptible function is used to wake up the RCU waiting queue. In the module initialization function, the kprobe mechanism is used to register the hook of synchronize_rcu and the pre-intercept function is set to synchronize_rcu_hook.
[0067] Step S4, adding the synchronize_rcu_hook function, includes the following steps: initializing the waiting queue wq, calling call_rcu, setting the callback function to rcu_async_callback, using wait_event_interruptible to wait for the rcu_async_callback function to wake up, and if it returns 1, it means that the original synchronize_rcu function is skipped and not executed.
[0068] This invention initializes 10240 global_srcu groups and completes a one-to-one mapping between RCU and SRCU structures. Combined with the kprobe mechanism, it precisely hooks core functions such as call_rcu, synchronize_rcu, and rcu_read_lock / unlock, achieving a full replacement of RCU to SRCU while ensuring semantic consistency of read-write synchronization. It uses for_each_process to traverse and locate the rcu_preempt process, setting a SCHED_FIFO scheduling policy and a priority level of 50 (lower than core RT tasks). Combined with kprobe, it hooks the rcu_process_callbacks function, relocates its logic, limits the loop execution count to 2, and implements breakpoint continuation, balancing RCU callback reclamation efficiency with RT task CPU resource consumption. By adjusting the global variables rcu_cpu_stall_timeout and rcu_cpu_stall_suppress, it disables RCU Stall detection and avoids accidental modification of other kernel detection logic. Finally, it initializes a wait queue and registers rcu_async_callback using call_rcu. Asynchronous callbacks and `wait_event_interruptible` enable preemptive waiting; `kprobe` skips the original blocking `synchronize_rcu` function while ensuring grace period synchronization semantics; based on the Phytium E2000Q hardware and Phytium 5.10-RT kernel features, all operations are adapted; the fully external module implementation avoids modifying the kernel source code, ensuring system stability and RT feature compatibility.
[0069] This invention addresses the hard real-time application scenarios (such as industrial control and automotive electronics) of the Phytium E2000Q hardware platform and Phytium 5.10-RT kernel. Existing RCU mechanisms suffer from defects such as read critical section preemption restrictions, severe IPI interference during grace periods, excessive CPU usage during callback reclamation, redundant Stall detection overhead, and write operation blocking, which severely restrict the deterministic response of high-priority RT tasks and system stability. This invention employs a full-link optimization scheme: "full SRCU replacement + balanced recycling mechanism + Stall detection and disabling + asynchronous write operations." The core implementation includes a one-to-one mapping replacement between RCU and SRCU, precise control of rcu_preempt thread priority, callback loop count limits and breakpoint continuation, non-blocking transformation of blocking write operations, and redundancy detection and trimming. It is fully compatible with the Phytium architecture and the 5.10-RT kernel features. After implementation, IPI interference faced by RT tasks is significantly reduced, read critical sections achieve no preemption restrictions, callback recycling and RT task CPU resource usage achieve dynamic balance, write operations are non-blocking and do not lose grace period synchronization semantics, and system redundancy overhead is greatly reduced. Real-world testing on the Phytium E2000Q platform shows that high-priority RT task latency is controlled within hard real-time requirements, and no RCU-related anomalies have occurred during long-term operation. The solution is implemented as a fully external module without modifying the kernel source code, exhibiting excellent compatibility with the Phytium 5.10-RT kernel. While ensuring stability, it improves the real-time performance of the system in real-time scenarios.
[0070] While the present invention discloses preferred embodiments to achieve the above objectives, these are not intended to limit the structural features of the invention. Anyone skilled in the art should know that any easily conceived variations or modifications are possible within the technical spirit of the invention and are covered by the claims of the present invention.
Claims
1. A real-time optimization method for RCU based on Preempt_RT, characterized in that, To address five issues—RCU read critical section preemption restrictions, grace period IPI interference, callback reclamation, Stall detection overhead redundancy, and write operation blocking—a full-link optimization scheme is implemented, which includes forcing the use of SRCU, balancing the RCU reclamation mechanism, disabling RCU Stall detection, and replacing blocking RCU write operations. This improves the real-time performance of the system in real-time scenarios. Specifically, forcing the use of SRCU is achieved through step S1, balancing the RCU reclamation mechanism is achieved through step S2, disabling RCU Stall detection is achieved through step S3, and replacing blocking RCU write operations is achieved through step S4. Step S1, Force the use of SRCU: Map RCU and SRCU structures, and use the kprobe mechanism to hook multiple core functions to achieve a full replacement of RCU to SRCU; Step S2, balancing the RCU reclamation mechanism: In the rcu_hook_to_scru.ko module, add the functions set_srcu_prio and srcu_callback_limit. The set_srcu_prio function iterates through all processes using the for_each_process function, obtains the process structure rcu_task with the process name rcu_preempt by matching it with comm, sets the priority of rcu_task to 50, and sets the scheduler to SCHED_FIFO. The srcu_callback_limit function hooks rcu_process_callbacks using kprobe and limits the number of times it is processed. Step S3, disable RCU Stall detection: adjust the global variables rcu_cpu_stall_timeout and rcu_cpu_stall_suppress; Step S4, replace blocking RCU write operations: add the rcu_async_callback function, register the hook of synchronize_rcu using the kprobe mechanism, and set the pre-intercept function to synchronize_rcu_hook; the rcu_async_callback function is used to wake up the write thread waiting after the grace period ends.
2. The RCU real-time performance optimization method based on Preempt_RT according to claim 1, characterized in that, The mapping between the RCU and SRCU structures in step S1 includes the following steps: Write the rcu_hook_to_scru.ko module, and initialize the srcu_struct structure group in the module. The group has a length of 10240 and is named global_srcu. Write the global_srcu_init function in the module to initialize the data in the 10240 global_srcu structure groups one by one; Write a global_srcu_mapping function in the module to convert the existing rcu structure that calls call_rcu in the system into an srcu structure within the module, and the conversion is one-to-one.
3. The RCU real-time performance optimization method based on Preempt_RT according to claim 2, characterized in that, In step S1, the combination of the kprobe mechanism to hook multiple core functions involves registering call_rcu, synchronize_rcu, rcu_read_unlock, and rcu_read_lock in the kprobe structure of rcu_kprobes, respectively. Before execution, the call_rcu_hook function, synchronize_rcu_hook function, rcu_read_unlock_hook function, and rcu_read_lock_hook function are entered respectively.
4. The RCU real-time performance optimization method based on Preempt_RT according to claim 3, characterized in that, The full replacement of RCU to SRCU in step S1 includes: Following the kprobe framework, write the call_rcu_hook function body, use global_srcu_mapping within the function body to convert the RCU into an in-module SRCU, and execute the call_srcu function to replace the call_rcu function call; Following the kprobe framework, write the synchronize_rcu_hook function body, and execute the synchronize_srcu function within the function body to replace the synchronize_rcu function call; Following the kprobe framework, write the rcu_read_unlock_hook function body, and execute the srcu_read_unlock function within the function body to replace the rcu_read_unlock function call; Following the kprobe framework, write the rcu_read_lock_hook function body, and execute the srcu_read_lock function within the function body to replace the rcu_read_lock function call.
5. The RCU real-time performance optimization method based on Preempt_RT according to claim 1, characterized in that, The step S2 of adding the srcu_callback_limit function includes the following steps: Before executing the rcu_process_callbacks function, the rcu_process_callbacks_pre function is executed. The body of the rcu_process_callbacks function is moved into the rcu_process_callbacks_pre function. The condition of the while loop is replaced. When the while loop is executed more than twice, the while loop is exited, the current execution point is saved, and it is restored the next time it is entered, so that the breakpoint can continue execution. If it returns 1, it means that the original rcu_process_callbacks function is skipped and not executed.
6. The RCU real-time performance optimization method based on Preempt_RT according to claim 1, characterized in that, In step S3, the disable_rcu_stall function is added to the rcu_hook_to_scru.ko module, setting the global variable rcu_cpu_stall_timeout to 0 and the global variable rcu_cpu_stall_suppress to 1.
7. The RCU real-time performance optimization method based on Preempt_RT according to claim 1, characterized in that, In step S4, the rcu_async_callback function is added, and wake_up_interruptible is used to wake up the RCU's waiting queue.
8. The RCU real-time performance optimization method based on Preempt_RT according to claim 7, characterized in that, The addition of the synchronize_rcu_hook function in step S4 includes the following steps: initializing the waiting queue wq, calling call_rcu, setting the callback function to rcu_async_callback, using wait_event_interruptible to wait for the rcu_async_callback function to wake up, and if it returns 1, it means that the original synchronize_rcu function is skipped and not executed.