Command execution method and device, equipment and medium
By merging adjacent and identical commands in the commit queue of the NVMe protocol, a commit queue entry containing two commands is generated, which solves the problem of multi-time performance and real-time performance of I/O commands and achieves more efficient command execution.
Patent Information
- Application Number
- CN202510198717.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-02-21
AI Technical Summary
In the scenario where there are many I/O commands, the NVMe protocol manages commands by submitting queue entries, which may negatively affect the host performance and real-time command execution.
Reduce the number of commits to submit queue entries by finding two commands adjacent positions and the same command type in the preset command queue, generating and submitting a commit queue entry with two commands.
Improves the performance of the host and the real-time command execution. By reducing the number of submissions of queue entries, ensures the order of command execution and improves system efficiency.
Smart Images

Figure CN119987682A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of command processing, and in particular to a command execution method, device, equipment and medium. Background Art
[0002] With the rapid development of Solid State Disk (SSD), NVMe (Non-Volatile Memory Express) protocol can significantly achieve better performance in key indicators such as throughput, latency, IOPS (Input / Output Operations Per Second, the number of read and write operations per second) through its advantages in PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) bus, multi-queue mechanism, parallelism, etc., thereby better realizing data interaction between the host Host and the SSD.
[0003] NVMe manages the submission and completion of I / O (Input / Output) commands through the Submission Queue (SQ) and Completion Queue (CQ) located in the host; the Submission Queue is used to store SQE (Submission Queue Entry), each SQE contains a complete I / O command, and the Completion Queue is used to store CQE (Completion Queue Entry) containing the execution status of the I / O command. However, since each I / O command needs to submit an SQE to the Submission Queue, in scenarios with a large number of I / O commands, the SQEs need to be submitted one by one, which may have a negative impact on the performance of the host and the real-time execution of I / O commands. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a command execution method, apparatus, device and medium, which can generate and submit a submission queue entry for two commands with adjacent positions and the same command type in a preset command queue, thereby improving the performance of the host and the real-time performance of command execution by reducing the number of submissions of the submission queue entries. The specific scheme is as follows:
[0005] In a first aspect, the present invention provides a command execution method, applied to a host, comprising:
[0006] Acquire a number of commands for the non-volatile memory, and store the commands in a local preset command queue;
[0007] When taking out a command to be submitted from the preset command queue and submitting it to a local preset submission queue, if there is a target command in the preset command queue that is adjacent to the command to be submitted and has the same command type as the command to be submitted, a first submission queue entry is generated based on the command to be submitted and the target command using a first preset data structure, and the first submission queue entry is submitted to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the command to be submitted and the target command;
[0008] After submitting the submission queue entry to the preset submission queue, the controller in the non-volatile memory is notified so that the controller executes a corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
[0009] Optionally, after submitting the submission queue entry to the preset submission queue, notifying a controller in the non-volatile memory so that the controller executes a corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue, includes:
[0010] After submitting the submission queue entry to the tail of the preset submission queue, the tail pointer of the preset submission queue stored in the first doorbell register is updated to notify the controller in the non-volatile memory, so that when the controller detects that the tail pointer in the first doorbell register is updated, the controller sends a first notification message indicating that there is a newly submitted submission queue entry in the preset submission queue to the non-volatile memory, and executes a corresponding command on the non-volatile memory using the newly submitted submission queue entry taken from the preset submission queue;
[0011] Wherein, the first doorbell register is located inside the controller.
[0012] Optionally, when taking out the command to be submitted from the preset command queue and submitting it to the local preset submission queue, if there is a target command in the preset command queue that is adjacent to the command to be submitted and has the same command type as the command to be submitted, generating a first submission queue entry based on the command to be submitted and the target command by using a first preset data structure, and submitting the first submission queue entry to the preset submission queue, including:
[0013] When taking out a command to be submitted from the preset command queue and submitting it to the local preset submission queue, determining the target command type of the command to be submitted and the target position of the command to be submitted in the preset command queue, and judging whether there is a command to be determined with the same type of the target command at a position adjacent to the target position in the preset command queue;
[0014] If the to-be-determined command of the same type as the target command does not exist at a position adjacent to the target position in the preset command queue, determining that the target command does not exist in the preset command queue;
[0015] If the to-be-determined command of the same type as the target command exists at a position adjacent to the target position in the preset command queue, determining whether the to-be-determined command and the to-be-determined command meet a preset data size condition based on the data sizes of the to-be-determined command and the to-be-determined command; wherein the preset data size condition is that the data size of the submission queue entry generated based on the to-be-submitted command and the to-be-determined command using the first preset data structure is not greater than the preset data size;
[0016] If the command to be submitted and the command to be determined meet the preset data size condition, the command to be determined is determined as the target command, and then a first submission queue entry is generated based on the command to be submitted and the target command using the first preset data structure, and the first submission queue entry is submitted to the preset submission queue.
[0017] Optionally, the command execution method further includes:
[0018] When taking out a command to be submitted from the preset command queue and submitting it to the local preset submission queue, if there is no target command in the preset command queue that is adjacent to the command to be submitted and has the same command type, converting the command to be submitted into a corresponding second submission queue entry using a second preset data structure, and submitting the second submission queue entry to the preset submission queue; the data size of the second submission queue entry is not greater than the preset data size;
[0019] Among them, the second submission queue entry includes a reserved bit indicating a specific position that is not currently in use, the command to be submitted, and a buffer pointer of the buffer required by the command to be submitted; the first submission queue entry includes the command to be submitted and the target command, buffer pointers of the buffers required by the command to be submitted and the target command respectively, a multi-command identifier, and a command execution order; the command execution order is an order determined based on the positions of the command to be submitted and the target command in the preset command queue.
[0020] Optionally, the process in which the controller executes a corresponding command on the non-volatile memory using a submission queue entry taken from the preset submission queue includes:
[0021] After the controller takes out a submission queue entry from the preset submission queue, if the submission queue entry includes a multi-command identifier, the controller sequentially executes a plurality of pending commands in the submission queue entry on the non-volatile memory based on the command execution order in the submission queue entry, and writes a completion queue entry including the execution result of the pending command into the preset completion queue in the host; wherein different pending commands correspond to different completion queue entries;
[0022] After writing the completion queue entry into the preset completion queue, the controller sends an interrupt instruction to the host, so that the host processes the completion queue entry taken out from the preset completion queue based on the interrupt instruction and notifies the controller after the processing is completed.
[0023] Optionally, the executing, in sequence, the plurality of to-be-executed commands in the submission queue entry on the non-volatile memory based on the command execution order in the submission queue entry includes:
[0024] A current command to be executed is determined from a number of commands to be executed in the submission queue entry based on the command execution order in the submission queue entry, a corresponding target buffer is determined based on a buffer pointer of a buffer required for the current command to be executed in the submission queue entry, and the current command to be executed is executed on the non-volatile memory using data stored in the target buffer.
[0025] Optionally, sending an interrupt instruction to the host so that the host processes the completion queue entry taken out from the preset completion queue based on the interrupt instruction and notifies the controller after the processing is completed, includes:
[0026] sending an interrupt instruction to the host, so that the host processes the completion queue entry taken from the head of the preset completion queue based on the interrupt instruction, and notifies the controller by updating the head pointer of the preset completion queue stored in the second doorbell register after the processing is completed; the second doorbell register is located inside the controller;
[0027] When it is detected that the head pointer in the second doorbell register is updated, a second notification message indicating that the completion queue entry has been processed is sent to the non-volatile memory.
[0028] In a second aspect, the present invention provides a command execution device, applied to a host, comprising:
[0029] A command storage module, used for acquiring a plurality of commands for the non-volatile memory, and storing the plurality of commands in a local preset command queue;
[0030] an entry submission module, configured to, when taking out a to-be-submitted command from the preset command queue and submitting it to a local preset submission queue, generate a first submission queue entry by using a first preset data structure and based on the to-be-submitted command and the target command if there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type as the to-be-submitted command, and submit the first submission queue entry to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the to-be-submitted command and the target command;
[0031] The command execution module is used to notify the controller in the non-volatile memory after submitting the submission queue entry to the preset submission queue, so that the controller executes the corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
[0032] In a third aspect, the present invention provides an electronic device, comprising:
[0033] Memory for storing computer programs;
[0034] The processor is used to execute the computer program to implement the aforementioned command execution method.
[0035] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the aforementioned command execution method when executed by a processor.
[0036] In the present invention, the host obtains several commands for the non-volatile memory and stores the several commands in a local preset command queue; when taking out the to-be-submitted command from the preset command queue and submitting it to the local preset submission queue, if there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type, a first submission queue entry is generated based on the to-be-submitted command and the target command using a first preset data structure, and the first submission queue entry is submitted to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the to-be-submitted command and the target command; after submitting the submission queue entry to the preset submission queue, the controller in the non-volatile memory is notified so that the controller executes the corresponding command on the non-volatile memory using the submission queue entry taken out from the preset submission queue.
[0037] Beneficial effect: The present invention first stores several commands for the non-volatile memory in the preset command queue of the host, and then when submitting the to-be-submitted command in the preset command queue to the preset submission queue of the host, it is determined whether there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type. If so, a submission queue entry is generated based on the to-be-submitted command and the target command, and the submission queue entry containing the to-be-submitted command and the target command is submitted to the preset submission queue of the host, so that the controller in the non-volatile memory can use the submission queue entry taken from the preset submission queue to execute the corresponding command on the non-volatile memory. In this way, compared with submitting a submission queue entry for each command, the present invention generates and submits a submission queue entry for two commands that are adjacent in position and have the same command type in the preset command queue. Not only can the execution order of the commands be guaranteed by the adjacent positions, but the number of submissions of the submission queue entry can be reduced by generating and submitting a submission queue entry for two commands, thereby better improving the performance of the host and the real-time performance of command execution. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A flow chart of a command execution method provided by an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of a data structure provided by an embodiment of the present invention;
[0041] Figure 3 Another data structure diagram provided by an embodiment of the present invention;
[0042] Figure 4 A command execution flow chart provided for an embodiment of the present invention;
[0043] Figure 5 A schematic diagram of the structure of a command execution device provided by an embodiment of the present invention;
[0044] Figure 6 A structural diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] Since each I / O command needs to submit an SQE to the submission queue, in a scenario with many I / O commands, the SQEs need to be submitted sequentially, which may have a negative impact on the performance of the host and the real-time execution of the I / O commands. To this end, the present invention provides a command execution method, which can generate and submit a submission queue entry for two commands with adjacent positions and the same command type in a preset command queue, thereby improving the performance of the host and the real-time execution of commands by reducing the number of submissions of the submission queue entries.
[0047] See also Figure 1 As shown, an embodiment of the present invention provides a command execution method, which is applied to a host and includes:
[0048] Step S11: Acquire several commands for the non-volatile memory, and store the several commands in a local preset command queue.
[0049] In an embodiment of the present invention, a host receives several commands for a non-volatile memory (NVM) issued by a user through an application; wherein the several commands include but are not limited to a data read command, a data write command, a data query command, a data check command, a data delete command, etc., and the commands can also be expanded according to specific user needs.
[0050] Furthermore, after obtaining several commands for the non-volatile memory, the host first stores the several commands for the non-volatile memory in a preset command queue of the host; wherein the preset command queue can be located in the preset memory of the host, and the preset memory can use DDR (Double Data Rate) memory.
[0051] Step S12: When taking out the command to be submitted from the preset command queue and submitting it to the local preset submission queue, if there is a target command in the preset command queue that is adjacent to the position of the command to be submitted and has the same command type as the command to be submitted, a first submission queue entry is generated based on the command to be submitted and the target command using a first preset data structure, and the first submission queue entry is submitted to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the command to be submitted and the target command.
[0052] In an embodiment of the present invention, when the host takes out a command to be submitted from a preset command queue and submits the command to be submitted to the preset submission queue of the host, it is determined whether there is a target command in the preset command queue that is adjacent to the position of the command to be submitted and has the same command type; if there is a target command in the preset command queue that is adjacent to the position of the command to be submitted and has the same command type, a first submission queue entry is generated based on the command to be submitted and the target command using a first preset data structure, and then the first submission queue entry containing the command to be submitted and the target command is submitted to the preset submission queue of the host. It should be noted that, considering that the data size of a submission queue entry is fixed, the data size of the first submission queue entry generated based on the command to be submitted and the target command needs to be less than or equal to the preset data size, and the preset data size is the data size of a submission queue entry, which can generally be set to 64 bytes.
[0053] Specifically, when the host takes out the command to be submitted from the preset command queue and submits it to the local preset submission queue, it determines the target command type of the command to be submitted and the target position of the command to be submitted in the preset command queue, and determines whether there is a command to be determined with the same type of target command at a position adjacent to the target position in the preset command queue. If there is no command to be determined with the same type of target command at a position adjacent to the target position in the preset command queue, it is determined that there is no target command in the preset command queue. If there is a command to be determined with the same type of target command at a position adjacent to the target position in the preset command queue, it is determined that the command to be submitted and the command to be determined meet the preset data size condition based on the data size of the command to be submitted and the command to be determined; wherein the preset data size condition is that the data size of the submission queue entry generated based on the command to be submitted and the command to be determined using the first preset data structure is not greater than the preset data size. If the command to be submitted and the command to be determined meet the preset data size condition, the command to be determined is determined as the target command, that is, there is a target command in the preset command queue, and then a first submission queue entry is generated based on the command to be submitted and the target command using the first preset data structure, and the first submission queue entry is submitted to the preset submission queue. If the command to be submitted and the command to be determined do not meet the preset data size condition, it is determined that the target command does not exist in the preset command queue. In this way, the present invention can reduce the number of submissions of the submission queue entry by generating and submitting a submission queue entry to the submission queue based on two commands, thereby reducing the time for command execution and the capacity of memory usage accordingly, thereby improving the performance of the host and the real-time performance of command execution.
[0054] Among them, based on the data size of the command to be submitted and the command to be determined, it is determined whether the command to be submitted and the command to be determined meet the preset data size condition. Specifically, by judging whether the data size of the submission queue entry generated based on the command to be submitted and the command to be determined using the first preset data structure is greater than the preset data size, so as to determine whether the command to be submitted and the command to be determined meet the preset data size condition; if the data size of the submission queue entry generated based on the command to be submitted and the command to be determined using the first preset data structure is not greater than the preset data size, it is determined that the command to be submitted and the command to be determined meet the preset data size condition; if the data size of the submission queue entry generated based on the command to be submitted and the command to be determined using the first preset data structure is greater than the preset data size, it is determined that the command to be submitted and the command to be determined do not meet the preset data size condition.
[0055] Furthermore, when the host takes out the command to be submitted from the preset command queue and submits it to the local preset submission queue, if there is no target command in the preset command queue that is adjacent to the position of the command to be submitted and has the same command type, the command to be submitted is converted into a corresponding second submission queue entry using a second preset data structure, and the second submission queue entry is submitted to the preset submission queue of the host; wherein the data size of the second submission queue entry should not be greater than the preset data size, and the preset submission queue is located in the preset memory of the host.
[0056] Among them, the second submission queue entry includes a reserved bit indicating a specific position that is not currently used, a command to be submitted, and a buffer pointer of a buffer required by the command to be submitted. The first submission queue entry includes a command to be submitted and a target command, a buffer pointer of a buffer required by each of the command to be submitted and the target command, a multi-command identifier, and a command execution order; it should be noted that the command execution order is an order determined based on the positions of the command to be submitted and the target command in the preset command queue, and the position of the command in the preset command queue is in direct proportion to the command execution order, that is, the earlier the position of the command in the preset command queue, the earlier the command execution order is, and the command execution order can be represented by the command execution order number.
[0057] Taking the data size of the submission queue entry as 16 command words (CMD), each command word includes 4 bytes (Byte0, Byte1, Byte2, Byte3), and each byte includes 8 bits as an example, the data structure of the first submission queue entry, that is, the first preset data structure is as follows: Figure 2As shown, the first submission queue entry includes the command to be submitted and the target command, the buffer pointers of the buffers required for the command to be submitted and the target command, the multi-command identifier, the command execution sequence number, the entry identifier, the storage method identifier (PSDT, PRP or SGL for Data Transfer), the command operation code (Opcode, OPC), and the namespace identifier (Namespace Identifier, NSID). Among them, the buffer pointer includes a metadata buffer pointer and a data buffer pointer. The data buffer pointer is used to determine the data buffer storing command-related data, and the metadata buffer pointer is used to determine the metadata buffer storing additional data information; the multi-command identifier is used to characterize that the submission queue entry includes multiple commands; the entry identifier is used to identify the submission queue entry; the storage method identifier is used to identify whether the storage method used for the data carried by the submission queue entry is PRP (Physical Region Page) or SGL (Scatter / Gather List); the command operation code is used to indicate the type of operation required to be performed for the command in the submission queue entry; and the namespace identifier is used to indicate to which command space the command in the submission queue entry needs to be sent. The data structure of the second submission queue entry, that is, the second preset data structure is as shown in FIG. Figure 3 As shown, the second submission queue entry includes a reserved bit indicating a specific position that is not currently in use, a command to be submitted, a buffer pointer of a buffer required by the command to be submitted, an entry identifier, a storage mode identifier, a command operation code, and a namespace identifier.
[0058] Step S13: After submitting the submission queue entry to the preset submission queue, notify the controller in the non-volatile memory so that the controller executes a corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
[0059] In the embodiment of the present invention, after submitting the submission queue entry to the local preset submission queue, the host notifies the controller in the non-volatile memory so that the controller takes the submission queue entry from the preset submission queue and uses the submission queue entry to execute the corresponding command on the non-volatile memory.
[0060] Specifically, after the host submits the submission queue entry to the tail of the local preset submission queue, the host notifies the controller in the non-volatile memory by updating the tail pointer of the preset submission queue stored in the first doorbell register, so that when the controller detects that the tail pointer in the first doorbell register is updated, it sends a first notification message used to characterize the existence of a newly submitted submission queue entry in the preset submission queue to the non-volatile memory, and uses the newly submitted submission queue entry taken out of the preset submission queue to execute corresponding commands on the non-volatile memory; it should be noted that the first doorbell register is located inside the controller.
[0061] In an embodiment of the present invention, the controller uses the submission queue entry taken from the preset submission queue to execute the corresponding command on the non-volatile memory, which may specifically include: after the controller takes out the submission queue entry from the preset submission queue, the controller parses the submission queue entry to determine whether the submission queue entry includes a multi-command identifier, and if the submission queue entry includes a multi-command identifier, the controller sequentially executes the plurality of pending commands included in the submission queue entry on the non-volatile memory based on the command execution order included in the submission queue entry, and generates a corresponding completion queue entry containing the execution result of the pending command after each pending command is executed, and writes the completion queue entry into the preset completion queue of the host; it should be noted that different pending commands correspond to different completion queue entries. Further, after the controller writes the completion queue entry into the preset completion queue of the host, the controller sends an interrupt instruction to the host, so that the host takes out the completion queue entry from the preset completion queue based on the interrupt instruction, processes the completion queue entry, and notifies the controller after the processing is completed. It should be noted that if the submission queue entry includes a command execution sequence number, the command execution sequence can be determined based on the command execution sequence number.
[0062] Among them, for executing several pending commands contained in the submission queue entries on the non-volatile memory in sequence based on the command execution order, the current pending command can be determined in sequence from the several pending commands contained in the submission queue entries based on the command execution order, and the buffer pointer of the buffer required for the current pending command can be determined from the submission queue entry, and then the corresponding target buffer is determined based on the buffer pointer, so as to execute the current pending command on the non-volatile memory using the data related to the current pending command stored in the target buffer.
[0063] Correspondingly, if the submission queue entry does not include a multi-command identifier, it indicates that the submission queue entry contains only one command to be executed. At this time, the corresponding target buffer can be determined directly based on the buffer pointer of the buffer required for the command to be executed contained in the submission queue entry, and then the data related to the command to be executed stored in the target buffer can be used to execute the command to be executed on the non-volatile memory.
[0064] Furthermore, after the controller sends an interrupt instruction to the host, the host can process the completion queue entry taken from the head of the preset completion queue based on the interrupt instruction, and after the processing is completed, the host notifies the controller by updating the head pointer of the preset completion queue stored in the second doorbell register; wherein the second doorbell register is located inside the controller. When the controller detects that the head pointer in the second doorbell register is updated, it can send a second notification message used to indicate that the completion queue entry has been processed to the non-volatile memory.
[0065] It should be noted that, when the controller is executing a corresponding command on the non-volatile memory using a submission queue entry taken from a preset submission queue, if the command execution fails, an execution result characterizing the failure of the command execution can be generated based on the error code, and a completion queue entry containing the execution result can be written into the preset completion queue of the host. The entire process of command execution is then terminated, and the controller is rolled back to the state before the command was executed, thereby protecting the controller. Furthermore, since the completion queue entry includes an error code, the host can determine the cause of the command execution failure based on the error code by processing the completion queue entry, and then provide a targeted solution.
[0066] Among them, if the submission queue entry includes multiple command identifiers, it represents that the submission queue entry includes multiple commands. Accordingly, when the controller executes the multiple commands included in the submission queue entry on the non-volatile memory in sequence based on the command execution order included in the submission queue entry, no matter which command among the multiple commands fails to execute, the entire process of command execution needs to be terminated and the controller itself needs to be rolled back to the state before the command is executed.
[0067] Beneficial effect: The present invention first stores several commands for the non-volatile memory in the preset command queue of the host, and then when submitting the to-be-submitted command in the preset command queue to the preset submission queue of the host, it is determined whether there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type. If so, a submission queue entry is generated based on the to-be-submitted command and the target command, and the submission queue entry containing the to-be-submitted command and the target command is submitted to the preset submission queue of the host, so that the controller in the non-volatile memory can use the submission queue entry taken from the preset submission queue to execute the corresponding command on the non-volatile memory. In this way, compared with submitting a submission queue entry for each command, the present invention generates and submits a submission queue entry for two commands that are adjacent in position and have the same command type in the preset command queue. Not only can the execution order of the commands be guaranteed by the adjacent positions, but the number of submissions of the submission queue entry can be reduced by generating and submitting a submission queue entry for two commands, thereby better improving the performance of the host and the real-time performance of command execution.
[0068] See also Figure 4 As shown, an embodiment of the present invention provides a command execution method, including:
[0069] The host obtains several commands for the non-volatile memory and stores the several commands in a local preset command queue. When the host takes out the command to be submitted from the preset command queue and submits it to the local preset submission queue, if there is a target command in the preset command queue that is adjacent to the position of the command to be submitted and has the same command type as the command to be submitted, a submission queue entry is generated based on the command to be submitted and the target command, and the submission queue entry including the command to be submitted and the target command is submitted to the preset submission queue, and then the controller in the non-volatile memory is notified. It should be noted that the data size of the submission queue entry is not greater than the preset data size.
[0070] Afterwards, the controller sends a first notification message for indicating that there is a newly submitted submission queue entry in the preset submission queue to the non-volatile memory, and takes out the newly submitted submission queue entry from the preset submission queue, and then determines whether the submission queue entry includes a multi-command identifier. If the submission queue entry includes a multi-command identifier, the to-be-submitted command and the target command included in the submission queue entry are sequentially executed on the non-volatile memory based on the command execution order included in the submission queue entry. Since the command execution order is an order determined based on the positions of the to-be-submitted command and the target command in the preset command queue, the command execution order is to execute the to-be-submitted command first and then the target command.
[0071] Specifically, in the process of the controller sequentially executing the to-be-submitted commands and target commands included in the submission queue entries on the non-volatile memory based on the command execution order included in the submission queue entries, the controller first determines the current to-be-submitted command from the to-be-submitted commands and target commands included in the submission queue entries based on the command execution order, and then determines the buffer pointer of the buffer required for the current to-be-executed command from the submission queue entries, and then determines the corresponding target buffer based on the buffer pointer, and finally the current to-be-executed command can be executed on the non-volatile memory using the data related to the current to-be-executed command stored in the target buffer.
[0072] Furthermore, after each command (command to be submitted or target command) is executed, the controller generates a corresponding completion queue entry containing the command execution result, writes the completion queue entry into the preset completion queue of the host, and then sends an interrupt instruction to the host to notify the host that there is a newly written completion queue entry in the preset completion queue. After receiving the interrupt instruction, the host can take out the completion queue entry from the preset completion queue based on the interrupt instruction, process the completion queue entry, and notify the controller in the non-volatile memory after the processing is completed.
[0073] Beneficial effect: The present invention first stores several commands for the non-volatile memory in the preset command queue of the host, and then when submitting the to-be-submitted command in the preset command queue to the preset submission queue of the host, it is determined whether there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type. If so, a submission queue entry is generated based on the to-be-submitted command and the target command, and the submission queue entry containing the to-be-submitted command and the target command is submitted to the preset submission queue of the host, so that the controller in the non-volatile memory can use the submission queue entry taken from the preset submission queue to execute the corresponding command on the non-volatile memory. In this way, compared with submitting a submission queue entry for each command, the present invention generates and submits a submission queue entry for two commands that are adjacent in position and have the same command type in the preset command queue. Not only can the execution order of the commands be guaranteed by the adjacent positions, but the number of submissions of the submission queue entry can be reduced by generating and submitting a submission queue entry for two commands, thereby better improving the performance of the host and the real-time performance of command execution.
[0074] See also Figure 5 As shown, an embodiment of the present invention provides a command execution device, which is applied to a host and includes:
[0075] A command storage module 11, used for acquiring a number of commands for the non-volatile memory, and storing the commands in a local preset command queue;
[0076] An entry submission module 12 is used for, when taking out a to-be-submitted command from the preset command queue and submitting it to a local preset submission queue, if there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type as the to-be-submitted command, generating a first submission queue entry based on the to-be-submitted command and the target command by using a first preset data structure, and submitting the first submission queue entry to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the to-be-submitted command and the target command;
[0077] The command execution module 13 is used to notify the controller in the non-volatile memory after submitting the submission queue entry to the preset submission queue, so that the controller executes the corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
[0078] Since the embodiments of the device part correspond to the above embodiments, please refer to the description of the embodiments of the method part for the embodiments of the device part, and will not be repeated here.
[0079] Beneficial effect: The present invention first stores several commands for the non-volatile memory in the preset command queue of the host, and then when submitting the to-be-submitted command in the preset command queue to the preset submission queue of the host, it is determined whether there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type. If so, a submission queue entry is generated based on the to-be-submitted command and the target command, and the submission queue entry containing the to-be-submitted command and the target command is submitted to the preset submission queue of the host, so that the controller in the non-volatile memory can use the submission queue entry taken from the preset submission queue to execute the corresponding command on the non-volatile memory. In this way, compared with submitting a submission queue entry for each command, the present invention generates and submits a submission queue entry for two commands that are adjacent in position and have the same command type in the preset command queue. Not only can the execution order of the commands be guaranteed by the adjacent positions, but the number of submissions of the submission queue entry can be reduced by generating and submitting a submission queue entry for two commands, thereby better improving the performance of the host and the real-time performance of command execution.
[0080] Furthermore, the present application also discloses an electronic device. Figure 6It is a structural diagram of an electronic device according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input and output interface 25 and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the command execution method disclosed in any of the aforementioned embodiments. In addition, the electronic device in this embodiment may specifically be an electronic computer.
[0081] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0082] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0083] The operating system 221 is used to manage and control various hardware devices on the electronic device and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the command execution method executed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0084] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the command execution method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the above embodiments, and no further description will be given here.
[0085] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0086] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0087] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0088] Finally, it should be noted that, in this article, 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 "include", "comprise" 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, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0089] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A command execution method, characterized in that: Applied to the host, including: Acquire a number of commands for the non-volatile memory, and store the commands in a local preset command queue; When taking out a command to be submitted from the preset command queue and submitting it to a local preset submission queue, if there is a target command in the preset command queue that is adjacent to the command to be submitted and has the same command type as the command to be submitted, a first submission queue entry is generated based on the command to be submitted and the target command using a first preset data structure, and the first submission queue entry is submitted to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the command to be submitted and the target command; After submitting the submission queue entry to the preset submission queue, the controller in the non-volatile memory is notified so that the controller executes a corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
2. The command execution method according to claim 1, characterized in that: After submitting the submission queue entry to the preset submission queue, notifying a controller in the non-volatile memory so that the controller executes a corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue, comprises: After submitting the submission queue entry to the tail of the preset submission queue, the tail pointer of the preset submission queue stored in the first doorbell register is updated to notify the controller in the non-volatile memory, so that when the controller detects that the tail pointer in the first doorbell register is updated, the controller sends a first notification message indicating that there is a newly submitted submission queue entry in the preset submission queue to the non-volatile memory, and executes a corresponding command on the non-volatile memory using the newly submitted submission queue entry taken from the preset submission queue; Wherein, the first doorbell register is located inside the controller.
3. The command execution method according to claim 1, characterized in that: When taking out the to-be-submitted command from the preset command queue and submitting it to the local preset submission queue, if there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type as the to-be-submitted command, generating a first submission queue entry based on the to-be-submitted command and the target command by using a first preset data structure, and submitting the first submission queue entry to the preset submission queue, including: When taking out a command to be submitted from the preset command queue and submitting it to the local preset submission queue, determining the target command type of the command to be submitted and the target position of the command to be submitted in the preset command queue, and judging whether there is a command to be determined with the same type of the target command at a position adjacent to the target position in the preset command queue; If the to-be-determined command of the same type as the target command does not exist at a position adjacent to the target position in the preset command queue, determining that the target command does not exist in the preset command queue; If the to-be-determined command of the same type as the target command exists at a position adjacent to the target position in the preset command queue, determining whether the to-be-determined command and the to-be-determined command meet a preset data size condition based on the data sizes of the to-be-determined command and the to-be-determined command; wherein the preset data size condition is that the data size of the submission queue entry generated based on the to-be-submitted command and the to-be-determined command using the first preset data structure is not greater than the preset data size; If the command to be submitted and the command to be determined meet the preset data size condition, the command to be determined is determined as the target command, and then a first submission queue entry is generated based on the command to be submitted and the target command using the first preset data structure, and the first submission queue entry is submitted to the preset submission queue.
4. The command execution method according to any one of claims 1 to 3, characterized in that: Also includes: When taking out a command to be submitted from the preset command queue and submitting it to the local preset submission queue, if there is no target command in the preset command queue that is adjacent to the command to be submitted and has the same command type as the command to be submitted, converting the command to be submitted into a corresponding second submission queue entry by using a second preset data structure, and submitting the second submission queue entry to the preset submission queue; The data size of the second submission queue entry is not greater than the preset data size; The second submission queue entry includes a reserved bit indicating a specific position that is not currently in use, the command to be submitted, and a buffer pointer of a buffer required by the command to be submitted; The first submission queue entry includes the command to be submitted and the target command, buffer pointers of the buffers required by the command to be submitted and the target command respectively, a multi-command identifier, and a command execution order; the command execution order is an order determined based on the positions of the command to be submitted and the target command in the preset command queue.
5. The command execution method according to claim 4, characterized in that: The process of the controller executing a corresponding command on the non-volatile memory using a submission queue entry taken from the preset submission queue includes: After the controller takes out a submission queue entry from the preset submission queue, if the submission queue entry includes a multi-command identifier, the controller sequentially executes a plurality of pending commands in the submission queue entry on the non-volatile memory based on the command execution order in the submission queue entry, and writes a completion queue entry including the execution result of the pending command into the preset completion queue in the host; wherein different pending commands correspond to different completion queue entries; After writing the completion queue entry into the preset completion queue, the controller sends an interrupt instruction to the host, so that the host processes the completion queue entry taken out from the preset completion queue based on the interrupt instruction and notifies the controller after the processing is completed.
6. The command execution method according to claim 5, characterized in that: The step of sequentially executing the plurality of to-be-executed commands in the submission queue entry on the non-volatile memory based on the command execution order in the submission queue entry includes: A current command to be executed is determined from a number of commands to be executed in the submission queue entry based on the command execution order in the submission queue entry, a corresponding target buffer is determined based on a buffer pointer of a buffer required for the current command to be executed in the submission queue entry, and the current command to be executed is executed on the non-volatile memory using data stored in the target buffer.
7. The command execution method according to claim 5, characterized in that: The sending of the interrupt instruction to the host so that the host processes the completion queue entry taken out from the preset completion queue based on the interrupt instruction and notifies the controller after the processing is completed, includes: sending an interrupt instruction to the host, so that the host processes the completion queue entry taken from the head of the preset completion queue based on the interrupt instruction, and notifies the controller by updating the head pointer of the preset completion queue stored in the second doorbell register after the processing is completed; the second doorbell register is located inside the controller; When it is detected that the head pointer in the second doorbell register is updated, a second notification message indicating that the completion queue entry has been processed is sent to the non-volatile memory.
8. A command execution device, characterized in that: Applied to the host, including: A command storage module, used for acquiring a plurality of commands for the non-volatile memory, and storing the plurality of commands in a local preset command queue; an entry submission module, configured to, when taking out a to-be-submitted command from the preset command queue and submitting it to a local preset submission queue, generate a first submission queue entry by using a first preset data structure and based on the to-be-submitted command and the target command if there is a target command in the preset command queue that is adjacent to the to-be-submitted command and has the same command type as the to-be-submitted command, and submit the first submission queue entry to the preset submission queue; wherein the data size of the first submission queue entry is not greater than the preset data size, and the first submission queue entry includes the to-be-submitted command and the target command; The command execution module is used to notify the controller in the non-volatile memory after submitting the submission queue entry to the preset submission queue, so that the controller executes the corresponding command on the non-volatile memory using the submission queue entry taken from the preset submission queue.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the command execution method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the command execution method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Front-end command processing method and device for improving SSD performance, computer equipment and storage medium
CN111221476A
NVME command processing device and method, equipment and medium
CN117687692A
Information processing method and related device
CN118069052A
Host command processing method and device, electronic equipment and storage medium
CN118132009A
Data storage device and method for logical range locking
CN118897647A