Encoding method for directory state in cache coherent distributed shared memory system

Abstract: A directory system directs cache line access requests from processors in a multi-processor system with a shared memory system through a cache line states directory. The cache line states directory stores a state value that identifies a cache line shared states word. The cache line shared states word identifies the processor that owns the cache line and the state of access of each processor that shares access to the cache line. A state value encoder encodes a cache line shared state word into a state value and loads the state value into the cache line states directory. A state value decoder decodes the state value into a cache line shared state word for use by the cache line directory system in retrieving the cache line. A plurality of cache line tables are used with each cache line assigned to one of the tables. The cache line table stores a state value for each cache line shared states word stored in the table. The encoder and decoder perform a table look-up to convert between a cache line shared state word and a state value. Each of said cache line tables stores an ordered list of cache line shared state words and their corresponding state values. The ordered list is a list of cache line shared state words that have the most significance to the multi-processor system.

Description: The invention relates to a method and apparatus for directing cache access requests in a shared memory system. A memory sharing system for controlling the sharing of memory by multiple processors has been used for many years to increase efficient use of memory. The speed of processing of each of the processors is much higher than the storage processing speed of the memory system. Thus, over the years various techniques have been devised to better match data processing speed in the processor with data access speed to data stored in a memory system. One technique for better matching the data processing speed of the processor to data access speed in the storage system is to add cache storage systems at the processor. The data access speed of the cache system is much higher than the data access speed of the memory shared by all processors. Each processor has its own cache separate from the shared memory. Accordingly, data currently being worked on by a processor will be stored in its cache. This creates a cache coherency problem. The shared memory programming model, which serves as the basis for most multi-processor operating systems (UNIX, WindowsNT, etc.) and applications, requires that each of the processors accessing the system must see the same data in memory. Another cardinal rule is that as data is posted in the shared memory the act of posting must be visible to all processors sharing the memory. In a cache system if first processor is working on a block of data, hereinafter referred to as a cache line, and a second processor wishes to access the same data or data in the same cache line, then the second processor must be made aware of the fact that the current data it is seeking is in the first processor's cache. Thus, the memory system managing the shared memory for all of the processors must maintain the coherency of cache lines between the multiple processors. A technique for doing this is to identify cache line processor states for each cache line in use in the multiple processor system. Exemplary, cache line states are M,O,S,I and E. State M means the cache line has been modified by the processor associated with the state. State O means the cache line is owned by the processor, and state S means the cache line is shared by the processor. State I means the cache line is invalid for the processor, and E means the cache line is exclusive for the processor. In a bus-based symmetric multi-processor (SMP) system, to communicate this state information for a cache line, a protocol known as the "Snoopy Bus Protocol" provides that these various cache line processor states be communicated along the system bus between the multiple processors. Each time there is a change of state of a cache line atone of the processor caches, that change of state is broadcast on the system bus to all other processors. The problem with this approach is that if the number of multiple processors and cache systems becomes high then the system bus is soon filled with nothing but change of state cache information, or snoop traffic. The scalability of the SMP system in processors is thus limited by the amount of snoop traffic supported by the system bus before it saturates. To alleviate this problem, a directory of cache line entries was developed. The directory entry identifies the owner of the cache line and the state of that cache line relative to each and every other processor in the multi-processor system sharing the common memory. As the number of processors in the multi-processor system approaches a large number, for example 100 processors, these cache line entries become quite large and the number of cache lines becomes quite large. As a result, this directory approach consumes a great deal of memory just storing the directory. To reduce the amount of memory,consumed by the directory, the most recent design uses partially mapped directories. Each cache line in the various caches of the multiple processors has an entry in the directory, however, each directory entry is much smaller. In a partially mapped directory the entry identifies the owner of the cache line and the first "m" number of sharers (processors sharing information in the cache line). Typically, "m" is 2, 3 or 4. Limiting the number of sharers referenced in the directory entry greatly reduces the size of the directory but raises another problem. If there are more than 4 processors sharing the cache line, the shared memory system must take action to accommodate the additional identification of processors sharing the cache line. This has been done by allocating more space to the directory, by creating a supplemental directory or by issuing a broadcast operation in the case of incomplete directory information. The first two options require additional memory space for the directory. The third option requires more system bandwidth and thus takes more time. An article entitled "Issues in Multi-Level Cache Designs by L Liu, published in the Proceedings of the International Conference on Computer Design: VLSI in Computers an Processors, Cambridge MA, October 10-12, 1994 at pages 46-52 " describes designs for multi-level caches. This article describes offloading entries from an level 2 cache (L2) to a supplementary storage structure RD ("RES Directory"). One approach called "forward chaining" is keeping explicit pointers to the RD in the L2. Aspects of the invention are set out in the accompanying independent and dependent claims. An embodiment of the present invention allows maximally efficient use of memory serving as a fully mapped or partially mapped directory. The foregoing and other features, utilities and advantages of the invention will be apparent from the following more particular description of a preferred embodiment of the invention as illustrated in the accompany drawings. Exemplary embodiments of the invention are described hereinafter, by way of example only, with reference to the accompanying drawings, in which: Fig. 1 shows a shared memory system in a preferred embodiment of the invention where there is a cache line states directory system. Fig. 2 is a data flow diagram indicating the flow of information in the directory system of Fig. 1. Fig. 3 shows a preferred embodiment of the cache line states directory system of Fig. 1. Fig. 4 shows the process for building the entries in a cache line table. Fig. 5 is an example of the contents of a cache line table. In the preferred embodiment of the invention illustrated in Fig. 1, a multiple processor shared memory system utilizes a cache line states directory system 14 to provide cache line shared state information to the multiple processors, 6, 7, 8 and 9. Each of the processors P0 through Pm have their own cache system 10, 11, 12 and 13, respectively. During a read or write operation each of the processors accesses the cache line states directory system to either ascertain the status of the cache line or to update the status of the cache line. In general both read and write operations may require a read and write of the directory entry. A read operation necessitates only obtaining the information from a cache line directory entry, i.e. the ownership and shared states of the cache line. In a write operation the cache line shared states may be updated, and thus the cache line directory entry may be updated. Retrieving information from the cache line directory or updating the cache line directory are operations performed by the cache line states directory system 14. In the cache lines states directory system 14, the directory contains a state value for the cache line shared state information rather than the actual cache line shared state information. This state value is an encoded n-bit word identifying a state that corresponds to a unique cache line shared state word. For example, a cache line shared state word might identify processor P1 as the owner of the cache line and indicate the shared state for that cache line with processor P2 and P9. In Fig. 2, the flow of shared state information for a cache line is illustrated. A cache line shared state word 20 identifies the processor that owns the cache line and the shared states for processors also sharing the cache line. In the example of Fig.2, the owner of the cache line is processor P2 and processors P1, P3 and P4 share the cache line. The shared states are, for example, MODIFIED, SHARED or INVALID. Directory system 14 (Fig. 1) contains a cache line table 22 for each cache line and a directory 24 of cache line state values. The cache line table is used to convert the cache line shared state word (CLSS) into a state value (SV) for the cache line shared state word. Effectively the state value identifies the cache line shared state word for the cache line. The state values for the cache line are then stored in directory 24 and may be accessed by a cache line address from a processor P1 - PX to the directory 24. A processor requesting access to the cache line to obtain the cache line shared state information would send a cache line address to the directory 24. If the access is for a cache line read, then the state value at the cache line address in directory 24 is read. This state value points to the state value in the cache line table 22 as indicated by the dash line arrow 25. From table 22 the state value is converted or decoded into the cache line shared state entry and that entry is provided back to the processor as word 20 in Fig. 2. If the processor then wishes to write or modify the cache line, the states of the cache line shared state word are updated by the processor. The processor passes back the updated cache line shared state word to the cache line table as indicated by the solid arrow 21. The cache line shared state entry in table 22 is encoded to a state value by the cache line table 22. Once the state value encoding is complete the state value as indicated by the solid arrow 23 is loaded into directory 24 at the cache line address for that cache line in the directory. The implementation of the cache line states directory system 14 in Fig. 1 is shown in Fig. 3. In Fig. 3 the directory system is implemented by directory 30 storing the state values for the cache line shared state entries. These state values are decoded by decoder 32 into cache line shared state words. When scoring state values in directory 30, the cache line shared state word is encoded by encoder 34 and stored in directory 30. In the preferred embodiment, decoder 32 and encoder 34 use a cache line table for each cache line to perform the decoding and encoding operation as a table look up operation. Accordingly, when a processor in the multi-processor system provides a cache line directory address to directory 30, a state value may be written into the directory at that address or read out of the directory at that address depending upon whether a cache line shared state word is to be decoded or encoded into a state value. Not all cache line shared state words are encoded into a state value. The cache line tables 36 are limited in size and only the most Significant cache line shared state words for the multi-processor system design are provided with state values in the cache line table. In the preferred embodiment of the present invention, the partially mapped directory 30 contains n-bit words which are state values or pointers to an actual cache line shared state word. The actual cache line shared state words are stored as entries in cache line tables 36 such as table 22 in Fig. 2. The process for building each cache line table is illustrated in Fig. 4. For a given cache line the process begins at operation 40 by listing all possible cache line shared state entries or words for the cache line. After these cache line shared state words have been enumerated, they are then arranged or ordered in significance according to the multi-processor system design. The criteria for creating this ordered list will be described shortly hereinafter. After operation 42 orders the CLSS entries, operation 44 loads the highest order 2n- 1 number of CLSS entries into the cache line table. The variable n corresponds to the number of bits in the state value word stored in directory 30 (Fig. 3). In other words, the cache line state value word has n-bits. After operation 44 loads the highest order 2 n - 1 entries in the cache line table, operation 46 assigns state values to each CLSS entry in the table. Since there are 2 n - 1 entries and n bits, there will be one state value unused. This state value is assigned to the condition where the cache line shared state word does not match any cache line shared state entry in the cache line table. In other words, this state value would indicate the need for "escape" to an additional process or to a supplemental directory for the cache line shared state word. An example of a cache line table is shown in Fig. 5. The cache line table includes a column for state values and a column for cache line shared state entries. As discussed earlier for Fig. 2, the cache line shared state words generally identify an owner followed by a shared state indicator identifying each of the processors that share the cache line and the state of that sharing. Thus in the table of Fig. 5, the cache line shared state for a state value "1" indicates the owner is processor 1 and contains shared state flags for processors 2, 4, 6 and 8. For shared state value "30," the owner of the cache line is processor 8 and only processor 1 has a shared state with the cache line. Shared state value 31 is for the no-match condition for cache line shared state entries and flags the need for "escape" to an additional process or to a supplemental directory. The criteria for building a cache line table and another example of entries in such a cache line table will now be described. In this example the total number of nodes (or cache domains) is eight. If n=8 in the n-bit state value in the directory, and if three bits are used to identify the owner, there are five bits remaining to identify shared states. With those five bits one can encode 32 state values. Allowing for some general states there is enough state values remaining to encode all possible sharing states among nodes 0-3 and with some trade offs, possibly among nodes 0-4. For example: broadcast 1 no sharers 1 any individual sharer 8 all pairs of sharers from nodes 0 - 3 C(4,2) 6 all triples of sharers from nodes 0 - 3 C(4,3) 4 20 This is sufficient to encode all the general states as well as all possible sharing states among the first 4 nodes. If there are actually more than 4 nodes some nodes have to be more privileged in the encoding than others. To implement this the following is needed: a transition function, add-sharer, which given a state and a new sharer returns the new state, a function, known-sharers, which given a state returns a bit vector of the known sharers, and a function possible-sharers, which given a state returns a bit vector of the possible sharers. The last two differ only in how they handle the broadcast state; the former gives an all zero bit vector while the latter gives all ones. There is some redundancy here because for n nodes there can be at most n-1 sharers. To fully exploit this however requires the mapping from sharer labels encoded in the states to actual node numbers to be dynamic depending on the current owner. (E.g. if the current owner is 0, then sharer 0 is node 1, sharer 1 is node 2, etc. If the current owner is 1, then sharer 0 is node 0, sharer 1 is node 2, etc). One possible way of dealing with this is to make the current owner be a parameter to possible-sharers and known-sharers and add a function, node-to-sharer, which given the current owner and a node number gives the sharer index. Given this, it is possible to encode all possible sharing states for 4 sharers: broadcast 1 no sharers 1 any individual sharer 7 all pairs from sharers 0 - 3 C(4,2) 6 all triples from sharers 0 - 3 C(4,3) 4 all sharers 0 - 3 1 20 There is a complication with this method in that an ownership change requires a translation of the state label. The only time this happens, when there are any sharers, is on a NUMA (Non Uniform Memory Access) writeback. Consider in addition the maintaining of previous owner state of no-sharers case for competitive algorithms, then: broadcast 1 no sharers - previous owner 8 any individual sharer 7 all pairs from sharers 0 - 3 C(4,2) 6 all triples from sharers 0 - 3 C(4,3) 4 all sharers 0 - 3 1 27 For a system with 5 or fewer nodes why not optimize for directory entry for the above case. For example, with n=8 and a 3 bit owner field, the other 5 bits designate the sharers if set. The position of a sharing bit determines the node id of a sharer. Some sharing bits could designate 2 nodes. Then: Bits Use 7-5 Owner 4 If 1 node #0 is a sharer 3 If 1 node #1 is a sharer 2 If 1 node #2 and node #5 may be sharers 1 If 1 node #3 and node #6 may be sharers 0 If 1 node #4 and node #7 may be sharers Non-existing nodes are filtered out with a mask of active nodes. If the system has 5 or less nodes numbered in such a way that there exist no 2 nodes whose sharing status is designated with the same bit, the directory will always exactly determine all the sharers. A five node system with nodes numbered 0 1 2 3 4 is an example of such a system. It is evident that there are multiple algorithms that can be used to set the criteria for building the cache line tables. These criteria depend on the system design and can be set during the system design development. The above example illustrates an alternate embodiment in which a single state value encodes more than one possible cache line shared states word. The advantage of this embodiment is that , when a system has less than the maximum number of nodes, or cache domains, there would be no ambiguity in the state value encoding. In this way directory memory space may be saved by limiting the size of state value space. For maximally configured systems, the ambiguity in the state value could be resolved by broadcasting to all possible nodes allowed by the multiple encoding. To illustrate the above, consider a system architecture with a maximum number of eight nodes. Let the state value X imply that either or both node 0 and node 4 may be sharers. In an instance of the system with only four nodes (0..3), state value X is not ambiguous -- since there is no node 4. In such a situation, state value X indicates uniquely that node 0 is a sharer. In an instance of the system with five or more nodes, state value X is a situation that requires limited broadcast to node 0 and node 4 since either or both could be sharers. In another embodiment of the invention, the processors in the multi processor system may be grouped into a domain. Referring again to Fig. 1, processors P0, P1 and P2 represent a domain 18 of three processors. This domain may be treated as a single node or a single processing system relative to the cache lines states directory system 14. Thus, the processors in domain 18 might use a Snoopy protocol to maintain track of each others cache systems. When working with cache systems outside of the domain, the domain would use the cache line states directory system 14 as described above. In another embodiment of the invention, the cache line states directory is a fully mapped directory. In this embodiment, all cache line shared state words are encoded into a state value. When implementing a fully mapped directory, the CLSS entry table, or cache line table, need not have an "escape" or supplemental entry.

Claims: Directory system apparatus for directing cache line access requests from processors (6, 7, 8, 9) in a multi-processor system with a shared memory system, each of the processors having a cache (10, 11, 12, 13), each of the caches storing cache lines, each cache line being owned by a processor and being available for sharing with all of the processors in the multi-processor system, said directory system apparatus comprising: a cache line states directory (14, 24, 30) configured to store a state value that identifies a cache line shared state word; a cache line table (22, 36, fig. 5) configured to store a plurality of cache line shared state words (CLSS) and a state value (SV) corresponding to each cache line shared state word, wherein each of said state words indicates an owning processor (OWNER) and a state (S1...S8) of access to one or more additional processors; and a state value decoder (32) responsive to a state value (SV) received from said cache line states directory (14, 24, 30), the decoder being configured to perform a table look-up in the cache line table (22, 36, fig. 5) based on the received state value (SV) in order to decode the state value into the corresponding cache line shared state word (CLSS) for use by the cache line directory system to identify the cache line in each of said caches, characterised in that said apparatus further comprises: a state value encoder (34) responsive to a received cache line shared state word (CLSS), the encoder being configured to perform a table look-up in the cache line table (22, 36, fig. 5) based on the received cache line shared state word (CLSS) in order to encode the cache line shared state word into said corresponding state value (SV) and to store the corresponding state value into the cache line states directory. The apparatus of claim 1 wherein: each cache line is a block of data stored in cache; said state value in an n-bit word; and said cache line table has a capacity to store 2 n entries of cache line shared state words with their corresponding state value. The apparatus of claim 2 wherein: said cache line table stores an ordered list of 2 n -1 cache line shared state words and their corresponding state values and one entry containing a state value to identify an escape process for cache line shared state words not included in the list. The apparatus of claim 3 wherein the ordered list is a list of cache line shared state words that have the most significance to the multi-processor system. A method for directing cache line access requests from processors (6, 7, 8, 9) in a multi-processor system with a shared memory system, each of the processors having a cache (10, 11, 12, 13), each of the caches storing cache lines, each cache line being owned by a processor and being available for sharing with other processors in the multi-processor system, said method comprising the computer implemented steps of: storing a plurality of cache line shared state words (CLSS) in a cache line table (22, 36, fig. 5) and storing an associated state value (SV) corresponding to each cache line shared state word stored in the table, wherein each of said state words indicates an owning processor (OWNER) and a state (S1...S8) of access to one or more additional processors; encoding (34) a received cache line shared state word (CLSS) into a corresponding state value (SV) by performing a table look-up based on the received cache line shared state word (CLSS) in the cache line table to encode the cache line shared state word into a state value (SV) said cache line shared state word identifying the processor that owns the cache line and processors that share access to the cache line; storing the state value (SV) in a cache line directory; decoding (32) the state value from the cache line directory into a cache line shared state word (CLSS) by performing a table look-up based on the state value (SV) in the cache line table to decode the state value into a cache line shared state word (CLSS) for use by the cache line directory system in identifying the cache line in each of said caches. The method of claim 5 wherein said state value is an n-bit word and the cache line table has an entry capacity to store 2 n entries of cache line shared state words with their associated state value. The method of claim 6 wherein the cache line table stores an ordered list of 2 n -1 cache line shared state words and their associated state values and one entry containing a state value to identify an escape process for cache line shared state words not included in the list. The method of claim 7 wherein the ordered list is a list of cache line shared state words that have the most significance to the multi-processor system.

Inventors: BROMLEY MARK, GUZOVSKIY ALEKSANDR, ZAK ROBERT C JR, BROMLEY, MARK, GUZOVSKIY, ALEKSANDR, ZAK, ROBERT C., JR.
Applicants: SUN MICROSYSTEMS INC, SUN MICROSYSTEMS, INC.
Application year: 1997
Main classification: G06F12
IPC codes: G06F12