PMU-based deterministic replay implementation method

By using a deterministic replay method based on PMU, and leveraging the PMU function and instruction counter of ARMv8, efficient and accurate replay of the domestic embedded operating system was achieved. This solves the problems of tool complexity and poor adaptability in existing technologies, and improves the stability and security of the system.

WO2026157124A1PCT designated stage Publication Date: 2026-07-30EAST CHINA INST OF COMPUTING TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
EAST CHINA INST OF COMPUTING TECH
Filing Date
2025-06-27
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

Existing deterministic replay recording methods rely on proprietary hardware or require compiler modifications, increasing tool complexity and overhead, and exhibiting poor accuracy and adaptability when handling special hardware events.

Method used

A deterministic replay method based on PMU is adopted. By pre-setting the event log file structure and instruction counter, the PMU function of ARMv8 is used to record the instruction execution sequence and time information. An efficient event log file format is designed to achieve accurate replay without special hardware and software support.

Benefits of technology

It improves the accuracy and efficiency of replay, enhances adaptability to different environments, reduces CPU resource consumption, and optimizes the interrupt handling process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025104882_30072026_PF_FP_ABST
    Figure CN2025104882_30072026_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides a PMU-based deterministic replay implementation method. Aiming at event recording and replay requirements of domestic embedded operating systems, and to provide a feasible technical solution for execution replay of domestic embedded operating systems, the study focuses on instruction counter-based time synchronization technology and event log file structure design technology, forming a real-time recording and post-replay solution for domestic embedded operating systems. In the method, by means of instruction counter-based time synchronization technology, the execution sequence and time information of each instruction is recorded, ensuring that the instruction path during replay is consistent with the original execution; by means of a PMU function of ARMv8, hardware events are accurately tracked without the need for special hardware and software support, thereby improving the accuracy and efficiency of replay, and enhancing the adaptability in different environments.
Need to check novelty before this filing date? Find Prior Art

Description

A deterministic replay implementation method based on PMU Technical Field

[0001] This invention relates to the field of deterministic replay technology for operating systems, and more specifically to a deterministic replay implementation method based on PMU. Background Technology

[0002] Domestically developed embedded real-time operating systems play a central role in modern industry and technology. These systems are widely used not only in industrial control systems but also in critical areas such as autonomous driving, aerospace, and medical equipment, ensuring operational safety and reliability. Real-time performance and reliability are the cornerstones of these applications, as they often involve critical safety operations and high-risk environments where any system failure can lead to serious consequences. Run-time replay is a technique that allows developers to record and precisely replay the system execution process to facilitate fault reproduction and analysis. This technique creates a path that can be repeatedly executed under identical operating conditions by capturing events such as instruction execution, external input, and internal state changes. The implementation of run-time replay in embedded operating systems, especially for systems requiring extremely high reliability and security, can significantly improve the efficiency of fault diagnosis and prevent potential problems before system deployment, thereby significantly enhancing system stability and security.

[0003] Patent No.: CN201910940847.8

[0004] Patent Title: A Deterministic Replay Method and Apparatus for Embedded Operating Systems

[0005] Specific details: This patent proposes a deterministic replay method and apparatus for embedded operating systems. By recording key information during system operation, including task execution sequence, event occurrence time, and resource allocation, the system can accurately reproduce its previous operating state when replay is needed. This method effectively helps developers reproduce problems during debugging and testing, improving development efficiency and system reliability. For example, when a system experiences a difficult-to-reproduce fault, this patented method can record the system state before the fault occurred and then replay it in subsequent analysis to better locate and resolve the problem.

[0006] Patent No.: CN201710543441.7

[0007] Patent Title: A Deterministic Recording and Replay Method for Embedded Real-Time Operating Systems

[0008] Specific details: This patent primarily relates to a deterministic recording and replay technology for embedded real-time operating systems. It employs a specific recording mechanism to record critical operations and events of the operating system kernel, including task scheduling, interrupt handling, and communication processes. During the replay phase, the system's operating state can be accurately restored based on the recorded information, making the system's operation repeatable and deterministic. This patented technology can be applied to embedded systems with high real-time and deterministic requirements, such as in aerospace and industrial control fields, helping to improve system stability and reliability while reducing debugging and testing costs. Summary of the Invention

[0009] The technical problem that the present invention aims to solve is that existing deterministic replay recording timing methods either rely on proprietary hardware or require modification of the compiler to instrument the code, which greatly increases the complexity and overhead of the tool, and is not accurate in handling some special hardware events, and has poor adaptability to different platforms and scenarios.

[0010] The present invention provides a deterministic replay implementation method based on PMU, comprising the following steps:

[0011] The default event log file structure includes the event type, instruction counter value, and data storage structure corresponding to non-deterministic events. The default data storage structure corresponding to the event type includes event-specific data, instruction count, and event data length.

[0012] The PMU is used to track and acquire events to be processed. It is determined whether the event to be processed matches the event type in the preset event log file structure. If they match, the event-specific data, instruction count, and instruction counter value corresponding to the instruction of each non-deterministic event are determined according to the event data length in the data storage structure.

[0013] The instruction counter acquires the instruction count, increments the counter value corresponding to the instruction count, and saves the current count value and the corresponding event-specific data after incrementing.

[0014] When the current count value reaches the preset value after incrementing, an interrupt command is sent to the PMU. The current count value is used to synchronize the time point of the event to realize the instruction path synchronization, so as to reproduce the event in a way that is consistent with the original execution and record it in the log file.

[0015] Preferably, the event log file is stored in binary format.

[0016] Preferably, the event types include interrupt events, timer events, random number generation events, read events, and write events.

[0017] Preferably, the event-specific data includes a data structure name, field name, field type, and description corresponding to the event type.

[0018] Preferably, the log file is initialized before recording, and file header information is set, including version number and creation time.

[0019] This invention proposes a deterministic replay implementation method based on a PMU (Programmable Memory Unit). Addressing the event recording and replay requirements of domestically developed embedded operating systems (EOS), it provides a feasible technical solution for replaying the operation of EOS. The method focuses on instruction counter-based time synchronization technology and event log file structure design technology, resulting in a real-time recording and post-event replay scheme for EOS. The method employs instruction counter-based time synchronization technology to record the execution order and time information of each instruction, ensuring that the instruction path during replay is consistent with the original execution. By utilizing the PMU function of ARMv8 and without requiring special hardware or software support, it accurately tracks hardware events, improving the accuracy and efficiency of replay and enhancing adaptability in different environments. Attached Figure Description

[0020] Figure 1 is a flowchart of the event logging mechanism based on instruction counting;

[0021] Figure 2 is a flowchart of the event replay mechanism based on instruction counting. Detailed Implementation

[0022] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.

[0023] This invention provides a deterministic replay implementation method based on a PMU, which implements instruction counter time synchronization technology based on a PMU. The method steps are as follows:

[0024] During the execution of an embedded operating system, non-deterministic events (such as interrupts and I / O operations) can lead to different execution paths, affecting the accuracy of replay. To ensure that the instruction path remains consistent with the original execution during replay, time synchronization technology is crucial. Instruction counter-based time synchronization technology achieves accurate reproduction of non-deterministic events by precisely recording the instruction execution order.

[0025] Instruction counter-based time synchronization technology ensures that the instruction path remains consistent with the original execution during replay by recording the execution order of each instruction. The core of this technology lies in using an instruction counter to track the execution of each instruction and recording the instruction counter value when non-deterministic events occur, thereby accurately synchronizing these events during replay.

[0026] Implementation steps:

[0027] 1. Initialize the instruction counter: The instruction counter is initialized when the program starts executing.

[0028] 2. Incrementing the instruction counter: After each instruction is executed, the instruction counter increments by one value.

[0029] 3. Recording nondeterministic events: To optimize performance, the instruction counter value is not recorded after each instruction is executed, but only when a nondeterministic event occurs. When a nondeterministic event occurs, the current instruction counter value and event information are recorded.

[0030] Detailed implementation:

[0031] Instruction Counting: The ARMv8 Performance Monitoring Unit (PMU) provides the ability to accurately track hardware events such as instruction execution, cache hits, and branch prediction. The PMU accurately obtains the number of instructions executed instead of constantly polling a counter or instrumenting each instruction to record the execution count, thus significantly reducing CPU resource consumption.

[0032] Event Logging Mechanism: By utilizing the PMU's interrupt functionality, we can receive interrupts when specific events occur. We can design an efficient event logging mechanism to ensure that the current instruction counter value is quickly recorded when an event occurs. Using PMU interrupts, we can configure the counter to issue an interrupt when it reaches a predetermined value. This allows us to process data only when critical events occur, thereby optimizing performance and response speed. For example, we can configure the PMU to issue an interrupt after executing a certain number of instructions, which is very useful for high-precision event replay.

[0033] The records include instruction execution records and event occurrence records, as shown in Figure 1 below:

[0034] Instruction execution log: A counter is incremented after each instruction is executed.

[0035] Event occurrence log: Records the current counter value when an event occurs.

[0036] Replay includes instruction path synchronization and event reproduction, as shown in Figure 2 below:

[0037] Instruction path synchronization: During replay, the instruction counter value is used to synchronize the time points when events occur.

[0038] Event Reproduction: Based on the recorded instruction counter value, ensure that the event is consistent with the original execution when it is replayed.

[0039] Event log file structure design technique: This technique employs an event log file structure design based on a specific algorithm and data structure. The event log file structure design ensures accurate reproduction of these events during replay by recording all non-deterministic events during system execution and their corresponding instruction counter values.

[0040] Implementation steps:

[0041] The core of event log file structure design lies in designing an efficient and clearly structured log file format, enabling fast and reliable event recording and retrieval. Specific implementation includes the following aspects:

[0042] 1. Basic structure of event log files: They are stored in binary format, and each record includes the event type, command counter value, and event data.

[0043] 2. Data storage structure: Different event types correspond to different data structures. All events use a unified log recording structure EventLogEntry, which contains basic information such as command count, event type, and event data length.

[0044] Detailed implementation:

[0045] 1. Initialize log file: When the program starts executing, create and initialize the event log file, and set the necessary file header information, including version number, creation time, etc.

[0046] 2. Event Recording: When the system detects a non-deterministic event, it immediately records the following information: the current instruction counter value; and event data, which provides detailed information about the event.

[0047] 3. Event Replay: During the replay process, nondeterministic events are accurately reproduced using records in the log file.

[0048] The detailed implementation is as follows:

[0049] 1. Data structure design:

[0050] 2. Event types and their data structures:

[0051] Depending on the event type, the `event_data` field stores different data structures. The following table details the data structures for each event type:

[0052] This invention proposes a deterministic replay implementation method based on PMU, with the following beneficial effects:

[0053] 1. Improved Replay Accuracy: The characteristics of the PMU enable this invention to consistently guarantee replay accuracy across different hardware environments and application scenarios. For example, in complex autonomous driving system hardware environments, facing large amounts of real-time data and complex instruction execution, this invention can still accurately replay system operation. Because the PMU can accurately track hardware events, such as instruction execution, cache hits, and branch prediction, it provides strong protection for system safety and reliability regardless of the complexity of the hardware environment.

[0054] 2. Significantly improved efficiency: Reducing the demand for CPU resources and optimizing the interrupt handling process will significantly improve the efficiency of the replay process, making it more suitable for use in production environments.

[0055] The key technical points and points to be protected in this invention are: using time synchronization technology of instruction counter based on PMU as a measurement reference value to cooperate with the system to realize replay function and event log file structure design technology.

[0056] This solution addresses the event logging and replay requirements of domestically developed embedded operating systems. It focuses on researching instruction counter-based time synchronization technology and event log file structure design, resulting in a real-time logging and replay solution for domestically developed embedded operating systems. The system architecture of this solution includes key components such as a time synchronization module, a logging module, and a replay module. It employs instruction counter-based time synchronization technology to record the execution order and time information of each instruction, ensuring that the instruction path is consistent with the original execution during replay. An efficient and clearly structured log file format is designed to record non-deterministic events during system execution. By periodically creating and restoring system state checkpoints, the execution order and logical consistency of events are maintained.

Claims

1. A deterministic replay implementation method based on PMU, characterized in that, Includes the following steps: The default event log file structure includes the event type, instruction counter value, and data storage structure corresponding to non-deterministic events. The default data storage structure corresponding to the event type includes event-specific data, instruction count, and event data length. The PMU is used to track and acquire events to be processed. It is determined whether the event to be processed matches the event type in the preset event log file structure. If they match, the event-specific data, instruction count, and instruction counter value corresponding to the instruction of each non-deterministic event are determined according to the event data length in the data storage structure. The instruction counter acquires the instruction count, increments the counter value corresponding to the instruction count, and saves the current count value and the corresponding event-specific data after incrementing. When the current count value reaches the preset value after incrementing, an interrupt command is sent to the PMU. The current count value is used to synchronize the time point of the event to realize the instruction path synchronization, so as to reproduce the event in a way that is consistent with the original execution and record it in the log file.

2. The deterministic replay implementation method based on PMU as described in claim 1, characterized in that, The event log file is stored in binary format.

3. The deterministic replay implementation method based on PMU as described in claim 1, characterized in that, The event types include interrupt events, timer events, random number generation events, read events, and write events.

4. The deterministic replay implementation method based on PMU as described in claim 1, characterized in that, The event-specific data includes the data structure name, field name, field type, and description corresponding to the event type.

5. The deterministic replay implementation method based on PMU as described in claim 1, characterized in that, The log file is initialized before recording, and the file header information is set, including the version number and creation time.