Order-preserving processing method, device and equipment for read-write requests in multi-page table system

By performing two hit tests on the page table of cached rows in the graphics processor cache system, a connection between requests for the same address is established, the problem of out-of-order output of the same address requests in the TLB is solved, and the order output of the requests is realized and resource overhead is saved. .

CN119065990APending Publication Date: 2024-12-03T-HEAD (SHANGHAI) SEMICON CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310631233.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-30
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the cache system of the graphics processor, when read and write requests of the same address hit on multiple cache lines in the TLB at the same time, the request output is out of order and the sequential output cannot be guaranteed.

Method used

By performing two hit tests on the page table cached in each cache row, tests based on the range granularity of the page table and 4KB granularity, establishing a connection for the same address requests to ensure the sequential output of the requests in the TLB.

Benefits of technology

It effectively avoids the problem of out-of-order output of the same address in TLB, and at the same time avoids additional resource overhead, ensuring the sequential output of the requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065990A_ABST
    Figure CN119065990A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an order-preserving processing method, device and equipment for a read-write request in a multi-page table system, and the method comprises the steps: carrying out a hit test on a page table according to the page table range of the page table in each cache line and the granularity corresponding to the page table range in the process that the electronic equipment carries out the address conversion of the received read-write request, obtaining a first hit test result of each page table; for the page table with the page table range being non-4KB, after the first hit test result is obtained, hit test is conducted on the page table again according to the 4KB granularity, and a second hit test result is obtained; and according to the second hit test result, establishing a relation for the read-write requests of the same address. According to the technical scheme, it is guaranteed that requests of the same address are output in a TLB in an order-preserving mode, and extra resource overhead is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, and apparatus for preserving the order of read and write requests in a multi-page table system. Background Art

[0002] In graphics processing unit (GPU) systems, the cache system must maintain the order in which read / write accesses initiated by shaders arrive. Currently, cache systems manage read / write requests in a linked list, indexed by the cache line index assigned to each read / write request in the Translation Lookaside Buffer (TLB). This ensures that requests for the same address are output in the order they arrive at the TLB.

[0003] However, when multiple cache lines in the TLB cache the same page table, a read or write request will hit multiple cache lines in the TLB simultaneously, resulting in the problem of out-of-order output of requests with the same address in the TLB. Summary of the Invention

[0004] Multiple aspects of the present application provide a method, apparatus, and device for preserving the order of read and write requests in a multi-page table system, so as to solve the problem of out-of-order output of TLB for requests with the same address in the prior art.

[0005] In a first aspect, an embodiment of the present application provides a method for preserving the order of read and write requests in a multi-page table system, comprising:

[0006] In the process of performing address conversion on the received read and write requests, performing a hit test on the page table in each cache line according to a page table range of the page table and a granularity corresponding to the page table range to obtain a first hit test result for each page table;

[0007] For a page table whose page table range is not 4KB, after obtaining the first hit test result, the page table is hit tested again according to the 4KB granularity to obtain a second hit test result;

[0008] According to the second hit test result, the read and write requests for the same address are associated.

[0009] In a possible implementation manner, establishing association between read and write requests for the same address according to the second hit test result includes:

[0010] If the second hit test result indicates a hit or a page table acquisition process, selecting the second hit test result to chain read and write requests of the same address;

[0011] If the second hit test result indicates a miss, the read and write requests are chained according to the first hit test result.

[0012] In one possible implementation, the method further includes:

[0013] The identifier of the cache line is used as an index to perform linked list management on the read and write requests that hit the cache line.

[0014] In a possible implementation, performing a hit test on the page table according to a page table range of the page table in each cache line and a granularity corresponding to the page table range to obtain a first hit test result for each page table includes:

[0015] For a page table having a page table range of 4 KB, performing a hit test on the page table according to a 4 KB granularity to obtain a first hit test result of the page table;

[0016] or,

[0017] For a page table having a page table range of 64 KB, performing a hit test on the page table according to a 64 KB granularity to obtain a first hit test result of the page table;

[0018] or,

[0019] For a page table having a page table range of 2MB, performing a hit test on the page table according to a 2MB granularity to obtain a first hit test result of the page table;

[0020] Among them, the first hit test result is used to indicate three states: hit, or in the process of page table acquisition, or miss. The page table acquisition process indicates that the page table corresponding to the cache line in the request process is the page table required by the read and write request.

[0021] In a possible implementation, during the address translation process for the received read and write request, before performing a hit test on the page table according to the page table range of the page table in each cache line and at a granularity corresponding to the page table range, the method further includes:

[0022] According to the received read and write requests, a page table request is sent to the MMU according to the minimum granularity of the page table, where the minimum granularity of the page table is 4KB;

[0023] The page table corresponding to each page table request returned by the MMU is received in sequence, and the page table corresponding to each page table request is stored in the cache line corresponding to the page table request.

[0024] In one possible implementation, the method further includes:

[0025] Each time a page table request is sent to the MMU, a cache line is allocated for the page table request.

[0026] In a second aspect, an embodiment of the present application provides an order-preserving processing device for read and write requests in a multi-page table system, comprising:

[0027] A first processing module is configured to, during address conversion of a received read or write request, perform a hit test on the page table in each cache line according to a page table range of the page table and a granularity corresponding to the page table range to obtain a first hit test result for each page table;

[0028] A second processing module is configured to, for a page table whose page table range is not 4 KB, perform a hit test on the page table again according to a 4 KB granularity after obtaining the first hit test result, to obtain a second hit test result;

[0029] The third processing module is configured to establish a connection between the read and write requests of the same address according to the second hit test result.

[0030] In a possible implementation, the third processing module is specifically configured to:

[0031] If the second hit test result indicates a hit or a page table acquisition process, selecting the second hit test result to chain read and write requests of the same address;

[0032] If the second hit test result indicates a miss, the read and write requests are chained according to the first hit test result.

[0033] In a possible implementation, the device further includes:

[0034] The fourth processing module is configured to use the identifier of the cache line as an index to perform linked list management on the read and write requests that hit the cache line.

[0035] In a possible implementation manner, the first processing module is specifically configured to:

[0036] For a page table having a page table range of 4 KB, performing a hit test on the page table according to a 4 KB granularity to obtain a first hit test result of the page table;

[0037] or,

[0038] For a page table having a page table range of 64 KB, performing a hit test on the page table according to a 64 KB granularity to obtain a first hit test result of the page table;

[0039] or,

[0040] For a page table having a page table range of 2MB, performing a hit test on the page table according to a 2MB granularity to obtain a first hit test result of the page table;

[0041] Among them, the first hit test result is used to indicate three states: hit, or in the process of page table acquisition, or miss. The page table acquisition process indicates that the page table corresponding to the cache line in the request process is the page table required by the read and write request.

[0042] In a possible implementation, during address translation of a received read or write request, before performing a hit test on the page table in each cache line according to a page table range of the page table and a granularity corresponding to the page table range, the apparatus further includes:

[0043] a fifth processing module, configured to send a page table request to the MMU according to the received read and write request and according to the minimum granularity of the page table, where the minimum granularity of the page table is 4 KB;

[0044] The page table corresponding to each page table request returned by the MMU is received in sequence, and the page table corresponding to each page table request is stored in the cache line corresponding to the page table request.

[0045] In a possible implementation, the device further includes:

[0046] The sixth processing module is configured to allocate a cache line to the page table request each time the page table request is sent to the MMU.

[0047] In a third aspect, an embodiment of the present application provides a chip, which includes a shader and a cache unit, the cache unit including a TLB and an MMU, the shader is used to send read and write requests to the cache unit, the TLB is used to execute the method as described in any one of the first aspects, and the MMU is used to store a page table.

[0048] In a fourth aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor;

[0049] The memory stores computer-executable instructions;

[0050] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method as described in any one of the first aspects.

[0051] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of the first aspects.

[0052] The embodiment of the present application provides a method, device and equipment for preserving the order of read and write requests in a multi-page table system. The method includes: in the process of address conversion for the received read and write requests, the electronic device performs a hit test on the page table according to the page table range of the page table in each cache line and the granularity corresponding to the page table range, and obtains a first hit test result for each page table; for page tables with a page table range other than 4KB, after obtaining the first hit test result, the page table is hit tested again according to the granularity of 4KB to obtain a second hit test result; according to the second hit test result, the read and write requests with the same address are linked. In this technical solution, by performing two hit tests on the page tables cached in each cache line according to the granularity corresponding to the page table range of the page table and the 4KB granularity, the read and write requests with the same address are linked according to the second hit test result of the second hit test, thereby ensuring that the requests with the same address are output in the TLB sequence with preserving the order, avoiding additional resource overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0054] Figure 1 A schematic diagram of the structure of a cache line provided in an embodiment of the present application;

[0055] Figure 2 A schematic diagram of the structure of another cache line provided in an embodiment of the present application;

[0056] Figure 3 A flowchart of a method for preserving the order of read and write requests in a multi-page table system provided by an embodiment of the present application;

[0057] Figure 4 A flowchart of another method for preserving the order of read and write requests in a multi-page table system provided by an embodiment of the present application;

[0058] Figure 5 A schematic structural diagram of an apparatus for preserving the order of read and write requests in a multi-page table system provided by an exemplary embodiment of the present application;

[0059] Figure 6 A schematic structural diagram of an electronic device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation portals for users to choose to authorize or refuse.

[0061] First, the terms involved in the embodiments of this application are explained:

[0062] TLB: A high-speed cache used by the memory management unit (MMU) to improve the speed of translating virtual addresses (VA) to physical addresses (PA). Using the TLB, the kernel can quickly point from VA to PA without requesting the random access memory (RAM) to obtain the VA to PA mapping. Simply put, the TLB is a cache of the page table, which stores the page table entries that are most likely to be accessed, and its content is a copy of some page table entries. The page table is only queried in memory when the TLB cannot complete the address translation task, thus reducing the processor performance degradation caused by page table queries.

[0063] Page table: A special data structure placed in the page table area of ​​the system space, used for the virtual memory of the computer system, which stores the mapping from VA to PA.

[0064] Virtual-to-real address translation: The process of finding the corresponding page table from VA and generating PA.

[0065] cache: A type of RAM that is accessed faster than regular random access memory (RAM), typically using expensive but faster static random access memory (SRAM) technology.

[0066] MMU: A hardware module responsible for processing memory access requests from the Central Processing Unit (CPU) / GPU. Its functions include VA to PA conversion (i.e., virtual memory management), memory protection, cache control, and, in simpler computer architectures, bus arbitration and memory bank switching.

[0067] Shader: It is the main unit of data processing in GPU / general-purpose computing on graphics processing units (GPGPU).

[0068] VA and PA: Microsoft Windows operating system (Windows) programs run in protected mode such as 386 protected mode. The logical address used by the program to access the memory is called VA, which is an address based on the algorithm; information is stored in bytes in the memory. In order to correctly store or obtain information, each byte unit is given a unique memory address, which is the address of the actual physical memory, called PA, also called real address or absolute address.

[0069] In practice, the CPU accesses memory locations through addresses. If the CPU does not have an MMU, or has an MMU but is not enabled, the address sent by the CPU core when fetching instructions or accessing memory (this must be a physical address; if it is a virtual address, the current action is invalid) will be directly transmitted to the external address pin of the CPU chip and directly received by the memory chip (physical memory). At this time, the address is the physical address. If the CPU has the MMU enabled, the address sent by the CPU core will be intercepted by the MMU. At this time, the address from the CPU to the MMU is called a virtual address.

[0070] Next, the scenarios involved in the embodiments of this application are introduced:

[0071] When the CPU wants to access a VA, it will search the TLB based on the upper 20 bits of the virtual address (20 is x86-specific and has different values ​​for different architectures). If the TLB contains the page table corresponding to the VA, it is called a TLB hit. Conversely, if the TLB does not contain the page table corresponding to the VA, it is called a TLB miss. In other words, during the TLB's VA-to-PA conversion process, if the TLB does not contain the page table corresponding to the VA, the page table information required for the VA-to-PA conversion will be continuously missed in the TLB cache during kernel startup.

[0072] In modern CPU / GPU systems, the MMU system supports multiple page table ranges. For example, consider an MMU system that supports 4KB, 64KB, and 2MB page tables. When the page table information required for VA-to-PA translation is continuously missed in the TLB cache, the TLB lacks the page table information. For read and write requests that fall within the 64KB range but not the 4KB range, the TLB must send multiple page table requests to the MMU, using the minimum granularity of 4KB.

[0073] Among them, every time a miss occurs, the TLB sends a page table request to the MMU according to the minimum granularity of the page table 4KB. Each page table request sent to the MMU will occupy a cache line in the TLB.

[0074] For example, for read and write requests within the 64KB range, if the TLB does not store the page table corresponding to the read and write request, the page table information required for VA to PA conversion will miss 16 times in a row in the TLB cache. The TLB then sends 16 page table requests to the MMU according to the minimum granularity of the page table, 4KB.

[0075] Figure 1 A schematic diagram of the structure of a cache line provided in an embodiment of the present application. Figure 1 As shown, in the warm-up phase, the TLB is allocated with multiple cache lines, such as Figure 1 As shown in FIG, cache line 0, cache line 1, cache line 2, ..., cache line 15, each cache line does not store a page table. Different cache lines can be used to cache the same page table or different page tables.

[0076] At the same time, each cache line has a corresponding identifier, which is the cache line index.

[0077] The MMU receives page table requests from the TLB and retrieves the page table from external storage based on the page table request. It then returns the page table required for each page table request, one by one, based on the number of page table requests. If the software uses a 64KB page table, then for multiple page table requests within the 64KB TLB, the MMU actually returns the same page table, which is then populated into the multiple cache lines in the TLB corresponding to the multiple page table requests.

[0078] For example, for read and write requests within the 64KB range, assuming that the TLB does not store the page table corresponding to the read and write request, the TLB needs to send 16 page table requests to the MMU according to the minimum granularity of the page table of 4KB. Among them, cache line 0, cache line 1, cache line 2...cache line 15 are allocated by the TLB based on the 16 page table requests. The structure of each cache line can be as follows: Figure 2 shown. Figure 2 This is a schematic diagram of another cache line structure provided by an embodiment of the present application. Figure 2 As shown in the figure, during the page table return phase, cache line 0, cache line 1, cache line 2, ..., cache line 15 are allocated by the TLB based on 16 page table requests, and these 16 page table requests correspond to the same read or write request. Therefore, the page table required for each page table request returned by the MMU is the same page table (page table 0). The TLB receives page table 0 corresponding to each page table request returned by the MMU one by one and fills page table 0 into cache line 0, cache line 1, cache line 2, ..., cache line 15 in sequence.

[0079] When multiple cache lines within the TLB cache the same page table, a read or write request can hit multiple cache lines simultaneously. This can cause requests with the same address to be assigned to different cache lines, leading to requests with the same address being placed on different linked lists. The TLB cannot maintain order when outputting requests from different linked lists, ultimately causing requests with the same address to be output out of order.

[0080] For example, assume that the TLB receives three requests for the same virtual address in sequence, namely read request 1, write request and read request 2. First, the TLB needs to obtain the page table 0 (stored in cache line 0) corresponding to the read / write request 1 according to the read / write request 1, so as to translate the virtual address into a physical address according to the page table 0, and then read the data in the physical address. Then, according to the write request, the page table 0 (stored in cache line 1) of the cache line cache in the TLB is determined, so as to translate the virtual address into a physical address according to the page table 0, and then write the data in the physical address. Finally, according to the read request 2, the page table 0 of the cache line cache in the TLB is determined, so as to translate the virtual address into a physical address according to the page table 0, and read the modified data in the physical address. For read request 2, it is necessary to first search in the TLB whether there is a corresponding page table according to the read request 2, that is, to perform a hit test (hit miss test) on the lists stored in each cache line of the TLB. Assume that the result of the hit test on cache line 0 is a TLB hit, and the result of the hit test on cache line 1 is a page table fetch (hit miss). Then, cache line 0 will be assigned to read request 2 instead of cache line 1, causing the write request and read request 2 to be on different TLB linked lists, resulting in the write request and read request 2 being output out of order in the TLB.

[0081] The technical solution provided by the present application, on the basis of the original hit test of the page table according to the granularity corresponding to the page table range of the page table, adds a hit test according to the granularity of 4KB for the page table with a page table range other than 4KB, and judges whether there are read and write requests with the same 4K address in the TLB according to the result of the second hit test, thereby establishing a connection between the read and write requests with the same address, ensuring that the requests with the same address are output sequentially in the TLB, and avoiding additional resource overhead.

[0082] The technical solutions shown in this application are described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be repeated in different embodiments.

[0083] Figure 3 A flowchart of a method for preserving the order of read and write requests in a multi-page table system provided in an embodiment of the present application.

[0084] See Figure 3 The method for preserving the order of read and write requests in the multi-page table system may include:

[0085] S301 . During address conversion of received read and write requests, perform a hit test on the page table according to the page table range of each cache line and the granularity corresponding to the page table range to obtain a first hit test result for each page table.

[0086] The execution subject of the embodiments of the present application can be an electronic device, or a read / write request preserving device in a multi-page table system provided in the electronic device. The read / write request preserving device in the multi-page table system can be implemented by software, or by a combination of software and hardware. For ease of understanding, the following description will be based on an example in which the execution subject is an electronic device.

[0087] In the embodiments of the present application, a multi-page table system refers to a system that supports multiple page table ranges. The page table range is determined based on the chip memory size of the electronic device. For example, the page table range can be 4KB, 64KB, or 2MB, or can also be 512MB, 1GB, or other specifications.

[0088] In this step, when the CPU of an electronic device wants to access a virtual address, it needs to send a read or write request to the TLB of the electronic device so that the TLB performs an address translation process based on the virtual address, thereby obtaining the physical address corresponding to the virtual address. During the address translation process of the TLB for read or write requests, in order to ensure that read or write requests for the same address can be output sequentially and in a sequence-preserving manner, it is necessary to perform two hit tests on each page table in the cache line, respectively, according to the granularity corresponding to the page table range of the page table and the 4KB granularity, so that the read or write requests for the same address can be subsequently linked based on the results of the two hit tests.

[0089] Among them, the read and write requests carry virtual addresses, and the same address mentioned in this application refers to the same virtual address. The cache line is used to cache the page table, and the page table is used to store the mapping relationship between the virtual address and the physical address. Different cache lines can cache the same page table or different page tables, which can be determined according to actual conditions and is not specifically limited in this embodiment of the application.

[0090] Since the page table is already cached in the TLB cache line during the page table return phase, the page table range information, i.e., whether the page table is a 4KB page table, a 64KB page table, or a 2MB page table, can be obtained from the page table header information. The granularity corresponding to the page table range refers to the same granularity as the page table range. For example, if the page table range is 4KB, the granularity corresponding to the page table range is 4KB. If the page table range is 64KB, the granularity corresponding to the page table range is 64KB. If the page table range is 2MB, the granularity corresponding to the page table range is 2MB.

[0091] That is, in a possible implementation, a page table having a page table range of 4 KB is hit tested according to a 4 KB granularity to obtain a first hit test result of the page table.

[0092] For a page table with a page table range of 64 KB, a hit test is performed on the page table according to a 64 KB granularity to obtain a first hit test result of the page table.

[0093] For a page table with a page table range of 2MB, a hit test is performed on the page table according to a 2MB granularity to obtain a first hit test result of the page table.

[0094] In the above hit process, it should be understood that performing a hit test on the page table at a 4KB granularity means using the 0-12 bits of the virtual address as the address offset within the page, and comparing the virtual address after removing the 0-12 bits with the identifier of the page table (the TAG address of the cache) to determine whether they are consistent; performing a hit test on the page table at a 16KB granularity means using the 0-16 bits of the virtual address as the address offset within the page, and comparing the virtual address after removing the 0-16 bits with the identifier of the page table (the TAG address of the cache) to determine whether they are consistent. It should be understood that performing a hit test on the page table at a 2MB granularity is generally consistent with the above-mentioned 4KB granularity and 16KB granularity, the difference being that the range of the address offset within the page is different, which will not be repeated here.

[0095] Among them, the first hit test result is used to indicate three states: hit, or in the process of page table acquisition, or miss. The page table acquisition process indicates that the page table corresponding to the cache line in the request process is the page table required by the read and write request.

[0096] In this manner, by performing a hit test on the page table according to the granularity corresponding to the page table range, a manner of establishing a connection between read and write requests for the same address can be preliminarily determined.

[0097] S302 : For a page table whose page table range is not 4 KB, after obtaining the first hit test result, perform a hit test on the page table again according to the 4 KB granularity to obtain a second hit test result.

[0098] In this step, for page tables with a non-4KB page table range, the existing method is to perform a hit test on the page table based on the granularity corresponding to the page table range, which will lead to the problem of allocating different cachelines twice in the TLB for the same address request, and then cause the same address requests to be output out of order in the TLB. In order to solve the TLB order preservation problem, for page tables with a non-4KB page table range, after performing a hit test on the page table based on the granularity corresponding to the page table range, it is necessary to perform a hit test on the page table again based on the 4KB granularity, so that the subsequent hit test results obtained from the two hit tests can establish a connection between read and write requests of the same address.

[0099] Performing a second hit test on the page table at a 4KB granularity means using bits 0-12 of the virtual address as the in-page address offset and comparing the virtual address (excluding bits 0-12) with the page table identifier (the cache TAG address) to determine if they match. The second hit test result indicates a hit, a page table fetch in progress, or a miss. The page table fetch process indicates that the cache line's corresponding page table being requested is the page table required for the read or write request.

[0100] Among them, the 4KB granularity is the minimum granularity for hit testing during the kernel startup phase.

[0101] It should be understood that since the TLB originally needs to support multi-range page tables, re-testing the page table at a 4KB granularity is just adding 2 bits for comparison on the basis of the hit test in S301, and the logic for re-testing the hit is already present in the TLB. Under the premise of achieving the maximum performance of first conversion, first output, there is no need to increase hardware resources, thus solving the problem of large hardware resource overhead in the prior art of storing address information and a large amount of comparator resources at each level of the cache system.

[0102] S303: Establish a connection between the read and write requests of the same address according to the second hit test result.

[0103] In this step, for page tables with a page table range other than 4KB, assuming that the second hit test result is used to indicate a hit, or during the page table acquisition process, it indicates that there may be a request with the same 4K address in the TLB, it is necessary to select the second hit test result to establish a connection between the read and write requests with the same address; assuming that the second hit test result is used to indicate a miss, it indicates that there must be no request with the same 4K address in the TLB, and the first hit test result can be selected to establish a connection between the read and write requests with the same address.

[0104] Optionally, for a page table with a page table range of 4 KB, the read and write requests of the same address are directly associated according to the first hit test result.

[0105] Among them, establishing a connection between read and write requests with the same address is mainly based on the second hit test result or the first hit test result, determining the target read and write request that has the same virtual address as the read and write request received in S301 and arrives at the TLB first, and associating the read and write request received in S301 with the target read and write request, for example, target read and write request-read and write request, so as to ensure that the target read and write request and the read and write request are output in sequence.

[0106] Assume that the target read / write request is already associated with other read / write requests, for example, other read / write request-target read / write request, where the other read / write request has the same virtual address as the target read / write request and arrives at the TLB first. Then, after associating the read / write request with the target read / write request according to the above method, the association relationship between the requests can be expressed as: other read / write request-target read / write request-read / write request, so that requests with the same address are chained in the order they arrive at the TLB first, thereby ensuring that read / write requests with the same address are output in order.

[0107] In a possible implementation, when the second hit test results in S203 are different, the read and write requests may be associated as follows:

[0108] In the first manner, if the second hit test result indicates a hit or the page table is being acquired, the second hit test result is selected to chain read and write requests of the same address.

[0109] In the second manner, if the second hit test result indicates a miss, the read and write requests are chained according to the first hit test result.

[0110] That is to say, in the specific implementation of this solution, assuming that the second hit test result is used to indicate a hit, or during the page table acquisition process, even if the first hit test result is used to indicate a hit, or during the page table acquisition process, it needs to be ignored, and the read and write requests for the same address are chained according to the second hit test result.

[0111] This approach uses a secondary hit test to transform the existing same-address comparison into a comparison within the minimum page table granularity (i.e., 4KB). Using the second hit test result as the primary condition, read and write requests with the same address are linked, thus resolving the problem of out-of-order TLB output caused by a single read or write request hitting multiple cache lines within the TLB. Furthermore, since this approach does not increase hardware resources, it avoids additional resource overhead.

[0112] Furthermore, when establishing connections between read and write requests for the same address, cache line identifiers can be used as indexes to manage linked lists for read and write requests that hit the cache line. Through linked list management, the electronic device's TLB can ensure that requests for the same address are output in the order they arrive at the TLB. Because cache line identifiers are a free resource and require no additional logic, this ensures that requests for the same address are output sequentially within the TLB while preserving their order, saving resource overhead.

[0113] The embodiment of the present application provides a method for preserving the order of read and write requests in a multi-page table system. In the process of address conversion for the received read and write requests, the electronic device performs a hit test on the page table according to the page table range of the page table in each cache line and the granularity corresponding to the page table range, and obtains a first hit test result for each page table; for page tables with a page table range other than 4KB, after obtaining the first hit test result, the page table is hit tested again according to the granularity of 4KB to obtain a second hit test result; according to the second hit test result, the read and write requests with the same address are linked. In this technical solution, by performing two hit tests on the page tables cached in each cache line according to the granularity corresponding to the page table range of the page table and the 4KB granularity, the read and write requests with the same address are linked according to the second hit test result of the second hit test, thereby ensuring that the requests with the same address are output in the TLB sequence with preserving the order, and avoiding additional resource overhead.

[0114] To ensure that requests with the same address are output sequentially within the TLB, all read and write requests cached in the TLB can be checked at the minimum cache access granularity. When a subsequent read or write request with the same address enters the TLB, the read or write request is chained to the chain where the previous read or write request with the same address is located. Compared with the method for preserving the order of read and write requests in a multi-page table system provided by this technical solution, chaining with the same address as the index has the following drawbacks:

[0115] 1. The TLB is a multi-level pipeline and cache module. If chaining is performed based on the same address as the index, the same address check must be performed on each level of the TLB pipeline and the data cache, which consumes a lot of hardware resources.

[0116] 2. The minimum granularity of the page table is 4KB. Two read and write requests that fall within the same 4KB address but different 64KB addresses will form two chains during kernel startup, but they actually use the same page table. The two chains formed by two different 4KB addresses within the same 64KB address space can result in a situation where the page table is already in the TLB, but the two chains are unaware of each other. One chain may continue to wait for its own page table to be returned, even though the page table has already been returned in another chain, resulting in degraded TLB performance.

[0117] In other words, the method for preserving the order of read and write requests in a multi-page table system provided by this technical solution maintains the original chaining method using cache lines as indexes, avoids the huge hardware resource overhead introduced by chaining using VA addresses as indexes, and at the same time solves the problem of out-of-order output of requests with the same address in the TLB due to a read or write request hitting multiple cache lines in the TLB at the same time.

[0118] Furthermore, compared with the method of using address comparison to obtain the correlation between two requests with the same address in the prior art, a first-in-first-out (FIFO) memory is used to ensure that the two requests with the same address are first-in-first-out, and the same page table is detected and returned and discarded, it effectively reduces resource overhead and simplifies design complexity.

[0119] Figure 4 This is a flow chart of another method for preserving the order of read and write requests in a multi-page table system provided by an embodiment of the present application. Figure 4 In the process of performing address translation on the received read and write requests, before performing a hit test on the page table according to the page table range of the page table in each cache line and the granularity corresponding to the page table range, the method for preserving the order of the read and write requests in the multi-page table system may further include:

[0120] S401 : According to the received read / write request, a page table request is sent to the MMU according to the minimum granularity of the page table.

[0121] In this step, after the electronic device's TLB receives a read or write request from the CPU, it converts the virtual address carried in the request into a physical address. If the TLB does not contain the page table corresponding to the read or write request, a page table request is sent to the MMU based on the minimum page table granularity, which is 4KB.

[0122] The number of page table requests the TLB sends to the MMU is equal to the number of read / write request misses in the TLB cache. That is, if the TLB doesn't contain the page table for a read / write request, it will continuously miss the page table it's searching for. Each miss causes the TLB to send a page table request to the MMU, based on the minimum granularity of 4KB.

[0123] Optionally, each time a page table request is sent to the MMU, a cache line is allocated for the page table request to store the page table obtained from the MMU by the page table request. For example, the structure of the cache line can refer to Figure 1 and Figure 2 The content shown will not be repeated here.

[0124] S402 : Receive the page table corresponding to each page table request returned by the MMU in sequence, and store the page table corresponding to each page table request in the cache line corresponding to the page table request.

[0125] In this step, after the MMU obtains the page table from external storage, it returns the page table required for each TLB request one by one. The TLB receives the page table returned by the MMU and stores it in the cache line corresponding to the page table request used to request the page table.

[0126] Among them, when multiple page table requests are used to request the same page table, the MMU returns the same page table for each page table request. After receiving the page table returned by the MMU, the TLB fills the page table into the cache lines corresponding to the multiple page table requests.

[0127] In the above embodiment, since the TLB does not have page table information, the TLB sends a page table request to the MMU according to the minimum granularity, thereby avoiding the problem of being unable to obtain the page table due to the granularity of the page table request being larger than the page table range.

[0128] The order-preserving processing methods for read and write requests in a multi-page table system provided by the above embodiments are applied in actual chip projects. Without increasing the original hardware resource overhead, they solve the TLB output disorder problem in a multi-page table scenario.

[0129] Figure 5 This is a schematic diagram of a structure of a read and write request preserving processing device in a multi-page table system provided by an exemplary embodiment of the present application. Figure 5 The order-preserving processing device 50 for read and write requests in a multi-page table system includes:

[0130] The first processing module 501 is configured to perform a hit test on the page table according to the page table range of each cache line and the granularity corresponding to the page table range during address conversion of the received read and write requests, thereby obtaining a first hit test result for each page table.

[0131] The second processing module 502 is configured to, for a page table whose page table range is not 4 KB, perform a hit test on the page table again at a 4 KB granularity after obtaining the first hit test result, to obtain a second hit test result;

[0132] The third processing module 503 is configured to establish a connection between the read and write requests of the same address according to the second hit test result.

[0133] In a possible implementation, the third processing module 503 is specifically configured to:

[0134] If the second hit test result indicates a hit or the page table is being retrieved, the second hit test result is selected to chain read and write requests for the same address;

[0135] If the second hit test result indicates a miss, the read and write requests are chained according to the first hit test result.

[0136] In a possible implementation, the order-preserving processing device 50 for read and write requests in a multi-page table system further includes:

[0137] The fourth processing module is configured to use the identifier of the cache line as an index to perform linked list management on the read and write requests that hit the cache line.

[0138] In a possible implementation, the first processing module 501 is specifically configured to:

[0139] For a page table with a page table range of 4 KB, a hit test is performed on the page table according to a 4 KB granularity to obtain a first hit test result of the page table;

[0140] or,

[0141] For a page table with a page table range of 64KB, a hit test is performed on the page table according to a 64KB granularity to obtain a first hit test result of the page table;

[0142] or,

[0143] For a page table with a page table range of 2MB, a hit test is performed on the page table according to a 2MB granularity to obtain a first hit test result of the page table;

[0144] Among them, the first hit test result is used to indicate three states: hit, or in the process of page table acquisition, or miss. The page table acquisition process indicates that the page table corresponding to the cache line in the request process is the page table required by the read and write request.

[0145] In one possible implementation, during the address translation process for the received read and write requests, before performing a hit test on the page table according to the page table range of the page table in each cache line and at a granularity corresponding to the page table range, the order-preserving processing device 50 for read and write requests in a multi-page table system further includes:

[0146] A fifth processing module is configured to send a page table request to the MMU according to the received read and write request, and the minimum granularity of the page table is 4KB;

[0147] The page table corresponding to each page table request returned by the MMU is received in sequence, and the page table corresponding to each page table request is stored in the cache line corresponding to the page table request.

[0148] In a possible implementation, the order-preserving processing device 50 for read and write requests in a multi-page table system further includes:

[0149] The sixth processing module is configured to allocate a cache line to the page table request each time the page table request is sent to the MMU.

[0150] The order-preserving processing device 50 for read and write requests in a multi-page table system provided in an embodiment of the present application can execute the technical solution shown in the above method embodiment. Its implementation principles and beneficial effects are similar and will not be repeated here.

[0151] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application, see Figure 6The electronic device 60 may include a processor 61 and a memory 62. Exemplarily, the processor 61 and the memory 62 are interconnected via a bus 63.

[0152] Memory 62 stores computer-executable instructions;

[0153] The processor 61 executes the computer execution instructions stored in the memory 62, so that the processor 61 performs the order-preserving processing method for read and write requests in the multi-page table system as shown in the above method embodiment.

[0154] Optionally, the above-mentioned components of the electronic device 60 may be connected via a system bus.

[0155] Optionally, the electronic device 60 may further include a communication interface for interacting with other devices.

[0156] It should be understood that the processor 61 can be a CPU, or other general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this application can be directly implemented by a hardware processor or performed by a combination of hardware and software modules in the processor.

[0157] The system bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. System buses can be divided into address buses, data buses, and control buses. For ease of illustration, the diagram uses only a single thick line, but this does not imply a single bus or type of bus. Memory may include random access memory (RAM) and non-volatile memory (NVM), such as at least one disk drive.

[0158] The electronic device 60 provided in the embodiment of the present application can be used to execute the order-preserving processing method for read and write requests in a multi-page table system provided in any of the above method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0159] Accordingly, an embodiment of the present application provides a chip, which includes a shader and a cache unit, the cache unit includes a TLB and an MMU, the shader is used to send read and write requests to the cache unit, the TLB is used to implement the order-preserving processing method of read and write requests in the multi-page table system of the above method embodiment, and the MMU is used to store page tables.

[0160] Accordingly, an embodiment of the present application provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, it is used to implement the order-preserving processing method of read and write requests in a multi-page table system of the above method embodiment.

[0161] Accordingly, an embodiment of the present application may also provide a computer program product, including a computer program, which, when executed by a processor, may implement the order-preserving processing method for read and write requests in a multi-page table system as shown in the above method embodiment.

[0162] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0163] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0164] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0165] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0166] In a typical configuration, a computing device includes one or more processors, input / output interfaces, network interfaces, and memory.

[0167] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0168] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), SRAM, dynamic random access memory (DRAM), other types of RAM, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0169] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0170] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for preserving the order of read and write requests in a multi-page table system, characterized in that: include: In the process of performing address conversion on the received read and write requests, according to the page table range of the page table in each cache line, the page table is hit tested according to the granularity corresponding to the page table range to obtain a first hit test result for each page table; For a page table whose page table range is not 4KB, after obtaining the first hit test result, the page table is hit tested again according to the 4KB granularity to obtain a second hit test result; According to the second hit test result, the read and write requests of the same address are associated.

2. The method according to claim 1, characterized in that The step of establishing association between read and write requests for the same address according to the second hit test result includes: If the second hit test result indicates a hit or a page table acquisition process, selecting the second hit test result to chain read and write requests of the same address; If the second hit test result indicates a miss, the read and write requests are chained according to the first hit test result.

3. The method according to claim 2, characterized in that The method further comprises: The identifier of the cache line is used as an index to perform linked list management on the read and write requests that hit the cache line.

4. The method according to any one of claims 1 to 3, characterized in that: According to the page table range of the page table in each cache line, the page table is hit tested according to the granularity corresponding to the page table range to obtain a first hit test result for each page table, including: For a page table with a page table range of 4 KB, a hit test is performed on the page table according to a 4 KB granularity to obtain a first hit test result of the page table; or, For a page table with a page table range of 64 KB, a hit test is performed on the page table according to a 64 KB granularity to obtain a first hit test result of the page table; or, For a page table with a page table range of 2MB, a hit test is performed on the page table according to a 2MB granularity to obtain a first hit test result of the page table; Among them, the first hit test result is used to indicate three states: hit, or in the process of page table acquisition, or miss. The page table acquisition process indicates that the page table corresponding to the cache line in the request process is the page table required by the read and write request.

5. The method according to any one of claims 1 to 3, characterized in that: In the process of performing address conversion on the received read and write requests, before performing a hit test on the page table according to the page table range of the page table in each cache line and the granularity corresponding to the page table range, the method further includes: According to the received read and write requests, a page table request is sent to the memory management unit MMU according to the minimum granularity of the page table, where the minimum granularity of the page table is 4KB; The page table corresponding to each page table request returned by the MMU is received in sequence, and the page table corresponding to each page table request is stored in the cache line corresponding to the page table request.

6. The method according to claim 5, characterized in that The method further comprises: Each time a page table request is sent to the MMU, a cache line is allocated for the page table request.

7. A read and write request preserving processing device in a multi-page table system, characterized in that: include: A first processing module is used to perform a hit test on the page table in each cache line according to a page table range of the page table in each cache line and a granularity corresponding to the page table range in the process of performing address conversion on the received read and write request, so as to obtain a first hit test result for each page table; A second processing module is used for, for a page table whose page table range is not 4KB, after obtaining the first hit test result, performing a hit test on the page table again according to the 4KB granularity to obtain a second hit test result; The third processing module is used to establish a connection between the read and write requests of the same address according to the second hit test result.

8. A chip, characterized in that: The chip includes a shader and a cache unit, the cache unit includes a translation lookaside buffer TLB and a memory management unit MMU, the shader is used to send read and write requests to the cache unit, the TLB is used to execute the order-preserving processing method for read and write requests in a multi-page table system as described in any one of claims 1 to 6, and the MMU is used to store page tables.

9. An electronic device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer execution instructions stored in the memory, so that the processor executes the order-preserving processing method for read and write requests in a multi-page table system according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method for preserving the order of read and write requests in a multi-page table system as described in any one of claims 1 to 6.