Deterministic replay implementation method based on PMU

Through the deterministic replay method based on PMU, the problems of high complexity and poor accuracy in the existing technology are solved, and an efficient and accurate replay process is achieved. It is suitable for domestic embedded operating systems, improving the reliability and security of the system.

CN120104443APending Publication Date: 2025-06-06EAST CHINA INST OF COMPUTING TECH

Patent Information

Application Number
CN202510092666.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

The existing deterministic repetition recording timing method has defects such as relying on proprietary hardware or requiring modification of compilers, which increases the complexity and overhead of the tool, and is poorly accurate and poorly adaptable when handling special hardware events.

Method used

Using the deterministic repetition implementation method based on PMU, the preset event log file structure is used, and the pending events are obtained using PMU tracking, and the instruction counter value and event specific data are recorded to realize instruction path synchronization and event reproduction.

Benefits of technology

It improves the accuracy and efficiency of re-enactment, enhances adaptability in different environments, ensures that the instruction path is consistent with the original execution, and provides guarantees for the reliability and security of domestic embedded operating systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104443A_ABST
    Figure CN120104443A_ABST
Patent Text Reader

Abstract

The invention provides a deterministic replay implementation method based on a PMU, aims at event recording and replay requirements of a domestic embedded operating system, further provides a feasible technical scheme for running replay of the domestic embedded operating system, and focuses on research on a time synchronization technology based on an instruction counter and an event log file structure design technology. And a domestic embedded operating system real-time recording and post replay scheme is formed. According to the method, a time synchronization technology based on an instruction counter is adopted, the execution sequence and time information of each instruction are recorded, it is ensured that an instruction path is consistent with original execution during replay, under the condition that a PMU function of ARMv8 is utilized and special hardware and software support is not needed, hardware events are accurately tracked, the replay accuracy and efficiency are improved, and the replay efficiency is improved. And the adaptability in different environments is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deterministic replay of operating systems, and in particular to a method for implementing deterministic replay based on a PMU. Background Art

[0002] Domestic embedded real-time operating systems play a core role in modern industry and technology. These systems are not only widely used in industrial control systems, but also ensure the safety and reliability of operations in key areas such as autonomous driving, aerospace, and medical equipment. Real-time and reliability are the cornerstones of these applications, as they often involve critical safety operations and high-risk environments, and any system failure may lead to serious consequences. Run replay is a technology that allows developers to record the execution process of a system and replay it accurately to facilitate the reproduction and analysis of failures. This technology creates a path that can be repeatedly executed under exactly the same operating conditions by capturing events such as instruction execution, external input, and internal state changes. The implementation of run replay in embedded operating systems, especially for systems that require extremely high reliability and safety, can not only greatly improve the efficiency of fault diagnosis, but also prevent potential problems before the system is deployed, thereby significantly improving the stability and safety of the system.

[0003] Patent number: CN201910940847.8

[0004] Patent name: A deterministic replay method and device for an embedded operating system

[0005] Specific content: This patent proposes a deterministic replay method and device for an embedded operating system, which records key information during the system operation, including the execution order of tasks, the occurrence time of events, the allocation of resources, etc., and then accurately reproduces the previous operating state of the system based on this recorded information when replay is needed. This method can effectively help developers reproduce problems during debugging and testing, improve development efficiency and system reliability. For example, when a system has a fault that is difficult to reproduce, the method of this patent can be used to record the system state before the fault occurs, and then replay it in subsequent analysis to better locate and solve the problem.

[0006] Patent number: CN201710543441.7

[0007] Patent Name: A deterministic recording and replay method for an embedded real-time operating system

[0008] Specific content: This patent mainly involves a deterministic recording and replay technology for an embedded real-time operating system. It uses a specific recording mechanism to record key operations and events of the operating system kernel, including task scheduling, interrupt processing, communication processes, etc. In 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. The technology of this patent can be applied to embedded systems with high requirements for real-time and determinism, such as aerospace, industrial control and other fields, which helps to improve the stability and reliability of the system and reduce the debugging and testing costs of the system. Summary of the invention

[0009] The technical problem to be solved by the technical solution of the present invention is that the existing deterministic replay recording timing methods have defects such as either relying on proprietary hardware or requiring the compiler to be modified to insert the code, which greatly increases the complexity and overhead of the tool, and has poor accuracy when processing some special hardware events and poor adaptability under different platforms and scenarios.

[0010] The technical solution of the present invention provides a method for implementing deterministic replay based on PMU, comprising the following steps:

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

[0012] Use PMU to track and obtain the pending events, determine whether the pending events match the event types in the preset event log file structure, and if they match, determine the event specific data, instruction count and instruction counter value corresponding to the instruction of each non-deterministic event according to the event data length in the data storage structure;

[0013] The instruction counter obtains the instruction count, counts up according to the instruction counter value corresponding to the instruction count, and saves the current count value and the corresponding event specific data after the increment;

[0014] When the current count value reaches the preset value after the count is incremented, an interrupt instruction is issued to the PMU, and the instruction path synchronization is achieved using the time point at which the current count value synchronization event occurs, so as to reproduce the event consistent with the original execution and record it in the log file.

[0015] Preferably, the event log file structure 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, a field name, a field type and a 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] The technical solution of the present invention proposes a method for implementing deterministic replay based on PMU, which aims at the event recording and replay requirements of domestic embedded operating systems, and further provides a feasible technical solution for running replay of domestic embedded operating systems, focusing on the time synchronization technology based on instruction counters and the event log file structure design technology, forming a real-time recording and post-event replay solution for domestic embedded operating systems. The method adopts the time synchronization technology based on instruction counters to record the execution order and time information of each instruction, ensuring that the instruction path is consistent with the original execution during replay, and accurately tracks hardware events while utilizing the PMU function of ARMv8 without the need for special hardware and software support, improving the accuracy and efficiency of replay, and enhancing adaptability in different environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flow chart of an event recording mechanism based on instruction counting;

[0021] Figure 2 Flowchart of the event replay mechanism based on instruction counting. DETAILED DESCRIPTION

[0022] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.

[0023] The embodiment of the present invention provides a method for implementing deterministic replay based on PMU, and implements a time synchronization technology of an instruction counter based on PMU. The method steps are as follows:

[0024] During the execution of an embedded operating system, non-deterministic events (such as interrupts, I / O operations, etc.) can lead to different execution paths, thus affecting the accuracy of replay. In order to ensure that the instruction path during replay is consistent with the original execution, time synchronization technology is essential. Time synchronization technology based on instruction counters achieves accurate reproduction of non-deterministic events by accurately recording the execution order of instructions.

[0025] The time synchronization technology based on instruction counter records the execution order of each instruction to ensure that the instruction path during replay is consistent with the original execution. The core of this technology is to use instruction counters to track the execution of each instruction and record the instruction counter value when non-deterministic events occur, so as to accurately synchronize these events during the replay process.

[0026] Implementation steps:

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

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

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

[0030] Detailed implementation details:

[0031] Instruction counting: ARMv8's performance monitoring unit (PMU) provides the ability to accurately track hardware events such as instruction execution, cache hits, and branch predictions. The PMU can accurately obtain the number of instructions executed instead of constantly polling counters or inserting stubs for each instruction to record the number of instructions executed, which greatly reduces the consumption of CPU resources.

[0032] Event recording mechanism: By utilizing the interrupt function of the PMU, we can receive interrupts when specific events occur and design an efficient event recording mechanism to ensure that the current instruction counter value can be quickly recorded when an event occurs. Using the PMU interrupt, we can set the counter to issue an interrupt when it reaches a predetermined value, which allows us to process data only when key events occur, thereby optimizing performance and responsiveness. For example, the PMU can be set to issue an interrupt after executing a certain number of instructions, which is very useful in high-precision event replay.

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

[0034] Instruction execution record: increase the counter after each instruction is executed.

[0035] Event occurrence record: Record the current counter value when an event occurs.

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

[0037] Instruction path synchronization: Use instruction counter values ​​to synchronize the time points at which events occur during replay.

[0038] Event Replay: Ensures that events are consistent with the original execution when replayed, based on recorded instruction counter values.

[0039] Event log file structure design technology: an event log file structure design technology based on a specific algorithm and data structure is used. The event log file structure design records all non-deterministic events in the system execution process and their corresponding instruction counter values ​​to ensure that these events can be accurately reproduced during the replay process.

[0040] Implementation steps:

[0041] The core of event log file structure design is to design an efficient and clearly structured log file format, so that the event recording and reading process is fast and reliable. The specific implementation includes the following aspects:

[0042] 1. The basic structure of the event log file: stored in binary format, each record includes event type, instruction counter value, and event data.

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

[0044] Detailed implementation details:

[0045] 1. Initialize the 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. Record events: When the system detects a non-deterministic event, it immediately records the following information: the current instruction counter value. Event data, which details the specific information of the event.

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

[0048] The detailed implementation details are as follows:

[0049] 1. Data structure design:

[0050]

[0051] 2. Event type and its data structure:

[0052] Depending on the event type, the event_data field stores different data structures. The following table shows the data structure of each event type in detail:

[0053]

[0054]

[0055] The embodiment of the present invention proposes a method for implementing deterministic replay based on PMU, which has the following beneficial effects:

[0056] 1. Improve the accuracy of replay: In different hardware environments and application scenarios, the characteristics of PMU enable the present invention to always ensure the accuracy of replay. For example, in a complex hardware environment of an autonomous driving system, facing a large amount of real-time data and complex instruction execution, the present invention can still accurately replay the system operation. Since PMU can accurately track hardware events such as instruction execution, cache hits, and branch predictions, no matter how complex the hardware environment is, it provides a strong guarantee for the safety and reliability of the system.

[0057] 2. Significant improvement in 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 a production environment.

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

[0059] This solution targets the event recording and replay requirements of domestic embedded operating systems, focusing on the time synchronization technology based on instruction counters and the event log file structure design technology, forming a real-time recording and post-event replay solution for domestic embedded operating systems. The system architecture of this solution includes key components such as time synchronization module, log module, and replay module. The time synchronization technology based on instruction counter is used to record the execution order and time information of each instruction to ensure 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. The execution order and logical consistency of events are maintained by regularly creating and restoring system status checkpoints.

Claims

1. A method for implementing deterministic replay based on PMU, characterized in that: The following steps are involved: Preset event log file structure, the event log file structure includes event type corresponding to non-deterministic events, instruction counter value, data storage structure, the data storage structure corresponding to the preset event type includes event specific data, instruction count and event data length; Use PMU to track and obtain the pending events, determine whether the pending events match the event types in the preset event log file structure, and if they match, determine the event specific data, instruction count and instruction counter value corresponding to the instruction of each non-deterministic event according to the event data length in the data storage structure; The instruction counter obtains the instruction count, counts up according to the instruction counter value corresponding to the instruction count, and saves the current count value and the corresponding event specific data after the increment; When the current count value reaches the preset value after the count is incremented, an interrupt instruction is issued to the PMU, and the instruction path synchronization is achieved using the time point at which the current count value synchronization event occurs, so as to reproduce the event consistent with the original execution and record it in the log file.

2. A method for implementing deterministic replay based on PMU as claimed in claim 1, characterized in that: The event log file structure is stored in binary format.

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

4. A method for implementing deterministic replay based on PMU as claimed in claim 1, characterized in that: The event specific data includes a data structure name, field name, field type and description corresponding to the event type.

5. A method for implementing deterministic replay based on PMU as claimed 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 the creation time.

Citation Information

Patent Citations

  • Voice interaction error correction method and device

    CN112669833A

Cited By

  • PMU-based deterministic replay implementation method

    WO2026157124A1