Abstract:
A method of updating, directing or moving page table entry values in a virtual memory management system. The method operates without requiring suspension of a search process looking for a predetermined page table entry value of a page table. In a first step, the method determines whether the current page table value is the predetermined page table entry value or whether the search process looking for a page table entry value is in progress. Then, the current page table entry value is deleted or moved in the event that the current page table entry value is not the predetermined page table entry value or in the event that the search process is not in progress. Next, the method waits until the search process has completed looking for the predetermined page table entry value or for a predetermined period of time before deleting or moving the current page table entry value, in the event that the current page table entry value is the predetermined page table entry value or in the event that the search process looking for a page table entry value is in progress.

Description:
FIELD OF THE INVENTION 
     The present invention relates to virtual memory management access in a computerized system and, in particular, to virtual-to-physical mapping of memory access for computerized systems. 
     BACKGROUND TO THE INVENTION 
     Modern processors typically provide hardware support for virtual memory systems by performing virtual to physical address mappings in hardware. Both the virtual and physical memory address spaces can be contemplated as a collection of &#34;pages&#34; of a predetermined size, often four kilobytes (4 kB). A set of mappings between virtual and physical memory pages which define the current virtual address space is stored in a data structure commonly called a &#34;page table&#34;. Typically, entries in the page table further include access protection information and other control information such as software maintained flags and reference counts. The page table information is accessed quite frequently since it is used on substantially each memory reference. Unfortunately, the page table is typically too large to store on-chip within a central processing unit (CPU). Instead, a translation lookaside buffer (TLB) is used to cache the most recently used page table entries with the CPU. 
     When a reference is made to a virtual memory address, most mappings can be immediately performed via a TLB lookup. If a desired entry is not found in the TLB (often referred as a &#34;TLB miss&#34;), a page table lookup is performed to fetch the required information. If the desired entry is further not located within a page table in primary memory (eg. semiconductor random access memory--RAM), a &#34;page Fault&#34; occurs and an appropriate physical memory page is found, for example on a secondary memory system such as a hard disk, and loaded into primary memory for subsequent direct access by the CPU. An appropriate page table entry for the physical memory page is then loaded into the page table thus making the desired entry available. In a multiprocessor system, where a plurality of processors can access a page table, a first processor can be attempting a page table update while a page table lookup from a second processor is in progress, which can result in a possible conflict. A mechanism is normally required or set in place to resolve this possible conflict. 
     To directly index a page table utilizing a portion of the virtual memory address requires that the page table be as large as the indexing that is possible from the virtual page number. For example, if the twenty most significant bits of the virtual memory address are utilized as the virtual page number, an indexing of up to 1 Meg. of pages (1,048,576 pages) is possible. A page table accommodating more than a million virtual pages occupies a significant portion of memory. On a computer system running several applications, each having an associated page table, the total number of page tables could thus occupy a substantial part of the physical memory. It is therefore desirable to reduce the size of the page table. 
     Several techniques are available to reduce the page table size. One such technique is to limit the size of the page table to a predetermined size and if a request for an entry indexed by a virtual page number is outside the limits of the page table, an entry is made to the page table to account for the request. In this manner the page table is increased (or grown) to a required size, rather than being created to a size as large as that addressable by the virtual page number. 
     Another technique of reducing the page table size is to apply a &#34;hashing function&#34; to the virtual page number in such a manner as to reduce a virtual page number value to a smaller hashed index value which is used to index a smaller page table structure that addresses those physical memory pages in main memory. 
     The smaller page table resulting from the technique of applying a hashing function is often referred to as an &#34;inverted page table&#34; or &#34;hashed page table&#34;. A hashing function typically maps substantially all virtual page numbers in a virtual memory system to a smaller subset of values herein referred to as hashed index values. 
     Consequently, applying a hashing function to a virtual page number can result in more than one virtual page number corresponding with a hashed index value. As a result a &#34;hash collision&#34; occurs, on an inverted page table lookup, when a current virtual address is hashed (ie. hash function applied) to obtain a hashed index value which is used to index an inverted page table entry having a virtual address, and the virtual address does not correspond to the current virtual address. 
     Similarly, when adding a new entry to an inverted page table, a &#34;hash collision&#34; occurs when a current virtual address is hashed to obtain a hashed index value which indexes an inverted page table entry currently occupied by a valid entry (ie. an entry having a valid flag set as described hereinafter). 
     A conflict arises if system software attempts to update the page table at the same time that a processor (or co-processor) of the system attempts a page table lookup resulting from a TLB miss. One solution to this conflict is to prevent page table lookups by locking out page table lookups while the table is being updated. However, locking the page table in this manner has adverse performance implications. 
     The above mentioned conflict is common to both multiprocessor systems (since multiple processors may be doing a page table lookup at any time) and uniprocessor systems (since the page table lookup is such a fundamental operation that a lookup may occur even while executing the privileged operating system code which updates the page table itself). 
     For example, a system using a graphics co-processor is inherently a multiprocessor system. Further, requiring synchronisation of the multiprocessors in relation to page table accesses is undesirable because the graphics co-processor may need to be halted, in the synchronisation process, effectively slowing down the image processing. 
     SUMMARY OF THE INVENTION 
     In accordance with one aspect of the present invention there is provided a method of deleting or moving a current page table entry value of a page table in a computer system without requiring suspension of a search process looking for a predetermined page table entry value of the page table, said method comprising the steps of: 
     determining whether the current page table value is the predetermined page table entry value; 
     deleting or moving the current page table entry in the event that the current page table entry value is not the predetermined page table entry value; and 
     waiting until said search process has completed looking for the predetermined page table entry value before deleting or moving the current page table entry value, in the event that the current page table entry value is the predetermined page table entry value. 
     In accordance with another aspect of the present invention there is provided a method of deleting or moving a current page table entry value of a page table in a computer system without requiring suspension of a search process looking for a predetermined page table entry value of the page table, said method comprising the steps of: 
     determining whether said search process looking for a page table entry value is in progress; 
     deleting or moving the current page table entry in the event that said search process is not in progress; and 
     waiting for a predetermined time before deleting or moving the current page table entry value, in the event that said search process looking for a page table entry value is in progress. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     A number of preferred embodiments of the present invention will now be described with reference to the drawings in which: 
     FIG. 1 shows a schematic block diagram representation of a memory management unit; 
     FIG. 2 illustrates a page table in main memory in accordance with the preferred embodiment; 
     FIG. 3 is a schematic block diagram representation of a page table lookup operation in accordance with the preferred embodiment; 
     FIGS. 4, 5 and 6 show the page table of FIG. 2 and a method of deleting entries of the page table; 
     FIG. 7 illustrates a schematic of a page table and the process of moving an entry of the table in accordance with a preferred embodiment of the present invention; 
     FIG. 8 is a flow chart depicting page table lookups described in FIGS. 2 and 3; 
     FIG. 9 is a flow chart depicting a page table insertion using the arrangement of FIGS. 2 and 3; and 
     FIG. 10 is a flow chart depicting a page table deletion using the arrangement of FIGS. 2 and 3. 
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
     FIG. 1 illustrates the main components of a memory management unit (MMU) 90, comprising an input means 91 for receiving a virtual memory address, a translation lookaside buffer 92 (TLB), an output means 93 for outputting a physical memory address and a page table lookup means 94 adapted to lookup a virtual-to-physical memory map as hereinafter described with reference to FIG. 3. 
     The page table lookup means 94 includes a hash function means 95 adapted to manipulate at least a portion of the virtual memory address to provide an index to a page table (described herein). Preferably, the page table is stored in a random access memory (RAM) 96 of a computer system. Alternatively, page tables can be stored on a secondary memory device such as a hard disk device in which case, the page tables are loaded into the RAM 96 as required by the computer system. 
     Referring to FIG. 2, an inverted or hash page table 100 (hereinafter referred to as page table) is shown with a plurality of page table entries 101 comprising two, typically 32-bit, words. A first word 102 of the two 32-bit words comprises a physical memory page number 103 that together with an page offset number (not illustrated) form a physical memory address to desired data values stored in a computer system&#39;s memory (typically RAM). In this example, the physical memory page number 103 occupies less than the 32-bit word example of this embodiment and therefore the remaining bits are often left as reserved bits 104. A second word 105 of the two 32-bit words comprises a virtual memory page number 106, a reserved bit section 107, a read only flag 108 and a valid flag 109. A flag, such as the read only flag 108 and valid flag 109 for example, can be a single bit which can take on a value of 1 (set) or zero (unset). The read only flag 108, an example of which is an address access protection information flag, when set indicates that data in physical memory indexed by a page table entry 101 should not be overwritten. The valid flag 109 indicates whether the physical page number and virtual page number are a valid entry to the page table 100. There are three possible outcomes of a page table lookup resulting from a set and unset valid flag 109, hence the valid flag is best explained by way of example. 
     Referring also to FIG. 8, a page table lookup process 700 is shown having an entry point 702 which is followed by the generation of a hash index (i) at step 704 from the given address, thus revealing a page table entry 101. If the valid flag 109 of the page table entry 101 is unset as determined at step 706 and the page table entry 101 is accessed as a result of a page table lookup then a &#34;page Fault&#34; error has occurred seen at step 708, which will be described hereinafter and which concludes the look-up. On the other hand, if the valid flag 109 is set and the page table entry 101 is accessed as a result of a page table lookup, then the virtual memory page number 106 of the page table entry 101 is compared at step 710 to a virtual page number of a virtual memory address utilized in the page table lookup, being the desired virtual memory address for which a virtual to physical memory address mapping is sought (a virtual-to-physical map being a number pair including a virtual page number and a physical page number). Upon comparison, if the virtual memory page number 106 of the page table entry 101 does not correspond to the virtual page number of the desired virtual memory address, then the index (i) to the page table entries 101 is incremented at step 712 to become (i+1) and subsequent entries are systematically searched and a virtual page number of each corresponding page table entry is compared with the desired virtual page number until a match is found or until a page table entry having an unset valid flag is encountered. In the event that the desired virtual page number is found in a page entry table 101, a physical memory address is returned 714. However, upon a page table lookup, if a page table entry 101 with an unset valid flag is encountered first, then a page fault occurs. 
     In recent modern computer systems, a memory management unit typically includes a &#34;Translation Lookaside Buffer&#34; (TLB) which is a table of virtual to physical address mappings and is usually a small size table of, often, most recently used entries of a page table. Each TLB entry comprises substantially similar information as an entry of a page table and the TLB is substantially a subset of most recently used entries of the page table. Often a TLB includes substantially the same address protection information included in a page table entry. The TLB is constantly updated in accordance with a need of the hardware system request for any one virtual-to-physical address translation. A TLB is typically the first table searched when a hardware system requests a virtual to physical address translation. Since the TLB is a subset of a total number of virtual to physical map entries included in a page table, sometimes a request by the hardware system for a desired virtual-to-physical memory map cannot be found in the TLB and, as a consequence, a page table lookup must be initiated. When a desired virtual to physical map is not found in the TLB, that is if no entry of the TLB, with a valid flag set, includes a virtual page number that matches a desired virtual page number, then a &#34;TLB miss&#34; occurs that initiates a page table lookup. 
     A page table lookup resulting from a TLB miss is now described with reference to FIG. 3. The flowchart of FIG. 8 also outlines comparable steps but does not include all the detail of the following. In a page table lookup, a virtual page number 200 from a virtual memory address for which a virtual to physical mapping is sought (ie. a physical memory address is sought corresponding to the virtual memory address), and has not been located in a TLB, the virtual page number 200 is subjected to a &#34;hash&#34; function 201. The output, of the hash function 201 applied to the virtual page number 200, is referred to herein as a hashed index value 202 which is used in identifying a page table entry. A page table address 205 is constructed, in this example, by concatenating a pointer base address value 204 as the upper most significant bits, the hash index value 202 as the intermediate bits and three null bits 208 (ie. 000) as the lowest significant bits to provide the address 205 to an entry of the page table (ie. a page table address). The three null bit 208 entries concatenated as the lowest significant bits, allow the page table address 205 to be used as a byte address for the page table entry. 
     A page table entry 101 is read, starting at the address pointed to by a current page table address 205, preferably a word at a time. The virtual memory page number 106 of the page table entry 101 is compared 209 with the virtual page number 200 which resulted in a TLB miss. If the page numbers (106, 200) are equal, that is, matching page numbers (106, 200) are found, the page table entry 101 is written to the TLB. A subsequent search of the TLB for the virtual page number 200 would not result in a TLB miss. In the event that the page numbers (106, 200) are not equal (ie. a &#34;hash collision&#34; occurs), the current hash index value 205 is repeatedly incremented 203 to a next page table entry and a virtual memory page number of each of the next page table entries is compared 209 with the desired virtual page number 200. The hash index value 205 is allowed to increment 203 until the comparison step 209 finds matching virtual page numbers 106, 200 or until a page table entry 101 having an unset valid flag 109 is encountered. In the event that matching virtual page numbers are found, a corresponding physical address 103 of the page table entry 101 having the matching virtual page number 106 is forwarded 207 to the TLB. The corresponding physical address 103 is written to the TLB and associated with the desired virtual page number 200 to provide a required virtual to physical translation in the TLB. 
     If necessary, when the incrementing reaches the last entry of the page table not having found the desired match, the incremental search for the desired match is initiated at the beginning of the page table hence &#34;wrapping-around&#34; until either the desired match is found or an entry having an unset valid flag is encountered, which ever is first. The valid flag 109 of a page table entry is checked before the comparison 209 and if the valid flag 109 is unset a page fault results, and the page table lookup is consequently terminated. Since searching the page table is allowed to wrap-around from the end of the page table to the beginning of the page table, at least one entry of the page table is usually maintained with a valid flag unset to ensure the search can terminate should a desired page table entry not be found. Similarly when a page table entry is to be updated, removed or moved from a current page table location to another location of the page table, a page table lookup is performed substantially as described with reference to FIG. 3 to determine which of the plurality of page table entries 101 is to be updated, removed or moved respectively. 
     A page table insertion, that is a page table entry inserted or added to a page table, is performed in a manner substantially as described above with reference to a page table lookup however an unset valid flag 107 is now not an indication of a page fault, but rather an indication that a page table entry may be inserted (or overwritten). Further, a page table insertion is not necessarily a result of a TLB miss but a specific request by the software or hardware system to insert or augment the page table. A depiction of this is shown in FIG. 9 as a process 800 having an entry point 802. The hash index value (i) is generated at step 804 to provide the virtual page number in the TLB. At step 806 the index is considered and if a TLB miss occurs, step 808 sets the virtual address as that of the index thus performing the insert. Preferably, the first word 102 (comprising the physical memory address) of a page table entry is updated or inserted before the second word 103 (comprising the virtual memory address) to prevent the system software or hardware from using the page table entry before a complete update is performed. If step 806 results in a valid index, a TLB &#34;hit&#34;, then step 810 compares the virtual address to that given for the insertion. If equal, step 808 is again invoked to complete the insertion. If not equal, step 812 increments the index and returns control to step 806. 
     Described with reference to FIGS. 4 to 6, is an example of a page table entry deletion, that is removing a page table entry from a page table. To remove or delete a page table entry the valid flag need only be &#34;unset&#34;, indicating that the page table entry at the current location can be overwritten. 
     As for the page table lookup (described above), when a hash collision occurs, a next page table entry is sought with a virtual page number matching a desired virtual page number, or in a page table entry insertion (also described above) when a hash collision occurs, a next available location is searched by incrementing the hashed index value 202 until a page table entry having an unset valid flag is found. Therefore an entry to be deleted or removed may not be at the hashed address (ie. the page table address 205 resulting from an application of the hash function), but at a page table entry location other than the location referenced by the hashed address. 
     In FIG. 4, a page table 300 having page table entry locations 301, referred to as &#34;slots&#34; for convenience, are numbered &#34;zero&#34; (0) to &#34;n&#34; representing &#34;n+1&#34; entry locations to the page table 300 having page table address values &#34;0 &#34; to &#34;n&#34;. A plurality of slots 301 are marked &#34;free&#34; indicating that page table entries at these slots have unset valid flags and the slots of the page table are free to have a page table entry inserted. 
     In this example a page table address value of zero (0) corresponds to &#34;slot 0&#34;, a page table address value of one (1) corresponds to &#34;slot 1&#34;, and a page table address value of &#34;n&#34; corresponds to &#34;slot n&#34;. Hence, for example, at page table insertion, a hash address value of two (2) would preferably see that a page table entry is inserted into &#34;slot 2&#34; 302, if &#34;slot 2&#34; 302 is available for insertion (ie. valid flag is unset). However, if a hash collision occurs at &#34;slot 2&#34;, that is the valid flag is set, then the page table entry is inserted at a next available &#34;slot&#34;. The page table in FIG. 4 shows two identical hash table address values at &#34;slot 2&#34; and &#34;slot 3&#34;. This indicates that a hash collision had occurred at page table insertion and a first page table entry having a virtual page address, that following the execution of a hash function, resulted in a hash address of two (2) (denoted in figure as hash value=2) and consequently the first page table entry was inserted at &#34;slot 2&#34;. Subsequently, a second page table entry also having a hash address of two (2) caused a hash collision because &#34;slot 2&#34; was occupied (valid flag set) by the first page table entry, hence the second page table entry was inserted at the next available slot which happened to be &#34;slot 3&#34;. A third page table entry with a corresponding hash address value of three (3) is then inserted at next available slot (slot 4) and continued in this manner. However, if a slot corresponding to a hash address value is available, then the corresponding slot is preferred (eg. hash address value of nine is inserted at &#34;slot 9&#34; which at the time of the insertion request was available). 
     Referring now to FIG. 5 it is desired to delete, or remove, from the page table of FIG. 4 the page table entry at &#34;slot 3&#34; 303. To delete this entry, the valid flag for the page table entry in &#34;slot 3&#34; 303 is changed from &#34;set&#34; to &#34;unset&#34; and slot 3 is therefore freely available to be overwritten (ie. free). However, as described previously an unset valid flag of a page table entry can terminate a page table lookup, therefore page table entries in slots greater than &#34;slot 3&#34; which were inserted into a high &#34;slot number&#34; as a result of a hash collision, and typically up to a first slot marked &#34;free&#34; 305, are shuffled up the page table 300 of the present example. The page table entries are shuffled up preferably in a manner so that each hash address value corresponds to a preferred slot. For example, FIG. 6 illustrates a preferred arrangement of page table entries of FIG. 4 following the removal (deletion) of the page table entry in &#34;slot 3&#34; of FIG. 4. That is a page table entry at &#34;slot 4&#34; 306 of FIG. 4 having a hash address value of three (3) is moved to &#34;slot 3&#34; and a page table entry at &#34;slot 6&#34; 307 is moved to &#34;slot 4&#34; to result in the arrangement of FIG. 6. 
     A page table should be consistent at substantially all times when a page table lookup is in progress, yet the page table cannot be automatically updated (ie. instantaneously) because a page table entry typically requires multiple accesses to be performed in an update operation (eg. move operation) on a page table entry. As a result, a page table lookup in progress while an update operation is being performed on a page table entry may result in the page table entry not being located by the lookup. Further, it is preferred that system software or hardware be permitted to access a page table while the page table is being updated. 
     Consequently, before a page table entry is to be moved from a first slot to a second slot (destination slot) as in the illustrated example of FIG. 5, a virtual address that provides a hash value corresponding to the destination slot is changed to an unused address (ie. a virtual address which would otherwise never appear in the page table) so that a page table lookup on the destination slot is not attempted while the page table entry and in particular while the physical address of a page table entry is being written to the destination slot. 
     An alternative to using an &#34;unused address&#34; to prevent a page table lookup from utilizing an existing page table entry in a destination slot, designated for a page table entry move, is to further include to all page table entries of a page table an additional access protection flag. The additional access protection flag, when set for a current page table entry, allows a page table lookup process to ignore the current page table entry and continue with the page table lookup in progress. 
     When a current page table entry is moved up, it is desirable for the MMU 90 to know that a page table lookup on the current page table entry is not in progress at a time when a virtual address of a destination slot is changed to an unused address (ie. while a page table entries are being moved) or a valid flag of a page table entry is to be unset. While a coincidental occurrence of a page table lookup on an entry being moved is rare, if a page table lookup is being performed for the current page table entry being moved then the lookup on the current entry is completed before the current page table entry is moved. This is illustrated in FIG. 7. As shown, a page table entry 601 to be moved to another page table entry location (slot) 602, while a page table lookup 603 is progressing towards and looking for the page table entry 601, then the search for the page table entry is allowed to complete before the page table entry 601 is moved. Following a successful page table lookup (ie. a lookup not resulting in a page fault) a page table entry is updated in a TLB, as described above, therefore a need to access the same page table entry in the immediate near future is considerably reduced. A page table entry, following a successful page table lookup on the entry, can be moved with a high probability that an immediate page table lookup on the same entry will not be performed while a move of the page table entry is in progress. 
     In another embodiment of the present invention a page table entry deletion is substantially as described above, however at a coincidental occurrence of a page table lookup on a page table entry about to be moved from a first page table entry location (a first slot) to a second page table entry location (a second slot), the completion of the move of the page table entry is delayed for a predetermined longest possible time a page table lookup takes to complete. Typically, a move operation on a page table entry comprises the steps of deleting a first page table entry from a first slot, copying a second page table entry from a second slot in the first slot and deleting the second page table entry, thereby effectively moving the second page table entry from the second slot to the first slot. 
     The processes described above with reference to FIGS. 4 to 7 are summarised by the process 900 depicted in FIG. 10. A removal or deletion commences at an entry point 902 which passes to step 904 which locates the entry for the index value (i) in the hash table. Once this is done, step 906 sets the virtual address at the entry to an invalid value. Step 908 then conducts a search further into the page table for another entry (j) to occupy entry (i). If there is no such entry, determined at step 910, the valid flag of the entry at index (i) is cleared, and the deletion is finished. If there is such an entry, the entry at index (j) is copied to index (i) at step 914. A wait step 916 is then entered which allows the MMU 90 to a coincidental page table lookup. When the maximum time required for a lookup has transpired, step 918 sets the index (i) to the current value of (j) and returns control to step 906. 
     In each of the above embodiments, when a page table entry is deleted (or removed) a corresponding TLB entry (if any) must be invalidated to prevent the MMU 90 from accessing the deleted page table entry via the TLB. To invalidate a TLB entry, a valid flag for each TLB entry to be invalidated is unset and therefore the TLB location of the invalidated TLB entry is free to be subsequently overwritten. Normally, when all page table entries are removed or a page table is replaced in physical memory, all TLB entries are invalidated by an invalidation cycle which unsets valid flags of all the entries of the TLB. 
     A pseudo-code for a page table entry deletion is provided in an attached Appendix for the preferred embodiment (option 1) and the other embodiment (option 2). The Appendix is indicative of the preferred embodiment being operable on computer systems such as IBM PC/AT devices, compatibles thereof, as well as other computer systems. Typically the preferred embodiment is implement by software that may be sourced from a computer readable medium such as a disk device, tape or a computer network, such as the Internet. 
     The foregoing describes the preferred embodiment of the present invention, and modifications obvious to those skilled in the art can be made without departing from the scope of the present invention. 
     APPENDIX 
     This Appendix provides pseudo code for a page table deletion process in accordance with the preferred (option 1) and other (option 2) embodiments of the present invention. 
     Apply a hash function to a virtual page address corresponding to the page table entry and find entry in page table; 
     do 
     search for a virtual address which hashes to a slot whose page table entry is to be deleted (first page table entry) 
     if found 
     Set virtual address of page table entry to be deleted to an illegal address, so the MMU skips this entry (first page table entry) 
     copy the physical address of a second page table entry into a corresponding position of the first page table entry (i.e. over-write) 
     copy the virtual address and valid flag bit(s) of the second page table entry into a corresponding position of the first page table entry (i.e. over-write) 
     if (option 1) MMU is currently doing a lookup on a virtual address referenced in a second page table entry 
     then wait 
     (option 1) until the MMU has completed the lookup 
     fi 
     (option 2) until the longest possible time taken for a lookup 
     delete the second page table entry on next iterative loop. 
     fi 
     while an entry still needs to be deleted 
     Set virtual address of second page table entry to Null, unset valid flag. 
     Set physical address of second page table entry to Null.