WO2013097246A1 - 高速缓冲存储器控制方法、装置和*** - Google Patents

高速缓冲存储器控制方法、装置和*** Download PDF

Info

Publication number
WO2013097246A1
WO2013097246A1 PCT/CN2011/085200 CN2011085200W WO2013097246A1 WO 2013097246 A1 WO2013097246 A1 WO 2013097246A1 CN 2011085200 W CN2011085200 W CN 2011085200W WO 2013097246 A1 WO2013097246 A1 WO 2013097246A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
address
memory
address range
range
Prior art date
Application number
PCT/CN2011/085200
Other languages
English (en)
French (fr)
Inventor
蔡安宁
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201180003800.3A priority Critical patent/CN102725741B/zh
Priority to PCT/CN2011/085200 priority patent/WO2013097246A1/zh
Publication of WO2013097246A1 publication Critical patent/WO2013097246A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0891Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches using clearing, invalidating or resetting means

Definitions

  • the present invention relates to computer technology, and more particularly to a cache control method, apparatus and system. Background technique
  • the Central Process Unit needs to read data from the main memory, that is, the memory.
  • the access speed of the memory is much slower than that of the CPU, so that the processing power of the CPU cannot be fully utilized. , affecting the efficiency of the entire system.
  • the cache cache is usually used between the CPU and the memory. The cache can read the data in the memory in advance, and the CPU directly accesses the cache.
  • the memory includes a stack memory and a heap memory for storing data
  • the stack memory is a piece of memory for storing temporary data in the running of the program
  • the heap memory is a piece of memory allocated for an application
  • the cache will Keep the data consistent with the stack memory and heap memory to ensure correct reading of the CPU. For example, when a new stack memory or heap memory is allocated in the memory, and when the program operates on the memory, the cache will first read the old storage data corresponding to the newly allocated address to keep the data consistent; but the newly allocated stack memory Or the heap memory will store new data, and the old data read by the cache is actually invalid data, and it does not need to be read at all.
  • the cache when the program finishes using the memory, and performs stack rollback or heap memory release operation, that is, when the occupied memory address is released, in order to keep the data consistent, the cache also rewrites the stored therein in the program running. The data is written back to the memory, but in fact the data is already used, has become invalid data, and does not need to be written back.
  • a first aspect of the present invention provides a cache control method for reducing unnecessary synchronization of a cache, improving CPU processing efficiency, and saving bandwidth.
  • Another aspect of the present invention is to provide a cache control device for reducing unnecessary synchronization of a cache, improving CPU processing efficiency, and saving bandwidth.
  • Yet another aspect of the present invention is to provide a cache control system to reduce unnecessary synchronization of caches, improve CPU processing efficiency, and save bandwidth.
  • the cache cache control method provided by the present invention includes:
  • the cache cache control system provided by the present invention includes:
  • An address detection module configured to acquire a changed address range of the target object
  • a cache control module configured to determine an address change type according to the changed address range; if the address change type is an allocation or release of a memory address, determine a cache operation address range corresponding to the changed address range, and control the cache
  • the cache operation address range executes cache operation information; the cache operation information is to prohibit the cache from performing data synchronization in the cache operation address range.
  • the cache control device provided by the present invention includes the cache control system of the present invention.
  • the technical effect of the cache control method of the present invention is: obtaining an address change type by acquiring a changed address range of the target object, and controlling the cache to perform a corresponding operation according to the change type, that is, when the memory address is allocated or released, the cache is prohibited. Data synchronization is performed, thereby solving the problem of CPU waiting delay, avoiding unnecessary synchronization work of the cache, and significantly improving the processing efficiency of the CPU.
  • the technical effect of the cache control device of the present invention is: obtaining an address change type by acquiring a changed address range of the target object, and controlling the cache to perform a corresponding operation according to the change type, that is, when the memory address is allocated or released, the cache is prohibited. Synchronize data to solve The problem of CPU waiting delay is eliminated, and the cache is prevented from performing unnecessary synchronization work, which significantly improves the processing efficiency of the CPU.
  • FIG. 1 is a schematic diagram showing an application structure of an embodiment of a cache memory control system according to the present invention
  • FIG. 2 is a schematic diagram showing the operation of another embodiment of a cache memory control system according to the present invention
  • FIG. 4 is a schematic flowchart of an embodiment of a cache control method according to an embodiment of the present invention
  • the embodiment of the present invention first provides a cache memory control system. In order to make the description of the structure and principle of the system clearer, this embodiment applies the system to a central processing unit.
  • the system is described as an example in the CPU.
  • the system of this embodiment may include: an address detection module 11 and a cache control module 12; wherein, the address detection module 11
  • the address range used to obtain the change of the target object for example, the target object may include stack memory, heap memory, or memory for storing data such as code segments, data segments, and the like.
  • the changed address range refers to, for example, for the stack memory, the changed address range corresponds to the stack growth or the stack fallback address range, and the initial memory address and the latest memory address corresponding to the address range can be obtained; Heap memory, the address range of the change corresponds to the address range of the heap memory allocation or release, and the start address and the end address corresponding to the address range can be obtained.
  • the address detection module 11 is connected to an arithmetic logic unit (Arithmetic Logic Unit, ALU) in the CPU, and can obtain the initial memory of the stack from the ALU. Start memory address and latest memory address. For example, the memory address occupied by the original stack ranges from a1 to a2. After the new stack memory is allocated, the memory address occupied by the new stack ranges from a1 to a3, and the initial memory address of the stack memory is a2. The memory address is a3; the address of the heap memory is the same.
  • ALU arithmetic Logic Unit
  • the cache control module 12 is connected to the address detecting module 11 and configured to determine an address change type according to an initial memory address and an latest memory address of the target object detected by the address detecting module 11, where the address change type includes allocation or release of the memory address;
  • the allocation of the memory address includes: stack growth, heap allocation; and release of the memory address: including stack fallback and heap release.
  • the above stack memory change is still taken as an example, and the stack memory is assumed to be a high address growth type. If the address a3 is greater than the address a2, it indicates that the change of the stack memory is "stack growth", that is, a new stack of memory is allocated; if the address a3 is smaller than a2, it indicates that the change of the stack memory is "stack rollback". That is, release a stack of memory. Therefore, by detecting the memory address, the change type can be analyzed according to the change of the memory address; generally, the newly allocated memory indicates that there may be a new application to run and use the memory, and releasing the memory indicates that the application has been run; that is, through The range of addresses that are perceived to change is the behavior of the application.
  • the cache control module 12 is further configured to: when the address change type is the allocation or release of the memory address, determine a cache operation address range corresponding to the changed address range, and control the cache to execute the cache operation information in the cache operation address range;
  • the cache operation information is to prohibit the cache from performing data synchronization in the cache operation address range.
  • the cache control module 12 determines a cache operation address range corresponding to the changed address range, that is, a cache operation address range corresponding to the allocated memory address, and controls the cache at the cache operation address.
  • the scope performs cache operation information, where the cache operation information is: prohibiting the cache from performing data synchronization in the cache operation address range.
  • the cache establishes a cache line unit corresponding to the changed address range, the cache line unit is the cache operation address range; and sets the status identifier to clean, according to the working principle of the cache, Setting to an unmodified flag such as clean disables clean-line from performing data read-in synchronization from the lower-level memory.
  • the cache operation information To: disable the cache from performing data synchronization in the cache operation address range. For example, a cache line unit corresponding to the changed address range is determined, the cache line unit is the cache operation address range; and the cache line unit is prohibited from performing data write synchronization to the lower level memory.
  • the specific implementation of prohibiting execution of data synchronization may be, for example, setting the status identifier of the cache-line to clean; or setting the status identifier of the cache-line to be invalid (ie, indicating that the cache-line is not used); or The cache-line status flag is set to be valid, but a bit is added to the status tag to store the status flag indicating that the data in the cache-line is invalid.
  • the above measures can cause the cache-line to no longer perform data synchronization.
  • the lower level memory includes a next level cache or memory in the cache.
  • the cache is usually stored according to a cache line unit (cache-line), that is, a cache is generally provided with a plurality of cache-line for storing data, and the operation instruction is usually an operation on the entire cache-line.
  • cache line unit that is, a cache is generally provided with a plurality of cache-line for storing data
  • the operation instruction is usually an operation on the entire cache-line.
  • the address range formed by the initial memory address and the latest memory address obtained by the address detecting module 11 may be part of the cache-line, not a complete cache-line. Generally, no operation is performed at this time.
  • the cache operation address range and the actually detected memory address change range are not necessarily identical, and the internal structure of the cache needs to be organized according to the cache-line, and the operation mode in the cache is The entire cache-line is the operation object to determine the specific cache operation address range.
  • the cache operation address range here can be understood as the operation of which cache-line in the cache, or the address corresponding to these cache-line. .
  • Each cache-line in the cache is correspondingly provided with a status identifier of the cache-line, and the cache-line is also operated according to the status identifier. For example, when the application is running, most of the data access operations involved are executed directly by the CPU from the cache. The data in the cache is overwritten, and the cacheline that the cache will be overwritten is marked as dirty, indicating that it is overwritten. Continued cache will write data back to the lower level memory (memory or subordinate cache) to ensure the correctness of the data. Correspondingly, in the embodiment, when the memory address is allocated or released, the cache is prohibited from performing data synchronization in the cache operation address range.
  • the cache line unit is the cache operation address range; and setting a cache-line status identifier to clean, so that the cache-line is in the state
  • the identifier no longer reads and writes invalid data, thereby reducing the waiting delay of the CPU, improving the processing efficiency of the CPU, and saving bandwidth resources.
  • the cache control module 12 of this embodiment may include: an address and operation generating unit 13, a cache instruction generating unit 14, and a cache operation control unit 15.
  • the address and operation generating unit 13 is connected to the address detecting module 11, and can receive the changed address range of the target object obtained by the address detecting module 11, and can determine that the address change type is allocated or released according to the changed address range; And determining, by the cache operation address range corresponding to the allocated or released memory address, the cache operation address range is a cache line unit including only the address in the allocated or released memory address; determining the address The cache operation information corresponding to the change type.
  • the cache operation information is a cache line unit corresponding to the memory address established and allocated in the cache, and the cache is prohibited from performing data synchronization in the cache line unit;
  • the cache operation information is that the prohibiting the cache performs data synchronization in the cache line unit.
  • the cache instruction generating unit 14 is connected to the address and operation generating unit 13 for receiving the cache operation address range transmitted by the address and operation generating unit 13, and the cache operation information; and converting the above information into A cache control instruction that controls the cache operation, for example, to generate a "cache operation address and instruction" sequence.
  • the cache instruction generating unit 14 is specifically configured to convert the cache operation address range into an address range instruction, or convert the cache operation address range into a corresponding address sequence instruction. That is, the control cache operation may be an address range or an address sequence in the cache. For example, it is usually based on an address sequence when controlling the cache, assuming that a cache-line address range is a1 to a2, and another cache-line The address range is a3 ⁇ a4. If you want to operate on these two cache-line, the control instruction is the address sequence "a2, a4", that is, select a separate address from the address range of each cache-line for identification.
  • the cache-line through the address sequence "a2, a4," It is known that the control is the cache-line corresponding to a2 and the cache-line corresponding to a4.
  • This embodiment is extended by the address range control cache, the control command can be "al ⁇ a2", and the cache can know which cache-line needs to be operated according to the address range.
  • the cache operation control unit 15 is located in the cache and is connected to the cache instruction generating unit 14 for controlling the corresponding cache operation information according to the cache control instruction generated by the cache instruction generating unit 14, for example, the cache and the change
  • the status identifier of the cache line unit corresponding to the address range is set to prohibit the data synchronization synchronization identifier such as clean.
  • the address and operation generating unit 13 is specifically configured to select a partial operation address range from the cache operation address range, and execute cache operation information in the partial operation address range to prohibit data synchronization. That is, the cache address range of the operation may be a partial address, and only the cache operation of the partial address is implemented.
  • the initial cache operation address range obtained by the memory address change includes three cache-lines. Two cache-lines can be selected as the actual cache operation address range, and the other cache-line does not perform related cache operation information.
  • the cache control module 12 is specifically configured to set the state identifier of the cache line unit of the cache to an unmodified identifier; or, the cache line unit of the cache The status ID is set to an invalid ID; or, an invalid ID is set for the stored data in the cache line unit of the cache.
  • the method for storing the stack address or the heap address in the address detecting module 11 may be: storing the foregoing address in a register of the address detecting module 11 by using a register mode; or, may be an instruction mode, transmitting by an address transmission instruction
  • the associated address and operation are in the address detection module 11.
  • the instruction mode may use an existing instruction, operate a general-purpose register, send the address to the address detection module 11, or add an instruction based on the existing instruction set, and the added instruction stores the address to the address detection.
  • the address and operation generating unit 13 can generate a cache operation address range and an operation instruction according to the address that the address detecting module 11 subsequently feeds.
  • the instruction mode can be an address and can be operated in two operations. Or one instruction can operate two addresses.
  • the instruction operation code can include the corresponding operation type, such as: setting the state of the cache-line corresponding to the address to be clean. , invalid or invalid data.
  • the above-mentioned "for a specific cache-line” is performed by "execution of a cache operation” to prohibit the cache from performing data synchronization in the cache line unit, and is represented by a code, which may be: Cache—clean rl, r2, or
  • each module in this embodiment is only an example.
  • the module division manner in this embodiment is not limited, as long as the function of the entire system can be implemented.
  • the generation of an address sequence can be in the address and operation generation unit, or in the cache instruction generation unit.
  • each module or unit in this embodiment may be implemented in hardware or in software, and is not limited.
  • the solution of this embodiment is applicable to one or more levels of cache.
  • the cache is a multi-level cache including multiple levels of storage units
  • the multi-level cache usually provides data cache for the upper level, and the capacity is larger, but the speed is lower.
  • L2cache and L3 cache the data stored in each level of cache needs to be consistent.
  • the interaction is mainly data synchronization.
  • the address and operation generation unit, the cache instruction generation unit, and the cache operation control unit of the embodiment are included in each level of the cache, and the three units can adopt the same processing as the previous stage, and are not described again; Because of the different cache-line sizes at all levels, the cache operation address range corresponding to each level of cache is different.
  • the upper-level storage unit in the multi-level storage unit sends the cache operation address range to the next-level storage unit, respectively, so that the next-level storage unit operates the address range according to the cache and the next level.
  • the length of the cache line unit of the storage unit generates a cache operation address range corresponding to the next-level storage unit.
  • the highest level one storage unit of the multi-level storage unit simultaneously sends the changed address range to all the lower level storage units, so that the lower level storage unit respectively obtains the corresponding lower level storage according to the changed address range.
  • the cache operation address range of the unit is mapped to the next-level storage unit, respectively, so that the next-level storage unit operates the address range according to the cache and the next level.
  • the length of the cache line unit of the storage unit generates a cache operation address range corresponding to the next-level storage unit.
  • the highest level one storage unit of the multi-level storage unit simultaneously sends the changed address range to all the lower level storage units, so that the lower level storage unit respectively obtains the corresponding lower
  • the cache control system of this embodiment can control the cache to perform corresponding operations according to the change type by detecting the address change type of the stack or the heap memory, that is, when the memory address is allocated or released, the cache is prohibited from performing data synchronization, thereby solving the problem.
  • the CPU waits for the delay problem, avoids the cache to perform unnecessary synchronization work, and significantly improves the processing efficiency of the CPU.
  • FIG. 2 is a schematic diagram showing the working flow of another embodiment of the cache control system of the present invention.
  • This embodiment is combined with the system structure shown in FIG. 1 and the system workflow shown in FIG. 2, with stack growth and stack back.
  • the cache control Take the cache control as an example to explain the working principle of the cache control system.
  • the memory management unit MMU
  • the cache address is not included in the CPU, that is, the cache address and the detected memory address.
  • the format is consistent, and there is no need to convert the virtual address (program memory address) to the physical address (cache address).
  • the address detection module detects a value of the stack pointer, and obtains an initial memory address and a latest memory address of the stack memory.
  • the address of the stack memory is identified by the stack pointer.
  • the value of the stack pointer register in the ALU changes accordingly.
  • the address detecting module 11 in the cache control system can acquire the stack pointer value in the ALU, the stack pointer value is the memory address, detecting whether the stack pointer value changes; and when the change occurs, the old stack pointer is corresponding
  • the initial memory address and the latest memory address corresponding to the new stack pointer are sent to the address and operation generating unit 13.
  • the address and operation generating unit determines the change type of the stack memory according to the value of the stack pointer.
  • the direction of the stack growth may be divided into a stack to a low address and a stack to a high address. This embodiment takes the stack to a low address as an example, but The same applies to the stack to high address growth.
  • the address and operation generation unit compares the value of the new and old stack pointers. If the new address is smaller than the old address, it indicates that the stack memory change type is stack growth; if the new address is larger than the old address, it indicates the stack memory change type. Roll back for the stack.
  • the address and operation generating unit determines the cache operation address range according to the change of the stack memory; and obtains the cache operation information corresponding to the change type according to the change type of the stack memory;
  • the cache operation information corresponding to the change type of the stack memory may be preset in the address and operation generating unit, and the address and operation generating unit may query and obtain the corresponding cache operation information after determining the address change type.
  • the corresponding cache operation information is: a cache line unit corresponding to the allocated memory address in the cache is cache-line, and the state identifier of the cache line unit is set to prohibit data synchronization.
  • the flag is clean; since the tag is clean, the cache-line will consider that the data does not need to perform synchronization, so the synchronization data will not be acquired from the lower-level storage device; the cache line unit is the cache operation address range;
  • the old stack address is 136
  • the new stack address is 68
  • the length of a single cache-line is 32
  • the address range of the cache operation may be in the range of the address range, according to the cache-line, or the start and end addresses of the address range itself are aligned according to the cache-line.
  • the address range can be as follows:
  • the corresponding cache operation information is: controlling the cache to prohibit data synchronization in the cache line unit of the cache;
  • the cache-line corresponding to the corresponding cache operation address range is set to clean, the data will no longer be synchronized; or, because the data of the stack fallback is invalid. Data, you can also directly eliminate the cache-line data. Thereby, the cache is prevented from performing unnecessary data synchronization work, and the processing efficiency of the CPU is improved.
  • the old stack address is 68
  • the new stack address is 136
  • the length of a single cache-line is 32
  • the address and operation generating unit sends the cache operation address range and the cache operation information.
  • the cache instruction generating unit generates a cache control instruction by the cache instruction generating unit; wherein, after receiving the cache operation address range and the cache operation information, the cache instruction generating unit 14 generates an instruction sequence for controlling the cache;
  • the cache instruction generating unit sends the cache control instruction to the cache operation control unit 15; and the cache operation control unit 15 controls the cache to execute the cache operation information in the cache operation address range according to the cache control instruction.
  • the foregoing workflow is an example of a change in stack memory; for a change in heap memory, the workflow of the system is basically the same as the above process, and the address range of the heap memory is obtained from the ALU, and the above process is executed. No longer.
  • the address range of the heap memory may be written by the software from the ALU and then written to the register in the address detecting module 11.
  • the determination of the address range of the cache operation for the heap memory change can be summarized as [roof(start, cache-line size, floor(end, cache-line size)], pin ⁇ ] "the stack memory becomes 4 cache operations.
  • the determination of the address range can be summarized as follows: if the address is increased to the lower address, it is aligned to the lower address, that is, [floor(start cache-line size, floor(end, cache-line size)]; 1 J is aligned to a high address, which is [roof(start, cache-line size, roof(end, cache-line size)].
  • the cache control system of this embodiment can control the cache to perform corresponding operations according to the change type by detecting the address change type of the stack or the heap memory, that is, when the memory address is allocated or released, the cache is prohibited from performing data synchronization, thereby solving the problem.
  • the CPU waits for the delay problem, avoids the cache to perform unnecessary synchronization work, and significantly improves the processing efficiency of the CPU.
  • FIG. 3 is a schematic diagram of a working flow of a cache control system according to another embodiment of the present invention.
  • the CPU used in the system of this embodiment stores In the MMU, a virtual address (memory address) to a physical address (cache address) conversion is required; and by detecting the MMU that a task switch has occurred, the task refers to an application, and the switch refers to a program switch. Run on another stack.
  • the translation lookup cache in the MMU can also be detected ( Translation
  • TLB Lookaside Buffer
  • the TLB is converted to the physical address by sending the virtual address of the stack pointer to the TLB. If the ASID in the TLBentry is different, it indicates that the switch has occurred. For example, if the mapping relationship of the MMU does not change, but the ASID of the hit TLB changes when the virtual address of the stack pointer is converted to the physical address by the TLB, the task switching is considered to have occurred.
  • the range of the stack is limited, so it is also possible to determine whether the stack is switched by comparing whether the change range of the stack pointer is greater than a set threshold.
  • This particular value can be provided by the software to a specific register or by hardware short-circuit hard-coded. That is, when the mapping relationship information of the MMU changes, the stack memory must be switched. When the mapping relationship information of the MMU does not change, if the address range of the change of the stack memory exceeds the set threshold, the task switching, that is, the stack memory is also determined. A switch has occurred. At this time, the initial memory address and the latest memory address of the stack memory corresponding to the memory mapping relationship information after the change may be obtained, or the initial memory address and the latest memory address corresponding to the stack memory exceeding the set threshold.
  • the address detection module detects the value of the stack pointer, and obtains an initial memory address and a latest memory address of the stack memory. The address detection module further queries the cache address corresponding to the memory address through the MMU/TLB, and whether task switching occurs.
  • the address and operation generating unit may perform the address translation operation, that is, querying, by using the MMU/TLB, a cache address corresponding to the memory address.
  • the address detection module also checks the MMU/TLB information to check whether task switching occurs.
  • the MMU/TLB stores the main information of the current task, for example, the memory mapping relationship information corresponding to the task.
  • the memory mapping relationship information in the MMU/TLB also changes, and the address detection module changes. It is possible to detect whether a task switch has occurred by detecting an information change of the MMU.
  • the address detection module sends the converted cache address to the address and the operation generating unit. And the notification address and the operation generating unit, the task switching occurs;
  • the address and operation generating unit sets the stack address detected by the previously received address detecting module to an invalid state, and receives the stack pointer value of the new task as the initial memory address of the new task; because the stack pointer changes before and after the task switching The space between them does not constitute a stack frame; therefore, the value of the stack pointer is invalid until the task switch is completed.
  • the running environment (register, etc.) of the task to be switched out is saved first, and then the memory mapping is switched. After the memory mapping is completed, the running environment of the newly switched task is restored, and the stack pointer value of the new task is set.
  • the new task program continues to run; the address detection module sends the stack pointer value of the new task to the address and operation generation unit, the stack pointer is the last memory address of the new task, that is, as the new task The initial memory address. At this point, the address and operation generation unit resets the received stack pointer value to a valid state.
  • the address detection module detects that the stack pointer of the new task changes, and sends the new stack pointer value to the address and operation generating unit.
  • the address and operation generating unit generates an address range, an address change type, and corresponding cache operation information of the new task according to the initial memory address in 303 and the latest memory address in 304.
  • the cache instruction generating unit receives the cache operation address range and the cache operation information, and converts the cache control instruction to the cache operation control unit.
  • the cache operation control unit controls the cache to execute the cache operation information in the cache operation address range according to the cache control instruction.
  • the cache control system of this embodiment can control the cache to perform corresponding operations according to the change type by detecting the address change type of the stack or the heap memory, that is, when the memory address is allocated or released, the cache is prohibited from performing data synchronization, thereby solving the problem.
  • the CPU waits for the delay problem, avoids the cache to perform unnecessary synchronization work, and significantly improves the processing efficiency of the CPU.
  • FIG. 4 is a schematic flowchart of a method for controlling a cache memory according to an embodiment of the present invention.
  • the method of this embodiment may be performed by a cache control system according to any embodiment of the present invention. It can be combined with the description of the examples. As shown in Figure 4, the method can include:
  • the address change type includes allocation or release of a memory address
  • the address change type is the allocation or release of the memory address
  • determine a cache operation address range corresponding to the changed address range and control the cache to execute the cache operation information in the cache operation address range; the cache operation information is prohibited.
  • the cache performs data synchronization in the cache operation address range.
  • a cache line unit corresponding to the allocated memory address is established in the cache, the cache line unit is the cache operation address range; and the cache is prohibited at the high speed.
  • the cache line unit performs data synchronization;
  • the cache line unit is the cache operation address range; and prohibiting the cache from being in the cache
  • the row unit performs data synchronization.
  • control cache executes the cache operation information in the cache operation address range, including: obtaining, according to the changed address range and the address change type, the cache operation address range, and the corresponding to the address change type Cache operation information; converting the cache operation address range and the cache operation information into a cache control instruction; and controlling, according to the cache control instruction, the cache operation information in the cache operation address range.
  • the obtained address range of the target object is specifically: detecting a value of a stack pointer corresponding to the stack memory, obtaining an initial memory address of the stack memory, and the latest Memory address.
  • the target object is a stack memory.
  • the method further includes: detecting whether the memory mapping relationship information in the MMU or the changed address range of the stack memory exceeds a set threshold; if the memory mapping relationship information changes or the address If the range exceeds the set threshold, the address range of the change of the target object is specifically: obtaining an initial memory address and a latest memory address of the stack memory corresponding to the memory mapping relationship information after the change, or a stack exceeding a set threshold Correspondingly, the initial memory address and the latest memory address corresponding to the memory; correspondingly, determining the cache operation address range corresponding to the allocated memory address, comprising: querying the MMU to obtain an initial memory address and a latest memory address respectively from the stack memory Corresponding cache address; determining a cache operation address range corresponding to the allocated memory address according to the cache address.
  • the unit is the address range of the cache operation.
  • the method further includes: selecting, by the cache operation address range, a partial operation address range; correspondingly, the control cache executes the cache operation information in the cache operation address range, specifically: controlling the cache to execute in a part of the cache operation address range Cache operation information.
  • the cache line unit of the control cache prohibits performing data synchronization, and the method includes: setting a state identifier of the cache cache line unit to an unmodified identifier; Alternatively, setting a status identifier of the cache line unit of the cache to an invalid identifier; or setting an invalid identifier for the stored data in the cache line unit of the cache.
  • the cache operation address range is converted into a cache control instruction, specifically: converting the cache operation address range into an address range instruction; or converting the cache operation address range into a corresponding address sequence instruction.
  • the cache includes a multi-level storage unit, and further includes: the upper-level storage unit of the multi-level storage unit respectively sends the cache operation address range to a next-level storage unit, so that the next step
  • the level storage unit generates a cache operation address range corresponding to the next-level storage unit according to the cache operation address range and the length of the cache line unit of the next-level storage unit; or the highest of the multi-level storage units
  • the first-level storage unit simultaneously sends the changed address range to all of the lower-level storage units, so that the lower-level storage unit respectively obtains a cache operation address range corresponding to the lower-level storage unit according to the changed address range.
  • the cache control method of the embodiment by detecting the address change type of the stack or the heap memory, the cache can be controlled according to the change type, that is, when the memory address is allocated or released, the cache is prohibited from being synchronized, thereby solving the problem.
  • the CPU waits for the delay problem, avoids the cache to perform unnecessary synchronization work, and significantly improves the processing efficiency of the CPU.
  • Embodiments of the present invention also provide a cache control device that includes a cache control system of any of the embodiments of the present invention.
  • the device may be a central processing unit CPU, as shown in FIG. 1, the CPU includes: a cache control system according to any embodiment of the present invention, further comprising an arithmetic logic unit ALU, a cache cache, and the like.
  • a cache control system according to any embodiment of the present invention, further comprising an arithmetic logic unit ALU, a cache cache, and the like.
  • the address detection module in the cache control system is connected to the ALU for The ALU obtains the memory address of the stack or the heap; the cache control module is connected with the cache, and can obtain the corresponding cache operation address range and the cache operation information according to the detected stack or heap memory address change, and control the cache to perform corresponding operations accordingly.
  • the CPU may further include an MMU/TLB, an address and operation generating unit in the cache control system, connected to the MMU, and performing address translation by the MMU to convert the virtual address of the memory into a corresponding cache address. And to check whether a task switch occurs, etc. by detecting a change in information in the MMU or a range of changes in the stack memory.
  • the cache control device of this embodiment can control the cache to perform corresponding operations according to the change type by detecting the address change type of the stack or the heap memory, that is, when the memory address is allocated or released, the cache is prohibited from performing data synchronization, thereby solving the problem.
  • the CPU waits for the delay problem, avoids the cache to perform unnecessary synchronization work, and significantly improves the processing efficiency of the CPU.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

本发明提供一种高速缓冲存储器控制方法、装置和***,其中方法包括:获取目标对象的变化的地址范围;根据变化的地址范围确定地址变化类型,若为内存地址的分配或者释放,则确定与变化的地址范围对应的cache操作地址范围,并控制cache在cache操作地址范围执行cache操作信息;所述cache操作信息为禁止所述cache在所述cache操作地址范围执行数据同步。本发明避免了cache执行不必要的同步工作,显著提高了CPU的处理效率,降低了对总线和内存带宽的需求。

Description

高速緩冲存储器控制方法、 装置和*** 技术领域 本发明涉及计算机技术, 尤其涉及一种高速緩冲存储器控制方法、 装置 和***。 背景技术
中央处理器(Central Process Unit, 简称: CPU )在运算时需要从主存储 器即内存中读取数据, 但是, 内存的存取速度比 CPU的操作速度慢得多, 使 得 CPU的处理能力不能充分发挥,影响整个***的工作效率。为了緩和 CPU 和内存速度不匹配的矛盾, 通常在 CPU 和内存之间采用高速緩冲存储器 cache , cache可以预先读取内存中的数据, CPU直接对 cache进行存取操作。
具体的, 内存中包括用于存放数据的栈内存和堆内存, 其中, 栈内存是 用于存储程序运行中的临时数据的一段内存, 堆内存是为某个应用程序分配 的一段内存, cache会保持与栈内存和堆内存之间的数据一致, 以保证 CPU 的正确读取。 例如, 当内存中新分配一段栈内存或者堆内存, 并在程序对该 内存操作时, cache会先读取该新分配地址对应的旧的存储数据, 以保持数据 一致; 但是新分配的栈内存或者堆内存后续会存放新数据, cache读取的这些 旧数据实际是无效数据, 根本不需要读取。 又例如, 当程序完成对内存的使 用后, 进行栈回退或者堆内存释放操作, 即释放所占用的内存地址时, 为保 持数据一致, cache也会将其内存储的在程序运行中改写过的数据写回到内存 中, 而实际上这些数据是已经使用过的数据, 已经成为无效数据, 根本不需 要写回。
因此, 现有技术的 cache执行了很多不必要的数据同步工作, 而这些同 步工作会使得在程序运行中 CPU的 ALU或者其他部件需要等待 cache做完 这些工作, 增加了 CPU的等待时间, 降低了 CPU的处理效率, 并且, 浪费 带宽资源。 发明内容 本发明的第一个方面是提供一种高速緩冲存储器控制方法,以减少 cache 不必要的同步工作, 提高 CPU的处理效率, 节省带宽。
本发明的另一个方面是提供一种高速緩冲存储器控制装置,以减少 cache 不必要的同步工作, 提高 CPU的处理效率, 节省带宽。
本发明的又一个方面是提供一种高速緩冲存储器控制***,以减少 cache 不必要的同步工作, 提高 CPU的处理效率, 节省带宽。
本发明提供的高速緩冲存储器 cache控制方法, 包括:
获取目标对象的变化的地址范围;
根据所述变化的地址范围确定地址变化类型; 若所述地址变化类型为内 存地址的分配或者释放; 则
确定与变化的地址范围对应的 cache操作地址范围,并控制 cache在 cache 操作地址范围执行 cache操作信息; 所述 cache操作信息为禁止所述 cache在 所述 cache操作地址范围执行数据同步。
本发明提供的高速緩冲存储器 cache控制***, 包括:
地址检测模块, 用于获取目标对象的变化的地址范围;
cache控制模块, 用于根据所述变化的地址范围确定地址变化类型; 若所 述地址变化类型为内存地址的分配或者释放, 则确定与变化的地址范围对应 的 cache操作地址范围, 并控制 cache在 cache操作地址范围执行 cache操作 信息; 所述 cache操作信息为禁止所述 cache在所述 cache操作地址范围执行 数据同步。
本发明提供的高速緩冲存储器控制装置, 包括本发明所述的高速緩冲存 储器控制***。
本发明高速緩冲存储器控制方法的技术效果是: 通过获取目标对象的变 化的地址范围得到地址变化类型, 并可以根据该变化类型控制 cache执行对 应操作, 即在内存地址分配或者释放时, 禁止 cache进行数据同步, 从而解 决了 CPU等待延时的问题, 避免了 cache执行不必要的同步工作, 显著提高 了 CPU的处理效率。
本发明高速緩冲存储器控制装置的技术效果是: 通过获取目标对象的变 化的地址范围得到地址变化类型, 并可以根据该变化类型控制 cache执行对 应操作, 即在内存地址分配或者释放时, 禁止 cache进行数据同步, 从而解 决了 CPU等待延时的问题, 避免了 cache执行不必要的同步工作, 显著提高 了 CPU的处理效率。
本发明高速緩冲存储器控制***的技术效果是: 通过获取目标对象的变 化的地址范围得到地址变化类型, 并可以根据该变化类型控制 cache执行对 应操作, 即在内存地址分配或者释放时, 禁止 cache进行数据同步, 从而解 决了 CPU等待延时的问题, 避免了 cache执行不必要的同步工作, 显著提高 了 CPU的处理效率。 附图说明 图 1为本发明高速緩冲存储器控制***一实施例的应用结构示意图; 图 2为本发明高速緩冲存储器控制***另一实施例的工作流程示意图; 图 3为本发明高速緩冲存储器控制***再一实施例的工作流程示意图; 图 4为本发明高速緩冲存储器控制方法实施例的流程示意图。 具体实施方式 实施例一
本发明实施例首先提供一种高速緩冲存储器控制***, 为了使得对于该 ***的结构和原理的说明更加清楚, 本实施例是将该***应用在中央处理器
CPU中为例对***进行描述。
图 1为本发明高速緩冲存储器控制***一实施例的应用结构示意图, 如 图 1所示, 本实施例的***可以包括: 地址检测模块 11、 cache控制模块 12; 其中, 地址检测模块 11 , 用于获取目标对象的变化的地址范围; 例如, 所述的目标对象可以包括栈内存、 堆内存, 或者用于存放代码段、 数据段等数据的内存等。 所述的变化的地址范围指的是, 例如, 对于栈内存, 该变化的地址范围对应于栈增长或者栈回退的地址范围, 可以获取该地址范 围对应的初始内存地址和最新内存地址; 对于堆内存, 该变化的地址范围对 应于堆内存分配或者释放时的地址范围, 可以获取该地址范围对应的起始地 址和结束地址。
例如, 该地址检测模块 11与 CPU中的算术逻辑单元算数逻辑单元 ( Arithmetic Logic Unit, 简称: ALU )连接, 可以从 ALU中获取栈内存的初 始内存地址和最新内存地址。 举例说明, 原来的栈所占用的内存地址范围为 al〜a2, 在新分配栈内存后, 新的栈所占用的内存地址范围为 al〜a3 , 则该栈 内存的初始内存地址为 a2, 最新内存地址为 a3; 堆内存的地址同理。
cache控制模块 12, 与地址检测模块 11连接, 用于根据地址检测模块 11 检测到的目标对象的初始内存地址和最新内存地址确定地址变化类型, 所述 地址变化类型包括内存地址的分配或者释放;
例如, 所述的内存地址的分配: 包括栈增长、 堆分配; 所述的内存地址 的释放: 包括栈回退、 堆释放。
例如, 仍以上述的栈内存变化为例, 假设该栈内存为向高地址增长型。 则若地址 a3大于地址 a2, 则表明该栈内存的变化为 "栈增长" , 即, 新分配 了一段栈内存; 若地址 a3小于 a2, 则表明该栈内存的变化为 "栈回退", 即, 释放一段栈内存。 所以, 通过检测内存地址, 可以根据该内存地址的变化分 析得到变化类型; 而一般新分配内存表示可能有新的应用程序将要运行并使 用该内存, 释放内存表示应用程序已经运行完毕; 即, 通过感知变化的地址 范围得到了应用程序的运行行为。
该 cache控制模块 12, 还用于在所述地址变化类型为内存地址的分配或 者释放时, 确定与变化的地址范围对应的 cache操作地址范围, 并控制 cache 在 cache操作地址范围执行 cache操作信息; 所述 cache操作信息为禁止所述 cache在所述 cache操作地址范围执行数据同步。
例如, 若地址变化类型为内存地址的分配, 则 cache控制模块 12确定与 变化的地址范围对应的 cache操作地址范围, 即与分配的内存地址对应的 cache操作地址范围, 并控制 cache在 cache操作地址范围执行 cache操作信 息, 其中, cache操作信息为: 禁止所述 cache在所述 cache操作地址范围执 行数据同步。 例如, 在所述 cache建立与所述变化的地址范围对应的高速緩 存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并将状态标识 设置为 clean, 根据 cache的工作原理, 只要设置为未修改标识例如 clean就 能够禁止 clean-line从下级存储器执行数据读入同步。
若地址变化类型为内存地址的释放, 则确定与变化的地址范围对应的 cache操作地址范围, 即与释放的内存地址对应的 cache操作地址范围, 并控 制 cache在 cache操作地址范围执行 cache操作信息, 其中, cache操作信息 为: 禁止所述 cache在所述 cache操作地址范围执行数据同步。 例如, 确定与 所述变化的地址范围对应的高速緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并禁止高速緩存行单元向下级存储器执行数据写出同 步。 所述的禁止执行数据同步的具体实施可以是, 例如, 将 cache-line的状态 标识设置为 clean; 或者, 将 cache-line的状态标识设置为无效(即表示该 cache-line未使用) ; 或者, 将 cache-line的状态标识设置有效, 但是在状态 标识处增加一比特位,用于存储标识 cache-line中的数据无效的状态标识; 上 述措施均可以使得 cache-line不再执行数据同步。 所述的下级存储器包括 cache中的下一级 cache或者内存。
例如, cache中通常是按照高速緩存行单元(cache-line )来存储的, 即 cache中一般设置有多个存储数据的 cache-line, 操作指令也通常是对整个 cache-line的操作。 由地址检测模块 11所获得的初始内存地址和最新内存地 址构成的地址范围有可能其中一部分地址对应的是部分 cache-line, 不是完整 的一个 cache-line, 此时一般是不进行操作的。
举例说明, 假设一个 cache-line的长度是 32字节, 有两个 cache-line , 其 中一个是 0〜32字节且均写满数据,另一个是 33〜64字节且只有 33〜36字节存 储数据其他空间为空。 现在发生了栈回退, 栈回退对应的地址范围是 28〜36 字节, 则如果该栈回退对应的地址范围均设置为禁止数据同步, 则两个 cache-line需要全部禁止同步, 这显然不合理, 因为, 第一个 cache-line中的 0〜27字节的数据是需要同步的, 否则会造成数据不一致。 因此, 只能是对第 二个 cache-line禁止同步, 第一个 cache-line需要同步。
由此可以看到, cache操作地址范围与实际检测到的内存地址变化范围并 不一定是完全相同的, 需要根据 cache的内部结构即是按照 cache-line组织存 储, 以及 cache中的操作方式即以整个 cache-line为操作对象, 来确定具体的 cache操作地址范围, 这里的 cache操作地址范围可以理解为, 对 cache中的 哪几个 cache-line执行操作 , 或者这几个 cache-line对应的地址。
其中, cache中的每一个 cache-line都对应设置有一个该 cache-line的状 态标识, cache-line也是按照该状态标识进行操作的。 例如, 应用程序在运行 时, 所涉及到的大部分数据存取操作都是 CPU直接从 cache执行的, cache 中的数据被改写, cache将被改写的 cacheline标记为 dirty, 表示被改写, 后 续 cache会将数据写回到下级存储器(内存或下级 cache ) , 以保证数据的正 确性。 相应的, 本实施例在内存地址分配或者释放时, 禁止所述 cache在所 述 cache操作地址范围执行数据同步。 例如, 确定与所述变化的地址范围对 应的高速緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并 将 cache-line的状态标识设置为 clean,使得 cache-line 居该状态标识不再读 写无效数据, 从而减少 CPU的等待延时, 提高 CPU的处理效率, 并且节省 了带宽资源。
更进一步的, 本实施例的 cache控制模块 12可以包括: 地址和操作生成 单元 13、 cache指令生成单元 14、 cache操作控制单元 15。
其中, 地址和操作生成单元 13 , 与地址检测模块 11连接, 可以接收地 址检测模块 11得到的目标对象的变化的地址范围,并可以根据上述变化的地 址范围判断得到地址变化类型为分配或者释放; 以及, 可以确定该分配或者 释放的内存地址对应的 cache操作地址范围,所述的 cache操作地址范围为仅 包括所述分配或者释放的内存地址中的地址的高速緩存行单元; 还确定所述 地址变化类型对应的 cache操作信息。
例如, 若为内存地址的分配, 则所述 cache操作信息为所述在 cache建立 与分配的内存地址对应的高速緩存行单元, 并禁止所述 cache在所述高速緩 存行单元执行数据同步; 若为内存地址的释放, 则所述 cache操作信息为所 述禁止所述 cache在所述高速緩存行单元执行数据同步。
其中, cache指令生成单元 14, 与地址和操作生成单元 13连接, 用于接 收地址和操作生成单元 13传送的所述 cache操作地址范围、 以及所述 cache 操作信息;并将上述信息转换为用于控制 cache操作的 cache控制指令,例如, 生成 "cache操作地址和指令" 序列。
可选的, cache指令生成单元 14, 具体用于将所述 cache操作地址范围转 换为地址范围指令, 或者, 将所述 cache操作地址范围转换为对应的地址序 列指令。 即, 控制 cache操作可以是对 cache中的地址范围或者地址序列, 例 如, 通常在对 cache控制时是根据地址序列, 假设某一个 cache-line的地址范 围是 al〜a2,另一个 cache-line的地址范围是 a3〜a4,如果要对这两个 cache-line 操作, 则控制指令是地址序列 "a2、 a4" , 即从每个 cache-line的地址范围中 选择一个单独的地址, 用于标识该 cache-line, 通过地址序列 "a2、 a4,, 就可 以得知控制的是 a2对应的 cache-line以及 a4对应的 cache-line。 本实施例对 此进行了扩展, 通过地址范围控制 cache, 控制指令可以为 "al〜a2" , cache 就可以根据该地址范围得知需要操作的是哪个 cache-line。
其中, cache操作控制单元 15 , 位于 cache中, 并且与 cache指令生成单 元 14连接, 用于根据 cache指令生成单元 14生成的 cache控制指令,控制对 应的 cache操作信息, 例如, 将 cache的与变化的地址范围对应的高速緩存行 单元的状态标识设置为禁止数据同步同步标识例如 clean。
可选的, 地址和操作生成单元 13 , 具体用于由所述 cache操作地址范围 中选取部分操作地址范围, 在所述部分操作地址范围执行 cache操作信息即 禁止执行数据同步。 即, 操作的 cache地址范围可以是部分地址, 只实现部 分地址的 cache操作。 例如, 由内存地址变化得到的初始 cache操作地址范围 包括三个 cache-line , 可以选择其中的两个 cache-line作为实际的 cache操作 地址范围, 另一个 cache-line不进行相关 cache操作信息。
可选的, 当地址变化类型为内存地址的释放时, cache控制模块 12, 具 体用于将 cache的高速緩存行单元的状态标识设置为未修改标识; 或者, 将 所述 cache的高速緩存行单元的状态标识设置为无效标识;或者,为所述 cache 的高速緩存行单元中的存储数据设置无效标识。
可选的, 地址检测模块 11中存储栈地址或者堆地址的方式可以为: 通过 寄存器方式, 将上述地址存储在地址检测模块 11的寄存器中; 或者, 可以是 指令方式, 通过地址传输指令, 传递相关地址和操作到地址检测模块 11中。 所述指令方式, 可以采用现有指令, 操作通用寄存器, 将上述地址送到地址 检测模块 11中, 或者在已有指令集基础上新增指令, 该新增的指令将上述地 址存储到地址检测模块 11。 地址和操作生成单元 13可以根据地址检测模块 11后续送入的地址, 产生 cache操作地址范围和操作指令。 指令方式每次操 作可以是一个地址, 分 2次操作; 或者一次指令操作两个地址; 指令操作码 可以包含对应的操作类型, 如: 将所述的地址对应的 cache-line的状态置为 clean, 无效或者数据无效。 例如, 通过对 cache操作的指令来完成上述的 "对 特定的 cache-line" 进行 "禁止所述 cache在所述高速緩存行单元执行数据同 步,, 的操作; 以代码的方式表示, 可以是: Cache— clean rl, r2, 或者
Cache— operation rl, r2, clean; 其中 rl, r2是通用寄存器, 存放地址范围, 可以 是起始地址 +长度, 也可以是起始地址 +结束地址等。
需要说明的是, 本实施例的各模块的划分只是一种示例, 具体实现中, 并不限制在本实施例的模块划分方式, 只要能实现该整个***的功能即可。 例如, 地址序列的产生可以在地址和操作生成单元, 也可以在 cache指令生 成单元等。 并且, 本实施例的各个模块或者单元, 可以是硬件实现, 也可以 是软件实现, 不做限制。
此外, 本实施例的方案适用于一级或者多级 cache, 当 cache为包括多级 存储单元的多级 cache时, 多级 cache通常下级为上级提供数据緩存, 容量更 大, 但速度更低, 例如 L2cache、 L3 cache, 各级 cache存储的数据需要保持 一致。 交互主要也是数据同步。 针对多级 cache, 在每一级 cache都包括本实 施例的地址和操作生成单元、 cache指令生成单元和 cache操作控制单元, 该 三个单元可采取与前级相同的处理,不再赘述;只是,由于各级 cache-line size 不同, 各级 cache对应的 cache操作地址范围是不同的。
可选的, 多级存储单元中的上一级存储单元分别向下一级存储单元发送 所述 cache操作地址范围,以使得所述下一级存储单元根据所述 cache操作地 址范围以及下一级存储单元的高速緩存行单元的长度, 生成对应所述下一级 存储单元的 cache操作地址范围。 或者, 多级存储单元中的最高一级存储单 元将所述变化的地址范围同时发送至所有下级存储单元, 以使得所述下级存 储单元根据所述变化的地址范围, 分别得到对应所述下级存储单元的 cache 操作地址范围。
本实施例的高速緩冲存储器控制***, 通过检测栈或堆内存的地址变化 类型, 可以根据该变化类型控制 cache执行对应操作, 即在内存地址分配或 者释放时, 禁止 cache进行数据同步, 从而解决了 CPU等待延时的问题, 避 免了 cache执行不必要的同步工作, 显著提高了 CPU的处理效率。
实施例二
图 2为本发明高速緩冲存储器控制***另一实施例的工作流程示意图, 本实施例是结合图 1所示的***结构, 以及该图 2所示的***工作流程, 以 栈增长、 栈回退的 cache控制为例, 对高速緩冲存储器控制***的工作原理 进行说明。 其中, 本实施例是以 CPU中不存在内存管理单元( Memory Management Unit, 简称: MMU )为例, 即 cache地址和所检测到的内存地址 的格式是一致的, 不需要进行虚拟地址(程序内存地址)到物理地址(cache 地址) 的转换。
201、 地址检测模块检测栈指针的值, 获得栈内存的初始内存地址和最新 内存地址;
其中, 栈内存的地址是由栈指针标识的, CPU在改变栈内存的地址时, 会相应使得 ALU中的栈指针寄存器的值发生改变。高速緩冲存储器控制*** 中的地址检测模块 11可以获取 ALU中的栈指针值, 该栈指针值即为内存地 址, 检测栈指针值是否发生变化; 并在发生变化时, 将旧栈指针对应的初始 内存地址、以及新栈指针对应的最新内存地址发送至地址和操作生成单元 13。
202、 地址和操作生成单元根据栈指针值判断栈内存的变化类型; 栈增长的方向可以分为栈向低地址增长、 栈向高地址增长; 本实施例以 栈向低地址增长为例, 但是对于栈向高地址增长也同样适用。
例如, 地址和操作生成单元比较新、 旧栈指针的值, 如果新地址比旧地 址小, 则表明栈内存的变化类型为栈增长; 如果新地址比旧地址大, 则表明 栈内存的变化类型为栈回退。
203、地址和操作生成单元根据栈内存的变化,确定 cache操作地址范围; 并根据栈内存的变化类型, 得到与该变化类型对应的 cache操作信息;
其中, 所述的与栈内存的变化类型对应的 cache操作信息可以是预先设 定在地址和操作生成单元的, 地址和操作生成单元在确定地址变化类型后, 可以查询获得对应的 cache操作信息。
具体的, 如果是栈增长, 则对应的 cache操作信息是: 在 cache建立与分 配的内存地址对应的高速緩存行单元即 cache-line , 并将高速緩存行单元的状 态标识设置为禁止数据同步, 例如标记为 clean; 由于标记为 clean, cache-line 就会认为该数据不需要执行同步, 所以不会从下级存储器件获取同步数据; 所述的高速緩存行单元为 cache操作地址范围;
例如, 对于栈向低地址增长的类型, cache操作地址范围是: 从新的栈地 址向低地址按 cache-line对齐开始, 到旧的栈地址向低地址按 cache-line长度 对齐对齐, 即 cache操作地址范围 [SI, S2]=[floor ( new SP (新的栈地址), cache-line size ) , floor(old SP (旧的栈地址 ) , cache-line size)];
举例说明: 假设旧的栈地址为 136, 新的栈地址为 68, 由于 68<136, 所 以为栈增长, 单个 cache-line的长度为 32, 地址高于 136的数据, 还在被使 用, 所以不能优化, 故地址 136所在的 cache-line不能被优化, 由此则 cache 操作地址范围 [SI, S2]= [floor ( 68, 32 ) , floor(136, 32)]=[64, 128]。
可能可选的, 该 cache操作地址范围, 在具体实现中, 可以是从地址范 围开始, 按照 cache-line增长, 也可以是地址范围本身起始和结束地址按照 cache-line对齐。
例如, 地址范围可以采用如下方式:
1 ) [起始地址,结束地址]; 如上述 [0x80202012, 0x80203034];
2 ) [起始地址,长度];如上述地址范围可表述为 [0x80202012,0x00001000]; 3 ) [起始地址,次数]; 如上述地址范围可表述为 [0x80202012,128];
4 ) [起始地址对齐到 cache line,结束地址对齐到 cache line]; 如上述地址 范围可表述为 [0x80202020, 0x80203020];
5 ) [起始地址对齐到 cache line,长度]; 如上述地址范围可表述为
[0x80202020, 0x00001000];
6 ) [起始地址对齐到 cache line,次数]; 如上述地址范围可表述为
[0x80202020, 128];
具体的, 如果是栈回退, 则对应的 cache操作信息是: 控制所述 cache在 所述 cache的高速緩存行单元禁止执行数据同步;
例如,具体实现中,可以是将对应的 cache操作地址范围对应的 cache-line 的状态标识设置为 clean, 则该数据将不再被同步; 或者, 由于栈回退的数据 是已经使用过的无效数据, 也可以直接将所述的 cache-line的数据进行消除。 从而避免了 cache执行不必要的数据同步工作, 提高了 CPU的处理效率。
所述对应的 cache操作地址范围是: 从新的栈地址向低地址按 cache-line 对齐开始, 到旧的栈地址向上按 cache-line长度对齐对齐, 即 [SI, S2]=[floor ( old SP, cache-line size ) , floor(new SP, cache-line size)]。
举例说明: 假设旧的栈地址为 68, 新的栈地址为 136, 由于 136>68, 所 以为栈回退, 单个 cache-line的长度为 32, 地址高于 136的数据, 还在被使 用, 所以不能优化, 故地址 136所在的 cache-line不能被优化, 由此则 cache 操作地址范围 [SI, S2]= [floor ( 68, 32 ) , floor(136, 32)]=[64, 128]。
204、 地址和操作生成单元将 cache操作地址范围、 cache操作信息发送 至 cache指令生成单元, 由 cache指令生成单元生成 cache控制指令; 其中, cache指令生成单元 14在接收到 cache操作地址范围、 cache操作 信息之后, 将其生成用于控制 cache的指令序列;
205、 cache指令生成单元将 cache控制指令发送至 cache操作控制单元 15 ; 由 cache操作控制单元 15根据所述 cache控制指令, 控制 cache在所述 cache操作地址范围执行所述 cache操作信息。
进一步的, 上述的工作流程是以栈内存的变化为例; 对于堆内存的变化, ***的工作流程与上述流程基本相同,也是从 ALU中获取到堆内存的地址范 围, 并执行上述的流程, 不再赘述。
其中, 在对于堆内存的变化时, 堆内存的地址范围可以是由软件从 ALU 中获取后写入到地址检测模块 1 1中的寄存器的。
其中, 在对于堆内存的变化时, 举例说明堆内存释放时的 cache操作地 址范围的确定: 堆内存释放时, 释放的内存地址从 0x80202012-0x80203034 , 这段地址范围内的数据不会再被使用, 因此也不需要同步到下级存储器。 但 是 0x80202012之前的数据, 以及 0x80203034之后的数据 (不含这 2个地址, 都有可能被程序使用) , 因此 cache优化操作不能对这部分数据进行优化。 因此实际操作的地址范围是 [roof ( 0x80202012, 32 ) , floor(0x80203034, 32)] = [0x80202020,0x80203020] , 共涵盖 128个 cache-line。
其中,针对堆内存变化的 cache操作地址范围的确定,可归纳为 [roof(start, cache-line size, floor(end, cache-line size)],针^] "栈内存变 4匕的 cache操作地址 范围的确定,可以归纳为:如果向低地址增长,则向低地址对齐,即为 [floor(start cache-line size, floor(end, cache-line size)]; 如果向高地址增长, 贝1 J向高地址对 齐, 即为 [roof(start, cache-line size, roof(end, cache-line size)]。
本实施例的高速緩冲存储器控制***, 通过检测栈或堆内存的地址变化 类型, 可以根据该变化类型控制 cache执行对应操作, 即在内存地址分配或 者释放时, 禁止 cache进行数据同步, 从而解决了 CPU等待延时的问题, 避 免了 cache执行不必要的同步工作, 显著提高了 CPU的处理效率。
实施例三
图 3为本发明高速緩冲存储器控制***再一实施例的工作流程示意图, 本实施例与图 2所示实施例的区别在于,本实施例的***所应用的 CPU中存 在 MMU, 需要进行虚拟地址(内存地址 )到物理地址( cache地址 )的转换; 并且以通过检测 MMU得知发生了任务切换为例, 所述的任务指的是应用程 序, 切换是指程序切换到另一个栈运行。
例如 intel x86CPU的 cr3寄存器的值发生变换, 则说明任务发生切换。 此外, 具体实施中, 也可以检测 MMU中的转译查找緩存 ( Translation
Lookaside Buffer, 简称: TLB ) , 通过将栈指针虚拟地址送给 TLB, TLB转 换得到物理地址, 如果所命中的 TLBentry中的 ASID不一样, 则说明发生了 切换。 例如, 如果 MMU的映射关系未发生变化, 但是通过 TLB转换栈指针 的虚拟地址到物理地址时, 所命中的 TLB中的 ASID发生变化, 即可认为是 发生了任务切换。
另外, 对于一个 CPU, 栈的范围是受限的, 所以也可以通过比较栈指针 的变化范围是否大于设定阈值, 来确定栈是否发生切换。 这个特定值可由软 件提供到特定的寄存器, 也可由硬件短路硬编码固定。 即, 在 MMU的映射 关系信息发生变化时, 栈内存一定发生切换; 在 MMU的映射关系信息未发 生变化时, 如果栈内存的变化的地址范围超过设定阈值, 则也断定任务切换 即栈内存发生切换。 此时可以获取变化之后的内存映射关系信息对应的栈内 存的初始内存地址和最新内存地址, 或者, 超过设定阈值的栈内存对应的初 始内存地址和最新内存地址。
301、 地址检测模块检测栈指针的值, 获得栈内存的初始内存地址和最新 内存地址; 并且,地址检测模块还通过 MMU/TLB查询内存地址对应的 cache 地址, 以及是否发生任务切换;
可选的, 也可以是地址和操作生成单元执行所述的地址转换操作, 即通 过 MMU/TLB查询内存地址对应的 cache地址。
同时, 地址检测模块还通过检测 MMU/TLB的信息查看是否发生任务切 换。 具体的, MMU/TLB中存储有当前任务的主要信息, 例如, 与任务对应 的内存映射关系信息, 当任务发生变化时, MMU/TLB中的内存映射关系信 息也会发生变化, 地址检测模块就可以通过检测 MMU的信息变化, 检测到 是否发生任务切换。
4叚设本实施例中发生了任务切换;
302、 地址检测模块将转换后的 cache地址发送至地址和操作生成单元, 并且通知地址和操作生成单元, 发生了任务切换;
303、地址和操作生成单元将之前接收到的地址检测模块检测到的栈地址 设置为无效状态, 并接收新任务的栈指针值, 作为新任务的初始内存地址; 因为任务切换前后, 栈指针变化之间的空间并不构成一个栈帧; 所以在 任务切换完成前, 栈指针的值是无效的。 任务切换时, 先保存被切换出去的 任务的运行环境(寄存器等) , 再切换内存映射, 在内存映射完成后, 将新 切换进来的任务的运行环境恢复, 此时将新任务的栈指针值写入栈指针寄存 器, 新任务的程序继续运行; 地址检测模块将新任务的栈指针值发送到地址 和操作生成单元, 该栈指针是该新任务上次的内存地址, 即可以作为该新任 务的初始内存地址。 此时, 地址和操作生成单元将接收到的栈指针值又重新 设置为有效状态。
304、 地址检测模块检测到新任务的栈指针发生变化, 将新的栈指针值发 送到地址和操作生成单元;
305、地址和操作生成单元根据 303中的初始内存地址和 304中的最新内 存地址, 生成新任务的地址范围、 地址变化类型以及对应的 cache操作信息;
306、 cache指令生成单元接收 cache操作地址范围、 cache操作信息, 并 转换为 cache控制指令发送至 cache操作控制单元;
307、 cache操作控制单元根据 cache控制指令, 控制 cache在所述 cache 操作地址范围执行所述 cache操作信息。
本实施例的高速緩冲存储器控制***, 通过检测栈或堆内存的地址变化 类型, 可以根据该变化类型控制 cache执行对应操作, 即在内存地址分配或 者释放时, 禁止 cache进行数据同步, 从而解决了 CPU等待延时的问题, 避 免了 cache执行不必要的同步工作, 显著提高了 CPU的处理效率。
实施例四
图 4为本发明高速緩冲存储器控制方法实施例的流程示意图, 本实施例 的方法可以由本发明任意实施例的高速緩冲存储器控制***所执行, 本实施 例对该方法只做简单说明, 具体可以结合参见实施例所述。 如图 4所示, 该 方法可以包括:
401、 获取目标对象的变化的地址范围;
402、 根据所述变化的地址范围确定地址变化类型; 所述地址变化类型包括内存地址的分配或者释放;
403、 若所述地址变化类型为内存地址的分配或者释放, 则确定与变化的 地址范围对应的 cache操作地址范围, 并控制 cache在 cache操作地址范围执 行 cache操作信息; 所述 cache操作信息为禁止所述 cache在所述 cache操作 地址范围执行数据同步。
例如, 若为内存地址的分配, 则在所述 cache建立与分配的内存地址对 应的高速緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并 禁止所述 cache在所述高速緩存行单元执行数据同步;
例如, 若为内存地址的释放, 则确定与所述变化的地址范围对应的高速 緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并禁止所述 cache在与所述高速緩存行单元执行数据同步。
具体的, 所述控制 cache在 cache操作地址范围执行 cache操作信息, 包 括: 根据所述变化的地址范围以及地址变化类型, 得到所述 cache操作地址 范围、 以及与所述地址变化类型对应的所述 cache操作信息; 将所述 cache操 作地址范围、 所述 cache操作信息转换为 cache控制指令; 根据所述 cache控 制指令, 控制 cache在所述 cache操作地址范围执行所述 cache操作信息。
例如, 当所述目标对象为栈内存时, 所述获取目标对象的变化的地址范 围, 具体为: 检测与所述栈内存对应的栈指针的值, 获得所述栈内存的初始 内存地址和最新内存地址。
可选的, 所述目标对象为栈内存; 还包括: 检测 MMU中的内存映射关 系信息或者栈内存的变化的地址范围是否超过设定阈值; 若所述内存映射关 系信息发生改变或者所述地址范围超过设定阈值, 则所述获取目标对象的变 化的地址范围, 具体为: 获取变化之后的内存映射关系信息对应的栈内存的 初始内存地址和最新内存地址, 或者, 超过设定阈值的栈内存对应的初始内 存地址和最新内存地址; 相应的, 所述确定与分配的内存地址对应的 cache 操作地址范围, 包括: 查询所述 MMU获得与所述栈内存的初始内存地址和 最新内存地址分别对应的 cache地址;根据所述 cache地址确定与分配的内存 地址对应的 cache操作地址范围。 单元为所述 cache操作地址范围。
可选的, 还包括: 由所述 cache操作地址范围中选取部分操作地址范围; 相应的,所述控制 cache在 cache操作地址范围执行 cache操作信息,具体为: 控制 cache在部分 cache操作地址范围执行 cache操作信息。
可选的, 若所述地址变化类型为内存地址的释放, 则所述控制 cache的 高速緩存行单元禁止执行数据同步, 具体包括: 将 cache的高速緩存行单元 的状态标识设置为未修改标识; 或者, 将所述 cache的高速緩存行单元的状 态标识设置为无效标识; 或者, 为所述 cache的高速緩存行单元中的存储数 据设置无效标识。
可选的, 所述 cache操作地址范围转换为 cache控制指令, 具体为: 将所 述 cache操作地址范围转换为地址范围指令; 或者, 将所述 cache操作地址范 围转换为对应的地址序列指令。
可选的, 所述 cache包括多级存储单元; 还包括: 所述多级存储单元中 的上一级存储单元分别向下一级存储单元发送所述 cache操作地址范围, 以 使得所述下一级存储单元根据所述 cache操作地址范围以及下一级存储单元 的高速緩存行单元的长度, 生成对应所述下一级存储单元的 cache操作地址 范围; 或者, 所述多级存储单元中的最高一级存储单元将所述变化的地址范 围同时发送至所有下级存储单元, 以使得所述下级存储单元根据所述变化的 地址范围, 分别得到对应所述下级存储单元的 cache操作地址范围。
本实施例的高速緩冲存储器控制方法, 通过检测栈或堆内存的地址变化 类型, 可以根据该变化类型控制 cache执行对应操作, 即在内存地址分配或 者释放时, 禁止 cache进行数据同步, 从而解决了 CPU等待延时的问题, 避 免了 cache执行不必要的同步工作, 显著提高了 CPU的处理效率。
实施例五
本发明实施例还提供一种高速緩冲存储器控制装置, 该装置包括本发明 任意实施例的高速緩冲存储器控制***。
例如, 该装置可以为中央处理器 CPU, 参见图 1所示, 该 CPU中包括: 本发明任意实施例的高速緩冲存储器控制***, 还包括算术逻辑单元 ALU、 高速緩冲存储器 cache等。
其中, 高速緩冲存储器控制***中的地址检测模块与 ALU连接, 用于从 ALU中获取栈或者堆的内存地址; cache控制模块与 cache连接, 可以根据检 测的栈或堆内存地址的变化得到对应的 cache操作地址范围、以及 cache操作 信息, 并据此控制 cache执行对应操作, 使得 cache在分配新内存或者释放内 存时不再进行不必要的数据同步, 从而提高 CPU的处理效率。
进一步的, 该 CPU还可以包括 MMU/TLB, 高速緩冲存储器控制***中 的地址和操作生成单元, 与所述 MMU连接, 可以通过 MMU进行地址转换, 将内存的虚拟地址转换为对应的 cache地址, 以及通过检测 MMU中的信息 变化或者栈内存的变化范围查看是否发生任务切换等。
本实施例的高速緩冲存储器控制装置, 通过检测栈或堆内存的地址变化 类型, 可以根据该变化类型控制 cache执行对应操作, 即在内存地址分配或 者释放时, 禁止 cache进行数据同步, 从而解决了 CPU等待延时的问题, 避 免了 cache执行不必要的同步工作, 显著提高了 CPU的处理效率。
本领域普通技术人员可以理解: 实现上述各方法实施例的全部或部分步 骤可以通过程序指令相关的硬件来完成。 前述的程序可以存储于一计算机可 读取存储介质中。 该程序在执行时, 执行包括上述各方法实施例的步骤; 而 前述的存储介质包括: ROM, RAM, 磁碟或者光盘等各种可以存储程序代码 的介质。
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并 不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims

权 利 要 求 书
1、 一种高速緩冲存储器 cache控制方法, 其特征在于, 包括:
获取目标对象的变化的地址范围;
根据所述变化的地址范围确定地址变化类型; 若所述地址变化类型为内 存地址的分配或者释放; 则
确定与变化的地址范围对应的 cache操作地址范围,并控制 cache在 cache 操作地址范围执行 cache操作信息; 所述 cache操作信息为禁止所述 cache在 所述 cache操作地址范围执行数据同步。
2、 根据权利要求 1所述的高速緩冲存储器控制方法, 其特征在于, 若所 述地址变化类型为内存地址的分配, 则
所述确定与变化的地址范围对应的 cache操作地址范围, 包括: 在所述 cache建立与所述变化的地址范围对应的高速緩存行单元,所述高速緩存行单 元为所述 cache操作地址范围;
所述禁止所述 cache在所述 cache操作地址范围执行数据同步具体为:禁 止所述 cache在所述高速緩存行单元执行数据同步。
3、 根据权利要求 1所述的高速緩冲存储器控制方法, 其特征在于, 若所 述地址变化类型为内存地址的释放, 则
所述确定与变化的地址范围对应的 cache操作地址范围, 包括: 确定与 所述变化的地址范围对应的高速緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围;
所述禁止所述 cache在所述 cache操作地址范围执行数据同步具体为:禁 止所述 cache在所述高速緩存行单元执行数据同步。
4、根据权利要求 1-3任一所述的高速緩冲存储器控制方法,其特征在于, 所述控制 cache在 cache操作地址范围执行 cache操作信息, 包括:
根据所述变化的地址范围以及地址变化类型, 得到所述 cache操作地址 范围以及所述 cache操作信息;
将所述 cache操作地址范围、所述 cache操作信息转换为 cache控制指令; 根据所述 cache控制指令, 控制 cache在所述 cache操作地址范围执行所 述 cache操作信息。
5、根据权利要求 1-4任一所述的高速緩冲存储器控制方法,其特征在于, 当所述目标对象为栈内存时, 所述获取目标对象的变化的地址范围, 具体为: 检测与所述栈内存对应的栈指针的值, 获得所述栈内存的初始内存地址 和最新内存地址;
相应的, 所述根据所述变化的地址范围确定地址变化类型, 所述地址变 化类型包括内存地址的分配或者释放, 具体为:
若根据所述栈内存的初始内存地址和最新内存地址获知为栈增长, 则确 定所述地址变化类型为内存地址的分配; 或者,
若根据所述栈内存的初始内存地址和最新内存地址获知为栈回退, 则确 定所述地址变化类型为内存地址的释放。
6、根据权利要求 1-4任一所述的高速緩冲存储器控制方法,其特征在于, 如果存在 MMU, 所述目标对象为栈内存, 所述方法还包括:
检测 MMU中的内存映射关系信息是否发生改变, 若所述内存映射关系 信息发生改变, 则所述获取目标对象的变化的地址范围具体为: 获取内存映 射关系信息发生改变之后的栈内存的初始内存地址和最新内存地址;
相应的, 所述确定与变化的地址范围对应的 cache操作地址范围, 包括: 查询所述 MMU获得与所述栈内存的初始内存地址和最新内存地址分别 对应的 cache地址;
根据所述 cache地址确定与所述变化的地址范围对应的 cache操作地址范 围。
7、根据权利要求 1-4任一所述的高速緩冲存储器控制方法,其特征在于, 如果存在 MMU, 所述目标对象为栈内存, 所述方法还包括:
检测栈内存的变化的地址范围是否超过设定阈值; 若所述地址范围超过 设定阈值, 则所述获取目标对象的变化的地址范围具体为: 获取超过设定阈 值的栈内存对应的初始内存地址和最新内存地址;
相应的, 所述确定与变化的地址范围对应的 cache操作地址范围, 包括: 查询所述 MMU获得与所述栈内存的初始内存地址和最新内存地址分别 对应的 cache地址;
根据所述 cache地址确定与所述变化的地址范围对应的 cache操作地址范 围。
8、根据权利要求 1-7任一所述的高速緩冲存储器控制方法,其特征在于, 所述确定与变化的地址范围对应的 cache操作地址范围, 包括: 确定仅包括所述变化的地址范围中的地址的高速緩存行单元为所述 cache操作地址范围。
9、根据权利要求 1-7任一所述的高速緩冲存储器控制方法,其特征在于, 所述控制 cache在 cache操作地址范围执行 cache操作信息, 具体为: 由所述 cache操作地址范围中选取部分操作地址范围, 在部分 cache操作地址范围执 行 cache操作信息。
10、 根据权利要求 3所述的高速緩冲存储器控制方法, 其特征在于, 若 所述地址变化类型为内存地址的释放, 则所述禁止 cache在所述高速緩存行 单元执行数据同步, 具体包括:
将所述高速緩存行单元的状态标识设置为未修改标识; 或者,
将所述高速緩存行单元的状态标识设置为无效标识; 或者,
为所述高速緩存行单元中的存储数据设置无效标识。
11、 根据权利要求 2所述的高速緩冲存储器控制方法, 其特征在于, 若 所述地址变化类型为内存地址的分配, 则所述禁止 cache在所述高速緩存行 单元执行数据同步, 具体包括:
将所述高速緩存行单元的状态标识设置为未修改标识; 或者,
为所述高速緩存行单元中的存储数据设置无效标识。
12、 根据权利要求 4所述的高速緩冲存储器控制方法, 其特征在于, 所 述 cache操作地址范围转换为 cache控制指令, 具体为:
将所述 cache操作地址范围转换为地址范围指令,
或者, 将所述 cache操作地址范围转换为对应的地址序列指令。
13、 一种高速緩冲存储器 cache控制***, 其特征在于, 包括: 地址检测模块, 用于获取目标对象的变化的地址范围;
cache控制模块, 用于根据所述变化的地址范围确定地址变化类型; 若所 述地址变化类型为内存地址的分配或者释放, 则确定与变化的地址范围对应 的 cache操作地址范围, 并控制 cache在 cache操作地址范围执行 cache操作 信息; 所述 cache操作信息为禁止所述 cache在所述 cache操作地址范围执行 数据同步。
14、 根据权利要求 13所述的高速緩冲存储器 cache控制***, 其特征在 于, 若地址变化类型为内存地址的分配, 则
所述 cache控制模块,具体用于在所述 cache建立与所述变化的地址范围 对应的高速緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并禁止所述 cache在所述高速緩存行单元执行数据同步。
15、 根据权利要求 13所述的高速緩冲存储器 cache控制***, 其特征在 于, 若地址变化类型为内存地址的释放, 则
所述 cache控制模块, 具体用于确定与所述变化的地址范围对应的高速 緩存行单元, 所述高速緩存行单元为所述 cache操作地址范围; 并禁止所述 cache在所述高速緩存行单元执行数据同步。
16、 根据权利要求 13-15任一所述的高速緩冲存储器控制***, 其特征 在于, 所述 cache控制模块, 包括:
地址和操作生成单元,用于根据所述变化的地址范围确定地址变化类型, 所述地址变化类型包括内存地址的分配或者释放; 以及, 用于根据所述变化 的地址范围以及地址变化类型, 得到所述 cache操作地址范围以及所述 cache 操作信息;
cache指令生成单元, 用于将所述 cache操作地址范围、 所述 cache操作 信息转换为 cache控制指令;
cache操作控制单元, 用于根据所述 cache控制指令, 控制 cache在所述 cache操作地址范围执行所述 cache操作信息。
17、 根据权利要求 13-16任一所述的高速緩冲存储器控制***, 其特征 在于, 所述目标对象为栈内存; 相应的,
所述地址检测模块, 具体用于检测与所述栈内存对应的栈指针的值, 获 得所述栈内存的初始内存地址和最新内存地址;
所述 cache控制模块, 具体用于根据所述栈内存的初始内存地址和最新 内存地址, 确定地址变化类型; 若为栈增长, 则所述地址变化类型为内存地 址的分配; 或者, 若为栈回退, 则所述地址变化类型为内存地址的释放。
18、 根据权利要求 13-16任一所述的高速緩冲存储器控制***, 其特征 在于, 如果存在 MMU, 所述目标对象为栈内存, 贝 J
所述地址检测模块, 具体用于检测 MMU中的内存映射关系信息是否发 生改变; 若所述内存映射关系信息发生改变, 则获取内存映射关系信息发生 改变之后的栈内存的初始内存地址和最新内存地址;
所述地址和操作生成单元, 具体用于查询所述 MMU获得与所述栈内存 的初始内存地址和最新内存地址分别对应的 cache地址,并根据 cache地址确 定与所述变化的地址范围对应的 cache操作地址范围。
19、 根据权利要求 13-16任一所述的高速緩冲存储器控制***, 其特征 在于, 如果存在 MMU, 所述目标对象为栈内存, 贝 J
所述地址检测模块, 具体用于检测栈内存的变化的地址范围是否超过设 定阈值; 若所述地址范围超过设定阈值, 则获取超过设定阈值的栈内存对应 的初始内存地址和最新内存地址;
所述地址和操作生成单元, 具体用于查询所述 MMU获得与所述栈内存 的初始内存地址和最新内存地址分别对应的 cache地址;并根据 cache地址确 定与所述变化的地址范围对应的 cache操作地址范围。
20、 根据权利要求 13-19任一所述的高速緩冲存储器控制***, 其特征 在于,
所述地址和操作生成单元, 具体用于确定仅包括所述变化的地址范围中 的地址的高速緩存行单元为所述 cache操作地址范围。
21、 根据权利要求 13-19任一所述的高速緩冲存储器控制***, 其特征 在于,
所述地址和操作生成单元, 具体用于由 cache操作地址范围中选取部分 操作地址范围, 控制 cache在部分 cache操作地址范围执行 cache操作信息。
22、 根据权利要求 13所述的高速緩冲存储器控制***, 其特征在于, 所述 cache控制模块, 具体用于在所述地址变化类型为内存地址的释放 时, 确定与所述变化的地址范围对应的高速緩存行单元, 所述高速緩存行单 元为所述 cache操作地址范围; 并将所述高速緩存行单元的状态标识设置为 未修改标识; 或者, 为所述高速緩存行单元中的存储数据设置无效标识; 或 者, 为所述高速緩存行单元中的存储数据设置无效标识;
或者, 具体用于在所述地址变化类型为内存地址的分配时, 在所述 cache 建立与所述变化的地址范围对应的高速緩存行单元, 所述高速緩存行单元为 所述 cache操作地址范围; 并将所述高速緩存行单元的状态标识设置为未修 改标识; 或者, 为所述高速緩存行单元中的存储数据设置无效标识。
23、 根据权利要求 13所述的高速緩冲存储器控制***, 其特征在于, 所述 cache指令生成单元,具体用于将所述 cache操作地址范围转换为地 址范围指令, 或者, 将所述 cache操作地址范围转换为对应的地址序列指令。
24、 一种高速緩冲存储器控制装置, 其特征在于, 包括权利要求 13-23 任一所述的高速緩冲存储器控制***。
25、 根据权利要求 24所述的高速緩冲存储器控制装置, 其特征在于, 所 述高速緩冲存储器控制装置为中央处理器 CPU;所述 CPU还包括算术逻辑单 元 ALU、 高速緩冲存储器 cache;
所述高速緩冲存储器控制***中的地址检测模块, 与所述 ALU连接; 所述高速緩冲存储器控制***中的 cache控制模块, 与所述 cache连接。
26、 根据权利要求 25所述的高速緩冲存储器控制装置, 其特征在于, 所 述 CPU还包括: 内存管理单元 MMU;
所述高速緩冲存储器控制***, 与所述 MMU连接。
PCT/CN2011/085200 2011-12-31 2011-12-31 高速缓冲存储器控制方法、装置和*** WO2013097246A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201180003800.3A CN102725741B (zh) 2011-12-31 2011-12-31 高速缓冲存储器控制方法、装置和***
PCT/CN2011/085200 WO2013097246A1 (zh) 2011-12-31 2011-12-31 高速缓冲存储器控制方法、装置和***

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/085200 WO2013097246A1 (zh) 2011-12-31 2011-12-31 高速缓冲存储器控制方法、装置和***

Publications (1)

Publication Number Publication Date
WO2013097246A1 true WO2013097246A1 (zh) 2013-07-04

Family

ID=46950463

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/085200 WO2013097246A1 (zh) 2011-12-31 2011-12-31 高速缓冲存储器控制方法、装置和***

Country Status (2)

Country Link
CN (1) CN102725741B (zh)
WO (1) WO2013097246A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104239237B (zh) * 2013-06-20 2017-07-14 华为技术有限公司 一种tlb管理方法及装置
CN107577614B (zh) * 2013-06-29 2020-10-16 华为技术有限公司 数据写入方法及内存***
CN105359115A (zh) * 2013-07-01 2016-02-24 惠普发展公司,有限责任合伙企业 包含虚拟地址空间和物理地址空间之间的映射的数据结构的查找
CN104346294B (zh) * 2013-07-31 2017-08-25 华为技术有限公司 基于多级缓存的数据读/写方法、装置和计算机***
GB2522906B (en) * 2014-02-10 2021-07-14 Advanced Risc Mach Ltd Region identifying operation for identifying a region of a memory attribute unit corresponding to a target memory address
US10303525B2 (en) * 2014-12-24 2019-05-28 Intel Corporation Systems, apparatuses, and methods for data speculation execution
GB2539455A (en) * 2015-06-16 2016-12-21 Nordic Semiconductor Asa Memory watch unit
CN110688329B (zh) * 2019-09-06 2021-08-10 无锡江南计算技术研究所 一种可同时支持多套Cache数据私有段动态设置的方法
CN112559141B (zh) * 2019-09-26 2024-04-30 上海亮衡信息科技有限公司 任务切换方法、装置、计算机设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1227932A (zh) * 1997-12-19 1999-09-08 日本电气株式会社 通过流水线控制访问的高速缓冲存储器***及其访问方法
US20060155886A1 (en) * 2005-01-11 2006-07-13 Da Silva Dilma M Methods and arrangements to manage on-chip memory to reduce memory latency
CN1879092A (zh) * 2003-11-12 2006-12-13 松下电器产业株式会社 高速缓冲存储器及其控制方法
CN101135994A (zh) * 2007-09-07 2008-03-05 杭州华三通信技术有限公司 一种划分缓存空间的方法和装置以及缓存控制器
WO2009037912A1 (ja) * 2007-09-20 2009-03-26 Nec Corporation キャッシュメモリシステムおよびキャッシュメモリ制御方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1227932A (zh) * 1997-12-19 1999-09-08 日本电气株式会社 通过流水线控制访问的高速缓冲存储器***及其访问方法
CN1879092A (zh) * 2003-11-12 2006-12-13 松下电器产业株式会社 高速缓冲存储器及其控制方法
US20060155886A1 (en) * 2005-01-11 2006-07-13 Da Silva Dilma M Methods and arrangements to manage on-chip memory to reduce memory latency
CN101135994A (zh) * 2007-09-07 2008-03-05 杭州华三通信技术有限公司 一种划分缓存空间的方法和装置以及缓存控制器
WO2009037912A1 (ja) * 2007-09-20 2009-03-26 Nec Corporation キャッシュメモリシステムおよびキャッシュメモリ制御方法

Also Published As

Publication number Publication date
CN102725741B (zh) 2014-11-05
CN102725741A (zh) 2012-10-10

Similar Documents

Publication Publication Date Title
WO2013097246A1 (zh) 高速缓冲存储器控制方法、装置和***
US10521375B2 (en) Controller for a memory system
US8495301B1 (en) System and method for scatter gather cache processing
JP7340326B2 (ja) メンテナンス動作の実行
US8924624B2 (en) Information processing device
US9524121B2 (en) Memory device having a controller unit and an information-processing device including a memory device having a controller unit
US8856588B2 (en) Information processing apparatus, control method, and computer-readable recording medium
KR102290464B1 (ko) 시스템 온 칩 및 그것의 주소 변환 방법
JP6021759B2 (ja) メモリシステムおよび情報処理装置
US8645612B2 (en) Information processing device and information processing method
US10540306B2 (en) Data copying method, direct memory access controller, and computer system
TW201202926A (en) Memory management device and memory management method
WO2014206217A1 (zh) 一种指令缓存的管理方法和处理器
JPWO2010035426A1 (ja) バッファメモリ装置、メモリシステム及びデータ転送方法
TW201214114A (en) Method and system to reduce the power consumption of a memory device
JP5128093B2 (ja) 複数のアドレス・キャッシュ・エントリを無効化する装置
WO2015010646A1 (zh) 混合内存的数据访问方法、模块、处理器及终端设备
CN103052945A (zh) 管理计算机存储器的方法、程序产品及数据存储设备
KR102482516B1 (ko) 메모리 어드레스 변환
WO2012075753A1 (zh) Cache存取的控制方法及装置
CN104679684A (zh) 半导体器件及其操作方法
KR20190059221A (ko) 메모리 어드레스 변환
CN115658588B (zh) 一种axi总线的id压缩装置及方法
JP4821887B2 (ja) コヒーレンシ制御システム、コヒーレンシ制御装置及びコヒーレンシ制御方法
JP7089530B2 (ja) データ処理

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201180003800.3

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11878736

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11878736

Country of ref document: EP

Kind code of ref document: A1