A command execution method, apparatus, device, and medium
By generating and submitting two adjacent and identical command submission queue entries in a preset command queue, the performance and real-time issues when dealing with a large number of I/O commands are resolved, resulting in more efficient command execution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2026-03-17
AI Technical Summary
In scenarios with a large number of I/O commands, existing technologies require submitting each entry in the submission queue sequentially, which negatively impacts host performance and the real-time execution of I/O commands.
By generating and submitting a submission queue entry containing two adjacent commands of the same type from a preset command queue, the number of submissions is reduced, command execution order is ensured, and performance and real-time performance are improved.
By reducing the number of submissions to the submission queue, host performance and real-time command execution are improved.
Smart Images

Figure CN119987682B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of command processing, and in particular to a command execution method, apparatus, device, and medium. Background Technology
[0002] With the rapid development of solid state drives (SSDs), the NVMe (Non-Volatile Memory Express) protocol, through its advantages in PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard), multi-queue mechanism, and parallelism, can significantly improve key indicators such as throughput, latency, and IOPS (Input / Output Operations Per Second), thereby better enabling data interaction between the host and the solid state drive.
[0003] NVMe manages the submission and completion of I / O (Input / Output) commands through Submission Queues (SQ) and Completion Queues (CQ) located on the host. The Submission Queue stores SQEs (Submission Queue Entry), each containing a complete I / O command. The Completion Queue stores CQEs (Completion Queue Entry) containing the execution status of I / O commands. However, since each I / O command requires submitting an SQE to the Submission Queue, in scenarios with a large number of I / O commands, the sequential submission of SQEs can negatively impact host performance and the real-time performance of I / O command execution. Summary of the Invention
[0004] The purpose of this invention is to provide a command execution method, apparatus, device, and medium that can generate and submit a submission queue entry for two adjacent commands of the same type in a preset command queue. By reducing the number of submission queue entries, the performance of the host and the real-time performance of command execution are improved. The specific solution is as follows:
[0005] In a first aspect, the present invention provides a command execution method applied to a host, comprising:
[0006] Obtain several commands for non-volatile memory and store the commands in a local preset command queue;
[0007] When retrieving 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, then a first submission queue entry is generated using a first preset data structure based on the command to be submitted and the target command, 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 a preset data size, and the first submission queue entry includes the command to be submitted and the target command;
[0008] After submitting a submission queue entry to the preset submission queue, the controller in the non-volatile memory is notified so that the controller can execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue.
[0009] Optionally, after submitting the submission queue entry to the preset submission queue, notifying the controller in the non-volatile memory so that the controller can execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue includes:
[0010] After submitting a submission queue entry to the tail of the preset submission queue, the controller in the non-volatile memory is notified by updating the tail pointer of the preset submission queue stored in the first doorbell register. When the controller detects that the tail pointer in the first doorbell register has been updated, it sends a first notification message to the non-volatile memory to indicate that there is a newly submitted submission queue entry in the preset submission queue, and executes a corresponding command on the non-volatile memory using the newly submitted submission queue entry taken from the preset submission queue.
[0011] The first doorbell register is located inside the controller.
[0012] Optionally, when retrieving 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, then a first submission queue entry is generated using a first preset data structure based on the command to be submitted and the target command, and the first submission queue entry is submitted to the preset submission queue, including:
[0013] When retrieving a command to be submitted from the preset command queue and submitting it to the local preset submission queue, 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 are determined, and it is determined whether there is a command to be determined with the same type as the target command in the preset command queue at a position adjacent to the target position;
[0014] If there is no command of the same type as the target command in the preset command queue adjacent to the target location, then it is determined that the target command does not exist in the preset command queue.
[0015] If there is a command to be determined of the same type as the target command in the preset command queue adjacent to the target location, then 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; wherein, the preset data size condition is that the data size of the submission queue entry generated using the first preset data structure and based on the command to be submitted and the command to be determined is not greater than the preset data size;
[0016] If the command to be submitted and the command to be determined satisfy the preset data size condition, then the command to be determined is determined as the target command. Then, the first preset data structure is used to generate a first submission queue entry based on the command to be submitted and the target command, and the first submission queue entry is submitted to the preset submission queue.
[0017] Optionally, the command execution method further includes:
[0018] When retrieving 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 of the same type and adjacent to the command to be submitted in the preset command queue, 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; the data size of the second submission queue entry is not greater than the preset data size;
[0019] The second submission queue entry includes a reserved bit indicating a specific unused position, the command to be submitted, and a buffer pointer to 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 to 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 determined based on the positions of the command to be submitted and the target command in the preset command queue.
[0020] Optionally, the process by which the controller executes a corresponding command on the non-volatile memory using a submission queue entry retrieved from the preset submission queue includes:
[0021] After retrieving a submission queue entry from the preset submission queue, if the submission queue entry includes multiple command identifiers, the controller sequentially executes several commands to be executed in the non-volatile memory based on the command execution order in the submission queue entry, and writes a completion queue entry containing the execution results of the commands to be executed into the preset completion queue in the host; wherein, different commands to be executed correspond to different completion queue entries.
[0022] After writing the completion queue entry into the preset completion queue, the controller sends an interrupt command to the host, so that the host processes the completion queue entry retrieved from the preset completion queue based on the interrupt command, and notifies the controller after processing is completed.
[0023] Optionally, the step of sequentially executing a plurality of commands to be executed in the submission queue based on the command execution order in the submission queue entries on the non-volatile memory includes:
[0024] Based on the command execution order in the submission queue entries, the current command to be executed is determined from a number of commands to be executed in the submission queue entries. Based on the buffer pointer of the buffer required by the current command to be executed in the submission queue entries, the corresponding target buffer is determined. The data stored in the target buffer is used to execute the current command to be executed on the non-volatile memory.
[0025] Optionally, sending an interrupt command to the host, so that the host processes the completion queue entries retrieved from the preset completion queue based on the interrupt command, and notifies the controller after processing, includes:
[0026] An interrupt command is sent 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 command, and notifies the controller by updating the head pointer of the preset completion queue stored in the second doorbell register after processing is completed; the second doorbell register is located inside the controller.
[0027] When an update is detected in the head pointer of the second doorbell register, a second notification message indicating that the 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 computer, comprising:
[0029] The command storage module is used to retrieve a number of commands for non-volatile memory and store the commands in a local preset command queue.
[0030] An entry submission module is used to, when retrieving 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, generate a first submission queue entry using a first preset data structure based on the command to be submitted and the target 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 a preset data size, and the first submission queue entry includes the command to be submitted and the target command;
[0031] The command execution module is used to notify the controller in the non-volatile memory after submitting a submission queue entry to the preset submission queue, so that the controller can execute a corresponding command on the non-volatile memory using the submission queue entry retrieved from the preset submission queue.
[0032] Thirdly, the present invention provides an electronic device, comprising:
[0033] Memory, used to store computer programs;
[0034] A processor for executing the computer program to implement the aforementioned command execution method.
[0035] Fourthly, the present invention provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the aforementioned command execution method.
[0036] In this invention, the host acquires several commands for the non-volatile memory and stores them in a local preset command queue. When retrieving a command to be submitted from the preset command queue and submitting it to a local preset submission queue, if a target command of the same type and adjacent to the command to be submitted exists in the preset command queue, a first submission queue entry is generated using a first preset data structure based on the command to be submitted and the target command, and the first submission queue entry is submitted to the preset submission queue. The data size of the first submission queue entry is no greater than a 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 host notifies the controller in the non-volatile memory so that the controller can execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue.
[0037] Beneficial Effects: This invention first stores several commands for non-volatile memory in a preset command queue of the host. Then, when submitting commands to be submitted from the preset command queue to the host's preset submission queue, it determines whether 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. If so, a submission queue entry is generated based on the command to be submitted and the target command, and this submission queue entry containing the command to be submitted and the target command is submitted to the host's preset submission queue. This allows the controller in the non-volatile memory to execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue. In this way, compared to submitting a submission queue entry for each command, this invention generates and submits a single submission queue entry for two adjacent commands of the same command type in the preset command queue. This not only ensures the execution order of commands through adjacency but also reduces the number of submission queue entries, thereby improving host performance and the real-time performance of command execution. Attached Figure Description
[0038] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 A flowchart of a command execution method provided in an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of a data structure provided in an embodiment of the present invention;
[0041] Figure 3 This is a schematic diagram of another data structure provided in an embodiment of the present invention;
[0042] Figure 4 A command execution flowchart is provided for an embodiment of the present invention;
[0043] Figure 5 This is a schematic diagram of a command execution device structure provided in an embodiment of the present invention;
[0044] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.
[0046] Since each I / O command requires submitting a SQE to the commit queue, in scenarios with a large number of I / O commands, the SQEs need to be submitted sequentially, which may negatively impact host performance and the real-time performance of I / O command execution. Therefore, this invention provides a command execution method that can generate and submit a commit queue entry for two adjacent commands of the same type in a preset command queue. By reducing the number of commit queue entries, host performance and the real-time performance of command execution are improved.
[0047] See Figure 1 As shown, this embodiment of the invention provides a command execution method applied to a host, including:
[0048] Step S11: Obtain several commands for the non-volatile memory and store the commands in a local preset command queue.
[0049] In this embodiment of the invention, the host receives several commands issued by the user through an application for the non-volatile memory (NVM); wherein, the several commands include, but are not limited to, data read commands, data write commands, data query commands, data verification commands, data deletion commands, etc., and the commands can be further extended according to the user's needs.
[0050] Furthermore, after the host obtains several commands for the non-volatile memory, it first stores the commands for the non-volatile memory in the host's preset command queue; wherein, the preset command queue may be located in the host's preset memory, and the preset memory may be DDR (Double Data Rate) memory.
[0051] Step S12: When retrieving a 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, then a first submission queue entry is generated using a first preset data structure based on the command to be submitted and the target command, 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 this embodiment of the invention, when the host retrieves a command to be submitted from a preset command queue and submits the command to be submitted to the host's preset submission queue, it determines whether 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. 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, a first submission queue entry is generated using a first preset data structure based on the command to be submitted and the target command. Then, the first submission queue entry containing the command to be submitted and the target command is submitted to the host's preset submission queue. 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 a preset data size, which is the data size of a submission queue entry, and can generally be set to 64 bytes.
[0053] Specifically, when the host retrieves a command to be submitted from the preset command queue and submits it to the local preset submission queue, it determines the target command type and the target position of the command to be submitted in the preset command queue, and checks whether there is a command of the same type to be determined in the preset command queue adjacent to the target position. If there is no command of the same type to be determined in the preset command queue adjacent to the target position, it is determined that there is no target command in the preset command queue. If there is a command of the same type to be determined in the preset command queue adjacent to the target position, it is determined whether the command to be submitted and the command to be determined meet the preset data size condition based on their data sizes; the preset data size condition is that the data size of the submission queue entry generated using the first preset data structure based on the command to be submitted and the command to be determined 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. Then, the first submission queue entry is generated using the first preset data structure based on the command to be submitted and the target command, 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, by generating and submitting a submission queue entry based on two commands to the submission queue, the present invention can reduce the number of submission queue entries, thereby reducing the command execution time and memory usage, and improving the performance of the host and the real-time performance of command execution.
[0054] Specifically, determining whether a command to be submitted and a command to be determined meet a preset data size condition based on their data sizes involves judging whether the data size of the submission queue entry generated using the first preset data structure and based on the command to be submitted and the command to be determined is greater than a preset data size. If the data size of the submission queue entry generated using the first preset data structure and based on the command to be submitted and the command to be determined is not greater than the preset data size, then 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 using the first preset data structure and based on the command to be submitted and the command to be determined is greater than the preset data size, then the command to be submitted and the command to be determined do not meet the preset data size condition.
[0055] Furthermore, when the host retrieves a 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 command to be submitted and has the same command type, the host uses the second preset data structure to convert the command to be submitted into a corresponding second submission queue entry and submits the second submission queue entry to the host's preset submission queue; 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 host's preset memory.
[0056] The second submission queue entry includes a reserved bit indicating a specific unused position, the command to be submitted, and a buffer pointer to 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 to the buffers required by the command to be submitted and the target command respectively, a multi-command identifier, and the command execution order. It should be noted that the command execution order is determined based on the position of the command to be submitted and the target command in the preset command queue. The position of a command in the preset command queue is directly proportional to its execution order; that is, the earlier a command is in the preset command queue, the earlier it will be executed. Furthermore, the command execution order can be represented by a command execution order number.
[0057] Taking a submission queue entry with a data size of 16 command words (CMD), each command word consisting of 4 bytes (Byte0, Byte1, Byte2, Byte3), and each byte consisting of 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, buffer pointers to the buffers required by each command, a multi-command identifier, a command execution order number, an entry identifier, a storage method identifier (PSDT, PRP, or SGL for Data Transfer), a command opcode (OPC), and a namespace identifier (NSID). The buffer pointers include a metadata buffer pointer and a data buffer pointer. The data buffer pointer identifies the data buffer storing command-related data, while the metadata buffer pointer identifies the metadata buffer storing additional data information. The multi-command identifier indicates that the submission queue entry includes multiple commands. The entry identifier identifies the submission queue entry. The storage method identifier identifies whether the data carried by the submission queue entry uses PRP (Physical Region Page) or SGL (Scatter / Gather List). The command opcode indicates the type of operation to be performed by the command in the submission queue entry. The namespace identifier indicates which command space the command in the submission queue entry needs to be sent to. The data structure of the second submission queue entry, i.e., the second preset data structure, is as follows... Figure 3 As shown, the second submission queue entry includes a reserved bit indicating a specific location that is not currently in use, the command to be submitted, a buffer pointer to the buffer required by the command to be submitted, an entry identifier, a storage method identifier, a command opcode, 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 can execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue.
[0059] In this embodiment of the invention, after the host submits a submission queue entry to a local preset submission queue, it notifies the controller in the non-volatile memory so that the controller can retrieve the submission queue entry from the preset submission queue and use the submission queue entry to execute corresponding commands on the non-volatile memory.
[0060] Specifically, after the host submits a submission queue entry to the tail of the local preset submission queue, it updates the tail pointer of the preset submission queue stored in the first doorbell register to notify the controller in the non-volatile memory. When the controller detects that the tail pointer in the first doorbell register has been updated, it sends a first notification message to the non-volatile memory to indicate that there is a newly submitted submission queue entry in the preset submission queue, and executes corresponding commands on the non-volatile memory using the newly submitted submission queue entry retrieved from the preset submission queue. It should be noted that the first doorbell register is located inside the controller.
[0061] In this embodiment of the invention, the process by which the controller executes corresponding commands on non-volatile memory using submission queue entries retrieved from a preset submission queue can specifically include: after retrieving a submission queue entry from the preset submission queue, the controller parses the submission queue entry to determine whether it includes a multi-command identifier. If the submission queue entry includes a multi-command identifier, the controller sequentially executes several commands to be executed in the submission queue entry based on the command execution order included in the submission queue entry. After each command to be executed is completed, a corresponding completion queue entry containing the execution result of the command to be executed is generated, and the completion queue entry is written to a preset completion queue located on the host. It should be noted that different commands to be executed correspond to different completion queue entries. Further, after writing the completion queue entry to the host's preset completion queue, the controller sends an interrupt instruction to the host, so that the host retrieves the completion queue entry from the preset completion queue based on the interrupt instruction, processes the completion queue entry, and notifies the controller after processing. It should be noted that if the submission queue entry includes a command execution order number, the command execution order can be determined based on the command execution order number.
[0062] Specifically, for executing several pending commands contained in the submission queue entries sequentially on non-volatile memory based on the command execution order, the current pending command can be determined sequentially 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 by the current pending command can be determined from the submission queue entries. Then, the corresponding target buffer can be determined based on the buffer pointer, thereby using the data related to the current pending command stored in the target buffer to execute the current pending command on the non-volatile memory.
[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. In this case, the corresponding target buffer can be determined directly based on the buffer pointer of the buffer required by the command to be executed contained in the submission queue entry. Then, the command to be executed is executed on the non-volatile memory using the data related to the command to be executed stored in the target buffer.
[0064] Furthermore, after the controller sends an interrupt command to the host, the host can process the completion queue entry retrieved from the head of the preset completion queue based on the interrupt command, and notify the controller by updating the head pointer of the preset completion queue stored in the second doorbell register; the second doorbell register is located internally in the controller. When the controller detects an update to the head pointer in the second doorbell register, it can send a second notification message indicating that the completion queue entry has been processed to non-volatile memory.
[0065] It should be noted that if the controller fails to execute a command on the non-volatile memory using a submission queue entry retrieved from the preset submission queue, it can generate an execution result indicating the command execution failure based on the error code, write the completion queue entry containing the execution result into the preset completion queue located on the host, then abort the entire command execution process, and roll back to the state before the command execution, 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] If a submission queue entry includes a multi-command identifier, it indicates that the submission queue entry includes multiple commands. Accordingly, when the controller executes the multiple commands included in the submission queue entry sequentially on the non-volatile memory based on the execution order of the commands included in the submission queue entry, regardless of which command fails to execute, the entire command execution process must be terminated, and the controller must roll back to the state before the command was executed.
[0067] Beneficial Effects: This invention first stores several commands for non-volatile memory in a preset command queue of the host. Then, when submitting commands to be submitted from the preset command queue to the host's preset submission queue, it determines whether 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. If so, a submission queue entry is generated based on the command to be submitted and the target command, and this submission queue entry containing the command to be submitted and the target command is submitted to the host's preset submission queue. This allows the controller in the non-volatile memory to execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue. In this way, compared to submitting a submission queue entry for each command, this invention generates and submits a single submission queue entry for two adjacent commands of the same command type in the preset command queue. This not only ensures the execution order of commands through adjacency but also reduces the number of submission queue entries, thereby improving host performance and the real-time performance of command execution.
[0068] See Figure 4 As shown, an embodiment of the present invention provides a command execution method, including:
[0069] The host retrieves several commands for non-volatile memory and stores them in a local preset command queue. When retrieving commands to be submitted from the preset command queue and submitting them to the local preset submission queue, if a target command of the same type and adjacent to the command to be submitted exists in the preset command queue, a submission queue entry is generated based on the command to be submitted and the target command. This submission queue entry, including the command to be submitted and the target command, is then submitted to the preset submission queue, and the controller in the non-volatile memory is notified. It should be noted that the data size of the submission queue entry does not exceed a preset data size.
[0070] Next, the controller sends a first notification message indicating the presence of a new submission queue entry in the preset submission queue to the non-volatile memory. It then retrieves the new submission queue entry from the preset submission queue and determines whether it contains a multi-command identifier. If the submission queue entry contains a multi-command identifier, the controller executes the pending command and the target command in the non-volatile memory sequentially based on the command execution order in the submission queue entry. Since the command execution order is determined by the positions of the pending command and the target command in the preset command queue, the command execution order is: the pending command is executed first, followed by the target command.
[0071] Specifically, during the process of the controller sequentially executing the pending 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 currently pending command from the pending commands and target commands included in the submission queue entries based on the command execution order. Then, it determines the buffer pointer of the buffer required by the currently pending command from the submission queue entries. After that, it determines the corresponding target buffer based on the buffer pointer. Finally, it can use the data related to the currently pending command stored in the target buffer to execute the currently pending command on the non-volatile memory.
[0072] Furthermore, after each command (either a command to be submitted or a target command) is executed, the controller generates a corresponding completion queue entry containing the command execution result, writes the completion queue entry into a preset completion queue located on the host, and then sends an interrupt command to the host to notify the host that a newly written completion queue entry exists in the preset completion queue. After receiving the interrupt command, the host can retrieve the completion queue entry from the preset completion queue based on the interrupt command, process the completion queue entry, and notify the controller in non-volatile memory after processing.
[0073] Beneficial Effects: This invention first stores several commands for non-volatile memory in a preset command queue of the host. Then, when submitting commands to be submitted from the preset command queue to the host's preset submission queue, it determines whether 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. If so, a submission queue entry is generated based on the command to be submitted and the target command, and this submission queue entry containing the command to be submitted and the target command is submitted to the host's preset submission queue. This allows the controller in the non-volatile memory to execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue. In this way, compared to submitting a submission queue entry for each command, this invention generates and submits a single submission queue entry for two adjacent commands of the same command type in the preset command queue. This not only ensures the execution order of commands through adjacency but also reduces the number of submission queue entries, thereby improving host performance and the real-time performance of command execution.
[0074] See Figure 5 As shown, an embodiment of the present invention provides a command execution device applied to a host, comprising:
[0075] Command storage module 11 is used to obtain a number of commands for non-volatile memory and store the number of commands in a local preset command queue;
[0076] The entry submission module 12 is used to, when retrieving 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, generate a first submission queue entry using a first preset data structure based on the command to be submitted and the target 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 a preset data size, and the first submission queue entry includes the command to be submitted and the target command;
[0077] Command execution module 13 is used to notify the controller in the non-volatile memory after submitting a submission queue entry to the preset submission queue, so that the controller can execute a corresponding command on the non-volatile memory using the submission queue entry retrieved from the preset submission queue.
[0078] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.
[0079] Beneficial Effects: This invention first stores several commands for non-volatile memory in a preset command queue of the host. Then, when submitting commands to be submitted from the preset command queue to the host's preset submission queue, it determines whether 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. If so, a submission queue entry is generated based on the command to be submitted and the target command, and this submission queue entry containing the command to be submitted and the target command is submitted to the host's preset submission queue. This allows the controller in the non-volatile memory to execute corresponding commands on the non-volatile memory using the submission queue entry retrieved from the preset submission queue. In this way, compared to submitting a submission queue entry for each command, this invention generates and submits a single submission queue entry for two adjacent commands of the same command type in the preset command queue. This not only ensures the execution order of commands through adjacency but also reduces the number of submission queue entries, thereby improving host performance and the real-time performance of command execution.
[0080] Furthermore, embodiments of this application also disclose an electronic device, Figure 6This is a structural diagram of an electronic device according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. Specifically, the electronic device may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the command execution method disclosed in any of the foregoing embodiments. Furthermore, the electronic device in this embodiment may specifically be an electronic computer.
[0081] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire 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 resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, 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 the various hardware devices on the electronic device and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the command execution method disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0084] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned command execution method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0085] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0086] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0087] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0088] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0089] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method of command execution, characterized by, The application is applied to a host, comprising: acquiring a plurality of commands for a non-volatile memory and storing the plurality of commands into a preset command queue locally; when a to-be-submitted command is taken out from the preset command queue and submitted to a preset submission queue locally, if there is a target command adjacent to the to-be-submitted command in position and of the same type in the preset command queue, a first preset data structure is used to generate a first submission queue entry based on the to-be-submitted command and the target command, 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 a preset data size, and the first submission queue entry includes the to-be-submitted command and the target command; after the submission queue entry is submitted to the preset submission queue, a controller in the non-volatile memory is informed so that the controller executes corresponding commands on the non-volatile memory by using the submission queue entry taken out from the preset submission queue; wherein, when a to-be-submitted command is taken out from the preset command queue and submitted to a preset submission queue locally, if there is a target command adjacent to the to-be-submitted command in position and of the same type in the preset command queue, a first preset data structure is used to generate a first submission queue entry based on the to-be-submitted command and the target command, and the first submission queue entry is submitted to the preset submission queue, comprising: when a to-be-submitted command is taken out from the preset command queue and submitted to a preset submission queue locally, the target command type of the to-be-submitted command and the target position of the to-be-submitted command in the preset command queue are determined, and it is judged whether there is a to-be-determined command of the same type as the target command type on the position adjacent to the target position in the preset command queue; if there is no to-be-determined command of the same type as the target command type on the 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 to-be-determined command of the same type as the target command type on the position adjacent to the target position in the preset command queue, based on the data sizes of the to-be-submitted command and the to-be-determined command, it is determined whether the to-be-submitted command and the to-be-determined command satisfy a preset data size condition; wherein the preset data size condition is that the data size of the submission queue entry generated by using the first preset data structure and based on the to-be-submitted command and the to-be-determined command is not greater than the preset data size; if the to-be-submitted command and the to-be-determined command satisfy the preset data size condition, the to-be-determined command is determined as the target command, then a first submission queue entry is generated by using the first preset data structure and based on the to-be-submitted command and the target command, and the first submission queue entry is submitted to the preset submission queue.
2. The command execution method according to claim 1, wherein The process that the controller executes corresponding commands on the non-volatile memory by taking out the submission queue entries from the preset submission queue, comprises: After submitting the submission queue entry to the tail of the preset submission queue, the controller in the non-volatile memory is informed by updating the tail pointer of the preset submission queue stored in the first gong register, so that 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 when monitoring that the tail pointer in the first gong register is updated, and executes corresponding commands on the non-volatile memory by taking out the newly submitted submission queue entry from the preset submission queue; The first gong register is located in the internal of the controller.
3. The command execution method according to claim 1 or 2, characterized by, Further comprising: When taking out a to-be-submitted command from the preset command queue and submitting it to the local preset submission queue, if there is no target command adjacent to the to-be-submitted command in the preset command queue and having the same command type, the to-be-submitted command is converted into a corresponding second submission queue entry by using a second preset data structure, and the second submission queue entry is submitted 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 not currently used, the to-be-submitted command, and a buffer pointer of a buffer required by the to-be-submitted command; The first submission queue entry includes the to-be-submitted command and the target command, buffer pointers of buffers required by the to-be-submitted command 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 to-be-submitted command and the target command in the preset command queue.
4. The command execution method according to claim 3, wherein The process that the controller executes corresponding commands on the non-volatile memory by taking out the submission queue entries from the preset submission queue, comprises: After taking out the submission queue entry from the preset submission queue, if the submission queue entry includes a multi-command identifier, the controller executes a plurality of to-be-executed commands in the submission queue entry on the non-volatile memory in sequence based on the command execution order in the submission queue entry, and writes a completion queue entry containing the execution results of the to-be-executed commands into a preset completion queue in the host; different to-be-executed 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 informs the controller after processing is completed.
5. The command execution method according to claim 4, wherein The process that the controller executes a plurality of to-be-executed commands in the submission queue entry on the non-volatile memory in sequence based on the command execution order in the submission queue entry, comprises: Determine a current to-be-executed command from the to-be-executed commands in the submission queue entry based on the execution order of the commands in the submission queue entry, determine a corresponding target buffer based on a buffer pointer of a required buffer of the current to-be-executed command in the submission queue entry, and execute the current to-be-executed command on the non-volatile memory by using data stored in the target buffer.
6. The command execution method according to claim 4, wherein 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 processing, comprising: The sending of the interrupt instruction to the host so that the host processes the completion queue entry taken out 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 processing; the second doorbell register is located inside the controller; When monitoring that the head pointer in the second doorbell register is updated, sending a second notification message for indicating that the completion queue entry has been processed to the non-volatile memory.
7. A command execution apparatus characterized by comprising: The device is applied to a host and is used to implement the command execution method according to any one of claims 1 to 6, and the device comprises: A command storage module is configured to acquire a plurality of commands for a non-volatile memory and store the plurality of commands in a preset command queue locally; An entry submission module is configured to, when taking out a to-be-submitted command from the preset command queue and submitting it to a preset submission queue locally, if there is a target command adjacent to the to-be-submitted command and of the same type in the preset command 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, 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 a preset data size, and the first submission queue entry comprises the to-be-submitted command and the target command; A command execution module is configured to, after submitting a submission queue entry to the preset submission queue, notify a controller in the non-volatile memory so that the controller executes a corresponding command on the non-volatile memory by using the submission queue entry taken out from the preset submission queue.
8. An electronic device, comprising: Comprise: A memory is configured to store a computer program; A processor is configured to execute the computer program to implement the command execution method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium and is executed by the processor to implement the command execution method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data storage device and method for logical range locking
CN118897647A
Storage System and Method for Early Host Command Fetching In a Low Queue Depth Environment
US20200310682A1