Method and device for allocating resources to controller of server

By dynamically allocating processors and calculating queue addresses in the server controller, the resource waste caused by fixed allocation of queue resources within NVMe SSD is solved, and efficient resource utilization is achieved.

CN119025273APending Publication Date: 2024-11-26SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411095716.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In the prior art, the queue resource allocation within the NVMe SSD has fixed allocation, resulting in resource waste.

Method used

By setting up storage units and resource allocation units in the controller on the server, receiving instructions and determining the allocation status of the controller based on the allocation information in the mapping table, dynamically allocating the processor to process pending commands in the queue, using the formula Doorbell_addr_i=Base_addr (port_id)+α×Ctrl_id+β×Queue_id calculates the target address of the queue and realizes dynamic allocation of queue resources.

Benefits of technology

It effectively solves the resource waste problem caused by fixed allocation of queue resources within NVMe SSD, and realizes the dynamic allocation of queue resources and the effect of saving resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025273A_ABST
    Figure CN119025273A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for allocating resources for controllers of a server side, and the method comprises the steps: receiving a first instruction from the server side, the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected with the second controller, the server side comprises a plurality of controllers, and the first identifier of the first port is connected with the second controller; the plurality of controllers comprise a second controller, each controller comprises at least one queue, and each queue comprises at least one to-be-processed command; determining the distribution state of a second controller under the first port according to the distribution information recorded in the mapping table of the storage unit; and allocating a target processor to the second controller through a resource allocation unit according to the allocation state of the second controller and the allocation state of each processor recorded in a storage unit, so as to process the to-be-processed command in the queue of the second controller through the target processor. Through the method and the device, the problem of resource waste caused by fixed allocation of queue resources in the NVMeSSD is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and in particular, to a method and device for allocating resources to a controller on a server side. Background Art

[0002] R-IOV (Single Root I / O Virtualization) is a hardware-assisted I / O virtualization technology designed to improve I / O performance in a virtualized environment. It allows a single physical PCIe device to be virtualized into multiple independent devices at the hardware level. These devices can be directly accessed by virtual machines, thereby reducing the I / O processing overhead of the virtualization layer. This technology introduces virtualization functions into physical devices and divides the resources of physical devices into multiple virtual devices. Each virtual device has its own I / O channel, memory space, and hardware resources for processing queues, which can be independently allocated to virtual machines for use while maintaining isolation between virtual machines. However, existing technologies mostly use fixed resource allocation, which can easily cause resource redundancy and waste.

[0003] There is currently no effective solution to the above problems. Summary of the invention

[0004] The embodiments of the present application provide a method and device for allocating resources to a server-side controller, so as to at least solve the problem of resource waste caused by fixed allocation of queue resources within the NVMe SSD in the related art.

[0005] According to an embodiment of the present application, a method for allocating resources to a controller of a server is provided, which is applied to a first controller, wherein the first controller is provided with a storage unit and a resource allocation unit, comprising: receiving a first instruction from a server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to the second controller, the server comprises a plurality of controllers, the plurality of controllers include the second controller, each of the controllers comprises at least one queue, and each of the queues comprises at least one command to be processed; determining an allocation status of the second controller under the first port according to allocation information recorded in a mapping table of the storage unit, wherein the allocation information comprises: an identifier of the allocated controller and an identifier of the port to which the allocated controller is connected; according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, allocating a target processor to the second controller through the resource allocation unit, so that the commands to be processed in the queue of the second controller are processed by the target processor.

[0006] In an exemplary embodiment, the allocation status of the second controller under the first port is determined according to the allocation information recorded in the mapping table of the storage unit, including: searching the mapping table for whether the allocation information of the first identifier and the second identifier exists; if so, determining that the allocation status of the second controller is an allocated status, wherein the allocated status indicates that a processor has been allocated to the second controller under the first port; if not, determining that the allocation status of the second controller is an unallocated status, wherein the unallocated status indicates that no processor is allocated to the second controller under the first port.

[0007] In an exemplary embodiment, the storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of the respective processors, and the second storage area is used to store the mapping table. According to the allocation status of the second controller and the allocation status of the respective processors recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, including: when the allocation status of the second controller is the unallocated state, according to the allocation status of the respective processors recorded in the first storage area, the processor with the allocation status of the unallocated state is determined as a processor to be allocated, and a plurality of processors to be allocated are obtained; the target processor is determined from the plurality of processors to be allocated; the target address of each queue in the second controller is determined through the resource allocation unit, and the target address is sent to the target processor.

[0008] In an exemplary embodiment, the storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of each processor, and the second storage area is used to store the mapping table. According to the first allocation status of the second controller and the second allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, including: when the allocation status of the second controller is the allocated status, and the allocated status indicates that the first processor has been allocated to the second controller under the first port, deleting the allocation information of the first identifier and the second identifier in the mapping table, and modifying the allocation status of the first processor recorded in the first storage area from the allocated status to the unallocated status; according to the first storage area for recording the allocation status of each processor, determining the processor with the allocation status of the unallocated status as a processor to be allocated, and obtaining multiple processors to be allocated; determining the target processor among the multiple processors to be allocated; determining the target address of each queue in the second controller through the resource allocation unit, and sending the target address to the target processor.

[0009] In an exemplary embodiment, determining the target address of each queue in the second controller by the resource allocation unit includes: when determining the target address of the i-th queue in the second controller, the resource allocation unit obtains the target address of the i-th queue by the following formula, where i is an integer:

[0010] Doorbell_addr_i=Base_addr(port_id)+α×Ctrl_id+β×Queue_id

[0011] Among them, Doorbell_addr_i is the target address of the i-th queue, Base_addr(port_id) is the base address of the first port, Ctrl_id is the second identifier of the second controller, Queue_id is the identifier of the i-th queue, and α and β are preset values.

[0012] In an exemplary embodiment, the first controller is further provided with a queue information allocation unit. After allocating a target processor to the second controller, the method further includes: receiving a second instruction from the server, wherein the second instruction carries a first identifier of the first port, a second identifier of the second controller, an identifier of the i-th queue, a size of the i-th queue, a page relative pointer PR P address, an allocation completion identifier, and i is an integer; determining the target processor allocated to the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit; and sending the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PR P address, and an allocation completion identifier to the target processor, so that the target processor processes the command in the i-th queue of the second controller according to the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, and the page relative pointer PR P address.

[0013] In an exemplary embodiment, before determining the target addresses of each queue in the second controller by the resource allocation unit, the method further includes: acquiring the base address of the first port in the first storage area of ​​the storage unit; the storage unit also includes a third storage area, and after receiving the first instruction from the server, the method further includes: recording the first identifier of the first port and the second identifier of the second controller carried in the first instruction in the third storage area; setting the first completion flag in the first storage area to a first value, wherein the first value is used to indicate that the first identifier of the first port and the second identifier of the second controller carried in the first instruction have been stored in the third storage area;

[0014] After receiving the second instruction from the server, the method also includes: recording the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier in the third storage area; setting the second completion flag in the first storage area to a second value, wherein the second value is used to indicate that the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier have been stored in the third storage area; deleting the first value in the first completion flag in the first storage area, or replacing the first value in the first completion flag in the first storage area with other values, wherein the other value is any value other than the first value.

[0015] According to another embodiment of the present application, there is provided a device for allocating resources to a controller of a server, which is applied to a first controller, wherein the first controller is provided with a storage unit and a resource allocation unit, and comprises: a receiving module, which is used to receive a first instruction from a server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to the second controller, the server comprises a plurality of controllers, the plurality of controllers include the second controller, each of the controllers comprises at least one queue, and each of the queues comprises at least one command to be processed; a determining module, which is used to determine the allocation status of the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit, wherein the allocation information comprises an identifier of the controller to which the allocation information has been allocated and an identifier of the port to which the allocated controller is connected; an allocating module, which is used to allocate a target processor to the second controller according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, so that the target processor can process the commands to be processed in the queue of the second controller.

[0016] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0017] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0018] According to yet another embodiment of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above methods are implemented.

[0019] Through this application, since the first controller (NVMe controller) receives the first instruction from the server, the first instruction carries the first identifier of the first port and the second identifier of the second controller, the first port is connected to the second controller, the server includes multiple controllers, the multiple controllers include the second controller, each controller includes at least one queue, and each queue includes at least one pending command; according to the allocation information recorded in the mapping table of the storage unit, the allocation status of the second controller under the first port is determined, and the allocation information includes: the identifier of the allocated controller and the identifier of the port to which the allocated controller is connected. According to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, so that the pending commands in the queue of the second controller are processed by the target processor. Therefore, the problem of resource waste caused by the fixed allocation of queue resources in the NVMeSSD in the related technology can be solved, and the effect of dynamic allocation of queue resources and resource saving in the NVMe SSD can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 The system framework of the server device of the method for allocating resources to the controller of the server side in the embodiment of the present application Figure 1 ;

[0021] Figure 2 is a flowchart of a method for allocating resources to a controller on a server side according to an embodiment of the present application;

[0022] Figure 3 The system framework of the server device of the method for allocating resources to the controller of the server side according to the embodiment of the present application Figure 2 ;

[0023] Figure 4 is an overall flow chart according to an embodiment of the present application;

[0024] Figure 5 It is a structural block diagram of an apparatus for allocating resources to a controller at a server side according to an embodiment of the present application. DETAILED DESCRIPTION

[0025] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0027] The method embodiment provided in the embodiment of the present application may be executed in a first controller, and the first controller may be a non-volatile memory host (Non-Volatile Memory Express, NVMe for short) controller. Figure 1 The system framework diagram of a server device of a method for allocating resources to a server controller in an embodiment of the present application includes a server host and a non-volatile memory host solid state drive (NVMe SSD for short).

[0028] The server includes multiple controllers, such as controller 0 to controller n (the value of n can be determined according to actual conditions) as shown in the figure. Each controller of the server includes at least one queue, such as Figure 1 The SQ and CQ shown in FIG. 4 each include multiple pending commands.

[0029] The NVMe SSD includes an NVMe controller (also referred to as a first controller), which includes a storage unit, a resource allocation unit, a queue creation information allocation unit, processors 1 to 1 (the value of k may be determined according to actual conditions) and other modules.

[0030] The storage unit includes: an initial information data storage area (also called a first storage area), a mapping table data storage area (also called a second storage area), and an allocation information data storage area (also called a third storage area).

[0031] In this embodiment, a method for allocating resources to a server controller is provided, which is applied to the NVMe controller in the above system framework diagram. Figure 2 is a flowchart of a method for allocating resources to a controller on a server side according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0032] Step S202, receiving a first instruction from the server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to at least one controller, the at least one controller includes the second controller, the server includes a plurality of controllers, the plurality of controllers include the second controller, each of the controllers includes at least one queue, and each of the queues includes at least one command to be processed;

[0033] The server is a host, the first instruction may be a Virtualization Management command, the first identifier of the first port is PClePortid, the second identifier of the second controller is NVMecontrollerid, and the second controller is Figure 1The server shown includes controllers 0 to n to which the first port PClePortid is connected.

[0034] Step S204, determining the allocation status of the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit, wherein the allocation information includes: an identifier of the allocated controller and an identifier of the port to which the allocated controller is connected;

[0035] Optionally, the allocation state of the second controller under the first port may be determined in the following manner:

[0036] Search the mapping table for the allocation information of the first identifier and the second identifier; if so, determine that the allocation status of the second controller is an allocated status, and the allocated status indicates that a processor has been allocated to the second controller under the first port; if not, determine that the allocation status of the second controller is an unallocated status, and the unallocated status indicates that no processor is allocated to the second controller under the first port.

[0037] For example, the above mapping table is stored in Figure 1 The second storage area in the storage unit. The queue processing hardware resource dynamic allocation device of the NVMe controller queries the mapping table to determine whether there is an allocation corresponding to PClePortid (the first identifier of the first port) and NVMecontrollerid (the second identifier of the second controller) in the mapping table. If so, it is determined that the second controller is in an allocated state. If not, it is determined that the second controller is in an unallocated state. In the present application, the allocation status of each controller of the server can be quickly queried through the mapping table of the storage area, and then the processor can be allocated according to the allocation status of each controller of the server, thereby improving the efficiency of allocating processors to the controllers of the server, and then the processing efficiency of the commands to be processed can be improved.

[0038] Step 5206, according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, so that the pending commands in the queue of the second controller are processed by the target processor.

[0039] Among them, Figure 1 The initial information data storage area (also called the first storage area) shown records the allocation status of each processor. The allocation status of the processor can be identified by a bit map. For example, a bit map equal to 1 indicates that the processor is allocated, and a bit map equal to 0 indicates that the processor is not allocated.

[0040] Optionally, the storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of each processor, and the second storage area is used to store the mapping table, and according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller by the resource allocation unit, including:

[0041] When the allocation state of the second controller is the unallocated state, the processor whose allocation state is the unallocated state is determined as a processor to be allocated according to the allocation state of each processor recorded in the first storage area, and a plurality of processors to be allocated are obtained; the target processor is determined among the plurality of processors to be allocated; the target address of each queue in the second controller is determined by the resource allocation unit, and the target address is sent to the target processor.

[0042] For example, the bit map of each processor recorded in the first storage area is Figure 1 Processor_1 to processor shown _ Search for a processor whose bit map is equal to 0 (in an unallocated state) in k. If there are multiple processors whose bit map is equal to 0 (in an unallocated state), determine a target processor from the multiple unallocated processors to allocate the target processor to the second controller, and process the pending commands in the queue of the second controller through the target processor.

[0043] As an optional implementation, the storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of each processor, and the second storage area is used to store the mapping table, and according to the first allocation status of the second controller and the second allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller by the resource allocation unit, including:

[0044] When the allocation state of the second controller is the allocated state, and the allocated state indicates that the first processor has been allocated to the second controller under the first port, the allocation information of the first identifier and the second identifier is deleted in the mapping table, and the allocation state of the first processor recorded in the first storage area is modified from the allocated state to the unallocated state; according to the first storage area used to record the allocation state of each processor, the processor with the allocation state of the unallocated state is determined as a processor to be allocated, and a plurality of processors to be allocated are obtained; the target processor is determined among the plurality of processors to be allocated; the target address of each queue in the second controller is determined by the resource allocation unit, and the target address is sent to the target processor.

[0045] Specifically, if the mapping table records that the second controller is in an allocated state, it means that a processor has been allocated to the second controller before. Assume that the allocation information of the second controller recorded in the mapping table indicates that the first processor has not been allocated to the second controller (the first processor can be any processor from processor_0 to processor_k). In this case, it is necessary to reallocate the processor to the second controller, and modify the allocation state of the first processor recorded in the first storage area from an allocated state to an unallocated state, so that the first processor can be released, and the target processor can be determined from the processors in the unallocated state recorded in the first storage area, so as to achieve the technical effect of quickly releasing the processor that needs to be reallocated.

[0046] As an optional implementation, after determining the target processor among multiple processors to be assigned, the target address of each queue in the second controller is determined by the resource allocation unit, and the target address is sent to the target processor, so that the target processor can find the queue through the target address to process the pending commands in the target queue.

[0047] Specifically, the target address of each queue in the second controller can be determined in the following manner:

[0048] In the case of determining the target address of the i-th queue in the second controller, the resource allocation unit obtains the target address of the i-th queue by the following formula, where i is an integer:

[0049] Doorbell_addr_i=Base_addr(port_id)+α×Ctr1_id+β×Queue_id

[0050] Among them, Doorbell_addr_i is the target address of the i-th queue, Base_addr(port_id) is the base address of the first port, Ctrl_id is the second identifier of the second controller, Queue_id is the identifier of the i-th queue, and α and β are preset values.

[0051] As an optional implementation, the first controller is further provided with a queue information allocation unit, and after allocating the target processor to the second controller, the method further includes:

[0052] Receive a second instruction from the server, where the second instruction carries a first identifier of the first port, a second identifier of the second controller, an identifier of the i-th queue, a size of the i-th queue, a page relative pointer PRP address, an allocation completion identifier, and i is an integer;

[0053] The above-mentioned second instruction can be a Create Queue command, which carries the first identifier PClePortid of the first port, the second identifier NVMecontrollerid of the second controller, the identifier queueid of the i-th queue, the size queuesize of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier cqid.

[0054] Determining the target processor that has been allocated to the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit;

[0055] The mapping table can be checked according to PClePortid, NVMecontrollerid, and queueid to find the identifier of the allocated second controller.

[0056] The second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier is sent to the target processor, so that the target processor processes the commands in the i-th queue of the second controller according to the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, and the page relative pointer PRP address. In this way, the technical effect of being able to fully utilize the queue processing hardware resources of the NVMe controller, avoiding redundancy and waste of resources, and improving the flexibility of adaptation is achieved.

[0057] As an optional implementation, before determining the target address of each queue in the second controller by the resource allocation unit, the method further includes: acquiring a base address of the first port in a first storage area of ​​the storage unit;

[0058] The storage unit also includes a third storage area. After receiving the first instruction from the server, the method further includes: recording the first identifier of the first port and the second identifier of the second controller carried in the first instruction in the third storage area; setting the first completion flag in the first storage area to a first value (which can be set according to actual conditions, for example, the first value is 1), wherein the first value is used to indicate that the first identifier of the first port and the second identifier of the second controller carried in the first instruction have been stored in the third storage area;

[0059] After receiving the second instruction from the server, the method also includes: recording the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier in the third storage area; setting the second completion flag in the first storage area to a second value, wherein the second value is used to indicate that the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier have been stored in the third storage area; deleting the first value in the first completion flag in the first storage area, or replacing the first value in the first completion flag in the first storage area with other values, wherein the other value is any value other than the first value.

[0060] like Figure 3 As shown, the SSD NVMe controller is implemented by hardware, including: storage unit, resource allocation unit, and queue creation information allocation unit. The storage unit includes: allocation information storage area, initial information storage area, and mapping table storage area. The allocation information storage area is used to store the parameters of the NVMeVirtualizationManagement command, including: PClePortid, NVMecontrollerid ( Figure 3 The corresponding Ctrl id indicates the identity of the controller), the number of queues to be allocated QNU M, and the parameters of the NVMeCreate Queue command include: PClePortid, NVMecontrollerid, Queueid, Queuesize, PRP address, cqid (allocation completion flag). The initial information storage area is used to store the base address of Doorbell, the processor's bit map (used to indicate the allocation status of the processor), the input completion flag and the allocation completion flag information. The mapping table storage area is used to store a mapping table consisting of PCle Portid, NVMecontrollerid, queueid, and the identity of the processor. The information stored in the storage unit is used by other units.

[0061] Furthermore, the queue resource allocation unit obtains the bitmap of the processor usage of the initial information storage area of ​​the storage unit to determine the allocation of the processor; the queue resource allocation unit obtains the PClePortid, NVMecontrollerid, the number of queues to be allocated Q_NUM, and the base address of the Doorbell of the initial information storage area stored in the allocation information storage area of ​​the storage unit, and calculates the address of each Doorbell by using hardware such as adders, multipliers, counters, and logic circuits. The calculation formula is as follows:

[0062] Doorbell_addr_i=Base_addr(port_id)+α×Ctrl_id+β×Queue_id

[0063] Doorbell_addr_i is the target address of the i-th queue, Base_addr(port_id) is the base address of the first port, Ctrl_id is the second identifier of the second controller, Queue_id is the identifier of the i-th queue, and α and β are preset values.

[0064] The Doorbell address is transmitted to the unassigned processor, and the bit position of the bit map of the processor usage corresponding to the corresponding processor is set to 1, and the PClePortid, NVMecontrollerid, queueid, and processor id are stored in the mapping table in the mapping table storage area.

[0065] Furthermore, a queue information allocation unit is created to obtain the PClePortid, NVMecontrollerid, queueid, queuesize, PRP address, and cqid information in the NVMeCreate Queue command, and search the corresponding processor identity from the mapping table in the mapping table storage area according to the PClePortid, NVMecontrollerid, and queueid, and then transmit the queuesize, PRP address, and cqid to the processor to complete the queue allocation.

[0066] Through the above embodiments, the problem of fixed allocation of queue resources in the NVMe SSD in the related art, which leads to waste of resources, is solved, and the effect of dynamic allocation of queue resources and resource saving is achieved.

[0067] The present application is described below by a specific embodiment. Figure 4 The flowchart shown includes the following steps:

[0068] S301, the server (Host) is powered on, the NVMe SSD is initialized, each storage area of ​​the storage unit is cleared, and then the Doorbell base address information is written into the initial information storage area (first storage area);

[0069] S302, during the power-on process, the server sends a Virtualization Management command (first command) to the SSD to allocate queue resources;

[0070] S303, after receiving the command, the firmware of the NVMe SSD writes the PCIePortid (the first identifier of the first port), the NVMecontrollerid (the second identifier of the second controller), and the number of queues to be allocated Q_NUM of the Virtualization Management command into the allocation information storage area (the third storage area) of the storage unit, and after the storage is completed, sets the input completion flag position in the initial information storage area (the first storage area) to 1;

[0071] S304, after the queue processing hardware resource dynamic allocation device detects that the input completion flag is set to 1, it starts to allocate queue resources;

[0072] S305, the queue processing hardware resource dynamic allocation device checks the mapping table to check whether there is an allocation corresponding to PCIePortid and NVMecontrollerid in the mapping table. If not, jump to S306, otherwise jump to S307;

[0073] S306, the queue processing hardware resource dynamic allocation device checks the processor usage bitmap in the initial information storage area, and allocates the processor according to the identity from low to high according to the number of queues to be allocated Q_NUM; calculates the address of the Doorbell corresponding to each queue in turn, and transmits the address to the processor, and stores the PCIePortid, NVMecontrollerid, queueid, and the processor identity in the mapping table in the mapping table storage unit, and sets the corresponding bit of the processor usage bitmap to 1. After the allocation is completed, the allocation completion flag position is 1, and the input completion flag position is 0;

[0074] S307, the queue processing hardware resource dynamic allocation device obtains the mapping table in the mapping table storage area, deletes the mapping corresponding to the Portid and NVMecontrollerid, and sets the corresponding bit position of the processor usage bitmap to 0. Then, according to the number of queues to be allocated Q_NUM, the processors are allocated from low to high according to the identity identifier; the address of the Doorbell corresponding to each queue is calculated in turn, and the address is transmitted to the processor, and the PCIe Port id, NVMe controller id, queue id, and processor id are stored in the mapping table in the mapping table storage area, and the corresponding bit of the processor usage bitmap is set to 1. After the allocation is completed, the allocation completion flag position is set to 1, and the storage completion flag position is set to 0;

[0075] S308, after the firmware detects that the allocation completion flag is set to 1, it returns the completion information of the VirtualizationManagement command to the server, and then sets the allocation completion flag to 0;

[0076] S309, after the Virtualization Management command is completed, the Host will send a Create Queue command to the SSD firmware. After receiving the command, the firmware writes the PCIePortid, NVMecontrollerid, queueid, queuesize, PRP address, and cqid in the command to the allocation information storage area, and sets the input completion flag position to 1;

[0077] S310, after the queue processing hardware resource dynamic allocation device detects that the input completion flag position is 1, it will check the mapping table in the mapping table storage area according to PCIePortid, NVMecontrollerid, and queueid, find out the corresponding processor ID, and then transmit the queuesize, PRP address, and cqid information to the processor, and then set the allocation completion flag position to 1 and the storage completion flag position to 0;

[0078] S311, after the SSD firmware checks that the allocation completion flag is set to 1, it returns completion information to the Host, and then sets the allocation completion flag to 1, completing a queue dynamic allocation.

[0079] The present application solves the problem in the prior art that when the host side needs multiple controllers and needs to process commands in multiple queues, the NVMe controller allocates fixed queue processing hardware resources to each controller, resulting in redundancy and resource waste, thereby achieving the technical effect of improving adaptation flexibility and solving resource problems.

[0080] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0081] In this embodiment, a device for allocating resources to a controller on the server side is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0082] Figure 5 is a structural block diagram of an apparatus for allocating resources to a controller at a server end according to an embodiment of the present application, which is applied to a first controller, wherein the first controller is provided with a storage unit, a resource allocation unit, such as Figure 5 As shown, the device includes: a receiving module 502, which is used to receive a first instruction from a server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to the second controller, the server includes multiple controllers, the multiple controllers include the second controller, each of the controllers includes at least one queue, and each of the queues includes at least one pending command; a determining module 504, which is used to determine the allocation status of the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit, wherein the allocation information includes the identifier of the controller to which the allocation information has been allocated and the identifier of the port to which the allocated controller is connected; an allocation module 506, which is used to allocate a target processor to the second controller according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, so that the pending commands in the queue of the second controller are processed by the target processor.

[0083] In an exemplary embodiment, the above-mentioned device is also used to search whether the allocation information of the first identifier and the second identifier exists in the mapping table; if so, determine that the allocation status of the second controller is an allocated status, wherein the allocated status indicates that a processor has been allocated to the second controller under the first port; if not, determine that the allocation status of the second controller is an unallocated status, wherein the unallocated status indicates that no processor is allocated to the second controller under the first port.

[0084] In an exemplary embodiment, the storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of the various processors, and the second storage area is used to store the mapping table. The above-mentioned device is also used to, when the allocation status of the second controller is the unallocated state, determine the processor with the allocation status of the various processors recorded in the first storage area as the processor to be allocated, and obtain multiple processors to be allocated; determine the target processor among the multiple processors to be allocated; determine the target address of each queue in the second controller through the resource allocation unit, and send the target address to the target processor.

[0085] In an exemplary embodiment, the above-mentioned device is also used to delete the allocation information of the first identifier and the second identifier in the mapping table, and modify the allocation status of the first processor recorded in the first storage area from the allocated state to the unallocated state when the allocation status of the second controller is the allocated state and the allocated state indicates that the first processor has been allocated to the second controller under the first port; determine the processor with the allocation status of the unallocated state as the processor to be allocated according to the first storage area used to record the allocation status of each processor, and obtain multiple processors to be allocated; determine the target processor among the multiple processors to be allocated; determine the target address of each queue in the second controller through the resource allocation unit, and send the target address to the target processor.

[0086] In an exemplary embodiment, the above-mentioned device is also used for, when determining the target address of the i-th queue in the second controller, the resource allocation unit obtains the target address of the i-th queue by the following formula, where i is an integer:

[0087] Doorbell_addr_i=Base_addr(port_id)+α×Ctr1_id+β×Queue_id

[0088] Among them, Doorbell_addr_i is the target address of the i-th queue, Base_addr(port_id) is the base address of the first port, Ctr1_id is the second identifier of the second controller, Queue_id is the identifier of the i-th queue, and α and β are preset values.

[0089] In an exemplary embodiment, the first controller is also provided with a queue information allocation unit. After allocating a target processor to the second controller, the above-mentioned device is also used to receive a second instruction from the server, wherein the second instruction carries a first identifier of the first port, a second identifier of the second controller, an identifier of the i-th queue, a size of the i-th queue, a page relative pointer PRP address, an allocation completion identifier, and i is an integer; according to the allocation information recorded in the mapping table of the storage unit, the target processor allocated to the second controller under the first port is determined; the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier is sent to the target processor, so that the target processor processes the command in the i-th queue of the second controller according to the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, and the page relative pointer PRP address.

[0090] In an exemplary embodiment, the apparatus is further configured to obtain a base address of the first port in a first storage area of ​​the storage unit before determining the target address of each queue in the second controller by the resource allocation unit;

[0091] The storage unit also includes a third storage area, and the above-mentioned device is further used for recording the first identifier of the first port and the second identifier of the second controller carried in the first instruction in the third storage area after receiving the first instruction from the server; setting the first completion flag in the first storage area to a first value, wherein the first value is used to indicate that the first identifier of the first port and the second identifier of the second controller carried in the first instruction have been stored in the third storage area;

[0092] The above-mentioned device is also used to, after receiving a second instruction from the server, record the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier in the third storage area; set the second completion flag in the first storage area to a second value, wherein the second value is used to indicate that the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier have been stored in the third storage area; delete the first value in the first completion flag in the first storage area, or replace the first value in the first completion flag in the first storage area with other values, wherein the other value is any numerical value other than the first value.

[0093] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0094] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0095] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0096] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0097] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0098] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0099] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0100] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for allocating resources to a controller at a server, characterized in that: Applied to a first controller, the first controller is provided with a storage unit and a resource allocation unit, including: Receive a first instruction from a server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to the second controller, the server includes a plurality of controllers, the plurality of controllers include the second controller, each of the controllers includes at least one queue, and each of the queues includes at least one command to be processed; Determine the allocation status of the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit, wherein the allocation information includes: an identifier of the allocated controller and an identifier of the port to which the allocated controller is connected; According to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller by the resource allocation unit, so that the pending commands in the queue of the second controller are processed by the target processor.

2. The method according to claim 1, characterized in that Determining, according to the allocation information recorded in the mapping table of the storage unit, an allocation state of the second controller under the first port, includes: Searching in the mapping table whether the allocation information of the first identifier and the second identifier exists; If so, determining that the allocation state of the second controller is an allocated state, wherein the allocated state indicates that a processor has been allocated to the second controller under the first port; If not, it is determined that the allocation state of the second controller is an unallocated state, wherein the unallocated state indicates that the second controller under the first port has no allocated processor.

3. The method according to claim 2, characterized in that The storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of each processor, and the second storage area is used to store the mapping table, and according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, including: In the case where the allocation state of the second controller is the unallocated state, according to the allocation state of each processor recorded in the first storage area, the processor whose allocation state is the unallocated state is determined as a processor to be allocated, so as to obtain a plurality of processors to be allocated; Determining the target processor among the multiple processors to be allocated; The target address of each queue in the second controller is determined by the resource allocation unit, and the target address is sent to the target processor.

4. The method according to claim 2, characterized in that: The storage unit includes a first storage area and a second storage area, the first storage area is used to record the allocation status of each processor, and the second storage area is used to store the mapping table, and according to the first allocation status of the second controller and the second allocation status of each processor recorded in the storage unit, the target processor is allocated to the second controller through the resource allocation unit, including: In a case where the allocation state of the second controller is the allocated state, and the allocated state indicates that the first processor has been allocated to the second controller under the first port, deleting the allocation information of the first identifier and the second identifier in the mapping table, and modifying the allocation state of the first processor recorded in the first storage area from the allocated state to the unallocated state; According to the first storage area being used to record the allocation status of each processor, the processor whose allocation status is unallocated is determined as a processor to be allocated, so as to obtain a plurality of processors to be allocated; Determining the target processor among the multiple processors to be allocated; The target address of each queue in the second controller is determined by the resource allocation unit, and the target address is sent to the target processor.

5. The method according to claim 3 or 4, characterized in that: Determining, by the resource allocation unit, a target address of each queue in the second controller includes: In the case of determining the target address of the i-th queue in the second controller, the resource allocation unit obtains the target address of the i-th queue by the following formula, where i is an integer: Doorbell_addr_i=Base_addr(port_id)+α×Ctrl_id+β×Queue_id Among them, Doorbell_addr_i is the target address of the i-th queue, Base_addr(port_id) is the base address of the first port, Ctrl_id is the second identifier of the second controller, Queue_id is the identifier of the i-th queue, and α and β are preset values.

6. The method according to any one of claims 1 to 5, characterized in that The first controller is further provided with a creation queue information allocation unit. After allocating a target processor to the second controller, the method further comprises: Receive a second instruction from the server, wherein the second instruction carries a first identifier of the first port, a second identifier of the second controller, an identifier of the i-th queue, a size of the i-th queue, a page relative pointer PRP address, an allocation completion identifier, and i is an integer; Determining the target processor that has been allocated to the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit; The second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier is sent to the target processor, so that the target processor processes the commands in the i-th queue of the second controller according to the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, and the page relative pointer PRP address.

7. The method according to claim 6, characterized in that Before determining the target addresses of the respective queues in the second controller by the resource allocation unit, the method further comprises: acquiring a base address of the first port in a first storage area of ​​the storage unit; The storage unit further includes a third storage area. After receiving the first instruction from the server, the method further includes: recording the first identifier of the first port and the second identifier of the second controller carried in the first instruction in the third storage area; setting the first completion flag in the first storage area to a first value, wherein the first value is used to indicate that the first identifier of the first port and the second identifier of the second controller carried in the first instruction have been stored in the third storage area; After receiving the second instruction from the server, the method further includes: recording the second instruction carrying the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier in the third storage area; setting the second completion flag in the first storage area to a second value, wherein the second value is used to indicate that the first identifier of the first port, the second identifier of the second controller, the identifier of the i-th queue, the size of the i-th queue, the page relative pointer PRP address, and the allocation completion identifier have been stored in the third storage area; deleting the first value in the first completion flag in the first storage area, or replacing the first value in the first completion flag in the first storage area with other values, wherein the other value is any value other than the first value.

8. A device for allocating resources to a controller at a server, characterized in that: Applied to a first controller, the first controller is provided with a storage unit and a resource allocation unit, including: A receiving module, configured to receive a first instruction from a server, wherein the first instruction carries a first identifier of a first port and a second identifier of a second controller, the first port is connected to the second controller, the server includes a plurality of controllers, the plurality of controllers include the second controller, each of the controllers includes at least one queue, and each of the queues includes at least one command to be processed; a determination module, configured to determine an allocation state of the second controller under the first port according to the allocation information recorded in the mapping table of the storage unit, wherein the allocation information includes an identifier of the controller to which the allocation information has been allocated and an identifier of the port to which the allocated controller is connected; An allocation module is used to allocate a target processor to the second controller according to the allocation status of the second controller and the allocation status of each processor recorded in the storage unit, so that the target processor can process the pending commands in the queue of the second controller.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.