A method, system, medium and product for tracking data transmission
By performing length detection and variable length indicator field processing on the payload of CPU trace packets, the problem of excessive data volume in the Trace function was solved, thus improving processor performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, the CPU's Trace function generates a large number of data packet headers during execution, resulting in excessive consumption of resources and bandwidth, which affects processor performance.
By creating the payload of the tracking data packet corresponding to the instruction and detecting its length, the payload length indication field is determined using a preset mapping relationship. The variable length indication field is then transmitted to the tracking data packet compression module to reduce redundant information in the packet header.
This reduces the amount of data in the tracking packets and improves processor performance.
Smart Images

Figure CN121833416B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of processor technology, and in particular to a method, system, medium, and product for tracking data transmission. Background Technology
[0002] The CPU (Central Processing Unit) tracing function is a mechanism used to record instruction flow, branches, memory accesses, exceptions, and other behaviors during processor execution. Currently, when executing the tracing function, the tracing packet header is quite large, consuming significant CPU resources and bandwidth to transmit it to the software tracer for display, thus impacting processor performance.
[0003] It is evident that how to reduce the amount of data in the tracking function, thereby improving processor performance, is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this invention is to provide a method, system, medium, and product for tracking data transmission, which can reduce the amount of data in the tracking data packets, thereby improving processor performance.
[0005] In a first aspect, the present invention discloses a method for tracking data transmission, comprising: creating a payload of a tracking data packet corresponding to an instruction; performing length detection on the payload to obtain target length information of the payload; when the target length information is not zero, determining a load length indication field corresponding to the target length information based on a first preset mapping relationship to obtain a target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field; and transmitting the target load length indication field to a tracking data packet compression module so that the tracking data packet compression module can determine the target length information.
[0006] Optionally, it also includes: when the target length information is zero, canceling the load length indication field and transmitting an indication signal indicating that the target length information is zero to the tracking data packet compression module.
[0007] Optionally, after transmitting the target payload length indication field to the tracking packet compression module, the method further includes: transmitting a transmission completion indication signal to the tracking packet compression module so that the tracking packet compression module can determine the target payload length indication field.
[0008] Optionally, creating the payload of the tracking data packet corresponding to the instruction includes: determining the instruction type of the instruction; and creating the payload of the tracking data packet based on the instruction type.
[0009] Optionally, creating a payload for a tracking data packet based on the instruction type includes: if the instruction type is a jump instruction, determining the jump address in the instruction information as the target jump address, determining the encoding information corresponding to the target jump address from a second preset mapping relationship, and obtaining target encoding information, wherein, in the second preset mapping relationship, the proportion of the encoding information is lower than the proportion of the jump address; and using the target encoding information to create a payload for the tracking data packet.
[0010] Optionally, it further includes: monitoring the occurrence frequency of each jump address; adjusting the second preset mapping relationship based on the occurrence frequency, so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address; wherein the occurrence frequency of the first jump address is higher than the occurrence frequency of the second jump address.
[0011] Optionally, after adjusting the second preset mapping relationship, the method further includes: notifying the tracker so that the tracker can obtain the adjusted second preset mapping relationship.
[0012] Optionally, determining the instruction type of an instruction includes: extracting the opcode field of the instruction; and determining the instruction type of the instruction based on the opcode field, wherein the instruction type is a jump instruction or a non-jump instruction.
[0013] In a second aspect, the present invention provides a data tracking system, comprising:
[0014] The payload creation module is used to create the payload of the tracking data packet corresponding to the instruction;
[0015] A length detection module is used to detect the length of the payload and obtain the target length information of the payload;
[0016] The length mapping module is used to determine the load length indication field corresponding to the target length information based on a first preset mapping relationship when the target length information is not zero, and obtain the target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field.
[0017] The length transmission module is used to transmit the target payload length indication field to the tracking data packet compression module so that the tracking data packet compression module can determine the target length information.
[0018] Optionally, it also includes: a length indication signal generation module, used to generate a transmission completion indication signal and transmit the transmission completion indication signal to the tracking data packet compression module, so that the tracking data packet compression module can determine the target payload length indication field.
[0019] Optionally, the length indication signal generation module is further configured to: transmit an indication signal indicating that the target length information is zero to the tracking data packet compression module.
[0020] Optionally, the payload creation module specifically includes:
[0021] The jump instruction information encoding module is used to determine the jump address in the instruction information as the target jump address if the instruction type is a jump instruction, and to determine the encoding information corresponding to the target jump address from the second preset mapping relationship to obtain the target encoding information, wherein the proportion of the encoding information in the second preset mapping relationship is lower than the proportion of the jump address.
[0022] The payload packet assembly module is used to create a payload for tracking data packets using the target encoding information.
[0023] Optionally, it further includes: an encoding adjustment module, used to monitor the occurrence frequency of each jump address; adjust the second preset mapping relationship based on the occurrence frequency, so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address; wherein, the occurrence frequency of the first jump address is higher than the occurrence frequency of the second jump address.
[0024] Thirdly, the present invention provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the aforementioned tracking data transmission method.
[0025] Fourthly, the present invention provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the aforementioned data transmission tracking method.
[0026] As can be seen, the beneficial effects of the present invention are as follows: When creating the payload of the tracking data packet corresponding to the instruction, the payload is first length-detected to obtain the target length information. Then, if the target length information is not zero, the payload length indication field corresponding to the target length information is determined based on a first preset mapping relationship, thus obtaining the target payload length indication field. In the first preset mapping relationship, the proportion of bits in the payload length indication field is the minimum number of bits that can represent the length information corresponding to the payload length indication field. The target payload length indication field is then transmitted to the tracking data packet compression module so that the tracking data packet compression module can determine the target length information. In this way, the width of the payload length indication field in the tracking data packet is variable, and the minimum number of bits that can represent the length information corresponding to the payload length indication field is reduced, thus reducing the data volume of the tracking data packet header and the data volume of the tracking function, thereby improving processor performance. Attached Figure Description
[0027] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a schematic diagram of a RISC-V CPU Trace function implementation scheme in the prior art;
[0029] Figure 2 A flowchart of a data tracking method provided in an embodiment of the present invention;
[0030] Figure 3 This is an application architecture diagram of a data transmission tracking scheme provided in an embodiment of the present invention;
[0031] Figure 4 A schematic diagram of a variable length module provided in an embodiment of the present invention;
[0032] Figure 5 This is a schematic diagram of a payload creation module provided in an embodiment of the present invention;
[0033] Figure 6 This is a schematic diagram of a tracking data transmission system provided in an embodiment of the present invention. Detailed Implementation
[0034] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.
[0035] The terms "comprising" and "having," and any variations thereof, in the specification and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may include steps or units not listed.
[0036] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0037] CPU Trace functionality: This function is a mechanism used to record instruction flow, branches, memory accesses, exceptions, and other behaviors during processor execution. It is primarily used for performance analysis, debugging, security monitoring, and fault diagnosis. Modern CPUs typically implement efficient, low-overhead instruction flow recording through hardware-level Trace modules.
[0038] See Figure 1 As shown, Figure 1 This is a schematic diagram of an existing RISC-V (Reduced Instruction Set Computing-V) CPU Trace functionality implementation scheme. Figure 1As shown, the traditional RISC-V CPU Trace architecture includes an instruction cache, an instruction parsing module, a non-jump instruction tracing packet assembly module, a jump instruction tracing packet assembly module, and a tracing data packet compression module. The compressed tracing data packet is then passed to the software tracer via the JTAG (Joint Test Action Group) interface or written to DDR memory (Double Data Rate Synchronous Dynamic Random-Access Memory), where it is read and displayed by the software tracer. The traditional RISC-V CPU Trace process is as follows: the instruction parsing module obtains the actual instruction information to be executed from the instruction cache and parses it. The parsing result is divided into two types: non-jump instructions and jump instructions. The instruction parsing module determines the instruction as a jump instruction and inputs it to the jump instruction tracing packet assembly module; the instruction parsing module determines the instruction as a non-jump instruction and inputs it to the non-jump instruction tracing packet assembly module.
[0039] The non-jump instruction tracing packet assembly module generates tracing data packets for non-jump instructions. Its format is divided into two parts: a Header and a Payload. The Header consists of a 2-bit Trace packet type, a 1-bit compression indicator, and a 5-bit payload length field. The Payload is 0x0. The 2-bit Trace packet type (2'b00) indicates the current instruction is a non-jump instruction. The 1-bit compression indicator (1'b1) indicates that subsequent Trace data packet compression has been initiated. The 5-bit payload length field (5'b0) indicates that the Payload length is 0. A Payload field of 0 indicates that no other information needs to be transmitted; the software tracer simply adds 4 to the previous instruction value when displaying the instruction value. Because there is no jump, the instruction's Program Counter (PC) value is executed sequentially. During sequential execution, the PC automatically increments, with the increment equal to the byte length of the current instruction. For 32-bit (4-byte) instructions, the PC increments by 4. This ensures that the CPU can fetch and execute the next instruction in sequence. If the PC value of the previous instruction is 0x80000000, then in sequential execution, the PC value of the next instruction will be 0x80000004.
[0040] The jump instruction Trace packet assembly module generates trace data packets for jump instructions, consisting of two parts: a header and a payload. The header contains a 2-bit Trace packet type, a 1-bit compression indicator, and a 5-bit payload length indicator. The payload includes the target jump address, the cause of any exception or interruption, and a timestamp. The 2-bit Trace packet type (2'b01) indicates the current instruction is a jump instruction, and the 1-bit compression indicator (1'b1) indicates that subsequent trace data packet compression has been initiated. The 5-bit payload length indicator has a variable value, representing the payload length, set according to the payload length (in bytes; for example, if the payload length is 6 bytes, the value is 5'b00110; if the payload length is 3 bytes, the value is 5'b00011). Payload field: This field transmits information such as the target jump address, the reason for the abnormal interruption, and the timestamp. Because this is a jump instruction, the software tracer cannot directly recover from the previous instruction value when displaying the instruction value. Therefore, the Trace package needs to transmit the actual target address of the jump instruction, as well as information such as the abnormal interruption. Its length and type are not fixed.
[0041] The compressed trace data packets are delivered to the software tracer in two ways: one is via the JTAG interface, and the other is written to DDR for the software tracer to read. The software tracer, based on the method used to compress the trace packets, reconstructs the trace data packets to obtain complete program execution instruction information and instruction flow, which is then displayed for the user to observe and trace.
[0042] In traditional CPU performance monitoring methods, for sequentially executed instructions, the CPU's trace module's trace data packet only contains header information. For instructions executed via jumps, the trace module's trace data packet contains both header information and data payload. These trace data packets are then compressed and sent to the host computer's software tracer for decompression and parsing to extract the specific instructions executed by the CPU for user process viewing. Traditional RISC-V CPU trace functionality has a problem: the header of the traditional trace data packet contains redundant information. The header length is 2 bits for packet type information + 1 bit for compression information + 5 bits for payload length information, totaling 8 bits. Because program execution involves a large number of instructions, a 3.0 GHz CPU with an average IPC (instructions per cycle) of 2 has a theoretical IPS (Instructions Per Second) of 3 × 10⁻⁶. 9 × 2 = 6 × 10 9IPS (i.e., 6 billion records / second), according to theoretical IPS, the data volume of the trace packet header (6 × 10⁻⁶) 9 (Bytes / s) is an enormous amount of data. Even with 1% compression, it's still 6 × 10⁷ Bytes / s, which is still very large. It consumes significant CPU resources, performance, and bandwidth to transmit the data to a software tracer for display, allowing users to view every instruction executed by the CPU. Furthermore, the compressed instruction trace data packets need to include the address information of jump instructions, resulting in a very large data load. For example, using 32 bits for the address information of a jump instruction, conservatively calculated, for 1% of jump instructions, the trace data volume (per second) for jump instructions would be 6 × 10⁷ Bytes / s. 9 32 / (4 100) = 0.48 billion Bytes / second. This is an extremely large data volume. Even after compression, the data size remains enormous, consuming significant CPU resources, performance, and bandwidth to transmit to the software tracer for display, allowing users to view each instruction executed by the CPU. Therefore, this invention provides a data transmission scheme for tracing that reduces the data volume required for tracing, thereby improving processor performance.
[0043] Next, a method for tracking data transmission provided by an embodiment of the present invention will be described in detail. Figure 2 A flowchart of a data transmission tracking method provided in an embodiment of the present invention is shown. The data transmission tracking method includes:
[0044] Step S11: Create the payload of the tracking data packet corresponding to the instruction.
[0045] This embodiment can retrieve instructions from the instruction cache and create the corresponding payload in the tracking data packet. The payload creation module can be used to create the payload of the tracking data packet corresponding to the instruction.
[0046] In this embodiment, creating the payload of the tracking data packet corresponding to the instruction may include: determining the instruction type of the instruction; and creating the payload of the tracking data packet based on the instruction type.
[0047] The process of determining the instruction type includes: extracting the opcode field of the instruction; and determining the instruction type based on the opcode field, wherein the instruction type is a jump instruction or a non-jump instruction. The instruction type can be identified through the opcode field, which consists of the lower 7 bits of the RISC-V instruction. When opcode[6:0] = 7'b1101111 / 7'b1100111 / 7'b1100011, it is determined to be a jump instruction. When the value of opcode[6:0] is not equal to the above three values, the instruction is determined to be a non-jump instruction. The instruction type can be determined through the instruction determination module.
[0048] Furthermore, creating the payload of the tracking data packet based on the instruction type may include: if the instruction type is a jump instruction, then determining the jump address in the instruction information as the target jump address, determining the encoding information corresponding to the target jump address from the second preset mapping relationship, and obtaining the target encoding information, wherein, in the second preset mapping relationship, the proportion of the encoding information is lower than the proportion of the jump address; and using the target encoding information to create the payload of the tracking data packet.
[0049] Although the jump address range of jump instructions is large, the number of addresses is small. A 16-bit encoding range can represent the jump addresses of all jump instructions. Jump addresses are typically 32 bits; this embodiment converts them into 16-bit encoded information, thereby reducing the amount of Trace data packets. The second preset mapping relationship can be cached in the form of a mapping table. As shown in Table 1, Table 1 is an example of a jump address and encoding information mapping table. When the instruction type is a jump instruction, the jump address in the instruction information can be determined as the target jump address by the jump instruction information encoding module. The encoding information corresponding to the target jump address can then be determined from the second preset mapping relationship to obtain the target encoding information.
[0050] Table 1
[0051]
[0052] Table 1 is for illustrative purposes only. The jump address column is based on the actual application's jump address input, and the encoding information column changes accordingly. In this way, the 32-bit jump address is replaced with 16-bit encoded information in the payload, reducing the jump address data by 50%, which will greatly reduce the total data size of the trace packet.
[0053] For jump instructions, the target encoding information and other information (such as the reason for the exception, timestamp, etc.) are packaged to obtain the payload. For non-jump instructions, no encoding information mapping is required; the payload is directly packaged to obtain the payload.
[0054] Furthermore, embodiments of the present invention can also monitor the occurrence frequency of each jump address; adjust the second preset mapping relationship based on the occurrence frequency, so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address; wherein, the occurrence frequency of the first jump address is higher than the occurrence frequency of the second jump address.
[0055] This embodiment can perform statistics at preset time intervals, such as 10 minutes or 5 minutes, with statistics collected every 10 minutes. High-frequency jump addresses are encoded as the encoding information at the beginning of Table 1; that is, the highest frequency jump address is encoded as 16'b0000, and the second highest frequency jump address is encoded as 0001. This further reduces the amount of data in the Trace data packet (after compression) ultimately transmitted to the software tracer, because a large number of 0s can achieve a higher compression ratio during data compression by the Trace compression module. The frequency of each jump address can be monitored through an encoding adjustment module; based on the frequency of occurrence, the second preset mapping relationship is adjusted so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address; wherein the frequency of occurrence of the first jump address is higher than the frequency of occurrence of the second jump address.
[0056] Furthermore, after adjusting the second preset mapping relationship, the method also includes: notifying the tracker so that the tracker can obtain the adjusted second preset mapping relationship.
[0057] This embodiment can store a second preset mapping relationship. In an optional implementation, the second preset mapping relationship is stored through an instruction address mapping module, and the output information of the encoding adjustment module is received in real time to store the adjusted second preset mapping relationship. The instruction address mapping module sends a notification message through its communication interface to inform the software tracker to read the second preset mapping relationship again to complete the decoding of the correct encoded information.
[0058] Step S12: Detect the length of the payload to obtain the target length information of the payload.
[0059] That is, the total length of the packaged payload segment is detected, and the length information of the effective payload, i.e. the target length information, is obtained in bytes.
[0060] In an optional implementation, a length detection module can be used to detect the length of the payload to obtain the target length information of the payload.
[0061] Step S13: When the target length information is not zero, determine the load length indication field corresponding to the target length information based on the first preset mapping relationship to obtain the target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field.
[0062] For example, a 1-byte length is represented by 1 bit, so the payload length indicator field is 1. A 2-byte length is represented by 2 bits, that is, the payload length indicator field is 10.
[0063] In an optional implementation, if the target length information is zero, the payload length indication field is canceled, and an indication signal indicating that the target length information is zero is transmitted to the tracking data packet compression module. As shown in Table 2, Table 2 is a mapping table between payload length information and the payload length indication field. In Table 1, n' corresponds to the field width, b represents binary, n is 1 to 5, that is, 1 to 5 bits, and what follows b represents the specific binary value, i.e., the value of the payload length indication field.
[0064] Table 2
[0065]
[0066] The length receiving module receives the payload length information under the current command sent by the payload creation module. The length mapping module maps the length information to the payload length indicator field in the Trace data packet, employing a variable-length length mapping method to significantly reduce the data volume of the payload length indicator field. The trace data packet header contains a payload length indicator field; this embodiment uses an adaptive payload length indicator field instead of a fixed field to reduce the header data volume.
[0067] Step S14: Transmit the target payload length indication field to the tracking data packet compression module so that the tracking data packet compression module can determine the target length information.
[0068] In this embodiment, after the target payload length indication field is transmitted to the tracking data packet compression module, a transmission completion indication signal is sent to the tracking data packet compression module so that the tracking data packet compression module can determine the target payload length indication field.
[0069] In this embodiment, the packet type field, the compression indication signal field, and the target payload length indication field can be transmitted sequentially to the tracking data packet compression module. When the transmission of the target payload length indication field is completed, a transmission completion indication signal is transmitted to the tracking data packet compression module so that the tracking data packet compression module can determine the target payload length indication field.
[0070] This embodiment can generate a transmission completion indication signal through a length indication signal generation module. Because the target payload length indication field, along with the packet header information and payload, is input together to the subsequent Trace packet compression module, this embodiment outputs a transmission completion indication signal to enable the Trace packet compression module to determine the target payload length indication field.
[0071] The length indication signal generation module receives the indication signal from the preceding packet type information creation module (which generates the Trace packet type field and compression indication signal field in the packet header, and outputs an indication signal to the length indication signal generation module after outputting these fields). If the length information is not zero, upon receiving this signal, after the length mapping module outputs the corresponding target payload length indication field, the length indication signal generation module generates a transmission completion indication signal and transmits it to the trace data packet compression module. The trace data packet compression module can then determine the actual value of the target payload length indication field in the current trace data packet. After the length mapping module outputs the corresponding target payload length indication field, it can send a signal to notify the length indication signal generation module.
[0072] Furthermore, a special design is made for the scenario where the length information is 0. In this case, the payload length indicator field in the packet header is removed. Instead, after the packet type information creation module outputs the Trace packet type field and the compression indicator signal field, the length indicator signal generation module generates an indicator signal indicating that the target length information is zero and transmits it to the tracking data packet compression module.
[0073] In one optional implementation, the transmission completion indication signal and the target length information zero indication signal can use different signal lines. In another optional implementation, the same signal line can be used. After transmitting the packet type and compression indication signals, the corresponding signal interface of that signal line is immediately pulled high. The subsequent module then determines that the length information = 0. If the signal interface is not pulled high, but the data interface still has data output (load length indication field), the subsequent module will determine that the length information is non-zero. Therefore, when the subsequent module waits for the signal interface to go high, it can determine the target load length indication field transmitted by the data interface, which may be 1 / 2 / 3 / 4 / 5 bits. The transmission of tracking data packets and indication signals can be transmitted through different lines.
[0074] This avoids fixing the payload length indicator field to 5 bits, greatly reducing the amount of data in the Trace packet.
[0075] The trace packet compression module compresses trace packets for both non-jump instructions and jump instructions. Several compression methods are used, such as: using a history buffer: maintaining the most recently accessed program counter (PC); if the current PC can be deduced from entries in the buffer (e.g., in a repeating loop), there's no need to record the full address; bit truncation: only recording the lower bits of the PC change (e.g., the lower 12 bits), with higher bits inferred from the context; and RLE (Run-Length Encoding): consecutive packets with the same Delta (e.g., a large number of +4) can be merged into a single packet, and the repetition count is marked. Delta is the difference between two PC values.
[0076] As can be seen, in this embodiment of the invention, the payload of the tracking data packet corresponding to the creation instruction is first subjected to length detection to obtain the target length information of the payload. Then, if the target length information is not zero, the payload length indication field corresponding to the target length information is determined based on a first preset mapping relationship to obtain the target payload length indication field. In the first preset mapping relationship, the proportion of bits in the payload length indication field is the minimum number of bits that can represent the length information corresponding to the payload length indication field. The target payload length indication field is then transmitted to the tracking data packet compression module so that the tracking data packet compression module can determine the target length information. In this way, the width of the payload length indication field in the tracking data packet is variable, and the minimum number of bits that can represent the length information corresponding to the payload length indication field is reduced, thus reducing the data volume of the tracking data packet header and the data volume of the tracking function, thereby improving processor performance.
[0077] Further, see Figure 3 As shown, Figure 3This invention provides an application architecture diagram for a data tracing scheme. Specifically, it provides an architecture diagram for implementing RISC-V CPU Trace functionality, adding a variable-length module, a payload creation module, and an instruction address mapping module, while optimizing the instruction trace packet assembly process. Non-jump instructions and jump instructions are processed in a single trace packet assembly module. The payload length indicator field in the header of the trace data packet for jump instructions is designed with a variable length, selecting its width based on the actual length of the payload, avoiding a fixed 5-bit field and significantly reducing the data volume of the trace data packet. The added payload creation module greatly reduces the payload length, further reducing the length of the trace data packet. The trace packet assembly module includes a packet type information creation module. A new instruction address mapping module is added to implement the mapping relationship between the jump address of the stored instruction and the encoded information, enabling the recovery of jump instructions by the software tracer. The three modules work together to greatly reduce the amount of data in the RISC-V CPU Trace data packet, significantly reduce the impact of the Trace function on the RISC-V CPU performance, and ensure that the RISC-V CPU can achieve its optimal performance state.
[0078] See Figure 4 As shown, Figure 4 This is a schematic diagram of a variable length module provided in an embodiment of the present invention. The function of the variable length module is to determine the width of the payload length indication field in the header field based on the actual length of the Trace data packet payload. The variable length module may include a length receiving module, a length mapping module, and a length indication signal generation module.
[0079] In traditional schemes, the Trace data packet header consists of 8 bits. (The Trace data packet is composed of header + payload), as shown in Table 3, which is the header field table.
[0080] Table 3
[0081]
[0082] In traditional solutions, the payload_length field (i.e., the payload length indicator field) in the Trace packet header is fixed at 5 bits, representing a maximum payload length of 32 bytes. However, in real-world applications, the actual payload length may not reach 32 bytes; it could be 16 bytes, 8 bytes, 4 bytes, etc. Therefore, using a fixed 5 bits to represent a payload length less than 32 bits is essentially a significant waste of resources. For example, to represent a 4-byte payload length, the actual required payload_length is 3'b100, instead of the 5-bit 5'b00100.
[0083] In this embodiment of the invention, the length receiving module receives the length information of the payload under the current instruction sent by the payload creation module. The length mapping module maps the payload length information to the payload_length field in the Trace data packet, using a variable-length length mapping method to greatly reduce the amount of data in the payload_length field. The mapping is performed as shown in Table 2 above.
[0084] Length Indicator Signal Generation Module: Because the value of the payload_length field output by the length mapping module and the value of the payload itself are mixed together and input to the subsequent trace packet compression module in this invention, the trace packet compression module has difficulty distinguishing which fields belong to the payload_length field. Therefore, this invention designs a length indicator signal generation module. This module receives an indication signal from the preceding packet type information creation module (which generates the Trace packet type field and compression indicator signal field in the Header; after outputting the Trace packet type field and compression indicator signal field, it outputs an indicator signal to the length indicator signal generation module). Upon receiving this signal, the length indicator signal generation module generates an indicator signal (payload_length output completion indicator signal) after the length mapping module has finished outputting the corresponding payload_length field, and transmits this signal to the trace packet compression module. The trace packet compression module can then determine the actual value of the payload_length field in the current trace packet. For example, when the payload length is 5, after the length mapping module outputs 3'b101, the length indication signal generation module will raise the indication signal (payload_length output completion indication signal). When the traced packet compression module obtains the variable payload_length field value based on this indication signal and the lengths of other fixed fields in the packet header, this indication signal can be lowered. For example, when the payload length is 12, after the length mapping module outputs 4'b1100, the length indication signal generation module raises the indication signal (payload_length output completion indication signal). The traced packet compression module obtains the variable Length field value based on this indication signal. This indication signal is lowered whenever the Trace packet type field begins transmission. The lengths of other fields in the packet header are fixed; the lengths of the data received before the indication signal is raised, along with the lengths of other fields in the packet header, determine the target payload length indication field.
[0085] This invention addresses the scenario where the payload length information is 0. It removes the payload_length field from the header and instead, after the packet type information creation module outputs the Trace packet type field and compression indication signal field, the length indication signal generation module synchronously generates an indication signal (payload_length=0 indication signal). This indication signal and the payload_length output completion indication signal can physically use the same signal line or different signal lines; different signal lines are easier to distinguish. When the tracking packet compression module detects the Trace packet type field and compression indication signal field, and then detects the payload_length=0 indication signal, it will parse that the current Trace packet does not contain the payload_length field (this applies to non-jump instruction processing flows).
[0086] This enables the generation, transmission, and identification of variable fields in the header. It avoids the drawback of the traditional approach where the payload_length field is fixed at 5 bits, significantly reducing the data volume of the trace packet.
[0087] See Figure 5 As shown, Figure 5 This is a schematic diagram of a payload creation module provided in an embodiment of the present invention. The function of the payload creation module is to reduce the length of the Payload field of the tracking data packet of a jump instruction. It can encode the jump address of the Payload segment corresponding to the jump instruction, without transmitting the complete instruction jump address information to the subsequent tracking data packet compression module, thereby reducing the amount of tracking data packet. Furthermore, the payload length information is passed to a variable length module. The payload creation module may include an instruction judgment module, a jump instruction information encoding module, an encoding adjustment module, a payload packet assembly module, and a payload length detection and transmission module.
[0088] The instruction judgment module determines the type of the current instruction. There are two possible outcomes: a non-jump instruction or a jump instruction. If the instruction is non-jump, the process jumps directly to the payload assembly module. If the instruction is jump, the process jumps to the jump instruction information encoding module. The instruction judgment module retrieves the instruction from the instruction cache and judges it based on the opcode field. The opcode field consists of the lower 7 bits of the RISC-V instruction. When opcode[6:0] = 7'b1101111 / 7'b1100111 / 7'b1100011, the instruction is judged as a jump instruction. When the value of opcode[6:0] is not equal to the above three values, it is judged as a non-jump instruction.
[0089] The jump instruction information encoding module is used to convert the jump address of a jump instruction (usually 32 bits) into 16-bit encoded information, thereby reducing the data size of the Trace packet. Although the jump address range of jump instructions is large, the number of addresses is small; a 16-bit encoding range can represent all jump addresses. The mapping table between jump addresses and encoded information is shown in Table 1 above. This allows Payload to replace the 32-bit jump address information with 16-bit encoded information, reducing the jump address data size by 50%, which will significantly reduce the total data size of the Trace packet.
[0090] The function of the encoding adjustment module is to perform frequency statistics on the jump addresses of jump instructions in the program (in units of T time intervals, where T can be a default value or configured, such as 10 minutes / 5 minutes). The jump addresses with high frequency are encoded as the encoding information at the beginning of Table 1, that is, the highest frequency jump address is encoded as 16'b0000, and the second highest frequency jump address is encoded as 0001. This can further reduce the amount of data in the Trace data packet (after compression) that is finally transmitted to the software tracer, because a large number of 0s can achieve a higher compression ratio during data compression.
[0091] The payload assembly module assembles the encoded jump address and other information (exception reason, timestamp, etc.) to obtain the payload.
[0092] The payload length detection and transmission module detects the total data volume / total length of the packaged payload segment (in bytes) and transmits the length information to the variable length module. Simultaneously, after detecting that the variable length module has completed the transmission of the Trace packet header segment, it transmits the payload segment to the subsequent trace packet compression module.
[0093] Furthermore, the instruction address mapping module stores a mapping table between jump addresses and encoding information, and receives the adjusted jump address and encoding information mapping table from the encoding adjustment module in real time, storing it as well. This module is not within the tracking packet assembly module but is stored separately. Simultaneously, this module is designed with a communication interface with the software tracker, allowing the software tracker to read the mapping table and restore and display the encoding and jump address information. When the encoding adjustment module adjusts the second preset mapping relationship, the instruction address mapping module must promptly send a notification to the software tracker to reread the stored jump address and encoding information mapping table to complete the correct decoding of the encoding information.
[0094] This greatly reduces the amount of data in the jump address in the jump instruction (by 50%), and significantly reduces the total amount of data in the Trace packet, thereby improving the overall performance of the RISC-V CPU.
[0095] As can be seen, this invention adds a variable-length module, a payload creation module, and an instruction address mapping module, while optimizing the instruction trace packet assembly process. Non-jump instructions and jump instructions are processed in a single trace packet assembly module. Furthermore, the payload length indicator field in the header field of the trace data packet for jump instructions is designed with a variable length, selecting its width based on the actual payload length, thus significantly reducing the data volume of the trace data packet. The added payload creation module reduces the amount of data in the jump address within jump instructions by 50%, thereby reducing the total data volume of the trace data packet. The added instruction address mapping module stores the mapping relationship between jump instruction addresses and their encodings, enabling the software tracer to recover jump instructions. Simultaneously, the encoding information of the jump addresses is dynamically updated, further reducing the data volume of the compressed trace data packet. These multiple modules work together to significantly reduce the data volume of the RISC-V CPU Trace data packet, greatly minimizing the impact of the Trace function on RISC-V CPU performance and ensuring that the RISC-V CPU can achieve optimal performance.
[0096] This invention enables hardware design and proposes a hardware design scheme to optimize the RISC-V CPU Trace function. Specifically, all the aforementioned modules are hardware modules. The hardware implements a variable-length design for the payload_length field in the Trace packet header segment, flexibly setting the field width based on the payload length and ensuring correct parsing by subsequent modules. This significantly reduces the data volume of the Trace packet header segment in the RISC-V CPU. It also implements the encoding of jump addresses for jump instructions and ensures proper parsing by the software tracer, reducing the data volume of jump addresses in the payload segment by 50%. Simultaneously, it achieves dynamic updates and adjustments to the encoding, further reducing the data volume of the compressed Trace packet. This invention significantly reduces the data volume of the header and payload segments in the Trace packet while maintaining normal Trace functionality, lowering the total data volume of the RISC-V CPU Trace function, reducing the impact of the Trace function on RISC-V CPU performance, and ensuring that the RISC-V CPU can achieve optimal performance.
[0097] See Figure 6 As shown, an embodiment of the present invention provides a data tracking system, comprising:
[0098] The payload creation module 11 is used to create the payload of the tracking data packet corresponding to the instruction.
[0099] Length detection module 12 is used to detect the length of the payload and obtain the target length information of the payload;
[0100] The length mapping module 13 is used to determine the load length indication field corresponding to the target length information based on a first preset mapping relationship when the target length information is not zero, and obtain the target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field.
[0101] The length transmission module 14 is used to transmit the target payload length indication field to the tracking data packet compression module so that the tracking data packet compression module can determine the target length information.
[0102] Optionally, it also includes: a length indication signal generation module, used to generate a transmission completion indication signal and transmit the transmission completion indication signal to the tracking data packet compression module, so that the tracking data packet compression module can determine the target payload length indication field.
[0103] Optionally, the length indication signal generation module is further configured to: transmit an indication signal indicating that the target length information is zero to the tracking data packet compression module.
[0104] Optionally, the payload creation module specifically includes:
[0105] The jump instruction information encoding module is used to determine the jump address in the instruction information as the target jump address if the instruction type is a jump instruction, and to determine the encoding information corresponding to the target jump address from the second preset mapping relationship to obtain the target encoding information, wherein the proportion of the encoding information in the second preset mapping relationship is lower than the proportion of the jump address.
[0106] The payload packet assembly module is used to create a payload for tracking data packets using the target encoding information.
[0107] Optionally, it further includes: an encoding adjustment module, used to monitor the occurrence frequency of each jump address; adjust the second preset mapping relationship based on the occurrence frequency, so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address; wherein, the occurrence frequency of the first jump address is higher than the occurrence frequency of the second jump address.
[0108] Figure 6 The description of the features in the corresponding embodiments can be found in [reference needed]. Figure 2 The relevant descriptions of the corresponding embodiments will not be repeated here.
[0109] It is understood that if the data transmission tracking method in the above embodiments is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk, and other media capable of storing program code.
[0110] Based on this, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the data transmission tracking method described above. In optional embodiments, the computer program may be a program corresponding to a hardware description language.
[0111] Based on this, embodiments of the present invention also provide a computer program product, including a computer program / instructions, which, when executed by a processor, implements the aforementioned data transmission tracking method. In optional embodiments, the computer program can be a program corresponding to a hardware description language.
[0112] The foregoing has provided a detailed description of a data tracking method, system, medium, and product provided by embodiments of the present invention. The various embodiments are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0113] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0114] The present invention has provided a detailed description of a data tracking method, system, medium, and product. Specific examples have been used to illustrate the principles and implementation methods of the invention. The descriptions of these embodiments are merely illustrative of the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to the invention without departing from its principles, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A method for tracking data transmission, characterized in that, include: Create the payload of the tracking data packet corresponding to the instruction; The target length information of the payload is obtained by performing length detection on the payload. When the target length information is not zero, the load length indication field corresponding to the target length information is determined based on the first preset mapping relationship to obtain the target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field. The target payload length indication field is transmitted to the tracking packet compression module so that the tracking packet compression module can determine the target length information; Creating the payload of the tracking data packet corresponding to the instruction includes: determining the instruction type of the instruction; creating the payload of the tracking data packet based on the instruction type; if the instruction type is a jump instruction, then determining the jump address in the instruction information as the target jump address, determining the encoding information corresponding to the target jump address from a second preset mapping relationship, and obtaining target encoding information, wherein the proportion of the encoding information in the second preset mapping relationship is lower than the proportion of the jump address; and creating the payload of the tracking data packet using the target encoding information. The method further includes: monitoring the occurrence frequency of each jump address; adjusting the second preset mapping relationship based on the occurrence frequency, so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address, so as to improve the compression ratio; wherein, the occurrence frequency of the first jump address is higher than the occurrence frequency of the second jump address; Specifically, the packet type field, the compression indication signal field, and the target payload length indication field are transmitted sequentially to the tracking data packet compression module, and a transmission completion indication signal is transmitted to the tracking data packet compression module when the target payload length indication field is transmitted, so that the tracking data packet compression module can determine the target payload length indication field. After adjusting the second preset mapping relationship, the method further includes: notifying the tracker so that the tracker can obtain the adjusted second preset mapping relationship.
2. The data transmission tracking method according to claim 1, characterized in that, Also includes: If the target length information is zero, the load length indication field is canceled, and an indication signal indicating that the target length information is zero is transmitted to the tracking data packet compression module.
3. The data transmission tracking method according to claim 1, characterized in that, Determine the instruction type, including: Extract the opcode field of the instruction; The instruction type of the instruction is determined based on the opcode field, wherein the instruction type is a jump instruction or a non-jump instruction.
4. A data transmission tracking system, characterized in that, include: The payload creation module is used to create the payload of the tracking data packet corresponding to the instruction; A length detection module is used to detect the length of the payload and obtain the target length information of the payload; The length mapping module is used to determine the load length indication field corresponding to the target length information based on a first preset mapping relationship when the target length information is not zero, and obtain the target load length indication field; wherein, in the first preset mapping relationship, the proportion of bits of the load length indication field is the minimum number of bits that can characterize the length information corresponding to the load length indication field. A length transmission module is used to transmit the target payload length indication field to a tracking data packet compression module, so that the tracking data packet compression module can determine the target length information; Specifically, the payload creation module is used to determine the instruction type of the instruction and create a payload for the tracking data packet based on the instruction type. The payload creation module specifically includes: The jump instruction information encoding module is used to determine the jump address in the instruction information as the target jump address if the instruction type is a jump instruction, and to determine the encoding information corresponding to the target jump address from the second preset mapping relationship to obtain the target encoding information, wherein the proportion of the encoding information in the second preset mapping relationship is lower than the proportion of the jump address. The payload packet assembly module is used to create a payload for tracking data packets using the target encoding information; The system also includes: An encoding adjustment module is used to monitor the frequency of occurrence of each jump address; and adjust the second preset mapping relationship based on the frequency of occurrence so that the addressing information corresponding to the first jump address in the second preset mapping relationship is less than the addressing information corresponding to the second jump address, so as to improve the compression ratio; wherein the frequency of occurrence of the first jump address is higher than the frequency of occurrence of the second jump address; Specifically, the packet type field, the compression indication signal field, and the target payload length indication field are transmitted sequentially to the tracking data packet compression module, and a transmission completion indication signal is transmitted to the tracking data packet compression module when the target payload length indication field is transmitted, so that the tracking data packet compression module can determine the target payload length indication field. The system is also configured to: after adjusting the second preset mapping relationship, notify the tracker so that the tracker can obtain the adjusted second preset mapping relationship.
5. The tracking data transmission system according to claim 4, characterized in that, Also includes: The length indication signal generation module is used to generate a transmission completion indication signal.
6. The tracking data transmission system according to claim 4, characterized in that, The length indication signal generation module is further configured to: transmit an indication signal indicating that the target length information is zero to the tracking data packet compression module.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the data transmission tracking method as described in any one of claims 1 to 3.
8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the data transmission tracking method as described in any one of claims 1 to 3.