Thread management method, electronic device and storage medium
By creating partitions and threads in the operating system and scheduling user threads to allocate interaction queues, the problem of the inability of existing technologies to effectively utilize multi-cores is solved and the overall performance of NVMe-oF devices is improved.
Patent Information
- Application Number
- CN202210430175.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-04-22
AI Technical Summary
Existing thread scheduling methods cannot effectively utilize the multi-core advantages of the host, resulting in the overall performance of the NVMe-oF device not being fully utilized and making it difficult to improve system performance.
The operating system creates partitions according to the partition configuration, and creates physical threads and user threads in each core. The user thread creates the corresponding queue based on the queue creation request initiated by the operating system. The physical thread schedules the user thread and assigns interactions to each physical thread. Queues for hosts to interact with NVMe-oF devices.
It realizes the balanced distribution of threads of NVMe-oF devices to all cores of the host, maximizes the efficiency of utilizing the processing power of the host CPU core, and improves the overall performance of the NVMe-oF device.
Smart Images

Figure CN114816701B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a thread management method, electronic device and storage medium applied to an NVMe-oF device. Background Art
[0002] Currently, NVMe-oF (NVMe over Fabric) technology is developing rapidly, and many hosts use NVMe-oF as the protocol for connecting to storage devices. Hosts are also becoming more and more CPU-intensive. As the number of CPU cores increases, the CPU cores owned by hosts are also becoming larger and larger, far exceeding the processing capacity of NVMe-oF devices.
[0003] The existing thread scheduling method does not target a specific NVMe-oF target device. Therefore, when the host is connected to multiple NVMe-oF target devices, it is difficult to fully utilize the advantages of the host's multi-core to improve the overall performance of the system.
[0004] Therefore, there is an urgent need for a thread management method applied to NVMe-oF devices to improve the efficiency of utilizing the processing power of the host's CPU core and improve the overall performance of the NVMe-oF device to solve the above technical problems. Summary of the invention
[0005] In order to solve the deficiencies of the prior art, the main purpose of the present invention is to provide a thread management method, an electronic device and a storage medium applied to NVMe-oF devices to solve the above-mentioned technical problems of the prior art.
[0006] In order to achieve the above object, the present invention provides a thread management method in a first aspect, the method comprising:
[0007] The operating system creates partitions according to the partition configuration;
[0008] After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads;
[0009] The user thread creates a corresponding queue based on a queue creation request initiated by the operating system;
[0010] The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0011] In some embodiments, the partition includes at least a first recording module, a scheduler, and a physical thread;
[0012] The first recording module is used to record the core set occupied by the partition, the number of devices that have occupied the partition, and the statistical information of the partition;
[0013] The scheduler is used for scheduling the physical thread and the user thread.
[0014] In some embodiments, the partition includes at least a first recording module, a scheduler, and a physical thread;
[0015] The first recording module is used to record the core set occupied by the partition, the number of devices that have occupied the partition, and the statistical information of the partition;
[0016] The scheduler is used for scheduling the physical thread and the user thread.
[0017] In some embodiments, the queue creation request includes a management queue creation request and an interaction queue creation request, and the user thread creates a corresponding queue method based on the queue creation request initiated by the operating system, including:
[0018] The user thread creates a management queue based on a management queue creation request;
[0019] Query the maximum number of interactive queues and the maximum queue depth supported by the NVMe-oF device through the management queue;
[0020] After the query is completed, the user thread creates an interaction queue based on the interaction queue creation request.
[0021] In some embodiments, allocating a corresponding queue to each physical thread in the partition includes:
[0022] The management queue is correspondingly allocated to the first physical thread in the partition;
[0023] The interactive queue is correspondingly allocated to all the physical threads in the partition.
[0024] In some embodiments, the physical thread includes at least a second recording module, a user thread, and a poller;
[0025] The second recording module is used to record the core to which the physical thread is bound and the statistical information of the physical thread;
[0026] The poller is used to poll the events in the user thread and call the corresponding user thread when an event is polled.
[0027] In some embodiments, the user thread includes at least a received request, an identifier of the user thread, state information of the user thread, and a communication channel;
[0028] Wherein, the communication channel is used to communicate with the user thread.
[0029] In some embodiments, the physical thread polls events in the user thread through an epoll mechanism.
[0030] In a second aspect, the present application further provides an electronic device, the electronic device comprising:
[0031] one or more processors;
[0032] and a memory associated with the one or more processors, the memory being used to store program instructions, the program instructions when read and executed by the one or more processors performing the following operations:
[0033] The operating system creates partitions according to the partition configuration;
[0034] After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads;
[0035] The user thread creates a corresponding queue based on a queue creation request initiated by the operating system;
[0036] The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0037] In a third aspect, the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program enables a computer to perform the following operations:
[0038] The operating system creates partitions according to the partition configuration;
[0039] After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads;
[0040] The user thread creates a corresponding queue based on a queue creation request initiated by the operating system;
[0041] The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0042] The beneficial effects achieved by this application are:
[0043] The present application provides a thread management method for NVMe-oF devices, including an operating system creating a partition according to a partition configuration; after the operating system initiates a device connection request, it selects a suitable partition, creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads; the user thread creates a corresponding queue based on the queue creation request initiated by the operating system; the operating system schedules the user thread through the physical thread, and allocates a corresponding queue to each physical thread in the partition, so that the host can interact with the NVMe-oF device through the queue. By partitioning the CPU cores in the computer system, binding a physical thread to each core, scheduling the user thread through the physical thread, and creating a queue through the user thread, a corresponding interaction queue with the NVMe-oF device is allocated to each core in the partition; it can give full play to the advantages of the host's multi-CPU and multi-core, evenly distribute the threads of the NVMe-oF device to all cores of the host, and use the processing power of the host's CPU core with maximum efficiency, thereby improving the overall performance of the NVMe-oF device. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0045] Figure 1 It is a thread management architecture diagram provided in an embodiment of the present application;
[0046] Figure 2 This is a schematic diagram of a partition chain provided in an embodiment of the present application;
[0047] Figure 3 It is a schematic diagram of the partition structure provided in the embodiment of the present application;
[0048] Figure 4 It is a schematic diagram of the physical thread structure provided in an embodiment of the present application;
[0049] Figure 5 It is a user thread schematic diagram provided in an embodiment of the present application;
[0050] Figure 6 is a schematic diagram of a thread management method provided in an embodiment of the present application;
[0051] Figure 7 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0053] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like in the entire specification and claims should be interpreted as inclusive rather than exclusive or exhaustive; that is, the meaning of "including but not limited to".
[0054] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0055] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.
[0056] As described in the background technology, with the improvement of CPU technology, the number of CPU cores is increasing, and the computing power is also increasing. The maximum number of cores of a single CPU can reach 60, and the host generally adopts a multi-CPU architecture, so that the number of CPU cores of the entire host is very large. However, the processing power of an NVMe-oF device is limited. After actual testing, 4 CPU cores can fully run the performance of the device. Therefore, the present application proposes a thread management method applied to NVMe-oF devices to achieve balanced distribution of the threads of NVMe-oF devices to all cores of the host, maximize the efficiency of utilizing the processing power of the CPU core of the host, and improve the overall performance of the NVMe-oF device.
[0057] Embodiment 1
[0058] The present application embodiment provides a thread management architecture, specifically, Figure 1 As shown, the process of thread management of NVMe-oF devices using the thread management architecture provided by this application includes:
[0059] S1. The operating system initiates an NVMe-oF device link request and selects a suitable partition.
[0060] In order to match the processing power of NVMe-oF devices, this application divides the CPU core of the entire computer system into different partitions; the operating system creates partitions based on the partition configuration and divides the CPU cores; the partition configuration includes the number of partitions in the entire system and the set of occupied CPU cores in each partition. The above partition configuration is set by the user according to actual needs. Figure 2 As shown in the figure, in order to make the partitions created by the system evenly occupied by NVMe-oF devices, after the partitions are created, the partitions are added to the partition list and arranged from small to large or from large to small according to the number of devices occupying the partitions; each time the operating system initiates a device connection request and selects a partition, the partition with the smallest occupied device is given priority.
[0061] S2. Create a physical thread (pthread) and a user thread (ult).
[0062] A physical thread and a user thread are created for each core in the partition. After the physical thread is created, it is bound to the CPU core, that is, one CPU core corresponds to one physical thread; each physical thread can schedule multiple user threads.
[0063] The partition structure is as follows: Figure 3 As shown, it includes a first recording module, a scheduling machine (sm) and a physical thread; wherein the first recording module includes a core set (cpuset) for recording the occupied partition, the number of devices (devices) of the occupied partition and the statistical information (stats) of the partition; the device here refers to the NVMe-oF target device; the statistical information of the partition includes CPU utilization, etc., which is used to reflect the running status of the partition. The scheduling machine is used to schedule physical threads and user threads. The physical thread structure is as follows Figure 4 As shown, it includes a second recording module, a user thread, and a poller; the second recording module includes a function for recording the core (CPU) bound to the physical thread and the statistical information (stats) of the physical thread; wherein the statistical information of the physical thread includes performance statistics, etc.; the poller is used to poll the events in the user thread and call the corresponding user thread when an event is polled. Preferably, the physical thread uses the epoll mechanism to poll the time in the user thread. The epoll mechanism is an enhanced version of the multiplexed IO interface select / poll under Linux. It does not force the developer to re-prepare the set of file descriptors to be listened to before each waiting for an event, and there is no need to traverse the entire set of descriptors to be listened to when obtaining an event. The user thread structure is as follows Figure 5As shown, it includes a received request (request), an identifier of a user thread (id), state information of a user thread (state), and a communication channel (channel); the communication channel is used to communicate with the user thread, and generally one object corresponds to one channel, such as an interaction queue of an NVMe-oF target device.
[0064] S3. The user thread creates an administration queue (adminQP) and an interaction queue (IO QP) based on the administration queue creation request and the interaction queue creation request.
[0065] The operating system initiates a management queue creation request to the user thread to create a management queue. The user thread creates a management queue based on the management queue creation request. At this time, the physical thread polls the user thread through the poller. After polling the event of creating a management queue in the user thread, it schedules the user thread to correspond the user thread corresponding to the management queue to the first physical thread in the partition. After the management queue is created, the host queries the maximum number of interactive queues and the maximum queue depth supported by the NVMe-oFtarget device through the management queue. After the query is completed, the user thread creates an interactive queue less than the maximum number of interactive queues based on the interactive queue creation request initiated by the interactive operating system. The physical thread polls the event of creating an interactive queue in the user thread, schedules the user thread, and allocates a corresponding interactive queue of the NVMe-oF target device to each CPU core in the partition; the host interacts with the NVMe-oF target device through the above interactive queue.
[0066] Embodiment 2
[0067] Corresponding to the above embodiment, the present application provides a thread management method, such as Figure 6 As shown, the method includes:
[0068] 210. The operating system creates partitions according to the partition configuration;
[0069] The partition at least includes a first recording module, a scheduler and a physical thread;
[0070] The first recording module is used to record the core set occupied by the partition, the number of devices that have occupied the partition, and the statistical information of the partition;
[0071] The scheduler is used for scheduling the physical thread and the user thread.
[0072] 220. After initiating a device connection request, the operating system selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one physical thread calls at least one user thread;
[0073] After the operating system initiates a device connection request, selecting a suitable partition also includes:
[0074] 221. Add the partition to the partition link table;
[0075] 222. The operating system arranges and maintains the partitions according to the number of devices in the occupied partitions;
[0076] 223. After the operating system initiates a device connection request, it selects the partition with the smallest number of devices in the occupied partitions.
[0077] The physical thread at least includes a second recording module, a user thread, and a poller;
[0078] The second recording module is used to record the core to which the physical thread is bound and the statistical information of the physical thread;
[0079] The poller is used to poll the events in the user thread and call the corresponding user thread when an event is polled.
[0080] The user thread at least includes a received request, an identifier of the user thread, state information of the user thread, and a communication channel;
[0081] Wherein, the communication channel is used to communicate with the user thread.
[0082] The physical thread polls events in the user thread through the epoll mechanism.
[0083] 230. The user thread creates a corresponding queue based on the queue creation request initiated by the operating system;
[0084] The queue creation request includes a management queue creation request and an interaction queue creation request. The user thread creates a corresponding queue method based on the queue creation request initiated by the operating system, including:
[0085] 231. The user thread creates a management queue based on a management queue creation request;
[0086] 232. Query the maximum number of interactive queues and the maximum queue depth supported by the NVMe-oF device through the management queue;
[0087] 233. After the query is completed, the user thread creates an interaction queue based on the interaction queue creation request.
[0088] 240. The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0089] The allocating a corresponding queue to each physical thread in the partition includes:
[0090] 241. The management queue is correspondingly allocated to the first physical thread in the partition;
[0091] 242. The interaction queue is correspondingly allocated to all the physical threads in the partition.
[0092] Embodiment 3
[0093] Corresponding to the above-mentioned Embodiment 1 and Embodiment 2, an embodiment of the present application provides an electronic device, including:
[0094] One or more processors; and a memory associated with the one or more processors, the memory being used to store program instructions, the program instructions when read and executed by the one or more processors, performing the following operations:
[0095] The operating system creates partitions according to the partition configuration;
[0096] After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads;
[0097] The user thread creates a corresponding queue based on a queue creation request initiated by the operating system;
[0098] The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0099] in, Figure 7 The architecture of the electronic device is shown as an example, which may include a processor 710, a video display adapter 711, a disk drive 712, an input / output interface 713, a network interface 714, and a memory 720. The processor 710, the video display adapter 711, the disk drive 712, the input / output interface 713, the network interface 714, and the memory 720 may be communicatively connected via a bus 730.
[0100] Among them, the processor 710 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solution provided in this application.
[0101] The memory 720 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 720 can store an operating system 721 for controlling the execution of the electronic device 700, and a basic input and output system (BIOS) 722 for controlling the low-level operations of the electronic device 700. In addition, a web browser 723, a data storage management system 724, and an icon font processing system 725, etc. can also be stored. The above-mentioned icon font processing system 725 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided in the present application is implemented by software or firmware, the relevant program code is stored in the memory 720 and is called and executed by the processor 710.
[0102] The input / output interface 713 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0103] The network interface 714 is used to connect to a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0104] The bus 730 comprises a pathway for transmitting information between the various components of the device (eg, the processor 710, the video display adapter 711, the disk drive 712, the input / output interface 713, the network interface 714, and the memory 720).
[0105] In addition, the electronic device 700 can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.
[0106] It should be noted that, although the above device only shows a processor 710, a video display adapter 711, a disk drive 712, an input / output interface 713, a network interface 714, a memory 720, a bus 730, etc., in the specific implementation process, the device may also include other components necessary for normal execution. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.
[0107] Embodiment 5
[0108] Corresponding to all the above embodiments, the embodiments of the present application further provide a computer-readable storage medium, characterized in that it stores a computer program, and the computer program enables the computer to operate as follows:
[0109] The operating system creates partitions according to the partition configuration;
[0110] After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads;
[0111] The user thread creates a corresponding queue based on a queue creation request initiated by the operating system;
[0112] The operating system schedules the user thread through the physical thread and allocates a corresponding queue to each physical thread in the partition so that the host interacts with the NVMe-oF device through the queue.
[0113] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a cloud service end, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0114] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0115] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A thread management method applied to NVMe-oF devices, characterized in that: The method comprises: The operating system creates partitions according to the partition configuration; After the operating system initiates a device connection request, it selects a suitable partition, and creates a physical thread and a user thread for each core in the partition, wherein one of the physical threads calls at least one of the user threads; The user thread creates a corresponding queue based on a queue creation request initiated by the operating system; The operating system schedules the user thread through the physical thread and allocates the corresponding queue to each core in the partition, so that the host interacts with the NVMe-oF device through the queue; The partition at least includes a first recording module, a scheduler and a physical thread; The first recording module is used to record the core set occupied by the partition, the number of devices that have occupied the partition, and the statistical information of the partition; The scheduler is used to schedule the physical thread and the user thread; The queue creation request includes a management queue creation request and an interaction queue creation request, and the user thread creates a corresponding queue based on the queue creation request initiated by the operating system, including: The user thread creates a management queue based on a management queue creation request; Query the maximum number of interactive queues and the maximum queue depth supported by the NVMe-oF device through the management queue; After the query is completed, the user thread creates an interaction queue based on the interaction queue creation request.
2. The method according to claim 1, characterized in that: After the operating system initiates a device connection request, selecting a suitable partition also includes: Adding the partition to the partition link table; The operating system arranges and maintains the partitions according to the number of devices in the occupied partitions; After the operating system initiates a device connection request, it selects the partition with the smallest number of devices already occupied.
3. The method according to claim 1, characterized in that The allocating a corresponding queue to each physical thread in the partition includes: The management queue is correspondingly allocated to the first physical thread in the partition; The interactive queue is correspondingly allocated to all the physical threads in the partition.
4. The method according to any one of claims 1 to 3, characterized in that: The physical thread at least includes a second recording module, a user thread, and a poller; The second recording module is used to record the core to which the physical thread is bound and the statistical information of the physical thread; The poller is used to poll the events in the user thread and call the corresponding user thread when an event is polled.
5. The method according to any one of claims 1 to 3, characterized in that: The user thread at least includes a received request, an identifier of the user thread, state information of the user thread, and a communication channel; Wherein, the communication channel is used to communicate with the user thread.
6. The method according to claim 5, characterized in that The physical thread polls events in the user thread through the epoll mechanism.
7. An electronic device, characterized in that: The electronic device comprises: one or more processors; And a memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, they execute any method described in claims 1-6.
8. A computer-readable storage medium, characterized in that: The computer program stores a computer program, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 6.
