This invention relates generally to a method for purging cache entries in a computer system, and more particularly to providing a method, system and computer program product for selectively purging cache entries thereby reducing the number of cache directory accesses, and decreasing the amount of time required to perform purging of the cache entries.
When multiple images are stored in computer systems, it is highly desirable to dynamically reallocate storage among the multiple images in order to increase storage sizes for images which need improved throughput. Therefore, it is necessary to purge cache entries which correspond to respective storage addresses being reallocated from existing images and into critical images. Typically, the storage addresses being reallocated include a large contiguous range of storage addresses. The purging of cache entries containing storage address being reallocated is required to be performed quickly to minimize any impact on the system performance. FIG. I illustrates a conventional cache directory 10 which is organized into Y congruence classes (ranging from 0 to Y−1) and X compartments (ranging from 0 to X−1). The total number of directory entries is equal to Y multiplied by X, where there is one entry for each line of data in the cache.
In a conventional method, purging of storage addresses 100 from a wide storage range is performed by separate cache directory lookups for each address within the storage range in order to determine whether any of the storage addresses from the storage being reallocated exists within the cache. If the address does exist in the cache, then an additional step is required to purge the data from the cache. Using this method, the number of directory lookups required to be performed is equal to the number of addresses within the targeted storage range being reallocated. If the size of the storage being reallocated is many times greater than the size of the cache, the number of directory lookups required is proportional to the size difference and thus, increases the amount of time required to complete the purging of addresses belonging to the storage being reallocated.
It would be desirable to be able to reduce the number of directory accesses required when purging cache entries.
An exemplary embodiment includes a method for selectively purging entries in a cache of a computer system. The method includes determining a starting storage address and a length of the storage address range to be purged, determining preset values for a congruence class and a compartment of a cache directory, accessing the cache directory based on the preset value of the congruence class, and selecting an entry in the cache directory based on the preset value of the compartment, determining validity of the entry accessed by examining an ownership tag of the entry, comparing a line address of the entry with the starting storage address and a sum of the starting storage address and the length of the storage address range, and selectively purging the entry based on the comparison result.
Another exemplary embodiment includes a system having a processor, a system memory, a bus system and a cache. The system includes a purge engine logic unit coupled with a cache directory having a plurality of entries including a plurality of congruence classes and compartments. The purge engine logic unit includes a congruence class incrementer which increments a value of the congruence class, a compartment incrementer which increments a value of the compartment, and a directory compartment selector which selects a compartment of the cache directory. When the system determines to purge entries in the cache directory, a starting storage address and a length of the storage address range to be purged are loaded into the purge engine logic unit, the purge engine logic unit sets preset values for the congruence class and the compartment, accesses the cache directory based on the preset value of the congruence class, and selects an entry in the cache directory based on the preset value of the compartment selected by the directory compartment selector, determines validity of the entry by examining an ownership tag of the entry, compares a line address of the entry with the starting storage address and a sum of the starting storage address and the length of the storage address range, and selectively purges the entry based on the comparison result.
A further exemplary embodiment includes a computer program product corresponding to the above-summarized method.
Referring now to the drawings wherein like elements are numbered alike in the several FIGURES:
Turning now to the drawings in greater detail, it will be seen that in
In
That is, from operation 210, the process moves to operation 215, where a line address of the entry is compared with the starting storage address. Alternatively, when it is determined that the selected entry is invalid in operation 210, the process moves to operation 230, where it is determined whether the current compartment value is equal to a maximum value.
According to an exemplary embodiment, when it is determined that the line address is less than the starting purge address in operation 215, the process moves to operation 230, where it is determined whether the current compartment value is equal to a maximum value (X−1). When it is determined that the current compartment is less than the maximum value (X−1), the compartment is incremented via a compartment incrementer 305 (see
Alternatively, according to an exemplary embodiment, when it is determined that the line address is greater than the starting purge address in operation 215, the process moves to operation 220, where the line address is compared with a sum of the starting storage address and the length of the storage address range. When it is determined that the line address is greater than the sum in operation 220, the process moves to operation 230, where it is determined whether the current compartment value is equal to a maximum value (X−1). As mentioned above, when it is determined that the current compartment value is less than the maximum value (X−1), the current compartment value is incremented by one and the process returns to operation 205 and repeats operations 205 through 230 until the current compartment value is equal to the maximum value (X−1).
According to an exemplary embodiment, when it is determined that the line address is less than the sum in operation 220, the process moves to operation 225, where the entry is selectively purged from the cache directory 20 based on the comparison result and from operation 225, the process moves to operation 230, where it is determined whether the current compartment value is equal to a maximum value (X−1).
Referring to operation 230, when it is determined that the current compartment value is equal to the maximum value (X−1), the process moves to operation 235, where it is determined whether the current congruence class value is equal to a maximum value (Y−1). When it is determined that the current class value is equal to the maximum value (Y−1) in operation 235, the process moves to operation 250 where the selective purging of entries in the cache directory 20 is completed. Alternatively, when it is determined that the current congruence class value is less than the maximum value (Y−1), the current congruence class value is incremented by one via a congruence class incrementer 310 (see
As shown in
According to an exemplary embodiment, the entry is purged when it is determined that the line address is greater than the starting storage address and less than a sum of the starting storage address and the length of the storage address range.
Further, when it is determined that the line address is not a valid entry, when it is determined that the line address is less than the starting storage address, when it is determined that the line address is greater than the sum of the starting storage address entry and the length of the storage address range or after the purging of the entry has been completed, the compartment incrementer 305 increments the preset value of the compartment by one when it is determined that the preset value is less than the maximum value and continuously repeats the accessing, determining, comparing, selectively purging of entries, and incrementing of the preset value of the compartment until the preset value of the compartment equals the maximum value (X−1). Then, upon reaching the maximum value (X−1) of the compartment, it is determined whether the preset value of the congruence class equals a maximum value (Y−1) and when the preset value of the congruence class is less than the maximum value (Y−1), the congruence class incrementer 310 increments the preset value of the congruence class and continuously repeats the accessing, determining, comparing, selectively purging of entries and incrementing of the present value of the congruence class until the preset value of the congruence class is equal to the maximum value (Y−1).
According to an exemplary embodiment, the number of directory accesses required to complete all the necessary purges is equal to the number of directory entries, i.e. Y congruence classes multiplied by X compartments, independent of the number of lines in the specified address range.
Technical effects and benefits include reducing the number of directory accesses to a number that is independent of the address range size being purged, thereby reducing the amount of time required to perform the cache purges. The number of directory accesses required is equal to the number of directory entries regardless of the number of addresses from the storage range being reallocated. This is accomplished thru a series of “reverse” directory lookups and compares.
As described above, the embodiments of the invention may be embodied in the form of computer-implemented processes and apparatuses for practicing those processes. Embodiments of the invention may also be embodied in the form of computer program code containing instructions embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other computer-readable storage medium, wherein, when the computer program code is loaded into and executed by a computer, the computer becomes an apparatus for practicing the invention. The present invention can also be embodied in the form of computer program code, for example, whether stored in a storage medium, loaded into and/or executed by a computer, or transmitted over some transmission medium, such as over electrical wiring or cabling, through fiber optics, or via electromagnetic radiation, wherein, when the computer program code is loaded into and executed by a computer, the computer becomes an apparatus for practicing the invention. When implemented on a general-purpose microprocessor, the computer program code segments configure the microprocessor to create specific logic circuits.
While the invention has been described with reference to exemplary embodiments, it will be understood by those skilled in the art that various changes may be made and equivalents may be substituted for elements thereof without departing from the scope of the invention. In addition, many modifications may be made to adapt a particular situation or material to the teachings of the invention without departing from the essential scope thereof. Therefore, it is intended that the invention not be limited to the particular embodiment disclosed as the best mode contemplated for carrying out this invention, but that the invention will include all embodiments falling within the scope of the appended claims. Moreover, the use of the terms first, second, etc. do not denote any order or importance, but rather the terms first, second, etc. are used to distinguish one element from another.