Log cache inflows to higher level caches by request

By detecting cache misses between processor cache levels and examining the data recorded in the upper-level cache, the performance and file size issues of existing tracking tools are resolved, enabling bit-precise time travel tracking.

CN111742301BActive Publication Date: 2024-11-08MICROSOFT TECHNOLOGY LICENSING LLC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980014496.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-04-06
Filing Date
2019-02-14
Publication Date
2024-11-08
Estimated Expiration
2039-02-14

AI Technical Summary

Technical Problem

Existing code debugging tools involve a trade-off between robustness and performance impact when recording trace data. In particular, hardware-assisted tracing methods have a significant impact on hardware design and cost, and also have a substantial impact on trace file size and performance.

Method used

By using at least two levels of processor caching mechanisms, when a cache miss is detected, the upper-level cache is checked to determine whether the data has been logged, reducing trace file size and performance impact, and employing hardware and/or microcode modifications to record bit-accurate time travel traces.

Benefits of technology

It effectively reduces the performance impact of tracking logs and the size of tracking files, achieves bit-precise execution tracking logs, and reduces the cost of hardware modifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111742301B_ABST
    Figure CN111742301B_ABST
Patent Text Reader

Abstract

Based on the tracking logging of the upper cache layer, determine how the lower cache layer logs the inflow. The second cache receives a logging request referencing a memory address from the lower first cache. The second cache determines whether it has a cache line for the memory address. When the cache line exists, the second cache forwards the request to the next logging cache layer, or if the second cache is the outermost logging layer, causes the cache line to be logged. When the cache line does not exist, when the cache line is not determined by the second cache to be logged, or when the cache line is determined by the second cache to be logged but it is not determined whether the first cache knows the current value of the cache line in the second cache, the second cache causes the cache line to be logged.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0001] When writing code during the development of a software application, developers typically spend a significant amount of time "debugging" the code to find runtime and other source code errors. In doing so, developers may employ several methods to reproduce and locate source code defects (bugs), such as observing the behavior of the program based on different inputs, inserting debugging code (e.g., printing variable values, tracing execution branches, etc.), temporarily deleting code sections, etc. Tracking down runtime errors to pinpoint code errors can take up a significant portion of application development time.

[0002] In order to assist developers in the code debugging process, many types of debugging applications ("debuggers") have been developed. These tools provide developers with the ability to track, visualize, and change the execution of computer code. For example, a debugger can visualize the execution of code instructions, can present code variable values ​​at different times during code execution, can enable developers to change the code execution path, and / or can enable developers to set "breakpoints" and / or "watchpoints" on code elements of interest ("breakpoints" and / or "watchpoints" are reached during execution, causing the execution of the code to be paused), etc.

[0003] Emerging forms of debugging applications enable "time travel," "reverse," or "historical" debugging. With "time travel" debugging, the execution of a program (e.g., an executable entity such as a thread) is recorded / traced by a tracing application into one or more trace files. These trace files can then be used to replay the execution of the program at a later time for forward and backward analysis. For example, a "time travel" debugger can enable a developer to set forward breakpoints / watchpoints (like a conventional debugger) as well as reverse breakpoints / watchpoints.

[0004] Several considerations may be taken into account when recording trace files. Most notably, there are inherent tradeoffs between the robustness of the recorded trace data and the overhead incurred by tracing the program. These tradeoffs are primarily in the size of the trace file and the performance impact on the execution of the traced program. Furthermore, since tracing may be done with hardware assistance (or entirely in software), there may also be hardware design and other hardware cost considerations. Summary of the invention

[0005] Embodiments described herein relate to mechanisms for creating bit-accurate "time travel" traces by a processor using hardware assistance. These mechanisms are based on using at least two levels (tiers) or layers of processor caches to track execution effects across multiple processing units. One mechanism modifies the hardware and / or microcode of the processor so that when it detects an influx (i.e., cache miss) to an internal or "lower" processor cache based on the activity of the processing unit being tracked, the mechanism checks one or more external or "upper" shared processor caches to determine whether the data of the influx has been logged on behalf of another processing unit being tracked. Another mechanism modifies the hardware and / or microcode of the processor so that one or more cache layers are configured to receive logging requests from (multiple) lower cache layers and use their knowledge of the cache lines being logged to determine how the influx (if any) to the lower cache layer should be logged. Either mechanism can enable influx to be logged by reference to previous log entries, and each mechanism can be extended to "N" level (level, also translated as level) caches. Using either mechanism to record trace files may require only modest processor modifications, and they can reduce the performance impact of trace recording and the size of trace files by several orders of magnitude compared to previous trace recording methods.

[0006] A first embodiment relates to a computing device(s) comprising a plurality of processing units, a plurality of N-level caches, and an (N+i)-level cache. The (N+i)-level cache is associated with two or more of the plurality of N-level caches and is configured as a backup repository for the plurality of N-level caches. In these embodiments, the computing device(s) comprises control logic that configures the computing device(s) to detect an influx into a first N-level cache of the plurality of N-level caches, and wherein the influx comprises data stored at a memory location. The control logic further configures the computing device(s) to check the (N+i)-level cache to determine whether the data for the memory location has been previously logged on behalf of the second processing unit. The control logic also configures the computing device(s) to perform one of the following based on the inspection: (i) causing data for the memory location to be logged on behalf of the first processing unit by reference to log data that was previously logged on behalf of the second processing unit (i.e., when data for the memory location was previously logged on behalf of the second processing unit), or (ii) causing data for the memory location to be logged by value on behalf of the first processing unit (i.e., when data for the memory location has not previously been logged on behalf of the second processing unit).

[0007] A second embodiment relates to a computing device (or devices) comprising a plurality of processing units and a plurality of caches arranged into a plurality of cache layers. The plurality of caches comprises a plurality of first caches within a first cache layer, and one or more second caches within a second cache layer. A particular second cache in the second cache layer serves as a backup repository for at least a particular first cache in the first cache layer. In these embodiments, the computing device (or devices) comprises control logic that configures at least a particular second cache to receive a logging request from a particular first cache with reference to a particular memory address. Based on the request, the particular second cache determines whether there is a cache line corresponding to the memory address in the particular second cache. When there is no cache line in the particular second cache, (i) when there is no third cache that participates in logging and acts as a backup repository for at least the particular second cache, the second cache causes the cache line to be logged; or (ii) when the third cache does exist, the second cache forwards the request to the third cache.

[0008] When a cache line exists in the particular second cache, the second cache causes the cache line to be logged (i) when the cache line is not determined to be logged by the particular second cache, or is determined to be logged by the particular second cache, but the particular second cache has not yet determined that the first cache knows the current value stored in the cache line of the particular second cache; or (ii) when the cache line is determined to be logged by the particular second cache and it is determined that the first cache knows the current value stored in the cache line of the particular second cache, the second cache determines that the cache line does not need to be logged.

[0009] Any embodiments described herein may also be implemented as method(s) performed by computing device(s) (e.g., such as a microprocessor) and / or as computer-executable instructions (e.g., processor microcode) stored on a hardware storage device and executable to perform the method(s).

[0010] This summary is provided to introduce some concepts in a simplified form, which are further described in the detailed description below. This summary is neither intended to identify key features or essential features of the claimed subject matter nor to be used as an aid in determining the scope of the claimed subject matter. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to describe the manner in which the above and other advantages and features of the present invention can be obtained, a more particular description of the invention briefly described above will be given by reference to specific embodiments of the invention illustrated in the accompanying drawings. Understanding that these drawings depict only typical embodiments of the invention and are therefore not to be considered limiting of the scope of the invention, the invention will be described and explained with additional specificity and detail through the use of the accompanying drawings, in which:

[0012] Figure 1An example computing environment is illustrated that facilitates recording a "bit accurate" execution trace across multiple processing units using at least two levels or layers of processor cache;

[0013] Figure 2A An example computing environment including multiple layers of cache is illustrated;

[0014] Figure 2B An example of caching is shown;

[0015] Figure 3 A flow chart of an example method for tracking and recording is illustrated, the tracking and recording being performed based on: recording inflows to a lower level cache by referring to previous log data based on knowledge of one or more upper level caches;

[0016] Figure 4A An example shared cache is illustrated wherein each cache line includes one or more additional bookkeeping bits;

[0017] Figure 4B An example of a shared cache is illustrated, the shared cache including one or more reserved cache lines for storing bookkeeping bits applied to regular cache lines;

[0018] Figure 5 An example of a set-associative mapping between system memory and cache is illustrated;

[0019] Figure 6 A flow chart illustrating an example method for an upper cache layer to determine how to log inflows to a lower cache layer based on a logging request from a lower cache layer;

[0020] Figure 7 A flow chart illustrating an example method for managing the logging state of a cache line when a processing unit transitions between enabling logging and disabling logging;

[0021] Figure 8 A flow chart illustrating an example method for managing the logging state of a cache line when a processing unit with logging disabled receives the cache line for writing only from a parent cache; and

[0022] Fig. 9 A flow chart illustrating an example method for managing the logging state of a cache line when a processing unit writes to a cache line that the processing unit is already in an “owned” cache coherence protocol state. DETAILED DESCRIPTION

[0023] Embodiments described herein relate to mechanisms for creating bit-accurate "time travel" traces by a processor using hardware assistance. These mechanisms are based on using at least two levels or layers of processor caches to track execution effects across multiple processing units. One mechanism modifies the hardware and / or microcode of the processor so that when it detects an influx (i.e., cache miss) to an internal or "lower" processor cache based on the activity of the processing unit being tracked, it checks one or more external or "upper" shared processor caches to determine whether the data of the influx has been logged by another processing unit being tracked. Another mechanism modifies the hardware and / or microcode of the processor so that one or more cache layers are configured to receive logging requests from (multiple) lower cache layers and use their knowledge of the cache lines being logged to determine how the influx (if any) to the lower cache layer should be logged. Either mechanism can enable influxes to be logged by reference to previous log entries, and each mechanism can be extended to "N" levels of cache. Using either mechanism to record trace files may require only modest processor modifications, and they can reduce the performance impact of trace recording as well as trace file size by several orders of magnitude when compared to previous trace recording methods.

[0024] Figure 1 An example computing environment 100 is illustrated that uses at least two levels or layers of processor cache to record "bit-accurate" execution traces across multiple processing units. As depicted, an embodiment may include or utilize a special-purpose or general-purpose computer system 101 that includes computer hardware such as, for example, one or more processors 102, system memory 103, one or more data repositories 104, and / or input / output hardware 105.

[0025] Embodiments within the scope of the present invention include physical and other computer-readable media for carrying or storing computer-executable instructions and / or data structures. Such computer-readable media can be any available media that can be accessed by the computer system 101. Computer-readable media that store computer-executable instructions and / or data structures are computer storage devices. Computer-readable media that carry computer-executable instructions and / or data structures are transmission media. Therefore, by way of example and not limitation, embodiments of the present invention may include at least two distinct types of computer-readable media: computer storage devices and transmission media.

[0026] Computer storage is a physical hardware device that stores computer-executable instructions and / or data structures. Computer storage includes various computer hardware such as RAM, ROM, EEPROM, solid-state drives ("SSD"), flash memory, phase-change memory ("PCM"), optical disk storage, magnetic disk storage or other magnetic storage, or any other hardware device(s) that can be used to store program code in the form of computer-executable instructions or data structures, and that can be accessed and executed by computer system 101 to implement the functionality disclosed herein. Thus, for example, computer storage can include the depicted system memory 103, the depicted data repository 104, or other storage devices (such as on-processor storage) as discussed later that can store computer-executable instructions and / or data structures.

[0027] Transmission medium can include network and / or data link that can be used for carrying program code in the form of computer executable instruction or data structure, and this program code can be visited by computer system 101." network " is defined as one or more data link that can transmit electronic data between computer system and / or module and / or other electronic equipment.When information is transmitted or provided to computer system by network or another communication connection (combination of hard-wired, wireless or hard-wired or wireless), computer system can be considered as transmission medium by connection.Above-mentioned combination also should be included in the scope of computer readable medium.For example, input / output hardware 105 can include the hardware (for example, network interface module (for example, " NIC ")) that can be used for network and / or data link that can be used for carrying program code in the form of computer executable instruction or data structure.

[0028] In addition, upon reaching various computer system components, program code in the form of computer-executable instructions or data structures may be automatically transferred from transmission media to computer storage devices (or vice versa). For example, computer-executable instructions or data structures received over a network or data link may be buffered in RAM within a NIC (e.g., input / output hardware 105) and then ultimately transferred to system memory 103 and / or a less volatile data storage device (e.g., data repository 104) at computer system 101. Thus, it should be understood that computer storage devices may be included in computer system components that also (or even primarily) utilize transmission media.

[0029] Computer executable instructions include, for example, instructions and data that cause computer system 101 to perform a specific function or group of functions when executed at processor(s) 102. Computer executable instructions may be, for example, binary, intermediate format instructions (e.g., assembly language), or even source code.

[0030] Those skilled in the art will appreciate that the present invention can be practiced in a network computing environment with many types of computer system configurations, including: personal computers, desktop computers, laptop computers, message processors, handheld devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, network PCs, minicomputers, mainframe computers, mobile phones, PDAs, tablet computers, pagers, routers, switches, etc. The present invention can also be practiced in a distributed system environment, in which local and remote computer systems with network links (through a hardwired data link, a wireless data link, or through a combination of a hardwired and wireless data link) perform tasks. Like this, in a distributed system environment, a computer system can include multiple component computer systems. In a distributed system environment, program modules can be located in local and remote memory storage devices.

[0031] Those skilled in the art will also appreciate that the present invention can be practiced in a cloud computing environment. A cloud computing environment can be distributed, but this is not required. When distributed, a cloud computing environment can be distributed internationally within an organization and / or have components owned across multiple organizations. In this specification and the appended claims, "cloud computing" is defined as a model for enabling on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage devices, applications, and services). The definition of "cloud computing" is not limited to any of the other numerous advantages that can be obtained from such a model when properly deployed.

[0032] The cloud computing model can consist of various characteristics, such as on-demand self-service, broad network access, resource pooling, rapid elasticity, measured services, etc. The cloud computing model can also take the form of various service models, such as, for example, software as a service ("SaaS"), platform as a service ("PaaS"), and infrastructure as a service ("IaaS"). The cloud computing model can also be deployed using different deployment models such as private cloud, community cloud, public cloud, hybrid cloud, etc.

[0033] Some embodiments (e.g., cloud computing environments) may include a system with one or more hosts, each capable of running one or more virtual machines. During operation, the virtual machine will emulate an operating computing system, thereby supporting an operating system and perhaps one or more other applications. In some embodiments, each host includes a hypervisor that emulates the virtual resources of the virtual machine using physical resources abstracted from the perspective of the virtual machine. The hypervisor also provides appropriate isolation between virtual machines. Thus, from the perspective of any given virtual machine, the hypervisor provides the illusion that the virtual machine is interfacing with physical resources, even if the virtual machine is only interfacing with the appearance of physical resources (e.g., virtual resources). Examples of physical resources include processing power, memory, disk space, network bandwidth, media drives, etc.

[0034] Figure 1 A simplified representation of the internal hardware components that comprise processor(s) 102. As shown, each processor 102 comprises multiple processing units 102a. Each processing unit may be physical (i.e., a physical processor core) and / or logical (i.e., a logical core provided by a physical core supporting hyperthreading, where more than one application thread executes at a physical core). Thus, for example, even though processor 102 in some embodiments comprises only a single physical processing unit (core), it may comprise two or more logical processing units 102a presented by the single physical processing unit.

[0035] Each processing unit 102a executes processor instructions defined by an application (e.g., tracer 104a, debugger 104b, operating kernel 104c, application 104d, etc.), and the instructions are selected from a predetermined processor instruction set architecture (ISA). The specific ISA of each processor 102 varies based on the processor manufacturer and processor model. Common ISAs include IA-64 and IA-32 architectures from INTEL, AMD64 architecture from ADVANCED MICRO DEVICES, and various Advanced RISC Machine ("ARM") architectures from ARMHOLDINGS, PLC, but a large number of other ISAs exist and can be used by the present invention. Typically, an "instruction" is the smallest externally visible (i.e., outside the processor) unit of code that can be executed by a processor.

[0036] Each processing unit 102a obtains processor instructions from one or more processor caches 102b and executes the processor instructions based on data in the cache(s) 102b, based on data in registers 102d, and / or in the absence of input data. In general, each cache 102b is a small amount (i.e., small relative to the typical amount of system memory 103) of random access memory that stores on-processor copies of portions of a backup storage repository (such as system memory 103 and / or another cache in the cache(s) 102b). For example, when executing application code 103a, one or more caches 102b contain certain portions of application runtime data 103b. If the processing unit(s) 102a requests data that is not yet stored in a particular cache 102b, a "cache miss" occurs, and the data is obtained from the system memory 103 or another cache, possibly "evicting" some other data from the cache 102b.

[0037] Typically, the processor cache(s) 102b are divided into separate hierarchies, layers or levels, such as level 1 (L1), level 2 (L2), level 3 (L3), etc. Depending on the processor implementation, the levels may be part of the processor 102 itself (e.g., L1 and L2) and / or may be separate from the processor 102 (e.g., L3). Thus, Figure 1 The cache(s) 102b may include one of these layers (L1), or may include multiple of these layers (e.g., L1 and L2, or even L3). To further understand these concepts, Figure 2A An example environment 200 illustrating multiple layers of caching is shown. Figure 2A In the example, there are two processors 201a and 201b (eg, each corresponding to Figure 1 different processors 102) and system memory 202 (e.g., corresponding to Figure 1 In the example environment 200, each processor 201 includes four physical processing units (ie, units A1-A4 for processor 201a and units B1-B4 for processor 201b).

[0038] The example environment 200 also includes a three-level cache hierarchy within each processing unit 201. Environment 200 is merely an example layout and is not limited to a cache hierarchy in which the embodiments herein may operate. In environment 200, at the bottom or innermost level, each processing unit is associated with its own dedicated L1 cache (e.g., L1 cache "L1-A1" in processor 201a is used for unit A1, L1 cache "L1-A2" in processor 201a is used for unit A2, etc.). Moving up one level, each processing unit 201 includes two L2 caches (e.g., L2 cache "L2-A1" in processor 201a used as a backup repository for L1 caches L1-A1 and L1-A2, L2 cache "L1-A2" in processor 201a used as a backup repository for L1 caches L1-A3 and L1-A4, etc.). Finally, at the highest or outermost level, each processing unit 201 includes a single L3 cache (e.g., L3 cache "L3-A" in processor 201a that serves as a backing store for L2 caches L2-A1 and L2-A2, and L3 cache "L3-B" in processor 201b that serves as a backing store for L2 caches L2-B1 and L2-B2). As shown, system memory 202 serves as a backing store for L3 caches L3-A and L3-B.

[0039] like Figure 2A As shown, when multiple cache layers are used, processing unit(s) 102a typically interact directly with the lowest layer (L1). In most cases, data flows between the layers (e.g., on reads, the L3 cache interacts with system memory 103 and serves data to the L2 cache, which in turn serves data to the L1 cache). When processing unit 102a performs a write operation, the caches coordinate to ensure that those caches that have affected data shared between processing unit(s) 102a no longer have the data. This coordination is performed using the CCP.

[0040] The caches in environment 200 may therefore be viewed as "shared" caches. For example, each L2 and L3 cache serves multiple processing units within a given processor 201 and is therefore shared by the processing units. Even though each cache corresponds to a single processing unit, the L1 cache in a given processor 201 may be viewed as shared overall because the individual L1 caches may be coordinated with each other (i.e., via CCP) to ensure consistency (i.e., so that the memory locations of each cache are viewed consistently across all L1 caches). Similarly, the L2 caches within each processor 201 may be coordinated via CCP. Additionally, if processor 201 supports hyperthreading, each individual L1 cache may be viewed as shared by two or more logical processing units and may therefore be "shared" even at an individual level.

[0041] Typically, each cache includes multiple “cache lines.” Each cache line stores a memory block from its backing store (e.g., system memory 202 or a higher-level cache). For example, Figure 2B An example of at least a portion of a cache 203 is illustrated, the cache 203 including a plurality of cache lines 206, each cache line 206 including at least an address portion 204 and a value portion 205. The address portion 204 of each cache line 206 is configured to store an address in the system memory 202 to which the cache line corresponds, and the value portion 205 initially stores a value received from the system memory 202. The value portion 205 may be modified by the processing unit and eventually evicted back to the backup storage repository. As indicated by the ellipsis, the cache 203 may include a large number of cache lines. For example, a contemporary 64-bit INTEL processor may include a separate L1 cache with 512 or more cache lines. In such a cache, each cache line may typically be used to store a 64-byte (512-bit) value for a 6-byte (48-bit) to 8-byte (64-bit) memory address. As shown in FIG. Figure 2A As intuitively shown, cache size generally increases with each level (i.e., L2 cache is generally larger than L1 cache, L3 cache is generally larger than L2 cache, etc.).

[0042] The addresses stored in the address portion 204 of each cache line 206 may be physical addresses such as actual memory addresses in the system memory 202. Alternatively, the addresses stored in the address portion 204 may be virtual addresses, which are addresses that are mapped to physical addresses to provide an abstraction (e.g., using a page table managed by an operating system). Such an abstraction may be used, for example, to facilitate memory isolation between different processes executing at the processor(s) 102, including isolation between user mode processes and kernel mode processes associated with the operating system kernel 104b. When virtual addresses are used, the processor 102 may include a translation lookaside buffer (TLB) 102f (typically part of a memory management unit (MMU)) that maintains recently used memory address mappings between physical addresses and virtual addresses.

[0043] The (multiple) caches 102b may include a code cache portion and a data cache portion. When the application code 103a is executed, the (multiple) code portions of the (multiple) caches 102b may store at least a portion of the processor instructions stored in the application code 103a and the (multiple) data portions of the (multiple) caches 102b may store at least a portion of the data structure of the application runtime data 103b. In addition, the cache may be inclusive, exclusive, or may include both inclusive and exclusive behaviors. For example, in an inclusive cache, the L3 layer typically stores a superset of data in the L2 layer below the L3 layer, and the L2 layer stores a superset of the L1 layer below them. In an exclusive cache, the layers may not intersect, for example, if there is data in the L3 cache that the L1 cache needs, they may exchange information, such as data, addresses, etc.

[0044] Back to Figure 1 Each processor 102 also includes microcode 102c, which includes control logic (i.e., executable instructions) that controls the operation of the processor 102, and which typically acts as an interpreter between the processor's hardware and the processor ISA exposed by the processor 102 to executing applications. The microcode 102 is typically embodied in an on-processor storage device such as a ROM, EEPROM, or the like.

[0045] Registers 102d are hardware-based storage locations that are defined based on the ISA of the processor(s) 102 and are read and / or written to by processor instructions. For example, registers 102d are typically used to store values ​​obtained from cache(s) 102b for use by instructions, store results of executing instructions, and / or store status or conditions (such as some side effects of executing instructions (e.g., the sign of a value changing, a value reaching zero, the occurrence of a carry, etc.)), processor cycle counts, etc. Therefore, some registers 102d may include a "flag" for signaling a certain state change caused by executing a processor instruction. In some embodiments, the processor 102 may also include control registers for controlling different aspects of the processor's operation. Although Figure 1 The registers 102d are depicted as a single block, but it will be understood that each processing unit 102a typically includes one or more corresponding register sets 102d that are specific to that processing unit.

[0046] In some embodiments, the processor(s) 102 may include one or more buffers 102e. As will be discussed below, the buffer(s) 102e may be used as a temporary storage location for trace data. Thus, for example, the processor(s) 102 may store portions of trace data in the buffer(s) 102e and, at appropriate times (e.g., when there is available memory bus bandwidth and / or idle processor cycles), flush the data to the trace data repository 104e.

[0047] As described above, the processor operates on the cache(s) 102b according to one or more CCPs. In general, the CCP defines how the consistency between data between the various caches 102b is maintained when the various processing units 102a read and write data from the various caches 102b, and how to ensure that the various processing units 102a always read valid data from a given location in the cache(s) 102b. The CCP is associated with and enables the memory model defined by the ISA of the processor 102.

[0048] Examples of general CCPs include the MSI protocol (i.e., modified, shared, and invalid), the MESI protocol (i.e., modified, exclusive, shared, and invalid), and the MOESI protocol (i.e., modified, owned, exclusive, shared, and invalid). Each of these protocols defines a state for a single location (e.g., a line) in the cache(s) 102b. A "modified" cache location contains data that has been modified in the cache(s) 102b and therefore may be inconsistent with corresponding data in a backing store (e.g., system memory 103 or another cache). When a location with a "modified" state is evicted from the cache(s) 102b, the general CCP requires the cache to ensure that its data is written back to the backing store, or that another cache takes over the responsibility. A "shared" cache location contains data that has not been modified from the data in the backing store, exists in a read-only state, and is shared by the processing unit(s) 102a. The cache(s) 102b can evict the data without having to write it to the backing store. An "invalid" cache location contains no valid data and can be considered empty and can be used to store data for cache misses. An "exclusive" cache location contains data that matches a backup storage repository and is only used by a single processing unit 102a. The data can be changed to a "shared" state at any time (i.e., in response to a read request), or can be changed to a "modified" state when it is written. An "owned" cache location is shared by two or more processing units 102a, but one of the processing units has exclusive rights to change it. When the process is changed, it can notify the other processing units because they may need to invalidate or update their own cache based on the CCP implementation.

[0049] Data repository 104 may store computer executable instructions representing application programs, such as, for example, tracer 104a, debugger 104b, operating system kernel 104c, and application 104d (e.g., the application that is the subject of tracing by tracer 104a). When these programs are executing (e.g., using processor(s) 102), system memory 103 may store corresponding runtime data, such as runtime data structures, computer executable instructions, etc. Thus, Figure 1 System memory 103 is illustrated as including application code 103a and application runtime data 103b (e.g., each corresponding to application 104g). Data repository 104 may further store data structures, such as trace data stored in one or more trace data repositories 104e. As indicated by ellipsis 104f, data repository 104 may also store other computer executable instructions and / or data structures.

[0050] The tracer 104a may be used to record a bit accurate execution trace of one or more entities (e.g., one or more threads of an application 104d or a kernel 104c) and store the trace data in a trace data repository 104e. In some embodiments, the tracer 104a is a standalone application, while in other embodiments, the tracer 104a is integrated into another software component (such as a kernel 104c, a hypervisor, a cloud fabric, etc.). Although the trace data repository 104e is depicted as part of the data repository 104, the trace data repository 104e may also be at least partially embodied in the system memory 103, in the cache(s) 102b, in the buffer(s) 102e, or at some other storage device.

[0051] As mentioned, the tracer 104a records a bit-accurate execution trace of one or more entities. As used herein, a "bit-accurate" trace is a trace that includes data sufficient to enable code previously executed at one or more processing units 102a to be replayed such that it executes in substantially the same manner as during the trace. There are a variety of methods that the tracer 104a can use to record a bit-accurate trace, each with various advantages and disadvantages (e.g., in terms of trace overhead, trace file size, amount of processor modification required, etc.). Some specific embodiments for recording such data are described later in conjunction with Figures 3 to 9 Let's discuss.

[0052] Regardless of which recording method the tracer 104a uses, it can record the trace data into one or more trace data repositories 104e. As an example, the trace data repository 104e may include one or more trace files, one or more regions of the system memory 103, one or more regions of the processor cache 102b (e.g., L2 or L3 cache), a buffer 102d in the processor 102, or any combination thereof or multiple thereof. The trace data repository 104e may include one or more trace data streams. In some embodiments, for example, multiple entities (e.g., processes, threads, etc.) may each be traced to a separate trace file or a trace data stream within a given trace file. Alternatively, the data packets corresponding to each entity may be marked so that they are identified as corresponding to the entity. If multiple related entities (e.g., multiple threads of the same process) are to be traced, the trace data for each entity may be tracked independently (so that they can be replayed independently), but any events that are sequenceable across entities (e.g., access to shared memory) may be identified using a sequence number (e.g., a monotonically increasing number) that is global across independent traces. The tracking data repository 104e can be configured for flexible management, modification and / or creation of tracking data streams. For example, modification of an existing tracking data stream may involve modification of an existing tracking file, replacement of portions of tracking data within an existing file, and / or creation of a new tracking file including the modification.

[0053] In some implementations, the tracer 104a may be continuously attached to the (multiple) trace data streams so that the trace data grows continuously during the trace. However, in other implementations, the trace data streams may be implemented as one or more circular buffers. In such an implementation, as new trace data is added to the trace data repository 104e, the oldest trace data is removed from the (multiple) data streams. Thus, when the trace data streams are implemented as (multiple) buffers, they contain rolling traces that were recently executed at the (multiple) processes being traced. The use of a circular buffer may enable the tracer 104a to always participate in tracing even in a production system. In some implementations, tracing may be enabled and disabled at virtually any time, such as by setting or clearing one or more bits in one or more control registers. Thus, whether tracing is to a circular buffer or attached to a conventional trace data stream, the trace data may include gaps between periods during which tracing is enabled for one or more processing units 102a.

[0054] The debugger 104b may be used to consume (e.g., replay) the trace data generated by the tracer 104a into the trace data repository 104e to assist a user in performing debugging actions on the trace data (or derivatives thereof). For example, the debugger 104b may present one or more debugging interfaces (e.g., user interfaces and / or application programming interfaces), replay before execution of one or more portions of the application 104d, set breakpoints / watchpoints (including reverse breakpoints / watchpoints), enable queries / searches on the trace data, etc.

[0055] Returning to the tracer 104a, in embodiments herein, the tracer 104a utilizes the cache(s) 102b of the processor 102 to effectively record a bit-accurate execution trace of the application 104d and / or the operating system kernel 104c. These embodiments are established based on the following observations of the inventors: the processor 102 (including the cache(s) 102b) forms a semi-closed or quasi-closed system. For example, once the portions of data for a process (i.e., code data and runtime application data) are loaded into the cache(s) 102b, the processor 102 can operate on its own in a semi-closed or quasi-closed system in a time burst without any input. In particular, once the cache(s) 102b are loaded with data, one or more processing units 102a use the runtime data stored in the data portion(s) of the cache(s) 102b and use registers 102d to execute instructions from the code portion(s) of the cache(s) 102b.

[0056] When processing unit 102a requires some influx of information (e.g., because an instruction it is executing, about to execute, or may execute accesses code or runtime data that is not yet in cache(s) 102b), a "cache miss" occurs and the information is brought into cache(s) 102b from system memory 103. For example, if a data cache miss occurs when an executed instruction performs a memory operation at a memory address within application runtime data 103b, the data from that memory address is brought into one of the cache lines of the data portion of cache(s) 102b. Similarly, if a code cache miss occurs when an instruction performs a memory operation at a memory address application code 103a stored in system memory 103, the code from that memory address is brought into one of the cache lines of the code portion of cache(s) 102b. Processing unit 102a then continues execution using the new information in cache(s) 102b until new information is again brought into cache(s) 102b (e.g., due to another cache miss or an uncached read).

[0057] The inventors have also observed that in order to record a bit-accurate representation of the execution of an application, the tracer 104a may record sufficient data to reproduce the influx of information into the cache(s) 102b as the processing units execute the threads(es) of the application. For example, a method of recording these influxes operates on a per-processing unit basis and at the innermost cache layer (e.g., L1). The method may involve, for each processing unit being traced, recording all cache misses and uncached reads (i.e., reads from hardware components and non-cacheable memory) associated with the L1 cache of the processing unit, and the time at which each data fragment was introduced into the L1 cache of the processing unit during execution (e.g., using an executed instruction count or some other counter). If there are events that can be ordered across processing units (e.g., accesses to shared memory), these events may be logged across the resulting data streams (e.g., by using a monotonically increasing (or decreasing) number (MIN) across the data streams).

[0058] However, since the L1 cache layer may include a plurality of different L1 caches, each of the L1 caches is associated with a different physical processing unit (e.g., Figure 2A ), so logging in this manner may record duplicate data, and therefore more data is strictly required for a "full-fidelity" trace. For example, if multiple physical processing units read from the same memory location (which may often happen in multi-threaded applications), then this approach can log cache misses for the same memory location as well as data for each of the multiple physical processing units. It is worth noting that, as used herein, a "full-fidelity" trace is any trace that contains enough information to enable a complete replay of the traced entity (even though a particular "full-fidelity" trace may actually contain less data that encapsulates the same information than might be recorded using alternative tracing techniques).

[0059] To further reduce the size of the trace file, the inventors have developed improved recording techniques that utilize one or more upper-level caches to avoid recording at least a portion of the duplicate data. Instead, these improved techniques can log by referencing previously logged data, or avoid logging in many cases.

[0060] Logging cache misses at lower cache layers based on knowledge that the processor has checked one or more higher cache layers

[0061] In a first embodiment, a processor detects an influx (i.e., a cache miss) to an internal or "lower level" processor cache (e.g., L1) based on activity of a first processing unit (e.g., reading from a particular memory address), and then checks one or more external or "upper level" shared processor caches to determine if the same data influx (i.e., the same memory address and the same value read by the first processing unit) has already been logged on behalf of a second tracked processing unit. If so, the processor can log the later influx by the first process by referencing the previous influx to the second processing unit, if possible.

[0062] To understand these embodiments, note that in most environments, the upper cache is larger than the lower caches below it, and it is often the backing store for multiple lower caches. Figure 2A In the example environment of , each L2 cache is a backing store for two L1 caches, and each L3 cache is a backing store for two L2 caches (and by extension four L1 caches). Thus, an upper cache can retain knowledge about multiple lower caches (e.g., Figure 2A By leveraging knowledge of one or more upper cache layers, embodiments herein enable multiple opportunities to log influx caused by one processing unit by referencing influx that has been logged on behalf of other processing units.

[0063] According to these first embodiments, Figure 3 An example of a method 300 for tracking and recording inflows to a lower level cache by referencing previous log data based on knowledge of one or more upper level caches is illustrated. Figure 3 exist Figure 1 and Figure 2A , Figure 2B is described in the context of.

[0064] In particular, Figure 3Operating in an environment such as processor 102 or 201a, processor 102 or 201a includes multiple processing units, multiple N-level caches, and an (N+i)-level cache associated with two or more of the multiple N-level caches and configured as a backing store for the multiple N-level caches. In method 300 (and in the claims), N and i are positive integers, i.e., N≥1, such that N is equal to 1, 2, 3, etc.; and i≥1, such that i is equal to 1, 2, 3, etc. For example, referring to Figure 2A Processor 201a includes multiple processing units A1, A2, etc. Processor 201a also includes multiple N-level caches L1-A1, L1-A2, etc. (i.e., where N is equal to 1). Processor 201a also includes an (N+i)-level cache associated with two or more of the multiple N-level caches and configured as a backup storage for the multiple N-level caches. For example, processor 201a includes an (N+i)-level cache L2-A1 as a backup storage for N-level caches L1-A1 and L1-A2 (i.e., where N is equal to 1 and i is equal to 1). In another example, processor 201a includes an (N+i)-level cache L3-A as a backup storage for N-level caches L1-A1, L1-A2, etc. (i.e., where N is equal to 1 and i is equal to 2). Processor 102 / 201a operates method 300 based on control logic such as microcode 102c and / or circuit logic.

[0065] As shown, method 300 includes act 301, which is to detect an influx to a level N cache during execution at a first processing unit. In some embodiments, act 301 includes detecting an influx to a first level N cache of a plurality of level N caches, the influx including data stored at a memory location. For example, based on the activity of processing unit A1 (such as a requested memory access to system memory 202 (e.g., caused by normal or speculative execution of a first thread of application 104c)), a cache miss may occur in cache L1-A1 (i.e., when N is equal to 1). In this way, a line of cache L1-A1 obtains a data influx (including a then-current value of the requested memory location). Depending on the cache attributes (e.g., which higher-level layers exist, whether the cache architecture is inclusive or exclusive, etc.) and the current cache state, the influx can originate from system memory 202 or a higher-level cache (e.g., L2-A1 and / or L3-A).

[0066] Method 300 also includes an action 302 of checking the (N+i) level cache based on execution at the second processing unit to determine whether the data of the influx has been logged. In some embodiments, action 302 includes: based on detecting the influx to the first N level cache, checking the (N+i) level cache to determine whether the data for the memory location has been previously logged by the second processing unit. For example, if i is equal to 1, so that the (N+i) level cache includes the (N+1) level cache, the processor 201 can check the L2 cache (such as, L2-A1) (which has knowledge of cache L1-A2 and processing unit A2). This check can be used to determine whether the data for the memory location has been previously logged on behalf of processing unit A2. For example, based on a previous execution of a second thread of application 104c at processing unit A2 that caused a cache miss in cache L1-A2, the data has been previously logged. In an alternative example, if i is equal to 2, such that the (N+i) level cache includes the (N+2) level cache, the processor 201 may check an L2 cache, such as cache L3-A (which has knowledge of all other caches in the processor 201). This check may be used to determine whether data for the memory location has been previously logged on behalf of any of the processing units A2-A4 (e.g., based on previous execution of one or more other threads of the application 104c at one or more processing units A2-A4 that caused a cache miss in cache(s) L1-A2, L1-A3, and / or L1-A4). Note that in this second example, the L2 cache may be skipped in the check.

[0067] As shown, action 302 may be repeated any number of times, while incrementing the value of i each time. Although i is typically incremented by 1 each time, there may be embodiments in which i is incremented by a positive integer greater than 1. The effect of repeating action 302 is that multiple upper-level caches will be checked when i is incremented. For example, if i=1, when action 302 is initially executed, processor 201 may check the L2 cache layer (e.g., L2-A1 and / or L2-A2). If sufficient knowledge about applicable memory locations is not found in the L2 cache, processor 201 may repeat action 302 with i=2, thereby checking the L3 cache layer (e.g., L3-A). This situation can continue for as many cache layers as the computing environment provides. If the value of i incremented is greater than 1, one or more cache layers along the way can be skipped. It will be understood that checking multiple cache layers may be beneficial in architectures that provide exclusive caches or provide caches that exhibit mixed inclusive / exclusive behavior. This is because in these architectures, it may not be guaranteed that the outer cache layer contains a complete superset of the data in the (multiple) inner cache layers.

[0068] In view of the foregoing, it will be appreciated that method 300 may operate in an environment such as processor 102 or 201a where i is equal to 1, such that the (N+i) level cache includes the (N+1) level cache, and the processor also includes an (N+2) level cache configured as a backup repository for the (N+1) level cache. In these environments, checking the (N+1) level cache to determine whether data for the memory location has been previously logged on behalf of the second processing unit (i.e., action 302) may include: determining that no cache line in the (N+1) level cache corresponds to the memory location. In addition, checking the (N+2) level cache to determine whether data for the memory location has been previously logged on behalf of the second processing unit.

[0069] As shown, based on the result of act 302 , the method includes act 303 : logging the inflow by reference when the data has been logged; or act 304 : logging the inflow by value when the data has not been logged.

[0070] In some embodiments, action 303 includes: when data for the memory location has been previously logged on behalf of the second processing unit, causing the data for the memory location to be logged on behalf of the first processing unit by referencing log data that was previously logged on behalf of the second processing unit. Continuing with the above example, for example, if checking the (N+1) level cache L2-A1 and / or checking the (N+2) level cache L3-A results in the following determination: the data / memory location has been logged on behalf of processing unit A2 (based on the influx to cache L1-A2), then processor 201a can cause the influx to cache L1-A1 to be logged on behalf of processing unit A1 by referencing the log entry created for processing unit A2. An example of how logging by reference is accomplished will be given later.

[0071] Turning to the alternative result of action 302, in some embodiments, action 304 includes: when the data for the memory location has not yet been logged on behalf of the second processing unit, causing the data for the memory location to be logged by value on behalf of the first processing unit. For example, if checking the (N+1) level cache L2-A1 and / or checking the (N+2) level cache L3-A causes the following determination: the data / memory location has not yet been logged on behalf of another processing unit, then the processor 201a causes the inflow to cache L1-A1 to be logged by value on behalf of processing unit A1. Logging by value can include, for example, logging memory addresses and memory values ​​in data packets for processing unit A1. Note that logging by value can include any number of compression techniques to reduce the number of bits required to complete the actual logging.

[0072] As combined Figure 1As described, the processor(s) 102 may include buffer(s) 102e that may be used to temporarily store trace data. Thus, in method 300, "causing" different types of data to be logged may include the processor 102 storing such data in buffer(s) 102e. Additionally or alternatively, it may include the processor 102 transmitting such data to the tracer 104a, writing such data to the trace data repository 104e, and / or notifying the tracer 104a that data is available in buffer(s) 102d. In some embodiments, buffer(s) 102d may include one or more reserved portions of cache(s) 102b. Thus, using buffer(s) 102e, in act 304 / 304, causing data for a memory location to be logged on behalf of the first processing unit (by reference or by value) may include delaying logging based on the availability of resources such as processor cycles, memory locations, bus bandwidth, etc. In embodiments where buffer(s) 102d comprise one or more retained portions of cache(s) 102b, the delayed logging may include invalidating a cache line (in the level N cache and / or the (N+i) level cache) rather than evicting it in order to retain data for the memory location for purposes of delayed logging.

[0073] The description of method 300 has been directed to an upper cache having "knowledge" about lower caches. The specific form of "knowledge" retained by the upper cache about lower caches may vary, as exemplified below.

[0074] In a basic form, this "knowledge" can simply be that there is a cache line in the upper level cache that corresponds to a cache line in the lower level cache (i.e., a cache line corresponding to the same memory location and memory data). As mentioned above, in an inclusive cache, the upper level (s) store a superset of the data in the level (s) below them. For example, suppose Figure 2AThe cache in is inclusive. In this case, when the activity of processing unit A2 causes a location from system memory 202 to be imported into cache L1-A2, the same memory location is also cached in caches L2-A1 and L3-A. If the activity of processing unit A2 is being tracked, an embodiment may cause the memory location and its value to be logged on behalf of processing unit A2. Later, if the activity of processing unit A1 causes the same location from system memory 202 to be imported into cache L1-A1, and the location still stores the same data, the location is provided from cache L2-A1 because cache L2-A1 already has the data. The prior art may log the data again for processing unit A1 based on the influx into cache L2-A1. However, embodiments herein may alternatively recognize that the memory location and its value already exist in cache L2-A1, and therefore already exist in cache L1-A2. Because processing unit A2 is being logged, an embodiment may recognize that the memory location and its value have been logged on behalf of processing unit A2 and therefore cause this new activity of processing unit A1 to be logged with reference to the log data previously logged on behalf of processing unit A2.

[0075] More elaborate forms of "knowledge" of upper-level caches are also possible. For example, embodiments may extend cache lines in one or more cache layers with additional "accounting" (or logging) bits that enable processor 102 to identify, for each cache line that implements the accounting bits, whether the cache line has been logged (possibly with the identity of the processing unit(s) that logged the cache line). To understand these concepts, Figure 4A The diagram is similar to Figure 2B 4 , wherein each of the cache lines 404 includes one or more additional accounting bits 401 . Thus, each cache line 404 includes (a plurality of) accounting bits 401 , conventional address bits 402 , and value bits 403 .

[0076] Alternatively, Figure 4B An example of a shared cache 400b is illustrated, which includes a regular cache line 405 storing a memory address 402 and a value 403, and one or more reserved cache lines 406 for storing accounting bits applicable to the regular cache line 405. The bits of the reserved cache line(s) 405 are assigned to different accounting bit groups, and the accounting bits each correspond to a different one of the plurality of regular cache lines 405.

[0077] In the example Figure 4BIn a variation of , (multiple) reserved cache lines 406 can be reserved as one (or more) ways in each index of a set associative cache (which will be discussed in detail later). For example, in an 8-way set associative cache, one way in a set can be reserved for bookkeeping bits applicable to the other seven ways in the set. Since all ways in a given set are typically read in parallel by most processors, this can reduce the complexity of implementing reserved cache lines and can speed up access to reserved cache lines.

[0078] Regardless of how the accounting bits are actually stored, the accounting bits (multiple) 401 for each cache line may include one or more bits used as a flag (i.e., turned on or off) that is used by the processor (multiple) 102 to indicate whether the current value in the cache line represents a processing unit being logged (or, alternatively, whether it is consumed by a processing unit participating in logging). Therefore, the check in action 302 may include using the flag to determine whether the cache line has been logged by a processing unit participating in logging.

[0079] Alternatively, the accounting bits 401 for each cache line may include multiple bits. Multiple bits can be used in several ways. Using a method referred to herein as "unit bits", the accounting bits 401 for each cache line may include a number of unit bits equal to the number of processing units 102a of the processor 102 (e.g., the number of logical processing units if the processor 102 supports hyperthreading, or the number of physical processing units if hyperthreading is not supported). These unit bits can be used by the processor 102 to track which or which specific processing units have logged the cache line (if any). Therefore, for example, a cache shared by two processing units 102a can associate two unit bits with each cache line.

[0080] In another approach using multiple accounting bits 401 (referred to herein as "index bits"), the accounting bits 401 for each cache line may include multiple index bits sufficient to represent an index to each processing unit 102a of the processor 102 of the computer system 101 that participates in logging, as well as a possible "reserved" value (e.g., -1). For example, if the processor 102 includes 128 processing units 102a, these processing units can be identified per cache line by an index value (e.g., 0-127) using only seven index bits. In some embodiments, one index value is reserved (e.g., "invalid") to indicate that no processor has logged the cache line. Thus, this would mean that the seven index bits would actually be able to represent 127 processing units 102a, plus the reserved value. For example, binary values ​​0000000-1111110 may correspond to index positions 0-126 (decimal), and binary value 1111111 (e.g., -1 or 127 in decimal, depending on interpretation) may correspond to "invalid" to indicate that no processor has logged the corresponding cache line, but such notation may vary depending on implementation. Thus, the unit bit may be used by processor 102 to indicate whether a cache line has been logged (e.g., a value other than -1) and as an index to a particular processing unit that logged the cache line (e.g., a processing unit that most recently consumed the cache line). This second approach of using multiple accounting bits 401 has the advantage of supporting a large number of processing units in cache 102b with little overhead, and the disadvantage of having a smaller granularity than the first approach (i.e., only one processing unit is identified at a time).

[0081] In view of the foregoing, it will be understood that in action 302, checking the (N+i) level cache to determine whether data for the memory location has previously been logged on behalf of the second processing unit includes: determining whether the cache line corresponding to the memory location in the (N+i) level cache has one or more accounting bits set.

[0082] Another mechanism that can be used to determine whether a cache line has been logged is to utilize set associative caches and way-locking. Since the processor's cache 102b is typically much smaller than the system memory 103 (typically by several orders of magnitude), there are typically many more memory locations in the system memory 103 than there are rows in any given layer of the cache 102b. As such, some processors define a mechanism for mapping multiple memory locations of the system memory to (multiple) rows of one or more cache layers. Processors typically employ one of two general techniques: direct mapping and associative (or set associative) mapping. Using direct mapping, different memory locations in the system memory 103 are mapped to only one row in the cache layer, so that each memory location can only be cached in a specific row in that layer.

[0083] On the other hand, using set associative mapping, different locations in system memory 103 may be cached to one of multiple lines in the cache layer. Figure 5 An example 500 of a set associative mapping between a system memory and a cache is illustrated. Here, cache lines 504 of a cache layer 502 are logically divided into two different groups of cache lines, including a first group of two first cache lines 504a and 504b (identified as index 0), and a second group of two cache lines 504c and 504d (identified as index 1). Each cache line in a group is identified as a different "way", such that cache line 504a is identified by index 0, way 0, cache line 504b is identified by index 0, way 1, and so on. As further depicted, memory locations 503a, 503c, 503e, and 503g (memory indexes 0, 2, 4, and 6) are mapped to index 0. As such, each of these locations in the system memory can be cached to any cache line at index 0 within the group (i.e., cache lines 504a and 504b). The particular pattern of mapping depicted is for illustrative and conceptual purposes only and should not be construed as the only way that memory indexes can be mapped to cache lines.

[0084] A set-associative cache is often referred to as an N-way set-associative cache, where N is the number of "ways" in each set. Figure 5 The cache 500 will be referred to as a 2-way set associative cache. Processors typically implement an N-way cache where N is a power of 2 (e.g., 2, 4, 8, etc.), where the value of N is typically selected to be 4 and 8 (although the embodiments herein are not limited to any particular N value or subset of N values). It is noteworthy that a 1-way set associative cache is typically equivalent to a direct mapped cache in that each set contains only one cache line. Additionally, if N is equal to the number of lines in the cache, it is referred to as a fully associative cache because it includes a single set containing all lines in the cache. In a fully associative cache, any memory location can be cached to any line in the cache.

[0085] Notice, Figure 5 A simplified view of system memory and cache is shown to illustrate the general principles. Figure 5 Individual memory locations are mapped to cache lines, but it should be understood that each line in the cache may store data associated with multiple addressable locations in system memory. Figure 5 In the example, each location (503a-503h) in the system memory (501) may actually represent multiple addressable memory locations. Additionally, the mapping may be between actual physical addresses in the system memory 501 and lines in the cache 502, or an intermediate layer of virtual addresses may be used.

[0086] A set associative cache may be used to determine whether a cache line has been logged by using way locking. Way locking locks or reserves one or more ways in a cache for a certain purpose. In particular, embodiments herein utilize way locking to reserve one or more ways for a processing unit being tracked, such that the locked / reserved ways are dedicated to storing cache misses associated with the execution of that unit. Therefore, again referring to Figure 5 , if "way 0" is locked for the tracked processing unit, then cache lines 504a and 504c (i.e., index 0, way 0 and index 1, way 0) will be dedicated to cache misses associated with the execution of that unit, and the remaining cache lines will be used for all other cache misses. Therefore, to determine whether a particular cache line has been logged, processor 102 only needs to determine whether the cache line stored in the "N+1" cache layer is part of a way that has been reserved for the tracked processing unit.

[0087] In view of the foregoing, it will be understood that in action 302, checking the (N+i) level cache to determine whether data for the memory location has previously been logged on behalf of the second processing unit includes: determining whether the cache line corresponding to the memory location in the (N+i) level cache is stored in the way corresponding to the logged processing unit.

[0088] As previously explained, caches operate according to CCPs, which define how consistency is maintained between various caches when a processing unit reads from and writes cache data, and how to ensure that a processing unit always reads valid data from a given location in the cache. In this way, in conjunction with operating the cache, the processor 102 maintains and stores CCP state data. The granularity with which different processors and / or different CCPs track cache consistency states and make the cache consistency data available to the tracker 104a can vary. For example, on the one hand, some processors / CCPs track the cache consistency of each cache line and each processing unit. Therefore, these processors / CCPs can track the state of each cache line associated with each processing unit. This means that because it is related to each processing unit 102a, a single cache line can have information about its state. Other processors / CCPs have a smaller granularity and only track cache consistency at the cache line level (and lack information for each processing unit). On the other hand, because only one processor can monopolize a line at a time (exclusive, modified, etc.), the processor manufacturer can choose to track cache consistency at the cache line level only for efficiency considerations. As an example of an intermediate granularity, a processor / CCP may track the cache coherency of each cache line, and the index of the processing unit that has the current cache line state (e.g., indices 0, 1, 2, 3 for a four processing unit processor).

[0089] Regardless of the granularity at which CCP state data is maintained at a given processor, the CCP state data may be included in the "knowledge" that the (N+i)-level cache has about cached data. In particular, CCP state data associated with a given cache line in the (N+i)-level cache may be used to determine whether the cache line has been logged by one of the processing units. For example, if the CCP state data indicates that a particular processing unit has considered a given cache line to be "shared," the data may in turn be used to determine that the processing unit has logged a read from the cache line. It will therefore be understood that, in action 302, checking the (N+i)-level cache to determine whether data for a memory location has previously been logged on behalf of a second processing unit may include determining whether a cache line in the (N+i)-level cache corresponding to the memory location has associated CCP state data that can be used to determine that the cache line has been logged.

[0090] In action 303, the data inflow may be logged by reference to previously logged data (typically data logged by a different processing unit that caused the current inflow). Logging by reference may be accomplished using one or more of a variety of methods (including combinations thereof), some of which are described below.

[0091] The first method logs by referencing the memory address of a previous log record. For example, assuming Figure 2A The processing unit A2 in the system memory 202 has recorded data representing a specific memory address (i.e., in the system memory 202) and specific data stored at the memory address. Later, if the specific memory address / specific data is an inflow for the processing unit A1, the processing unit A1 can store a log entry that identifies (i) the specific memory address and (ii) the processing unit A2. Here, the processing unit A1 avoids re-logging the actual data stored at the memory address (which may be of considerable size). Some variations of the first method can also store sorting data, such as a series of MINs that increment from the data flow across the processing units A1 and A2. The MIN can be later used to sort the inflow of the processing unit A1 for one or more events at the processing unit A2 (e.g., those events that are also associated with the MIN from the same series). Accordingly, in action 303, by referring to the log data that has been previously logged on behalf of the second processing unit, the data for the memory location being logged on behalf of the first processing unit can include one or more of the following: the address of the logging memory location, or the address of the logging memory location and sorting data (such as, MIN).

[0092] The second method logs by referencing the previous owner of the cache line that stored the data. For example, suppose Figure 2AProcessing unit A2 in has logged a first influx of data. Assume also that the first influx causes the data to be cached in a cache line of a (N+i) level cache (e.g., cache L2-A1), where processing unit A2 is identified as the owner of the cache line. Later, if processing unit A1 causes a second influx of the same data, processing unit A1 may become the owner of the cache line in the (N+i) level cache. Processing unit A1 may then store a log entry identifying the previous owner of the cache line (i.e., processing unit A2) so that A2's log entry can be used later to obtain the data. This means that logging by reference can involve recording the identity of the cache line as well as the previous owner of the cache line (e.g., possibly avoiding recording memory addresses and memory values). Therefore, in action 303, causing data for a memory location to be logged on behalf of the first processing unit by reference to log data that has previously been logged on behalf of the second processing unit may include: logging the second processing unit as the previous owner of the cache line corresponding to the memory location.

[0093] The third method logs by reference to CCP data. For example, as mentioned above, the CCP can store cache coherence states for each cache line used for reading and writing by different processing units. The granularity of this data can vary depending on the implementation of the processor, but for example, the cache coherence state of each cache line associated with each processing unit can be tracked, the cache coherence state of each cache line can be tracked, and the index (e.g., 0, 1, 2, 3, etc.) of the processing unit that owns the current cache line state can be tracked. The third method uses available CCP data to track which (which) processing units previously owned the cache coherence state of the cache line, which cache coherence state can then be used to identify which (which) processing units have logged the value of the cache line. This means that logging by reference can involve recording CCP data for cache lines (e.g., again possibly avoiding recording memory addresses and memory values). Therefore, in action 303, by referring to log data that has previously been logged on behalf of the second processing unit, the data for the memory location being logged on behalf of the first processing unit can include logging reference to the CCP data of the second processing unit.

[0094] The fourth method logs by reference to cache ways. As mentioned, a set associative cache can be used to determine whether a cache line has been logged by using way locking. For example, assume that way locking is used to reserve one or more ways for processing unit P2, and P2 logs a first influx of data. The first influx also causes the (N+i) level cache (e.g., cache L2-A1) to store the data of the first influx in a cache line associated with the way. When another processing unit (e.g., P1) has a second influx of the same data, the presence of the cache line in the (N+i) level cache indicates that P2 has logged the data. An embodiment can log a reference to P2's log data based on annotating the way in which the cache line is stored, and can potentially avoid logging memory addresses and memory values ​​again. This embodiment can also be used in conjunction with record sorting information (e.g., MIN) to sort events between P1 and P2. Thus, in act 303, causing data for a memory location to be logged on behalf of the first processing unit by referencing log data that was previously logged on behalf of the second processing unit may include one or more of: a log reference to a cache way, or a log reference to a cache way and sort data.

[0095] In addition to logging the inflow of a first processing unit based on the previous inflow of a second processing unit, embodiments also include optimizations for reducing (or even eliminating) logging by a single processing unit when there are multiple inflows of the same data. Figure 2A , processing unit A1 may cause a cache miss in an N-level cache (e.g., an L1-A1 cache) for specific data at a memory location. In response, the cache hierarchy may import the data into the L1-A1 cache, and potentially also into the (N+i)-level cache (e.g., an L2-A1 cache and / or an L3-A cache). In addition, the inflow to processing unit A1 may be logged by value. Later, the data may be evicted from the L1-A1 cache. In a typical cache environment, this may cause the data to be actively evicted from the L2-A1 cache and / or the L3-A cache as well. However, instead of causing (multiple) evictions in the L2-A1 and / or L3-A caches, various embodiments may retain appropriate (multiple) cache lines in one or more of these (N+i)-level caches. Therefore, method 300 may include evicting a first cache line in a first N-level cache corresponding to a memory location, while retaining a second cache line in a (N+i)-level cache corresponding to the memory location.

[0096] Later, if processing unit A1 causes a subsequent cache miss for the same data in the L1-A1 cache, the (multiple) retained cache lines in the (N+i) level cache (e.g., L2-A1 and / or L3-A cache) can be used to determine that the data has been logged on behalf of processing unit A1. Therefore, in some embodiments, the subsequent cache miss is logged by processing unit A1 with reference to the previous log entry. In other embodiments, the log entry may be omitted entirely for the subsequent cache miss because processing unit A1 already has the data in its trace. Therefore, method 300 may include: based on detecting a subsequent influx to the first N level cache, the subsequent influx also including data stored at a memory location, causing the subsequent influx to be logged by reference based on the presence of a second cache line. Additionally or alternatively, method 300 may include (i) detecting subsequent inflows to the first level N cache based on additional code executed at the first processing unit, the subsequent inflows also including data stored at the memory location, and (ii) determining that the subsequent inflows do not need to be logged based at least on detecting the subsequent inflows to the first level N cache and at least on the presence of the second cache line.

[0097] It will be appreciated that the first embodiment of logging at a lower cache layer based on a processor checking one or more upper cache layers may be implemented to implement Figure 3 The processor control logic (e.g., circuitry and / or microcode) of the method 300 of the embodiment. Thus, the processor 102 implementing this embodiment may include processor control logic that detects inflow to a lower level (e.g., L1) cache, and then (potentially stepwise) checks one or more upper level caches to determine whether the inflow can be logged by reference, or even whether the inflow does not need to be logged at all, as described in the method 300.

[0098] Sending logging request(s) to upper cache layer(s) based on lower cache layer, logging cache misses at lower cache layer

[0099] In a second embodiment, the processor detects inflow (i.e., cache miss) to a lower level processor cache (e.g., L1) based on the activity of a first processing unit (e.g., a read from a particular memory address), and the lower level processor cache then requests an upper level cache to log the inflow and / or requests an upper level cache to inform the lower level how to log the inflow. The upper level cache then determines whether the inflow needs to be logged and how to log the inflow (e.g., by value or by reference), and / or passes the request to another upper level cache (if any) to determine how to log the inflow if the request lacks the necessary knowledge. This can continue for N cache levels.

[0100] The processor 102 implementing this second embodiment can potentially do so by implementing common (or at least very similar) control logic at all (multiple) upper caches, or at least all (multiple) upper caches that participate in the logging process. In some implementations, the control logic required to implement the second embodiment may not be as extensive as the control logic required to implement the first embodiment, but provides many (or all) of the same advantages derived from logging influx at lower cache levels based on leveraging knowledge of the (multiple) upper cache levels. Additionally, since cache levels already pass CCP messages between each other in most processors, the control logic required to implement the second embodiment can potentially be implemented as an extension of existing control logic.

[0101] According to this second embodiment, Figure 6 A flow chart of an example method 600 of an upper cache layer determining how to log inflow through a lower cache layer based on a logging request of a lower cache layer is illustrated. Similar to method 300, method 600 may be implemented in a microprocessor environment such as, Figure 2A An example environment of the present invention is implemented in a microprocessor environment depicting a processor 201a that includes a plurality of processing units (e.g., two or more of processing units A1-A4) and that includes a plurality of caches arranged into a plurality of cache layers. These caches may include a plurality of first caches within a first cache layer (e.g., two or more of caches L1-A1 to L1-A4) and one or more second caches within a second cache layer (e.g., one or more of caches L2-A1 or L2-A2 or cache L3A). These caches may include a specific second cache in the second cache layer (e.g., L2-A1 or L3-A) that serves as a backup repository for at least a specific first cache in the first cache layer (e.g., L1-A1). For simplicity, method 600 refers to a specific first cache as a "first cache" and a specific second cache as a "second cache". The microprocessor environment may include control logic (e.g., microcode 102c and / or circuitry) for executing the method. In some embodiments, such control logic is implemented in one or more upper cache layers (e.g., Figure 2A It is implemented at the cache layers L2 and / or L3).

[0102] Method 600 is executed at the second cache introduced above, the second cache participates in logging, and starts with action 601, in which the second cache receives a logging request from an internal cache layer. In some embodiments, action 601 may include the second cache receiving a logging request referencing a specific memory address from a first cache. For example, cache L2-A1 in the L2 cache layer (or cache L3-A if method 600 is executed at the L3 cache layer) may receive a logging request from cache L1-A1 in the L1 cache layer. The logging request may be based on the activity of processing unit A1 (such as a read of a specific memory address (e.g., in system memory 202)), which causes an influx of data to the first cache L1-A1. Figure 2A In an environment where the data in the inflow can be provided from cache L2-A2, cache L3-A, or system memory 202.

[0103] Based on the request, method 600 proceeds to act 602, in which the second cache determines whether there is a cache line for the memory address at the cache layer. In some embodiments, act 602 may include determining, based on the request, whether there is a cache line corresponding to the memory address in the second cache. For example, based on receiving the request, cache L2-A1 in the L2 cache layer (or cache L3-A if method 600 is executed at the L3 cache layer) may determine whether it contains a cache line that caches a particular memory address from a logging request. Although such a cache line will typically exist in the case where the cache hierarchy includes an inclusive cache (e.g., where a second cache stores a superset of the data in the (multiple) caches in the first cache layer below it), it will be understood that this may not be the case if the cache hierarchy is exclusive or exhibits some exclusive behavior.

[0104] Following the "no" branch of action 602 (i.e., when the cache line does not exist in the particular second cache), method 600 reaches action 603, in which the second cache can determine whether it is the outermost logging cache layer. As will be discussed, based on the result of action 603, method 600 can include (i) when there is no third cache (e.g., within the third cache layer) that participates in logging and acts as a backing store for at least the second cache, the second cache causing the cache line to be logged (i.e., following the path of action 608), or (ii) when the third cache does exist, the second cache forwarding the request to the third cache (i.e., following the path of action 606).

[0105] For example, if the second cache is cache L2-A1, then at action 603, the second cache can determine whether cache L3-A exists and participates in logging (so L2-A1 is not the outermost logging cache layer). If cache L3-A does exist, it will be understood that in some implementations, depending on the current configuration of the processor, the cache may participate in logging at one moment and not participate in logging at another moment. In another example, if the second cache is cache L3-A, then at action 603, the second cache can determine that there are no external cache layers, so the second cache is the outermost logging cache layer. Note that there can be intermediate non-logging cache layers between logging cache layers. For example, if action 603 is performed by cache L2-A1, and a certain L4 cache layer will exist, the L3 cache layer can be non-logging and the L4 cache layer can be logging.

[0106] If the determination from action 603 is that the second cache is not an external logging cache layer (i.e., the "no" branch from action 603), method 600 proceeds to action 606, in which the second cache forwards the logging request to the next logging cache layer. Method 600 is then repeated at the cache of that layer. For example, if the second cache is cache L2-A1, it can forward the request to cache L3-A, and cache L3-A can repeat method 600. This can be extended to many logging cache levels that exist. In some implementations, when action 606 is reached, the second cache layer can send one or more reply messages to the first cache to instruct it to send its logging request directly to the next logging cache layer, rather than forwarding the logging request to the next logging cache layer.

[0107] On the other hand, if the determination from act 603 is that the second cache is the outermost logging cache layer (i.e., the "yes" branch from act 603), then method 600 proceeds to act 608, in which the second cache causes the inflow to be logged. As will be discussed later, the logging at act 608 can be performed by value or by reference (depending on the particular situation), and the actual logging at act 608 can be performed at the current cache layer and / or the lower cache layer.

[0108] Note that, as indicated by the dashed line in the decision box of action 603, action 603 may be an optional action, depending on the computing environment in which method 600 is executed. For example, if the cache hierarchy includes only one upper cache layer that participates in logging (and executes method 600), that cache layer will always be the "outermost" logging cache layer. In these environments, action 603 may not be required. In addition, even if there are multiple logging cache layers, the outermost logging cache layer may have inherent knowledge that it is the outermost layer. In either case, the "no" decision at action 602 can therefore simply proceed to action 608.

[0109] Returning to act 602, and following the "yes" branch (i.e., when the cache line is present in the second cache), method 600 reaches act 604, in which the second cache determines whether the cache line is logged. This determination may include determining whether the cache line is logged by the second cache, or whether the cache line is logged by some other cache, and whether the second cache is aware of the logging. The manner in which the second cache determines that the cache line has been logged (and potentially by the processing unit(s)) may depend on the manner in which the cache line is logged in conjunction with the first cache logging embodiment (e.g., including, for example, in conjunction with Figure 4A , Figure 4B and Figure 5 For example, the second cache may be combined with Figure 4A and Figure 4B As described above, the second cache can store bookkeeping bits (i.e., flag bits, unit bits, and / or index bits), and the second cache can utilize as described in conjunction with Figure 5 The described way locking, and / or the second cache may store and rely on CCP data.

[0110] As will be discussed, if the cache line is not determined by the second cache to be logged, method 600 may include the second cache forwarding the request to the next logging cache layer (i.e., following the path of action 606) and / or logging the cache line (i.e., following the path of action 608). On the other hand, if the cache line is determined by the second cache to be logged, method 600 may include: when the second cache has not yet determined whether the first cache knows the current value stored in the cache line of the cache, the second cache causing the cache line to be logged (i.e., following the path of operation 608), or when it is determined that the requesting processor knows the current value stored in the cache line of the second cache, the second cache determines that the cache line does not need to be logged (i.e., following the path of action 609).

[0111] For example, if the determination from action 604 is that the cache line is not determined by the second cache to be not logged (i.e., the "no" branch from action 604), then at action 608, the second cache may cause the inflow to be logged while potentially notifying an external logging cache layer (if any) of the logging that occurred (i.e., action 607). If action 607 is performed, then at action 608, in the event that the cache line is not determined by the particular second cache to be logged, causing the cache line to be logged may include: determining that a third cache layer exists, and notifying the third cache that the cache line has been logged by value by the particular second cache. Note that in method 600, actions 607 and 608 may be performed in any order relative to each other (including actions performed in parallel). Note that action 607 may cause method 600 to be performed at the next logging cache layer.

[0112] Alternatively, Figure 6 It is shown that if the determination from action 604 is that the cache line is not determined by the second cache to be logged, the second cache can determine whether it is the outermost logging cache layer at action 603, and based on the result, forward the request to the next logging cache layer at action 606 or log the influx at action 608. Essentially, the information conveyed by these alternative paths is that if there is a "no" determination at action 604, the second cache can (i) log the influx and notify the next logging cache layer (if any) (i.e., make the next layer aware of the logging event for later use), and / or (ii) forward the request to the next logging cache layer, because the second cache (or even higher layers) may contain knowledge that may cause the influx to be logged by reference or not logged at all.

[0113] Returning to action 604, if the second cache knows that the cache line is being logged (i.e., the "yes" branch from action 604), then at action 605, the second cache determines whether the processing unit that caused the logging request has a current value in the cache line. It should be understood that the second cache can have a more recent value for the requested memory address than the first cache currently has. For example, if the first cache is cache L1-A1 and the second cache is cache L2-A1, it may be that the value that cache L2-A2 has for a particular memory address is more recent than the value that L1-A1 had when processing unit A1 performed the read that caused the logging request in action 601 (e.g., due to the activity of processing unit A2). If it is known with certainty that the first cache has the current value in the cache line at the second cache (i.e., the "yes" branch of action 605), the second cache can choose not to log anything at action 609 (i.e., because the current value has been logged). On the other hand, if it is not known for certain that the first cache has the current value in the cache line at the second cache (i.e., the "no" branch of action 605), the second cache can cause the inflow to be logged at action 608, while potentially notifying an external logging cache layer (if present) that the logging occurred (i.e., action 607). Again, actions 607 and 608 can be performed in any order relative to each other (including actions performed in parallel).

[0114] As mentioned, the logging of the inflow at action 608 can be performed by value or by reference according to the specific circumstances. Generally, if the value of the inflow cannot be located based on tracking, the inflow is logged by value (e.g., by processor activity during replay or cache lines previously logged). If the value of the inflow can be obtained by replaying the logged processor activity, or if the value of the inflow is stored in the previously logged cache line, the inflow may be able to be logged by reference. It is worth noting that even in the case where it may be legal to log the inflow by reference, it is still legal to log the inflow by value. A decision to log by value can be made, such as to save processing time during tracking, create a track that is more easily replayed, etc. Therefore, it will be understood that action 608 may include logging the reference of the previous log entry of the specific memory address based on direct logging and / or logging, so that the cache line is logged.

[0115] One situation in which logging in method 600 may be performed by reference is if action 608 has already been reached by action 605 (i.e., the second cache knows that the value has been logged, but the requesting processor cannot explicitly know the current value). Here, logging at action 608 may be performed for the first cache with reference to the value known to be logged by the second cache. For example, cache L1-A2 may have logged the current value, and cache L2-A1 knows this, so the inflow may be logged for cache L1-A1 with reference to the logging of L1-A2.

[0116] In these cases, it may make sense not to log anything if the replay code can recover the value by other means. For example, the current inflow caused by processing unit A1 may have been logged in relation to previous activity of processing unit A2, so it is possible to log the current inflow at action 608 by reference to A2's log. However, if method 600 refuses to log anything for A1 at this point, the trace may still be correct. This reduces the size of the trace, and the trade-off is the need to locate the previously logged value in the traces of other processing units during replay.

[0117] The task of locating the value of the previous log record during replay depends on being able to reproduce at least part of the order of events between different logged processing units. Some content can be included in the trace to help locate the value of the previous log record. For example, logging cache eviction helps to determine that the value required to satisfy the read of A1 is not available in cache A1-L1 (i.e., because it has been evicted) during replay. Therefore, the value can then be searched in (multiple) traces for (multiple) other processing units. In another example, logging CCP data can also help determine that the value required to satisfy the read of A1 during replay is not available or is not currently in cache A1-L1. Therefore, the value can then be searched in (multiple) traces for (multiple) other processing units. Please note that CCP data can potentially indicate where to find the current value. In another example, knowledge of the geometry of the cache can help locate the required log entry. For example, it may be known that processing units A1 and A2 share the same L2 cache (i.e., L2-A1). Thus, for example, it makes sense to first search the trace for A2 to get the desired log entry, as opposed to searching the trace for A3 and A4.

[0118] Another case where logging can be performed by reference is when method 600 is executed at the current cache layer based on the notification sent by the lower cache layer to the current cache layer at action 607, and whether action 608 has been reached. Here, the lower cache layer will have logged the inflow (either by value or by reference), so the current cache layer can reference the log of the lower cache layer for logging.

[0119] As also mentioned, the logging at action 608 can be performed at the current cache layer or the lower cache layer. For example, in some implementations, instead of the second cache layer performing logging on its own when reaching action 608, one or more reply messages can be sent back to the first cache to instruct the first cache inflow to be logged and how to log the inflow (i.e., by value or by reference, if by reference, where the reference log entry is). The (multiple) reply messages can also instruct the first cache how to set the accounting bit, save CCP data, etc. Similarly, at action 609, the second cache layer can send a reply message to the first cache layer to notify it that logging is not necessary. If the original logging request has been propagated through more than one logging cache layer, these reply messages can be propagated back through the layers downward, or can be sent directly to the original requester. In view of the foregoing, it will be understood that action 608 can include causing the cache line to be logged based on instructing the first cache to directly record the value of a specific memory address, or instructing the first cache to record a reference to a previous log entry of a specific memory address.

[0120] Regardless of how logging is performed, action 608 may include the second cache layer setting any appropriate logging accounting bit (e.g., a flag bit, a unit bit, or an index bit), or saving any appropriate CCP message, to document the fact that the inflow is being logged. Thus, it will be appreciated that in action 608, causing the cache line to be logged may include marking the cache line as being logged within a particular second cache (e.g., by appropriately setting an accounting bit associated with the cache line).

[0121] In some embodiments, the logging at action 608 may include a second cache actively notifying one or more lower cache layers that it has logged a cache line, and possibly how it logs the cache line. For example, if cache L2-A1 has been logged at action 608, it can send one or more messages to caches L1-A2 to L1-A4 (i.e., L1 caches other than the cache that initiated the logging request) to notify them that it has logged the cache line. The information may include whether cache L2-A1 has logged the cache line by value or by reference. If the cache line is logged by reference, cache L2-A1 may even send information about the location where the original log data exists. In response, the cache (e.g., one or more of L1-A2 to L1-A4) may store information recording the fact that cache L2-A1 has logged the cache line (potentially including how cache L2-A1 has logged the cache line). This information may be stored, for example, in additional accounting bits within these L1 caches. In this way, if one of these L1 caches later determines that they need to log a cache line, they can know ahead of time that it has been logged and avoid sending a logging request to an upper cache or the question of how to log to an upper cache.

[0122] It is noteworthy that any of the techniques discussed above in conjunction with the first embodiment for performing latency logging using a dedicated portion of the buffer(s) 102(e) and / or cache(s) 102b are also applicable to the second embodiment. Thus, it will be appreciated that in act 608, causing the cache line to be logged may include logging the cache line within a trace buffer such as a portion of the buffer(s) 102e and / or cache(s) 102b.

[0123] Although method 600 focuses on performing actions at the upper logging cache layer, Figure 7-Figure 9 Some example methods that may be performed at a lower cache layer (e.g., the L1 cache layer(s) that initiated the original logging request) are shown. In particular, while method 600 focuses on performing logging (including setting a logging state of a cache line to indicate that the value of the cache line has been logged (e.g., setting an accounting bit associated with the cache line, storing CCP data, etc.), these methods are related to clearing the logging state when the value of the cache line is no longer logged.

[0124] A cache may contain a cache line that has its logging state set because a processing unit using the cache performed a memory read while logging was enabled for that processing unit. A cache may also receive a cache line from a higher-level cache that has the logging state set on it. As mentioned above, a cache line may also have the logging state set because the higher-level cache has proactively notified it that the cache line has been logged. Typically, the logging state of a cache line is cleared when a processing unit performs a write operation on a cache line while logging is disabled for that processing unit.

[0125] first, Figure 7 A flow chart of an example method 700 for managing the logging state of a cache line when a processing unit switches between enabling logging to disabling logging is illustrated. As with method 600, method 700 may be implemented in a manner such as Figure 2A . In general, method 700 operates after a processing unit (e.g., A1) has been operating with logging enabled, and it uses a cache (e.g., L1-A1) that now includes one or more cache lines that have been logged. If the processing unit writes to one of these logged cache lines, method 700 retains or clears the logging state depending on whether logging is currently enabled or disabled for the processing unit.

[0126] Method 700 begins at act 701, in which it detects a write to a cache line marked as logged. In some embodiments, act 701 may include detecting a write to a cache line in a first cache having a set logging state. For example, the first cache may be cache L1-A1. The cache may have a cache line that was previously marked as logged (e.g., by appropriately setting its accounting bit) based on a memory read by processing unit A1. For example, the cache line may correspond to a particular memory address discussed above in conjunction with method 600.

[0127] Next, method 700 includes action 702, in which it is determined whether logging is enabled. In this context, action 702 determines whether logging is enabled for a processing unit associated with a first cache. In some embodiments, action 702 may include determining whether logging is enabled for a particular processing unit based on detecting a write. For example, control logic for cache L1-A1 may determine whether logging is enabled for processing unit A1. If logging is enabled (i.e., the "yes" branch from action 702), the logging state for the cache line may be retained at action 703. Therefore, in some embodiments, action 703 may include retaining the logging state for the cache line based at least on enabling logging for the particular processing unit.

[0128] Alternatively, if logging is disabled (i.e., the "no" branch of action 702), then the logging state for the cache line may be cleared at action 704. Thus, in some embodiments, the action may include clearing the logging state for the cache line based at least on disabling logging for a particular processing unit. For example, cache L1-A1 may clear the accounting bits for the cache line as needed.

[0129] As shown, in addition to clearing the logging state, method 700 also includes notifying the next logging cache layer. In some embodiments, action 705 may include notifying at least one of the one or more second caches that its logging state for the second cache line should be cleared based at least on disabling logging for the particular processing unit. For example, one of the second caches may be cache L2-A1, and thus cache L1-A1 may notify cache L2-A1 to clear the logging state of its cache line copy. Note that actions 704 and 705 may be performed in any order relative to each other (including in parallel).

[0130] Although not in Figure 6 , but method 600 may correspondingly include a specific second cache receiving a message from a first cache, the message indicating that another cache line in the first cache that also corresponds to the memory address is marked as not logged in the first cache. Method 600 may also include marking the cache line as not logged in the specific second cache based on the message.

[0131] Figure 8 8 is a flow chart illustrating an example method 800 for managing the logging state of a cache line when a processing unit with logging disabled receives the cache line for writing only from a parent cache. As with methods 600 and 700, method 800 may be implemented in a microprocessor environment such as, Figure 2A In general, the method 800 operates when a processing unit (e.g., A1) operates with logging enabled, and it uses a cache (e.g., L1-A1) of a parent cache (e.g., L2-A1 and / or L3-A) that contains a cache line with a logging state set, and the cache uses a cache line to write from the parent cache.

[0132] Method 800 begins at act 801, where, with logging disabled, the cache requests a cache line from an upper cache for writing. For example, a cache miss may occur in cache L1-A1 based on a request from processing unit A1 to write to a particular memory address. As a result, cache L1-A1 may request a copy of the appropriate cache line from cache L2-A1 or cache L3-A.

[0133] In some cases, cache L1-A1 may receive a cache line with a logging state cleared. Thus, method 800 may include action 802, in which the cache receives only cache lines with a logging state cleared from an upper cache. The logging state may be cleared in the received cache line, for example because (i) the logging state is not set in the upper cache, or (ii) the upper cache knows that logging is disabled at processing unit A1, so when providing the cache line to cache L1-A1, the upper cache clears the logging state. For example, method 600 may include: receiving a message from a first cache requesting a cache line to be written, and sending the cache line to the first cache, the cache line being marked as not being logged based at least on logging being disabled for the first cache.

[0134] In other cases, cache L1-A1 may receive a cache line with a logging state set. Thus, method 800 may include action 803, in which the cache receives only cache lines with a logging state set from an upper cache. For example, because the logging state is set in the upper cache, the logging state may be set in the received cache line.

[0135] Next, method 800 may include action 804, in which, while logging is still disabled, the cache performs a write to the cache line. For example, cache L1-A1 may complete the original write request from processing unit A1 by writing an appropriate value to the cache line. Next, method 800 may include action 805 and action 806, in which the logging state for the cache line is cleared, and in which the upper cache is notified to clear its logging state for the cache line. Although action 805 is described separately from action 804, it should be noted that clearing the logging state for the cache line can be a natural part of performing a write operation at action 804. For example, with logging disabled, any write operation may cause the logging state to be cleared for the cache line being written. Thus, the arrow between actions 804 and 805 is shown in dashed lines to indicate that action 804 may actually be optional. Action 806 may operate in a manner similar to action 705 discussed above in conjunction with method 700.

[0136] Similar to action 705 of method 700, when action 806 is performed, method 600 may correspondingly include the specific second cache receiving a message from the first cache, the message indicating that another cache line in the first cache that also corresponds to the memory address is marked as not logged in the first cache. Method 600 may also include marking the cache line as not logged in the specific second cache based on the message.

[0137] Fig. 9900 is a flow chart illustrating an example method 900 for managing the logging state of a cache line when a processing unit writes to a cache line that the processing unit has occupied the "owned" CCP state. As with methods 600-800, method 900 may be implemented in a processor such as Figure 2A In general, the method 900 operates in a situation where the CCP provides a state in which, during a period in which a processing unit has occupied a cache line for writing, (multiple) other processing units can request the current value of the cache line. An example of this is the "owned" state in the MOESI CCP introduced earlier.

[0138] Method 900 begins with act 901, in which a cache line is modified in an owned state with logging disabled. For example, processing unit A1 may have considered a cache line as "owned" in cache L1-A1. During this time, processing unit A1 may perform a write to the cache line. Figure 8 As discussed, when logging is disabled, clearing the logging state for the cache line can be a natural part of performing a write operation. Thus, method 900 does not depict any fast action for clearing the logging state, but there may be a fast action in some implementations.

[0139] Based on action 901, method 900 illustrates that one (or more) actions may be taken to communicate that the logging state of a cache line should also be cleared on (multiple) other caches. In action 902, based on the request, the cache notifies a peer cache to clear the logging state for the cache line. For example, after a write to a cache line owned by cache L1-A1 has been performed, cache L1-A1 may receive a request (e.g., a CCP message) from a peer cache such as cache L2-A2 to request the current value of the cache line. As a result of the request, if the logging state has been set, cache L1-A1 may notify cache L2-A2 that the logging state in its corresponding cache line should be cleared. The notification may be sent together with the CCP message that communicates the current value of the cache line in cache L1-A1, or may be sent as part of a separate message.

[0140] In action 903, based on modifying the cache line, the cache notifies one or more peer caches to clear the logging state for the cache line. For example, after performing a write operation on a cache line owned by cache L1-A1, cache L1-A1 can broadcast a notification to its peer caches (e.g., L1-A2 to L1A4) to let them know that the logging state for the cache line should be cleared (if the cache line exists in these caches and the logging state is set). Therefore, while action 902 relatively notifies peer caches to clear the logging state, action 903 actively notifies peer caches.

[0141] In action 904, based on modifying the cache line, the cache notifies the upper cache layer to clear the logging state for the cache line. For example, after performing a write operation on a cache line owned by cache L1-A1, cache L1-A1 can broadcast a notification to its (multiple) parent caches (such as caches L2-A1 and / or L3-A) so that they know that the logging state for the cache line should be cleared (if the cache line exists in these caches and the logging state is set). Therefore, similar to action 903, action 904 performs active notification, but this time it is for (multiple) parent caches instead of (multiple) peer caches.

[0142] It is worth noting that some implementations may perform more than one of actions 902-904. For example, an implementation may proactively notify the upper cache (i.e., action 904) when performing a write, but only reactively notify the peer cache (i.e., action 902). In another example, an implementation may proactively notify the upper cache (i.e., action 904) and the peer cache (i.e., action 903).

[0143] Additionally, similar to action 705 of method 700 and action 806 of method 800, when executing 903, method 600 may correspondingly include the specific second cache receiving a message from the first cache, the message indicating that another cache line corresponding to the memory address in the first cache is marked as not logged in the first cache. Method 600 may also include marking the cache line as not logged in the specific second cache based on the message.

[0144] Based on the knowledge of (multiple) upper caches (e.g., L2, L3, etc.), logging inflows to lower caches (e.g., L1) can provide several advantages over logging by reference and avoiding logging in some cases. For example, the lower layer starts the logging process only when the data from the cache miss has actually been consumed by the processing unit. For example, this can avoid recording cache misses caused by speculative execution. In addition, the lower layer can perform logging at the same time as the exit of the instruction that caused the cache activity. This can cause a trace that captures higher precision timing. Finally, when recording the lower layer, if necessary, the recording can be based on virtual memory addressing instead of physical memory addressing. It is worth noting that if logging is performed based on virtual memory addressing, there may be a situation where multiple virtual addresses are mapped to the same physical address. In these cases, the cache may not cause access to the same physical address through different virtual addresses to appear as a cache miss. If this happens, the tracker 104a can log data from the TLB 102f. In some implementations, the virtual or physical address may be further distinguished by an additional identifier (e.g., a virtual processor ID, a security setting for the memory address, etc.) In at least some of these implementations, the cache may cause access to the same address with a different additional identifier (or with a higher, lower, or different security level) to appear as a cache miss.

[0145] Thus, embodiments herein provide different embodiments for recording bit-accurate "time travel" traces based on tracking execution effects across multiple processing units using at least two levels or layers of processor cache. Recording trace files in this manner may require only modest processor modifications and can reduce the performance impact of trace recording and the size of trace files by orders of magnitude when compared to existing trace recording methods.

[0146] The present invention may be embodied in other specific forms without departing from the spirit or essential features of the present invention. The described embodiments should be considered in all respects only as illustrative and not restrictive. Therefore, the scope of the present invention is indicated by the appended claims rather than the preceding description. All changes falling within the equivalent meaning and scope of the claims should be included within their scope.

Claims

1. A microprocessor, comprising: Multiple processing units; a plurality of caches arranged into a plurality of cache tiers, the plurality of caches comprising a plurality of first caches within a first cache tier and one or more second caches within a second cache tier, particular second caches in the second cache tier serving as a backing store for at least particular first caches in the first cache tier; as well as The control module configures at least the specific second cache to perform at least one of the following: receiving a logging request referencing a specific memory address from the specific first cache; and Based on the request, determining whether a cache line corresponding to the memory address exists in the specific second cache, and When the cache line does not exist in the specific second cache, performing one of the following: causing the cache line to be logged when there is no third cache participating in logging and acting as a backing store for at least the particular second cache; or When the third cache does exist, forwarding the request to the third cache; or When the cache line exists in the specific second cache, at least one of the following is performed: Causing the cache line to be logged when (i) the cache line is not determined by the particular second cache to be logged, or (ii) the cache line is determined by the particular second cache to be logged, but the particular second cache has not yet determined that the first cache knows the current value stored in the cache line of the particular second cache; or Those The cache line is determined not to be logged when (i) the cache line is determined to be logged by the particular second cache and (ii) the first cache is determined to know the current value stored in the cache line of the particular second cache.

2. The microprocessor of claim 1 , wherein causing the cache line to be logged comprises: recording the cache line log in a trace buffer; as well as The cache line is marked as being logged in the particular second cache.

3. The microprocessor of claim 1 , wherein causing the cache line to be logged comprises one of: Instruct the first cache to directly log the value of the specific memory address; or The first cache log is instructing to record a reference to a previous log entry for the particular memory address.

4. The microprocessor of claim 1 , wherein when the cache line is not determined by the particular second cache to be logged, causing the cache line to be logged comprises: determining that the third cache exists, and The third cache is notified that the cache line has been logged by value by the specific second cache. 5 . The microprocessor of claim 1 , wherein the first cache layer comprises an L1 cache layer, and wherein the second cache layer comprises an L2 cache layer or an L3 cache layer.

6. The microprocessor according to claim 1, wherein the control module further configures at least the specific second cache to: receiving a message from the first cache, the message indicating that another cache line in the first cache that also corresponds to the memory address is marked as not logged in the first cache; and Based on the message, the cache line is marked as not logged in the particular second cache. 7 . The microprocessor of claim 6 , wherein the another cache line is marked as not logged in the first cache based on the another cache line being written by a processing unit corresponding to the first cache with logging disabled for the processing unit.

8. The microprocessor according to claim 1, wherein the control module further configures at least the specific second cache to: receiving a message from the first cache requesting the cache line to be written; and The cache line is sent to the first cache, the cache line being marked as not being logged based at least on disabling logging for the first cache.

9. A method for an upper cache layer to determine how to log inflows of a lower cache layer based on a logging request of a lower cache layer, the method being implemented at a computing device, the computing device comprising (i) a plurality of processing units, (ii) a plurality of caches arranged into a plurality of cache layers, the plurality of caches comprising a plurality of first caches in a first cache layer and one or more second caches in a second cache layer, a particular second cache in the second cache layer being used as a backup repository for at least a particular first cache in the first cache layer, the method comprising: receiving, from the specific first cache, a logging request referencing a specific memory address; as well as Based on the request, determining whether a cache line corresponding to the memory address exists in the specific second cache, and When the cache line does not exist in the specific second cache, performing one of the following: causing the cache line to be logged when there is no third cache participating in logging and acting as a backing store for at least the particular second cache; or When the third cache does exist, forwarding the request to the third cache; or When the cache line exists in the specific second cache, at least one of the following is performed: causing the cache line to be logged when (i) the cache line is not determined by the particular second cache to be logged, or (ii) the cache line is determined by the particular second cache to be logged, but the particular second cache has not yet determined that the first cache knows the current value stored in the cache line of the particular second cache; or The cache line is determined not to be logged when (i) the cache line is determined to be logged by the particular second cache and (ii) the first cache is determined to know the current value stored in the cache line of the particular second cache.

10. The method of claim 9, wherein causing the cache line to be logged comprises: recording the cache line log in a trace buffer; as well as The cache line is marked as being logged in the particular second cache.

11. The method of claim 9, wherein causing the cache line to be logged comprises one of: Instruct the first cache to directly log the value of the specific memory address; or The first cache log is instructing to record a reference to a previous log entry for the particular memory address.

12. The method of claim 9, wherein when the cache line is not determined by the particular second cache to be logged, causing the cache line to be logged comprises: determining that the third cache exists, and Based on the knowledge of the third cache, the cache line is caused to be logged by reference.

13. The method of claim 9, wherein when the cache line is not determined by the particular second cache to be logged, causing the cache line to be logged comprises: determining that the third cache exists, and The third cache is notified that the cache line has been logged by value by the specific second cache.

14. The method of claim 9, wherein the first cache layer comprises an L1 cache layer, and wherein the second cache layer comprises an L2 cache layer or an L3 cache layer.

15. The method according to claim 9, further comprising: receiving a message from the first cache, the message indicating that another cache line in the first cache corresponding to the memory address is marked as not logged in the first cache; as well as Based on the message, the cache line is marked as not logged in the particular second cache. 16 . The method of claim 15 , wherein the another cache line is marked as not logged within the first cache based on the another cache line being written by a processing unit corresponding to the first cache with logging disabled for the processing unit.

17. The method according to claim 9, further comprising: receiving a message from the first cache requesting the cache line to be written; as well as The cache line is sent to the first cache, the cache line being marked as not being logged based at least on disabling logging for the first cache.

18. A microprocessor comprising: Multiple processing units; a plurality of caches arranged into a plurality of cache layers, the plurality of caches comprising a plurality of first caches within a first cache layer and one or more second caches within a second cache layer, the second cache layer serving as a backing store for at least a particular first cache in the first cache layer, the particular first cache corresponding to a particular processing unit of the plurality of processing units; as well as The control module configures at least the specific first cache to perform at least one of the following: detecting a write to a cache line in the first cache having a logging state set; Based on detecting the write, determining whether logging is enabled for the particular processing unit, and based at least on logging being disabled for the particular processing unit, clearing the logging state for the cache line, and notifying at least one second cache of the one or more second caches that a logging state of the at least one second cache for the cache line should be cleared, or Based at least on logging being enabled for the particular processing unit, the logging state for the cache line is retained.

19. The microprocessor of claim 18 , wherein the specific processing unit has the cache line in an owned state, and wherein the control module further configures at least the specific first cache to notify at least one first cache of the plurality of first caches that the logging state of the at least one first cache for the cache line should be cleared.

20. The microprocessor of claim 18, wherein based on a request received from the at least one first cache among the plurality of first caches, the specific first cache notifies the at least one first cache among the plurality of first caches that a logging state of the at least one first cache for the cache line should be cleared.