Message scheduling method, system, storage medium and electronic device
By recording the message type and location in the message linked list, it realizes flexible order preservation and efficient scheduling of messages in the PCIe protocol, solves the performance bottleneck problem caused by message queue depth, and improves communication performance.
Patent Information
- Application Number
- CN202410965963.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-18
AI Technical Summary
In the PCIe protocol, when the packet queue depth is deep, a large amount of resources are required to store and compare timestamp information, resulting in a bottleneck in improving packet transmission performance.
Using a message linked list, by recording the message type and its position in the linked list, it determines whether the message has sufficient flow control credit, and schedules it according to the message type, avoiding dependence on timestamps and achieving flexible order preservation. and efficient message scheduling.
It reduces resource overhead, supports flexible order preservation of Relaxed Order messages in the PCIe protocol, and improves message transmission performance.
Smart Images

Figure CN118519729B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a message scheduling method, system, storage medium and electronic device. Background Art
[0002] In the PCIE protocol, the transaction layer is used to receive data requests from the core layer of the PCIe device and convert them into PCIe bus transactions. These bus transactions used by the PCIe bus are defined in the TLP (Transaction Layer Packet) header. All TLP messages are divided into three types: Posted messages (abbreviated as P), Non-Posted messages (abbreviated as NP), and Completion messages (abbreviated as CPL). Among them, NP messages can be divided into requests without data (Non-Posted Request, NPR) and requests with data (Non-Posted Request With Data, NPD).
[0003] In the prior art, timestamps are used to perform message order preservation. However, when the message queue depth is relatively deep, a large amount of resources are required to store additional message timestamp information. In addition, when preserving the order, the timestamps of messages of different types need to be compared, which relies on very complex combinational logic circuits and uses a lot of resources, and has become a bottleneck for improving message transmission performance.
[0004] Therefore, how to improve the message transmission performance is a technical problem that technical personnel in this field need to solve urgently. Summary of the invention
[0005] The purpose of the present application is to provide a message scheduling method, system, computer-readable storage medium and electronic device, which get rid of the application dependence on message transmission timestamps by adopting a message linked list and improve communication performance.
[0006] In order to solve the above technical problems, the present application provides a message scheduling method, and the specific technical solution is as follows:
[0007] Receive messages to be scheduled, fill the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determine that the pointer of the message linked list points to a queue; the pointer points to the queue to indicate the next message of each message to be scheduled in the scheduling order;
[0008] The messages to be scheduled are stored in the corresponding cache queues in sequence according to the message types; the message types include flexible order-preserving Posted messages, strict order-preserving Posted messages, flexible order-preserving Non-Posted With Data messages, strict order-preserving Non-Posted messages and completion messages;
[0009] Determine whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit;
[0010] If not, adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and return to execute the step of determining whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit;
[0011] If so, the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer to the queue is redirected according to the message order preservation requirement.
[0012] Optionally, when the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer pointing to the queue is redirected according to the message order preservation requirement, it also includes:
[0013] If the first message to be scheduled is a flexible order-preserving Non-Posted message, and when the message order-preserving requirement includes that the flexible order-preserving Posted message must be able to exceed the previous flexible order-preserving Non-Posted message, the NPD_RO cache queue corresponding to the flexible order-preserving Non-Posted message and the P_RO cache queue corresponding to the flexible order-preserving Posted message are set to use the first time slice round-robin scheduler to perform scheduling; and if there is any cache queue in a blocked state between the NPD_RO cache queue and the P_RO cache queue, the message to be scheduled in the other cache queue will be dispatched first until the blocking state ends and the time slice round-robin scheduling is resumed.
[0014] Optionally, when the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer pointing to the queue is redirected according to the message order preservation requirement, it also includes:
[0015] When the message order preservation requirement includes that the completion message must be able to surpass the previous strictly order-preserving Non-Posted message, the CPL cache queue corresponding to the completion message and the NPR / NPD_SO cache queue corresponding to the strictly order-preserving Non-Posted message are set to use the second time slice round-robin scheduler to perform scheduling; and if there is any cache queue in a blocked state among the CPL cache queue and the NPR / NPD_SO cache queue, the message to be scheduled in the other cache queue will be dispatched first until the blocking state ends and the time slice round-robin scheduling is resumed.
[0016] Optionally, when the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer pointing to the queue is redirected according to the message order preservation requirement, it also includes:
[0017] When the message order preservation requirement includes that the flexible order preservation Posted message must be able to exceed the previous flexible order preservation Non-Posted message, strict order preservation Non-Posted message and completion message, and the flexible order preservation Non-Posted Request message, strict order preservation Non-Posted With Data message and completion message are prohibited from exceeding the previous flexible order preservation Posted message and strict order preservation Posted message, a first message selector is used to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strict order preservation Posted message, and the output priority of the P_SO cache queue is higher than the output priority of the second time slice round-robin scheduler.
[0018] Optionally, when the first message selector is used to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strictly sequence-preserving Posted message, the method further includes:
[0019] If the strictly sequence-preserving Posted message does not have sufficient flow control credit, output the to-be-scheduled message corresponding to the second time slice round-robin scheduler;
[0020] Or, when the first timer of the first message selector expires, and based on the pointer of the message linked list pointing to the queue, it is confirmed that there is no strictly order-preserving Posted message before the to-be-scheduled message output by the second time slice round-robin scheduler, the to-be-scheduled message corresponding to the second time slice round-robin scheduler is output.
[0021] Optionally, when the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer pointing to the queue is redirected according to the message order preservation requirement, it also includes:
[0022] The message order preservation requirement includes that flexible order preservation Posted messages and flexible order preservation Non-Posted WithData messages can exceed the previous strict order preservation Posted messages, strict order preservation Non-Posted messages and completion messages, and the strict order preservation Posted messages are prohibited from exceeding the previous strict order preservation Posted messages and flexible order preservation Posted messages. The strict order preservation Posted messages are allowed to exceed the previous completion messages and strict order preservation Non-Posted messages. A second message selector is used to control the output of the first time slice round-robin scheduler and the first message selector, and the output priority of the first time slice round-robin scheduler is higher than the output priority of the first message selector; when the second timer of the second message selector is full, the to-be-scheduled message corresponding to the first message selector is allowed to be output.
[0023] Optionally, before receiving the to-be-scheduled messages and sequentially filling the message information of the to-be-scheduled messages into the message linked list in the order of receiving, the method further includes:
[0024] Create a message linked list including message type and next message pointer;
[0025] According to each of the next message pointers, the pointer pointing queue is formed;
[0026] The width of the pointer pointing to the queue is determined according to the depth of the message linked list.
[0027] The present application also provides a message dispatching system, comprising:
[0028] A message receiving module, used for receiving messages to be scheduled, filling the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determining that the pointer of the message linked list points to a queue; the pointer points to the queue to indicate the next message of each message to be scheduled in the scheduling order;
[0029] A message cache module, used to store the to-be-scheduled messages into corresponding cache queues in sequence according to the message types; the message types include flexible order-preserving Posted messages, strict order-preserving Posted messages, flexible order-preserving Non-Posted WithData messages, strict order-preserving Non-Posted messages and completion messages;
[0030] A message flow control judgment module, used to judge whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit;
[0031] A scheduling module, which is used to adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and re-enter the message flow control judgment module when the judgment result of the message flow control judgment module is no; and when the judgment result of the message flow control judgment module is yes, schedule the first message to be scheduled in the message linked list from the corresponding cache queue, and redirect the pointer to the queue pointed by the pointer according to the message order preservation requirement.
[0032] The present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above-mentioned method when executed by a processor.
[0033] The present application also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method when calling the computer program in the memory.
[0034] The present application provides a message scheduling method, comprising: receiving a message to be scheduled, filling the message information of the message to be scheduled into a message linked list in sequence according to the order of reception, and determining that a pointer of the message linked list points to a queue; the pointer points to a queue to indicate the next message of each message to be scheduled in the scheduling sequence; storing the message to be scheduled into a corresponding cache queue in sequence according to the message type; the message type includes a flexible order-preserving Posted message, a strictly order-preserving Posted message, and a flexible order-preserving Non-Posted With Data messages, strictly sequence-preserving Non-Posted messages and completion messages; determine whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; if not, adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and return to execute the step of determining whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; if so, schedule the first message to be scheduled in the message linked list from the corresponding cache queue, and redirect the pointer to the queue according to the message sequence preservation requirement.
[0035] The message scheduling method provided by the present application records the reception of all messages through a message linked list when they enter the cache. For messages with specific transaction order requirements, whether they can exceed other messages is determined based on their order in the message linked list. Since only the type of message and their position in the message linked list need to be recorded, and there is no need to record the message timestamp, the additional resource overhead of the entire device is small. At the same time, since dedicated cache queues are set for Posted messages and NPD messages with a Relaxed Order of 1, flexible order preservation of Relaxed Order messages in the PCIE protocol is supported, achieving high-efficiency and low-overhead message order preservation and high-performance message scheduling.
[0036] The present application also provides a message scheduling system, a computer-readable storage medium and an electronic device, which have the above-mentioned beneficial effects and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0038] Figure 1 A flow chart of a message scheduling method provided in an embodiment of the present application;
[0039] Figure 2A schematic diagram of a process of adjusting a pointer pointing to a queue provided in an embodiment of the present application;
[0040] Figure 3 A schematic diagram of the message sequence preservation process provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of a message dispatching system provided in an embodiment of the present application;
[0042] Figure 5 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] When various messages are transmitted in the PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) system, in order to meet the producer / consumer model, ensure performance as much as possible and avoid deadlock, the PCIE protocol defines a set of order-preserving rules that the transaction layer must follow. As shown in Table 1:
[0045] Table 1 PCIE transaction sequence requirements
[0046]
[0047] In Table 1, "yes" means that the transaction of a row can definitely exceed the transaction of the column before it; "no" means that the transaction of a row must not exceed the transaction of the column before it; "no requirement" means that there is no specific requirement for the order between the transaction of a row and the transaction of a column.
[0048] Among them, condition a) in row A, column 2 means that a Posted message cannot exceed the Posted message that precedes it unless condition b is triggered. Condition b) means that there is no requirement for the order of a P message with the Relaxed Order field being 1 and the message that precedes it (i.e., it is allowed to exceed or not, but allowing it to exceed may help improve performance);
[0049] Condition a) in row A, column 5 means that there is no specific order requirement between a Posted message and the preceding Completion message, unless condition b) occurs. Condition b) means that when there is a PCIE to PCI / PCIX bridge in the system, a Posted message must be allowed to exceed the preceding Completion message;
[0050] Condition a) in row C, column 2 means that an NPD message is not allowed to exceed the Posted message that precedes it unless condition b) occurs; condition b) means that an NPD message with the Relaxed Order field set to 1 is allowed to exceed the Posted message that precedes it;
[0051] Condition a) in row D, column 2 means that a completion message is not allowed to exceed the Posted message that precedes it unless condition b) occurs; and condition b) means that a completion message with the Relaxed Order field being 1 is allowed to exceed the Posted message that precedes it (which is beneficial to improving system performance).
[0052] See also Figure 1 , Figure 1 A flowchart of a message scheduling method provided in an embodiment of the present application, the method comprising:
[0053] S101: receiving messages to be scheduled, filling the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determining that a pointer of the message linked list points to a queue; the pointer points to the queue to indicate the next message of each message to be scheduled in the scheduling order;
[0054] S102: storing the to-be-scheduled messages in the corresponding cache queues in sequence according to the message types; the message types include flexible order-preserving Posted messages, strict order-preserving Posted messages, flexible order-preserving Non-Posted With Data messages, strict order-preserving Non-Posted messages, and completion messages;
[0055] S103: Determine whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; if not, proceed to S104; if yes, proceed to S105;
[0056] S104: adjusting the pointer to point to the queue or determining that the pointer points to the next message to be scheduled in the queue whose message type is different from that of the first message to be scheduled, and returning to execute the step of determining whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credits;
[0057] S105: The first message to be scheduled in the message linked list is dispatched from the corresponding cache queue, and the pointer pointing to the queue is redirected according to the message order preservation requirement.
[0058] When receiving a TLP message, the present application fills in the message linked list in the order of precedence. The message linked list is only filled with the message information of the message to be scheduled, and the message to be scheduled needs to be cached in the cache queue. This embodiment assumes that the message linked list has been obtained or generated before receiving the message to be scheduled. The message linked list mainly includes the message type and the pointer to the queue. The message type determines whether it can be reordered, and the pointer points to the queue containing the next message of each message to be scheduled in the scheduling order. It can be seen that the scheduling order in the pointer pointing to the queue in the initial state is the receiving order of each TLP message.
[0059] This embodiment does not limit how to generate the message linked list. The following is a feasible method for generating the message linked list:
[0060] The first step is to create a message list containing the message type and the next message pointer;
[0061] Step 2: forming the pointer pointing queue according to each of the next message pointers;
[0062] The third step is to determine the pointer width of the queue pointed by the pointer according to the depth of the message linked list.
[0063] In the generation process of the above message linked list, the pointer points to the queue as a component of the message linked list. In other embodiments of the present application, the pointer points to the queue and can exist independently of the message linked list. Since the message usually adopts a FIFO (FirstIn First Out) queue, if only one cache queue is used to receive the TLP message, even if the sequence is adjusted, the message order preservation requirement cannot be met due to the limitation of the FIFO queue. Therefore, the present application constructs a corresponding cache queue for each message type, and when a TLP message is received, it is cached to the corresponding cache queue according to the corresponding type of the TLP message. The message types in this embodiment include flexible order-preserving Posted messages, strict order-preserving Posted messages, flexible order-preserving Non-Posted WithData messages, strict order-preserving Non-Posted messages and completion messages. Among them, the completion message is also called a CPL message. Correspondingly, the P_RO queue refers to the Posted message queue with the Relaxed Order field being 1; the NPD_RO queue refers to the Non-Posted Request With Data message queue with the Relaxed Order field being 1; the P_SO queue refers to the Posted message queue with the Relaxed Order field being 0; the CPL queue refers to the Completion message queue; the NPR / NPD-SO queue refers to the Non-PostedRequest (without data) and Non-Posted Request With Data (with data) queues with the Relaxed Order field being 0.
[0064] On the PCIe bus, data transmission efficiency and sequence control are two extremely important aspects. In order to optimize these two aspects, PCIe introduces a variety of transaction sorting rules, including Strong Ordering and Relaxed Ordering. Strong Ordering forces first-come-first-served, while Relaxed Ordering allows certain types of TLP messages to be transmitted ahead of other TLP messages under certain conditions. If the Relaxed Ordering bit in the Attr field of the message is set to 1, that is, the Relaxed Order field is 1, it means that the message can be reordered. It mainly includes P_RO messages and NPD_RO messages. If the Relaxed Order field is 0, it means that the previous message cannot be transmitted.
[0065] When scheduling messages, the message status of the peer device needs to be considered. In order to solve the congestion problem that may occur during data transmission, the data transmission rate of the sender is reasonably adjusted to avoid data packet loss and improve the efficiency and stability of the network. A message with sufficient flow control credit means that this type of message has sufficient credit during the transmission process to ensure that it is correctly processed by the receiving end, thereby avoiding data loss or retransmission due to insufficient buffer at the receiving end. If a certain type of message does not have sufficient flow control credit, it indicates that the peer device no longer receives this type of message, that is, the sender is restricted from sending this type of message. If a certain type of message has sufficient flow control credit, it can be sent to the peer device normally.
[0066] If the message type corresponding to the first message to be scheduled does not have enough flow control credit, the head position of the message list can be adjusted at this time, that is, the first message to be scheduled is no longer used as the head of the message list. This process does not need to perform data migration in the message list and other processes, only the head data and the pointer pointing to the queue need to be changed. It is easy to understand that if the consecutive messages after the first message to be scheduled are all of the same message type, the next message to be scheduled of a different message type should be used as the head. For example, before adjusting the head position of the message list, suppose the message list contains four messages A, A, B, and C, where the first two A represent messages of the same type. If A does not have enough flow control credit, the A message at the head position can be adjusted at this time, and the message list can be changed to B, A, A, C. If the A type message has enough flow control credit after B is sent, the actual sending order is B→A→A→C. It may also be that there is no longer enough flow control credit only after the first A type message is sent. At this time, the actual sending order may also be B→A→C→A. Of course, if type A messages do not have sufficient flow control credit for a long time, the corresponding sending order may be B→C→A→A.
[0067] In addition, the message linked list may not be adjusted, but the pointer may be determined to point to a message to be scheduled in the queue that is different in message type from the first message to be scheduled, and it may be determined whether it has sufficient flow control credits. If so, it may be sent.
[0068] After the pointer points to the queue updated, the judgment of whether the message type of the first message to be scheduled has sufficient flow control credit is re-executed until it has sufficient flow control credit, and the pointer points to the queue adjusted according to the message order preservation requirement.
[0069] The following describes the adjustment process of the pointer to the queue, see Figure 2 , Figure 2A schematic diagram of the adjustment process of the pointer pointing to the queue provided in the embodiment of the present application. In the following embodiment, on the basis of the pointer pointing to the queue, a corresponding message pointer queue is constructed for each type of message, which is used to indicate the position information of the message of this type in the entire message linked list, and the order of the position information in the message pointer queue can reflect the scheduling order of each message.
[0070] When adjusting the pointer pointing queue, configure the message pointer queue of each type of received message to be scheduled; the message pointer queue is used to record the position information of the message in the message linked list, and the element sequence of the message pointer queue is used to indicate the scheduling order of the message;
[0071] If scheduling is performed according to the message order preservation requirements or there are new messages or message scheduling, the message pointer queue of the message type described in the corresponding message is updated, and the pointer pointing to the queue is updated. The pointer pointing to the queue includes a head pointer, a message pointer, and a tail pointer. The head pointer is used to indicate the first message to be scheduled, the tail pointer is used to indicate the last message to be scheduled, and the message pointer is used to indicate the next message of each message to be scheduled except the last message to be scheduled.
[0072] The scheme of the order-preserving linked list is illustrated by taking the Posted message (hereinafter referred to as P or P message) and NP (i.e. NP request without data) as examples. Assume that the depth of the message linked list is 5, and 5 TLP messages are received. In chronological order, the messages are NP, P, P, NP, NP. At this time, see Figure 2 In the initial state row, the element status and pointer pointing queue in the message list. Among them, the head pointer of the list is head=0, the tail pointer of the list is tail=4, and the NP pointer queue is 0, 3, 4, which records the pointer of the NP message in the list. The P pointer queue is 1, 2, which records the position of the P message in the list. Since the queue is full, the available pointer queue is empty. At this time, the pointer pointing queue is shown by the direction arrow under each element.
[0073] If the P message is allowed to be scheduled, the P message at the front of the linked list is scheduled out, and the P pointer queue becomes 2, and the available pointer queue is 1. The NP pointer queue remains unchanged, and the next pointer of the NP message at the head of the linked list is updated from 1 to 2. At this time, the pointer points to the queue as shown by the direction arrows under each element.
[0074] If a new NP message is received in the queue, since the current available pointer queue is 1, the new NP message is placed in the buffer with pointer 1, and the NP pointer queue is updated to 0, 3, 4, 1. The available pointer queue is empty, and the P pointer queue remains unchanged. The new incoming NP message is placed at the end of the linked list, so the next pointer of the buffer at the tail pointer position is updated to 1, and the tail pointer is also updated to 1; at this time, the pointer points to the queue as shown by the direction arrows under each element.
[0075] When the scheduler allows the scheduling of NP messages, since there is an NP message at the head of the linked list, the NP message can be scheduled out. At this time, the NP pointer queue is updated to 3, 4, 1, the available pointer queue is 0, and the P pointer remains unchanged. Since the NP at the head of the linked list is scheduled out and the P message must surpass the NP message, the head is updated to 2 at this time, and the tail pointer remains unchanged and is still 1; at this time, the pointer points to the queue as shown by the direction arrows under each element.
[0076] If the scheduler still wants to schedule the NP operation (the P message may not be sent out due to insufficient flow control credit), but the P message is at the head of the linked list, the NP operation cannot be scheduled out because there is an earlier P operation that has not been dequeued. This is because the protocol does not allow the NP message to exceed the previous P message. At this time, the pointer points to the queue as shown by the direction arrows under each element.
[0077] It can be seen that the above implementation process further sets a dedicated pointer queue for each type of message. When it is necessary to add or delete a linked list element, the position of the element can be quickly found in the linked list, thereby realizing the order of saving the message based on the linked list data structure.
[0078] The message scheduling method provided in the embodiment of the present application records the message reception through the message linked list when all messages enter the cache. For messages with specific transaction order requirements, whether they can exceed other messages is determined based on their order in the message linked list. Since only the type of message and their position in the message linked list need to be recorded, and there is no need to record the message timestamp, the additional resource overhead of the entire device is small. At the same time, since dedicated cache queues are set for Posted messages and NPD messages with Relaxed Order 1, flexible order preservation of Relaxed Order messages in the PCIE protocol is supported, achieving high-efficiency and low-overhead message order preservation.
[0079] The following is an explanation of message order preservation. Figure 3 , Figure 3 The schematic diagram of the message sequence preservation process provided in the embodiment of the present application, the message sequence preservation can refer to Table 1 above, and the specific process can be performed as described below:
[0080] After the TLP message is input, each TLP message is stored in the corresponding buffer queue according to the message type, that is, Figure 3 The P_RO cache queue, NPD_RO cache queue, P_SO cache queue, CPL queue and NPR / NPD_SO cache queue are shown. At the same time, the message information is written into Figure 3 The message chain table control module below performs message sequence detection. After the TLP message is input, Figure 3 The arrow pointing back to the linked list control is included, indicating that the message order-keeping control process of the next TLP message is restarted.
[0081] If the first message to be scheduled is a flexible order-preserving Non-Posted message, and when the message order-preserving requirement includes that the flexible order-preserving Posted message must be able to surpass the previous flexible order-preserving Non-Posted message, the NPD_RO cache queue corresponding to the flexible order-preserving Non-Posted message and the P_RO cache queue corresponding to the flexible order-preserving Posted message are set to use the first time slice round-robin scheduler to perform scheduling; and if any cache queue in the NPD_RO cache queue and the P_RO cache queue is in a blocked state, the message to be scheduled in the other cache queue will be dispatched first until the blocking state ends and the time slice round-robin scheduling is resumed.
[0082] It should be noted that the message order preservation requirement includes that the flexible order-preserving Posted message must be able to surpass the previous flexible order-preserving Non-Posted message, which means that the flexible order-preserving Posted message must be able to surpass the previous flexible order-preserving Non-Posted message, but it does not have to surpass it. When any of the two cache queues, the NPD_RO cache queue and the P_RO cache queue, is blocked, the messages to be scheduled in the other cache queue are sent first, and the first time slice round-robin scheduler is used to perform scheduling until the blockage ends.
[0083] According to the PCIE message order preservation requirements, the P_RO message in the P_RO cache queue (i.e., the flexible order preservation Posted message mentioned above) must be able to exceed the NPD_RO message in the NPD_RO cache queue in front (i.e., the flexible order preservation Non-Posted message mentioned above), while the NPD_RO message can exceed the P_RO message or not. Therefore, the P_RO queue and the NPD_RO queue adopt RR scheduling (Round Robin, time slice round-robin scheduling algorithm), and randomly dequeue when the flow control credit is sufficient. The first time slice round-robin scheduler applies RR scheduling, and RR scheduling achieves this goal by allocating a CPU time unit called a "time slice" to each process. If a process does not complete execution within its time slice, it will be placed back at the end of the ready queue and wait for the next scheduling. This mechanism ensures that all processes make progress and avoids the occurrence of starvation.
[0084] When the message order preservation requirement includes that the completion message must be able to surpass the previous strictly order-preserving Non-Posted message, the CPL cache queue corresponding to the completion message and the NPR / NPD_SO cache queue corresponding to the strictly order-preserving Non-Posted message are set to use the second time slice round-robin scheduler for scheduling; and if there is any cache queue in a blocked state in the CPL cache queue and the NPR / NPD_SO cache queue, the message to be scheduled in the other cache queue will be sent out first until the blocking state ends and the time slice round-robin scheduling is resumed. The second time slice round-robin scheduler and the first time slice round-robin scheduler play the same role. In order to distinguish its application scenarios, this embodiment uses expressions such as "first" and "second".
[0085] According to the PCIE message order preservation requirement, the completion message must be able to exceed the previous NP message, and there is no order requirement between the NP message and the previous completion message. Therefore, the CPL queue and the NPR / NPD_SO queue can also use the second time slice round-robin scheduler to perform RR scheduling. When the flow control credit is met, the queue is randomly dequeued. If one of the queues is blocked due to insufficient flow control credit, it cannot be dequeued, and the other queue is allowed to dequeue first.
[0086] When the message order preservation requirement includes that the flexible order preservation Posted message must be able to exceed the previous flexible order preservation Non-Posted message, strict order preservation Non-Posted message and completion message, and the flexible order preservation Non-Posted Request message, strict order preservation Non-Posted With Data message and completion message are prohibited from exceeding the previous flexible order preservation Posted message and strict order preservation Posted message, the first message selector is used to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strict order preservation Posted message, and the output priority of the P_SO cache queue is higher than the output priority of the second time slice round-robin scheduler.
[0087] According to the PCIE message order preservation requirement, the Posted message must be able to exceed the NP and completion messages in front, while the Non-Posted and completion messages are not allowed to exceed the Posted messages in front. Therefore, the output of the second time slice round-robin scheduler and the output of the P_SO queue use a message selector. Usually, the message output of the P_SO queue is selected.
[0088] On this basis, in order to avoid severe starvation or even starvation of the queues for Non-Posted messages and the CPL queue, this embodiment proposes that Non-Posted messages or completion messages can be selected for output in the following two situations:
[0089] In the first case, if the strictly sequence-preserving Posted message does not have sufficient flow control credit, the to-be-scheduled message corresponding to the second time slice round-robin scheduler is output;
[0090] In the second case, when the first timer of the first message selector expires, and according to the pointer of the message linked list pointing to the queue, it is confirmed that there is no strictly order-preserving Posted message before the to-be-scheduled message output by the second time slice round-robin scheduler, and the to-be-scheduled message corresponding to the second time slice round-robin scheduler is output.
[0091] When there is not enough flow control for the Posted message, the to-be-scheduled message corresponding to the second time slice round-robin scheduler can be directly output.
[0092] At the same time, a first timer can be set for the first message selector, and when the first timer is full, the message output of the second time slice round-robin scheduler can be selected. It is easy to understand that the full time of the first timer can be configured by software. And the first timer is reset after full.
[0093] However, since the Non-Posted message and the completion message are not allowed to exceed the previous Posted message, when selecting the message output of the second time slice round-robin scheduler, it is necessary to check whether the Posted message in front of it has not been sent out. If so, the message of the second time slice round-robin scheduler cannot be output, otherwise it can be output. Checking whether there is any Posted message that has not been sent before the Non-Posted message / Completion message can be achieved through the message linked list.
[0094] The message list is sorted according to the order of various types of messages, with the Header entering first and the Tail entering last. Each element of the message list is the message type and the pointer NEXT of the next message (the width of the pointer is selected according to the depth of the queue). At the same time, each type of message also has a pointer queue that records the position of each message in the list. Whenever a message is sent out, the element corresponding to the message needs to be deleted from the list (the position of the deleted element can be obtained from the pointer queue of the corresponding message). When a new message enters, a new element needs to be added to the list (the pointer of the new element is obtained from the available pointer queue) and the pointer is updated to point to the queue.
[0095] The message order-preserving requirements include that flexible order-preserving Posted messages and flexible order-preserving Non-Posted WithData messages can exceed the previous strict order-preserving Posted messages, strict order-preserving Non-Posted messages and completion messages, and that strict order-preserving Posted messages are prohibited from exceeding the previous strict order-preserving Posted messages and flexible order-preserving Posted messages. Strict order-preserving Posted messages are allowed to exceed the previous completion messages and strict order-preserving Non-Posted messages. A second message selector is used to control the output of the first time slice round-robin scheduler and the first message selector, and the output priority of the first time slice round-robin scheduler is higher than the output priority of the first message selector; when the second timer of the second message selector is full, the to-be-scheduled message corresponding to the first message selector is allowed to be output.
[0096] On this basis, the following two types of information can be output according to the addition and deletion of elements in the current message list:
[0097] Whether there are any Posted messages before NP / CPL that have not been sent out?
[0098] Is there any Posted message before the P_SO message that has not been sent?
[0099] According to the PCIE protocol, P_RO and NPD_RO messages can exceed the P_SO / CPL / NP messages in front of them, while P_SO messages are not allowed to exceed the Posted messages in front of them (whether P_SO or P_RO), and P_SO messages can exceed the NP and completion messages in front of them. Therefore, the second message selector usually selects the message output of RR scheduler 1. In order to avoid starvation of the channel where message selector 1 is located, the output of the first message selector may be selected in the following two cases:
[0100] The message flow control output by the first time slice round-robin scheduler is insufficient; or the second timer is full, allowing the message output of the second message selector to be selected at regular intervals.
[0101] It can be seen that when selecting the output of the second message selector, it is also possible to determine whether the current message can be output according to the state of the message sequence control module:
[0102] Case 1: If the second message selector outputs an NP message, it is necessary to determine whether there is a P message that is not output before it. If so, the message of the second message selector cannot be output, otherwise it can be output;
[0103] Case 2: If the second message selector outputs a completion message, it is necessary to determine whether its RelaxedOrder field is 1; if it is 1, it can be directly output; if it is 0, it is still necessary to determine whether there is a P message before it that has been output. If so, the message of the second message selector cannot be output, otherwise it can be output;
[0104] The third case: if the second message selector outputs a P_SO message, it is necessary to determine whether there is a P_RO message before it. If so, the message of the second message selector cannot be output, otherwise it can be output.
[0105] This embodiment uses the RR scheduling algorithm to implement scheduling for messages without order preservation requirements. For messages with specific transaction order requirements, it will determine whether they can exceed each other based on their order in the linked list. Since only the type of messages and their positions in the linked list need to be recorded, the entire device has little additional resource overhead. At the same time, since dedicated cache queues are set for Posted messages with Relaxed Order 1 and Non-Posted With Data messages, flexible order preservation of Relaxed Order messages in the PCIE protocol is supported.
[0106] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of a message dispatching system provided in an embodiment of the present application. The present application also provides a message dispatching system, including:
[0107] A message receiving module, used for receiving messages to be scheduled, filling the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determining that the pointer of the message linked list points to a queue; the pointer points to the queue to indicate the next message of each message to be scheduled in the scheduling order;
[0108] A message cache module, used to store the to-be-scheduled messages into corresponding cache queues in sequence according to the message types; the message types include flexible order-preserving Posted messages, strict order-preserving Posted messages, flexible order-preserving Non-Posted WithData messages, strict order-preserving Non-Posted messages and completion messages;
[0109] A message flow control judgment module, used to judge whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit;
[0110] A scheduling module, which is used to adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and re-enter the message flow control judgment module when the judgment result of the message flow control judgment module is no; and when the judgment result of the message flow control judgment module is yes, schedule the first message to be scheduled in the message linked list from the corresponding cache queue, and redirect the pointer to the queue pointed by the pointer according to the message order preservation requirement.
[0111] Based on the above embodiments, as a preferred embodiment, it also includes:
[0112] The first message order-keeping module is used for setting the NPD_RO cache queue corresponding to the flexible order-keeping Non-Posted message and the P_RO cache queue corresponding to the flexible order-keeping Posted message to use the first time slice round-robin scheduler to perform scheduling if the first message to be scheduled is a flexible order-keeping Non-Posted message, and when the message order-keeping requirement includes that the flexible order-keeping Posted message must be able to exceed the previous flexible order-keeping Non-Posted message; and if there is any cache queue in a blocked state between the NPD_RO cache queue and the P_RO cache queue, the message to be scheduled in the other cache queue will be sent out first until the time slice round-robin scheduling is resumed after the blocking state ends.
[0113] Based on the above embodiments, as a preferred embodiment, it also includes:
[0114] The second message order preservation module is used to set the CPL cache queue corresponding to the completion message and the NPR / NPD_SO cache queue corresponding to the strict order preservation Non-Posted message to be scheduled using the second time slice round-robin scheduler when the message order preservation requirement includes that the completion message must be able to exceed the previous strict order preservation Non-Posted message; and if there is any cache queue in a blocked state between the CPL cache queue and the NPR / NPD_SO cache queue, the to-be-scheduled message in the other cache queue will be sent out first until the blocking state ends and the time slice round-robin scheduling is resumed.
[0115] Based on the above embodiments, as a preferred embodiment, it also includes:
[0116] The third message order preservation module is used to use the first message selector to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strict order preservation Posted message when the message order preservation requirement includes that the flexible order preservation Posted message must be able to exceed the previous flexible order preservation Non-Posted message, strict order preservation Non-Posted message and completion message, and the flexible order preservation Non-Posted Request message, strict order preservation Non-Posted With Data message and completion message are prohibited from exceeding the previous flexible order preservation Posted message and strict order preservation Posted message, and the output priority of the P_SO cache queue is higher than the output priority of the second time slice round-robin scheduler.
[0117] Based on the above embodiment, as a preferred embodiment, the third message sequence preservation module further includes:
[0118] A message starvation control unit is used to output the to-be-scheduled message corresponding to the second time slice round-robin scheduler if the strictly order-preserving Posted message does not have sufficient flow control credit; or, when the first timer of the first message selector expires, and based on the pointer of the message linked list pointing to the queue, confirm that there is no strictly order-preserving Posted message before the to-be-scheduled message output by the second time slice round-robin scheduler, output the to-be-scheduled message corresponding to the second time slice round-robin scheduler.
[0119] Based on the above embodiments, as a preferred embodiment, it also includes:
[0120] A fourth message order preservation module is used to include in the message order preservation requirements that flexible order preservation Posted messages and flexible order preservation Non-Posted With Data messages can exceed the previous strict order preservation Posted messages, strict order preservation Non-Posted messages and completion messages, and the strict order preservation Posted messages are prohibited from exceeding the previous strict order preservation Posted messages and flexible order preservation Posted messages. The strict order preservation Posted messages are allowed to exceed the previous completion messages and strict order preservation Non-Posted messages. A second message selector is used to control the output of the first time slice round-robin scheduler and the first message selector, and the output priority of the first time slice round-robin scheduler is higher than the output priority of the first message selector; when the second timer of the second message selector is full, the to-be-scheduled message corresponding to the first message selector is allowed to be output.
[0121] Based on the above embodiments, as a preferred embodiment, it also includes:
[0122] The pointer-to-queue generation module is used to create a message linked list including a message type and a next message pointer; form the pointer-to-queue according to each of the next message pointers; and determine the pointer width of the pointer-to-queue according to the depth of the message linked list.
[0123] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0124] The present application also provides an electronic device, see Figure 5 , a structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 5 As shown, a processor 1410 and a memory 1420 may be included.
[0125] Among them, the processor 1410 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1410 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1410 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1410 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1410 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0126] The memory 1420 may include one or more computer-readable storage media, which may be non-transitory. The memory 1420 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 1420 is at least used to store the following computer program 1421, wherein, after the computer program is loaded and executed by the processor 1410, it can implement the relevant steps in the method performed by the electronic device side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 1420 may also include an operating system 1422 and data 1423, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 1422 may include Windows, Linux, Android, etc.
[0127] In some embodiments, the electronic device may further include a display screen 1430 , an input / output interface 1440 , a communication interface 1450 , a sensor 1460 , a power source 1470 , and a communication bus 1480 .
[0128] certainly, Figure 5 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Figure 5 More or fewer components than shown, or combinations of certain components.
[0129] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the system provided in the embodiment, since it corresponds to the method provided in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0130] Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
[0131] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A message scheduling method, characterized in that: include: Receive messages to be scheduled, fill the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determine that the pointer of the message linked list points to the queue; The pointer points to a queue for indicating the next message in the scheduling order of each message to be scheduled; The messages to be scheduled are stored in the corresponding cache queues in sequence according to the message types; the P_RO queue refers to the Posted message queue with the RelaxedOrder field being 1; the NPD_RO queue refers to the Non-PostedWithData message queue with the RelaxedOrder field being 1; the P_SO queue refers to the Posted message queue with the RelaxedOrder field being 0; the CPL queue refers to the Completion message queue; the NPR / NPD-SO queue refers to the Non-Posted Request and Non-Posted With Data queues with the RelaxedOrder field being 0; wherein, if the RelaxedOrder field is 0, it means that the previous message transmission cannot be surpassed, and if the RelaxedOrder field is 1, it means that the message can be reordered; Determine whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; If not, adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and return to execute the step of determining whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; If so, the first message to be scheduled in the message linked list is scheduled to be sent out from the corresponding cache queue, and the pointer to the queue is redirected according to the message order preservation requirement.
2. The message scheduling method according to claim 1, characterized in that: The first message to be scheduled in the message linked list is dispatched from the corresponding cache queue, and when the pointer to the queue is redirected according to the message order preservation requirement, the method further includes: If the first message to be scheduled is a flexible order-preserving Non-Posted message, and when the message order-preserving requirement includes that the flexible order-preserving Posted message must be able to exceed the previous flexible order-preserving Non-Posted message, the NPD_RO cache queue corresponding to the flexible order-preserving Non-Posted message and the P_RO cache queue corresponding to the flexible order-preserving Posted message are set to use the first time slice round-robin scheduler to perform scheduling; and if there is any cache queue in a blocked state between the NPD_RO cache queue and the P_RO cache queue, the message to be scheduled in the other cache queue will be dispatched first until the blocking state ends and the time slice round-robin scheduling is resumed.
3. The message scheduling method according to claim 2, characterized in that: The first message to be scheduled in the message linked list is dispatched from the corresponding cache queue, and when the pointer to the queue is redirected according to the message order preservation requirement, the method further includes: When the message order preservation requirement includes that the completion message must be able to surpass the previous strictly order-preserving Non-Posted message, the CPL cache queue corresponding to the completion message and the NPR / NPD_SO cache queue corresponding to the strictly order-preserving Non-Posted message are set to use the second time slice round-robin scheduler to perform scheduling; and if there is any cache queue in a blocked state among the CPL cache queue and the NPR / NPD_SO cache queue, the message to be scheduled in the other cache queue will be dispatched first until the blocking state ends and the time slice round-robin scheduling is resumed.
4. The message scheduling method according to claim 3, characterized in that: The first message to be scheduled in the message linked list is dispatched from the corresponding cache queue, and when the pointer to the queue is redirected according to the message order preservation requirement, the method further includes: When the message order preservation requirement includes that the flexible order preservation Posted message must be able to exceed the previous flexible order preservation Non-Posted message, strict order preservation Non-Posted message and completion message, and the flexible order preservation Non-Posted Request message, strict order preservation Non-Posted With Data message and completion message are prohibited from exceeding the previous flexible order preservation Posted message and strict order preservation Posted message, a first message selector is used to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strict order preservation Posted message, and the output priority of the P_SO cache queue is higher than the output priority of the second time slice round-robin scheduler.
5. The message scheduling method according to claim 4, characterized in that: When the first message selector is used to control the output of the second time slice round-robin scheduler and the P_SO cache queue corresponding to the strictly sequence-preserving Posted message, it also includes: If the strictly sequence-preserving Posted message does not have sufficient flow control credit, output the to-be-scheduled message corresponding to the second time slice round-robin scheduler; Or, when the first timer of the first message selector expires, and based on the pointer of the message linked list pointing to the queue, it is confirmed that there is no strictly order-preserving Posted message before the to-be-scheduled message output by the second time slice round-robin scheduler, the to-be-scheduled message corresponding to the second time slice round-robin scheduler is output.
6. The message scheduling method according to claim 5, characterized in that: The first message to be scheduled in the message linked list is dispatched from the corresponding cache queue, and when the pointer to the queue is redirected according to the message order preservation requirement, the method further includes: The message order preservation requirement includes that flexible order preservation Posted messages and flexible order preservation Non-Posted With Data messages can exceed the previous strict order preservation Posted messages, strict order preservation Non-Posted messages and completion messages, the strict order preservation Posted messages are prohibited from exceeding the previous strict order preservation Posted messages and flexible order preservation Posted messages, and the strict order preservation Posted messages are allowed to exceed the previous completion messages and strict order preservation Non-Posted messages. A second message selector is used to control the output of the first time slice round-robin scheduler and the first message selector, and the output priority of the first time slice round-robin scheduler is higher than the output priority of the first message selector; when the second timer of the second message selector is full, the to-be-scheduled message corresponding to the first message selector is allowed to be output.
7. The message scheduling method according to any one of claims 1 to 6, characterized in that: Receiving the message to be scheduled, and before filling the message information of the message to be scheduled into the message linked list in sequence according to the receiving order, it also includes: Create a message linked list including message type and next message pointer; According to each of the next message pointers, the pointer pointing queue is formed; The width of the pointer pointing to the queue is determined according to the depth of the message linked list.
8. A message dispatching system, characterized in that: include: A message receiving module, used for receiving messages to be scheduled, filling the message information of the messages to be scheduled into a message linked list in sequence according to the order of receiving, and determining that the pointer of the message linked list points to a queue; The pointer points to a queue for indicating the next message in the scheduling order of each message to be scheduled; A message cache module is used to store the to-be-scheduled messages into corresponding cache queues in sequence according to the message types; a P_RO queue refers to a Posted message queue whose Relaxed Order field is 1; an NPD_RO queue refers to a Non-Posted With Data message queue whose Relaxed Order field is 1; a P_SO queue refers to a Posted message queue whose Relaxed Order field is 0; a CPL queue refers to a Completion message queue; an NPR / NPD-SO queue refers to a Non-Posted Request and a Non-Posted With Data queue whose Relaxed Order field is 0; wherein, a Relaxed Order field of 0 indicates that the previous message transmission cannot be surpassed, and a Relaxed Order field of 1 indicates that the message can be reordered; A message flow control judgment module, used to judge whether the message type of the first message to be scheduled in the message linked list has sufficient flow control credit; A scheduling module, which is used to adjust the pointer to point to the queue or determine that the pointer points to the next message to be scheduled in the queue that is different from the message type of the first message to be scheduled, and re-enter the message flow control judgment module when the judgment result of the message flow control judgment module is no; and when the judgment result of the message flow control judgment module is yes, schedule the first message to be scheduled in the message linked list from the corresponding cache queue, and redirect the pointer to the queue pointed by the pointer according to the message order preservation requirement.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the message scheduling method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor calls the computer program in the memory, the steps of the message scheduling method according to any one of claims 1 to 7 are implemented.
