Equipment driving method and device, computer equipment and storage medium
By obtaining the devices to be driven during the server startup process and allocating memory resources based on the allocation thread group, parallel device drivers are implemented, solving the problem of too long boot time caused by the initialization of multiple external devices, and improving the boot efficiency and user experience.
Patent Information
- Application Number
- CN202411517167.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2024-11-29
AI Technical Summary
During the server startup process, the initialization of multiple external devices causes too long boot time, affecting customer experience and efficiency.
By obtaining the devices to be driven during the server startup, allocating memory resources to each device based on the allocation thread group, and executing device drivers in parallel, multi-threading technology is used to optimize the device initialization sequence and resource allocation.
It significantly shortens the server's boot time, improves the boot efficiency and user experience, and avoids resource conflicts and data inconsistencies.
Smart Images

Figure CN119045905A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a device driving method, an apparatus, a computer device and a storage medium. Background Art
[0002] Servers generally have powerful CPU processing capabilities. According to actual usage requirements, they are equipped with a large number of external devices with PCIE interfaces, such as network cards and graphics cards. During the server startup process, the BIOS (Basic Input / Output System) can be used to implement the self-test and initialization functions of external devices. Here, if the external device does not meet the basic conditions for computer operation, the motherboard will issue an alarm, indicating that there is a problem with the hardware and the server cannot be started.
[0003] In related BIOS solutions, most of them are developed based on process-oriented languages (such as C language). For external devices on the server equipped with PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) interface, such as network cards, sound cards and other devices, single linear serial access initialization memory and other operations can be used to initialize the external devices.
[0004] However, since the relevant BIOS operating programs mostly adopt a single-threaded process-oriented implementation method, they usually execute the drivers of various external devices in serial. If the driver trial time of a single external device is long, the overall boot time of the server will be prolonged. Especially when the number of external devices is large, the server boot time can reach 20-30 minutes, seriously affecting the customer experience and low boot efficiency. Summary of the invention
[0005] In view of this, the present invention provides a device driving method, apparatus, computer equipment and storage medium to solve the problem that when there are a large number of external devices on a server, the long boot time seriously affects the customer experience.
[0006] In a first aspect, the present invention provides a device driving method, the method comprising: During the startup of the target server, each to-be-driven device corresponding to the target server is obtained, and a device queue is determined based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server; Based on the allocation thread group, memory resources are allocated in the target server for each device to be driven; Each device to be driven is driven according to the memory resources.
[0007] In an optional implementation, determining a device queue based on each device to be driven includes: When the target server includes multiple processors, traverse the data interface corresponding to the target processor currently driven to obtain an address identifier, wherein the address identifier is used to indicate a bus address allocated to the device to be driven connected to the data interface; Based on the bus address, the device queue is determined.
[0008] In the embodiment of the present disclosure, a device queue can be determined based on the device to be driven corresponding to the target server currently driven, so as to allocate memory resources to each device to be driven based on the device queue, thereby providing a technical basis for executing the driving of each device to be driven in parallel.
[0009] In an optional embodiment, the method further includes: After the devices to be driven in the device queue corresponding to the target processor are driven, the devices to be driven corresponding to the next processor are initialized in the multiple processors based on the preset initialization order until the devices to be driven corresponding to all processors of the target server are driven completely.
[0010] In the embodiment of the present disclosure, a device queue can be determined based on the device to be driven corresponding to the target server currently driven, so as to allocate memory resources to each device to be driven based on the device queue, thereby providing a technical basis for executing the driving of each device to be driven in parallel.
[0011] In an optional implementation, determining a device queue based on each device to be driven further includes: Estimate the running time of each device to be driven, and sort the devices to be driven in ascending or descending order of running time; The device queue of the device to be driven is determined according to the sorting result.
[0012] In an embodiment of the present invention, due to the differences in hardware initialization time, device type and complexity, driver loading order and system resource allocation among different types of devices to be driven, there may be differences in the running time of different types of devices to be driven. Therefore, the devices to be driven can be sorted in increasing or decreasing order of running time to reasonably allocate the initialization time of the devices to be driven, thereby greatly improving the device initialization efficiency and shortening the startup time of the target server.
[0013] In an optional implementation, based on the allocation thread group, memory resources are allocated to each device to be driven in the target server, including: Based on the device type of the device to be driven, determining the configuration space pre-allocated for the device type in the target server; Based on the allocation thread group, memory resources are allocated to the device to be driven according to the configuration space.
[0014] In the disclosed embodiment, memory resources can be allocated to each device to be driven in the target server based on the allocation thread group, so as to rationally utilize the processor and memory resources, so that each device to be driven can efficiently obtain the required resources, maximize the use of the processor's analysis and processing capabilities, and maximize the use of memory resources to improve the boot efficiency.
[0015] In an optional embodiment, the method further includes: Obtain the device type of each device to be driven corresponding to the target server; A corresponding configuration space is set for the device type in the target server, and an association relationship between the configuration space and the device type is established.
[0016] In the disclosed embodiment, memory resources can be allocated to each device to be driven in the target server based on the allocation thread group, so as to rationally utilize the processor and memory resources, so that each device to be driven can efficiently obtain the required resources, maximize the use of the processor's analysis and processing capabilities, and maximize the use of memory resources to improve the boot efficiency.
[0017] In an optional embodiment, the method further includes: In the case where a newly added external device corresponding to the target server is detected, a corresponding configuration space is allocated to a device type of the newly added external device based on the free configuration space of the target server.
[0018] In the disclosed embodiment, memory resources can be allocated to each device to be driven in the target server based on the allocation thread group, so as to rationally utilize the processor and memory resources, so that each device to be driven can efficiently obtain the required resources, maximize the use of the processor's analysis and processing capabilities, and maximize the use of memory resources to improve the boot efficiency.
[0019] In an optional embodiment, the method further includes: Based on a preset ratio value of the number of devices to be driven, the number of allocation threads in the allocation thread group is determined; or the number of allocation threads in the allocation thread group is determined to be a preset number of threads.
[0020] In the embodiments of the present disclosure, considering that different types of servers or the number of external devices connected to the same server in different usage scenarios may vary greatly, therefore, in order to ensure the initialization efficiency of the device to be driven, the number of allocated threads in the allocation thread group can be determined according to the number of devices to be driven connected to the target server, thereby avoiding the increase of CPU overhead due to a large number of threads and the impact of a small number of threads on device driving efficiency while avoiding the increase of CPU overhead due to a large number of threads.
[0021] In an optional embodiment, the method further includes: Based on any allocation thread in the allocation thread group, a target thread is established, wherein the target thread is used to process an address allocation request of the device to be driven; In response to the address allocation request, a bus address is allocated to the device to be driven based on the target thread to obtain an address identifier.
[0022] In an embodiment of the present invention, a semaphore can be set in the device queue, and combined with multi-threading technology, synchronization and efficient processing between multiple allocation threads can be achieved, which can not only avoid resource conflicts and data inconsistency problems, but also improve the processing efficiency of allocation tasks and the response speed of the system.
[0023] In an optional embodiment, the method further includes: Set up semaphores for device queues; When allocating memory resources to the devices to be driven in the device queue based on the allocation threads in the allocation thread group, the signal device is set to a first state, and after the allocation is completed, the signal device is set to a second state, wherein the first state is used to indicate that memory is allocated to the current device to be driven, and the second state is used to indicate that memory is allocated to the next device to be driven in the device queue after the current device to be driven.
[0024] In an embodiment of the present invention, a semaphore can be set in the device queue, and combined with multi-threading technology, synchronization and efficient processing between multiple allocation threads can be achieved, which can not only avoid resource conflicts and data inconsistency problems, but also improve the processing efficiency of allocation tasks and the response speed of the system.
[0025] In an optional implementation, driving each device to be driven according to memory resources includes: Based on the memory resources, the device to be driven is driven by the allocation thread corresponding to the device to be driven until the device queue is empty.
[0026] In an embodiment of the present invention, a semaphore can be set in the device queue, and combined with multi-threading technology, synchronization and efficient processing between multiple allocation threads can be achieved, which can not only avoid resource conflicts and data inconsistency problems, but also improve the processing efficiency of allocation tasks and the response speed of the system.
[0027] In a second aspect, the present invention provides a device driving apparatus, the apparatus comprising: A determination module, used for obtaining each to-be-driven device corresponding to the target server during the startup process of the target server, and determining a device queue based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server; An allocation module, used for allocating memory resources to each device to be driven in a target server based on an allocation thread group; The driver module is used to drive each device to be driven according to the memory resources.
[0028] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the device driving method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0029] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the device driving method of the first aspect or any corresponding embodiment thereof.
[0030] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the device driving method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 is a flow chart of a device driving method according to an embodiment of the present invention; Figure 2 is a flow chart of another method according to an embodiment of the present invention; Figure 3 is a flow chart of another device driving method according to an embodiment of the present invention; Figure 4 is a schematic diagram of a memory resource allocation process according to an embodiment of the present invention; Figure 5 is a flow chart of another device driving method according to an embodiment of the present invention; Figure 6 is a structural block diagram of a device driver according to an embodiment of the present invention; Figure 7 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0034] In conjunction with the application scenario on which the execution of the device driver method depends, the application scenario is described here.
[0035] Servers generally have powerful CPU processing capabilities. According to actual usage requirements, they are equipped with a large number of external devices with PCIE interfaces, such as network cards and graphics cards. During the server startup process, the BIOS (Basic Input / Output System) can be used to implement the self-test and initialization functions of external devices. Here, if the external device does not meet the basic conditions for computer operation, the motherboard will issue an alarm, indicating that there is a problem with the hardware and the server cannot be started.
[0036] In related BIOS solutions, most of them are developed based on process-oriented languages (such as C language). For external devices on the server equipped with PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) interface, such as network cards, sound cards and other devices, single linear serial access initialization memory and other operations can be used to initialize the external devices.
[0037] However, since the relevant BIOS operating programs mostly adopt a single-threaded process-oriented implementation method, they usually execute the drivers of various external devices in serial. If the driver trial time of a single external device is long, the overall boot time of the server will be prolonged. Especially when the number of external devices is large, the server boot time can reach 20-30 minutes, seriously affecting the customer experience and low boot efficiency.
[0038] Based on this, an embodiment of the present invention provides a device driving method. First, during the startup of the target server, each device to be driven corresponding to the target server can be obtained, and a device queue can be determined based on each device to be driven, wherein the device to be driven is an external device carried by the target server. Next, based on the allocation thread group, memory resources can be allocated to each device to be driven in the target server, and each device to be driven can be initialized based on the memory resources to meet the startup conditions of the target server, thereby realizing a device driving method of executing the driver of the external device in multiple threads by allocating the thread group, reducing the startup time of the server, thereby improving the startup efficiency and user experience.
[0039] According to an embodiment of the present invention, a device driver method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] In this embodiment, a device driving method is provided, which can be used for the above server. Figure 1 is a flow chart of a device driving method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps: Step S101 , during the startup of the target server, each to-be-driven device corresponding to the target server is obtained, and a device queue is determined based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server.
[0041] In an embodiment of the present invention, the target server may be a server equipped with a multi-core high-performance processor (hereinafter referred to as CPU), and the device to be driven may be connected to the target server through the PCIE interface and run. Here, the device to be driven may include external devices such as a network card and a graphics card.
[0042] As can be seen from the above, during the startup of the target server, the external devices installed need to be driven. Therefore, it is necessary to determine the device queue based on the various devices to be driven connected to the target server, so as to allocate the devices to be processed in the device queue to the corresponding allocation thread for driving. Here, the memory resources may include MMIO (Memory-Mapped I / O) resources.
[0043] Step S102: allocating memory resources to each device to be driven in the target server based on the allocation thread group.
[0044] In an embodiment of the present invention, the allocation thread group includes multiple allocation threads, and the allocation threads can be used to drive the devices allocated to be driven. Here, the resource allocation of each processing module can be comprehensively scheduled, so as to more reasonably utilize the memory resources of the target server.
[0045] Specifically, in response to the memory application request of the device to be driven, the task manager in the target server can execute a corresponding allocation algorithm to allocate the memory application request to different allocation threads for execution, so that the allocation thread allocates memory resources to the device to be driven according to a pre-set resource allocation strategy to execute the driving of the memory resources to be allocated.
[0046] In the embodiment of the present invention, C++ language can be used instead of C language to develop the BIOS solution, so as to support multi-threading and object-oriented development at a lower cost, and introduce the concept of object into BIOS development. It also supports data structures such as structures and unions, so that the EDKII library can be encapsulated as a static library for use. C++, like C language, does not require additional underlying libraries as support. At the same time, C++ supports cross-platform development and can process SMI (System Management Interrupt) and NMI (Non-Maskable Interrupt) under Window and Linux systems.
[0047] On this basis, in the BIOS solution, we can develop and allocate thread modules (that is, objects) to replace the single-threaded processing mode supported only in related solutions. This development method can only be repeated in different places of the same scenario, which improves the reusability and encapsulation of the solution, and at the same time improves the convenience of program debugging.
[0048] At the same time, by using object-oriented development languages, the object-oriented features of encapsulation, inheritance, and reusability can be applied to the BIOS field, reducing the difficulty of expanding BIOS code functions, truly achieving high clustering and low coupling of BIOS codes, and saving the overhead of duplicate code.
[0049] Step S103: driving each of the devices to be driven according to the memory resources.
[0050] In the embodiment of the present invention, in the preset resource allocation strategy, different memory resource partitions can be set for different devices to be driven, so that there is no influence between different devices to be driven when driving. Therefore, the present invention can execute the driving of the devices to be driven in parallel, thereby improving the driving efficiency.
[0051] It can be known from the above description that in the embodiment of the present invention, first, during the startup of the target server, each device to be driven corresponding to the target server can be obtained, and a device queue can be determined based on each device to be driven, wherein the device to be driven is an external device mounted on the target server. Next, based on the allocation thread group, memory resources can be allocated to each device to be driven in the target server, and each device to be driven can be initialized based on the memory resources to meet the startup conditions of the target server, thereby realizing a device driving method of multi-threaded execution of the driver of the external device by allocating the thread group, reducing the startup time of the server, and thereby improving the startup efficiency and user experience.
[0052] In this embodiment, another device driving method is provided, which can be used for the above server. Figure 2 is a flow chart of another device driving method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps: Step S201 , during the startup of the target server, each to-be-driven device corresponding to the target server is obtained, and a device queue is determined based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server.
[0053] Specifically, the above step S201 includes: Step S2011, when the target server includes multiple processors, traverse the data interface corresponding to the target processor currently driven to obtain an address identifier, wherein the address identifier is used to indicate a bus address allocated to the device to be driven connected to the data interface.
[0054] Step S2012, determining the device queue based on the bus address.
[0055] In the embodiment of the present invention, it can be seen from the above that the target server can be a server configured with a multi-core high-performance CPU. Therefore, when initializing the device to be driven, the device to be driven corresponding to each CPU in the target server can be driven in turn until all the devices to be driven corresponding to all CPUs are driven.
[0056] In some optional implementations, the above step S201 further includes: After the devices to be driven in the device queue corresponding to the target processor are driven, the devices to be driven corresponding to the next processor are initialized in the multiple processors based on the preset initialization order until the devices to be driven corresponding to all processors of the target server are driven completely.
[0057] In an embodiment of the present invention, a CPU queue of the target server can be established. For example, the CPU queue may include CPU0, CPU1, CPU2, ..., CPUn, and the devices to be driven are driven for each CPU in turn according to the CPU queue until the CPU queue is empty. In this case, it is considered that the devices to be driven corresponding to all processors are driven.
[0058] When determining the device queue corresponding to the current CPU, the data interface corresponding to the CPU can be traversed. For example, when the data interface includes PE0-PE5, the data interface can be traversed in the order of PE0-PE5 to obtain the address identifier of the device to be driven connected to each data interface. Here, the address identifier can be the Bus number corresponding to the device to be driven.
[0059] Step S202: Based on the allocation thread group, memory resources are allocated to each device to be driven in the target server. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0060] Step S203: driving each of the devices to be driven according to the memory resources. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0061] In the embodiment of the present disclosure, a device queue can be determined based on the device to be driven corresponding to the target server currently driven, so as to allocate memory resources to each device to be driven based on the device queue, thereby providing a technical basis for executing the driving of each device to be driven in parallel.
[0062] In some optional implementations, the above step S101 further includes: Step S11 , estimating the operating time of each device to be driven, and sorting the devices to be driven in ascending or descending order of the operating time.
[0063] Step S12: determining a device queue of devices to be driven according to the sorting result.
[0064] In the embodiments of the present disclosure, due to the differences in hardware initialization time, device type and complexity, driver loading order, and system resource allocation among different types of devices to be driven, there may be differences in the running time of different types of devices to be driven. Therefore, the devices to be driven can be sorted in increasing or decreasing order of running time to reasonably allocate the initialization time of the devices to be driven.
[0065] For example, the driver of some devices to be driven depends on the driver of other devices. The dependent driver must be loaded first to initialize the device to be driven normally. Then the running time of the device to be driven corresponding to the driver is earlier than that of the device to be driven.
[0066] Therefore, the devices to be driven can be sorted in the order of increasing row time, so as to determine the device queue according to the sorting result, and the devices to be driven in the device queue are allocated according to the first-in-first-out method, so as to ensure that the devices with earlier running time can be driven first. Alternatively, the devices to be driven can be sorted in the order of decreasing row time, so as to determine the device queue according to the sorting result, and the devices to be driven in the device queue are allocated according to the first-in-last-out method, so as to ensure that the devices with earlier running time can be driven first.
[0067] In an embodiment of the present invention, due to the differences in hardware initialization time, device type and complexity, driver loading order and system resource allocation among different types of devices to be driven, there may be differences in the running time of different types of devices to be driven. Therefore, the devices to be driven can be sorted in increasing or decreasing order of running time to reasonably allocate the initialization time of the devices to be driven, thereby greatly improving the device initialization efficiency and shortening the startup time of the target server.
[0068] In this embodiment, another device driving method is provided, which can be used for the above server. Figure 3 is a flow chart of another device driving method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps: Step S301: During the startup of the target server, each to-be-driven device corresponding to the target server is obtained, and a device queue is determined based on each to-be-driven device, wherein the to-be-driven device is an external device installed on the target server. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0069] Step S302: Allocate memory resources to each device to be driven in the target server based on the allocation thread group.
[0070] Specifically, the above step S302 includes: Step S3021: Based on the device type of the device to be driven, determine the configuration space pre-allocated for the device type in the target server.
[0071] Step S3022: Allocate memory resources to the device to be driven according to the configuration space based on the allocation thread group to obtain an allocation result.
[0072] In an embodiment of the present invention, a memory resource allocation strategy may be pre-set to execute a corresponding allocation strategy on the acquired allocation task of the device to be driven through an allocation thread. Here, the step of pre-setting the allocation strategy includes: In step a1, the device type of each device to be driven corresponding to the target server may be obtained.
[0073] Step a2: setting a corresponding configuration space for the device type in the target server, and establishing an association relationship between the configuration space and the device type.
[0074] In the embodiment of the present invention, the memory resources required by the device to be driven during initialization and operation can be estimated according to the device type. For example, a graphics card has a large memory requirement, while an audio device has a small memory requirement. Therefore, more configuration space can be allocated to the graphics card.
[0075] After setting the corresponding configuration space for the device type, an association relationship between the configuration space and the device type can be established so that the allocation thread can directly find the corresponding configuration space according to the association relationship when driving the device to be driven, so as to allocate memory resources in the configuration space.
[0076] In addition, when a newly added external device corresponding to the target server is detected, a corresponding configuration space may be allocated to the device type of the newly added external device based on the free configuration space of the target server.
[0077] Specifically, when a new external device is detected, the device type of the external device can be obtained and whether the device type is a new device type can be determined. If not, the currently unallocated free configuration space in the target server can be queried and the corresponding configuration space can be allocated to the device type of the new external device in the free configuration space.
[0078] In an embodiment of the present invention, when executing a corresponding allocation strategy on the acquired allocation task of the device to be driven through the allocation thread, the device to be driven can be allocated to different allocation threads in the thread management module through the corresponding allocation algorithm of the task manager, so as to comprehensively schedule the memory resource allocation through the thread management module.
[0079] Here, dynamic memory resource allocation can be achieved through the TLSF (Two-Level Segregated Fit) memory allocation method. Figure 4 The figure shows a schematic diagram of the memory resource allocation process, in which TLSF can achieve fast memory allocation and release through a two-level linked list structure, reduce fragmentation, and improve memory utilization.
[0080] Specifically, the memory pool can be divided into multiple areas, namely the above configuration space, according to the priority and importance of the devices to be processed. Devices with high priority can obtain faster memory allocation response time. At the same time, a cache mechanism can be introduced to cache frequently used memory blocks to reduce the overhead of repeated allocation and release.
[0081] For example, you can first initialize the memory pool. When the BIOS starts, call the tlsf_create or tlsf_add_pool function to initialize the TLSF memory pool, ensuring that the memory pool covers all available physical memory areas. Then, you can dynamically allocate memory: when you need to allocate resources for the device to be driven, call the tlsf_malloc function. For example, allocate 256 bytes of memory for a device to be driven. When the device to be driven no longer needs certain resources, you can call the tlsf_free function to release the corresponding memory block.
[0082] Step S303: driving each of the devices to be driven according to the memory resources. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0083] In the disclosed embodiment, memory resources can be allocated to each device to be driven in the target server based on the allocation thread group, so as to rationally utilize the CPU and memory resources, so that each device to be driven can efficiently obtain the required resources, maximize the use of the CPU's analysis and processing capabilities, and maximize the use of memory resources to improve the BIOS boot efficiency.
[0084] In some optional embodiments, the above Figure 1 The corresponding embodiments also include: Based on a preset ratio value of the number of devices to be driven, the number of allocation threads in the allocation thread group is determined; or the number of allocation threads in the allocation thread group is determined to be a preset number of threads.
[0085] In the embodiment of the present disclosure, considering that different types of servers or the number of external devices connected to the same server in different usage scenarios may vary greatly, therefore, in order to ensure the initialization efficiency of the devices to be driven, the number of allocated threads in the allocation thread group can be determined according to the number of devices to be driven connected to the target server.
[0086] For example, for low-density rack servers, EOR / MOR access is usually used in low-density server cabinets. In this scenario, the server has fewer access devices and relatively simple maintenance, but cable maintenance may be more complicated. For example, a 2U rack server may be configured with a fixed GE / 10GE network card and may be equipped with an FC (Fibre Channel) network card for connecting the business network port and the storage network port. In addition, for specific access switches, in certain specific access solutions, such as using CE6870-24S6CQ-EI as an access switch, the switch has 24 10GE Ethernet optical interfaces and 6 40GE / 100GE Ethernet optical interfaces, which means that the server can support up to 30 different peripherals or network connections.
[0087] Here, when the number of servers to be allocated exceeds the number threshold, the number of allocated threads in the allocation thread group can be determined based on a preset ratio value of the number of devices to be driven, wherein the preset ratio value can be 1 / 3, thereby avoiding setting a large number of threads to increase CPU overhead. In addition, if the number of servers to be allocated does not exceed the number threshold, the number of allocated threads in the allocation thread group can be determined as a preset number of threads, for example, the preset number of threads can be 5, thereby avoiding a small number of threads affecting device driving efficiency.
[0088] In the embodiments of the present disclosure, considering that different types of servers or the number of external devices connected to the same server in different usage scenarios may vary greatly, therefore, in order to ensure the initialization efficiency of the device to be driven, the number of allocated threads in the allocation thread group can be determined according to the number of devices to be driven connected to the target server, thereby avoiding the increase of CPU overhead due to a large number of threads and the impact of a small number of threads on device driving efficiency while avoiding the increase of CPU overhead due to a large number of threads.
[0089] In some optional embodiments, the above Figure 1 The corresponding embodiments also include: Step S21: establishing a target thread based on any allocation thread in the allocation thread group, wherein the target thread is used to process an address allocation request of the device to be driven.
[0090] Step S22, in response to the address allocation request, allocate a bus address for the device to be driven based on the target thread to obtain an address identifier.
[0091] In an embodiment of the present disclosure, an address allocation request may include a Bus request, and a target thread may be established to process the address allocation request. For example, any allocation thread in the allocation thread group may be determined as a target thread to execute the Bus request of the device to be driven, so as to ensure that the initialization work of these devices is performed in a separate execution environment to avoid mutual interference.
[0092] Specifically, first, during the system initialization phase, an independent thread can be created to handle the Bus number assignment task. For the device to be driven that needs to be assigned a Bus number, a suitable Bus number is assigned to it based on the system's resource conditions and the device's priority, etc. At the same time, the status information of the device to be driven is updated to reflect its new Bus number.
[0093] It should be understood that in the process of allocating bus numbers, attention should be paid to resource synchronization issues with other threads in the allocated thread group. Synchronization mechanisms such as mutex locks and conditional variables can be used to ensure that threads can safely access shared resources. When all devices that need to be allocated bus numbers have been processed, the independent thread can end its operation and release the resources it occupies.
[0094] In addition, in the process of allocating Bus numbers, various abnormal situations (such as equipment failure, resource conflict, etc.) may be encountered. Therefore, a complete exception handling mechanism can be designed to ensure the stability and reliability of the system. The specific exception handling mechanism is based on the setting method that can be implemented, and will not be repeated in the present invention.
[0095] In some optional embodiments, the above Figure 1 The corresponding embodiments also include: Step S31, setting a signal device for the device queue.
[0096] Step S32, when allocating memory resources to the device to be driven in the device queue based on the allocation thread in the allocation thread group, the signal device is set to the first state, and after the allocation is completed, the signal device is set to the second state, wherein the first state is used to indicate memory allocation for the current device to be driven, and the second state is used to indicate memory allocation for the next device to be driven in the device queue after the current device to be driven.
[0097] In the embodiment of the present disclosure, the signal device may be a signal light, the first state may be 1, and the second state may be 0. The allocation thread in the allocation thread group may monitor the state of the signal device in real time, and thus obtain the allocation task of the device to be driven in the device queue according to the monitoring result.
[0098] Specifically, you can first initialize the semaphore, that is, you need to create a semaphore variable and set its initial value to 0, which means that no assigned task is currently being executed. When a dispatcher starts processing an assigned task, it first checks the state of the semaphore. If the value of the semaphore is 0, the dispatcher will set the value of the semaphore to 1 and take out an assigned task from the device queue for processing, which means that the device has started to be processed and other threads need to wait.
[0099] When the semaphore state is 1, other device threads in the allocation thread group can try to acquire the device and check the state of the semaphore. If the semaphore value is 1, these allocation threads will wait until the semaphore value becomes 0, thereby ensuring that only one thread is processing the device at the same time, avoiding resource conflicts and data inconsistency problems. After the current allocation thread completes processing the allocation task, the semaphore value can be reset to 0, which means that the allocation task has been processed and other threads can start to acquire the allocation task for processing.
[0100] In some optional implementations, the above step S101 further includes: Based on the memory resources, the device to be driven is driven by the allocation thread corresponding to the device to be driven until the device queue is empty.
[0101] In an embodiment of the present invention, after the current allocation thread executes the allocation task to drive the device to be driven, the state of the above-mentioned signal light can be obtained, and when the state of the signal light is 0, the Bus request of the device to be driven in the device list is processed based on the above-mentioned target thread, and the corresponding allocation task is executed through the idle allocation thread until the device queue is empty.
[0102] Then, it is possible to monitor in real time whether all the allocated threads in the allocated thread group are in an idle state. If so, it is determined that all the devices to be driven corresponding to the current CPU have been driven, and the driving task of the next CPU is obtained and executed in the above CPU queue until the CPU queue is empty, and it is determined that all the devices to be driven have been driven.
[0103] In an embodiment of the present invention, a semaphore can be set in the device queue, and combined with multi-threading technology, synchronization and efficient processing between multiple allocation threads can be achieved, which can not only avoid resource conflicts and data inconsistency problems, but also improve the processing efficiency of allocation tasks and the response speed of the system.
[0104] In this embodiment, another device driving method is provided, which can be used for the above server. Figure 5 is a flow chart of another device driving method according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps: Step S501: establishing a driving task based on the CPU in the target server, and establishing a CPU queue according to the driving task.
[0105] Step S502, taking out the driving task from the CPU queue.
[0106] Step S503: establishing a device queue based on the to-be-driven device corresponding to the driving task.
[0107] Step S504: obtaining the signal device status of the device queue based on the allocated thread group.
[0108] Step S505, determining whether the signal device corresponding to the device queue is in the first state. If yes, executing step S504, if no, executing step S506.
[0109] Step S506: acquiring the sub-driving task of the device to be driven in the device queue based on the allocation thread in the allocation thread group.
[0110] Step S507: Based on the sub-driver task, a memory resource request is sent to the CPU and the driver is loaded.
[0111] Step S508: Run the driver to initialize the device to be driven.
[0112] Step S509, determine whether the device queue is empty, if so, execute step S510, if not, execute step S504.
[0113] Step S510, determining whether all allocation threads in the allocation thread group are idle, if so, executing step S502, if not, executing step S511.
[0114] Step S511, wait.
[0115] In the embodiment of the present invention, the specific process of executing the device driving method of the target server is as described above. Figure 1 The corresponding embodiments are described in detail and will not be repeated here.
[0116] In summary, in an embodiment of the present invention, first, during the startup of the target server, each device to be driven corresponding to the target server can be obtained, and a device queue can be determined based on each device to be driven, wherein the device to be driven is an external device mounted on the target server. Next, based on the allocation thread group, memory resources can be allocated to each device to be driven in the target server, and each device to be driven can be initialized based on the memory resources to meet the startup conditions of the target server, thereby realizing a device driving method of executing the driver of the external device in multiple threads by allocating the thread group, reducing the startup time of the server, and thereby improving the startup efficiency and user experience.
[0117] In this embodiment, a device driver is also provided, which 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.
[0118] This embodiment provides a device driver, such as Figure 6 As shown, including: The determination module 601 is used to obtain each to-be-driven device corresponding to the target server during the startup process of the target server, and determine a device queue based on each to-be-driven device, wherein the to-be-driven device is an external device installed in the target server; An allocation module 602 is used to allocate memory resources to each device to be driven in the target server based on the allocation thread group; The driving module 603 is used to drive each device to be driven according to the memory resources.
[0119] In some optional implementations, the determination module 601 is further configured to: When the target server includes multiple processors, traverse the data interface corresponding to the target processor currently driven to obtain an address identifier, wherein the address identifier is used to indicate a bus address allocated to the device to be driven connected to the data interface; Based on the bus address, the device queue is determined.
[0120] In some optional implementations, the determination module 601 is further configured to: After the devices to be driven in the device queue corresponding to the target processor are driven, the devices to be driven corresponding to the next processor are initialized in the multiple processors based on the preset initialization order until the devices to be driven corresponding to all processors of the target server are driven completely.
[0121] In some optional implementations, the determination module 601 is further configured to: Estimate the running time of each device to be driven, and sort the devices to be driven in ascending or descending order of running time; The device queue of the device to be driven is determined according to the sorting result.
[0122] In some optional implementations, the allocation module 602 is further configured to: Based on the device type of the device to be driven, determining the configuration space pre-allocated for the device type in the target server; Based on the allocation thread group, memory resources are allocated to the device to be driven according to the configuration space.
[0123] In some optional implementations, the allocation module 602 is further configured to: Obtain the device type of each device to be driven corresponding to the target server; A corresponding configuration space is set for the device type in the target server, and an association relationship between the configuration space and the device type is established.
[0124] In some optional implementations, the allocation module 602 is further configured to: In the case where a newly added external device corresponding to the target server is detected, a corresponding configuration space is allocated to a device type of the newly added external device based on the free configuration space of the target server.
[0125] In some optional embodiments, the device is also used for: Determine the number of allocation threads in the allocation thread group based on a preset ratio value of the number of devices to be driven; or The number of allocation threads in the allocation thread group is determined to be the preset number of threads.
[0126] In some optional embodiments, the device is also used for: Establishing a target thread, wherein the target thread is used to process an address allocation request of the device to be driven; In response to the address allocation request, a bus address is allocated to the device to be driven based on the target thread to obtain an address identifier.
[0127] In some optional embodiments, the device is also used for: Set up semaphores for device queues; When allocating memory resources to the devices to be driven in the device queue based on the allocation threads in the allocation thread group, the signal device is set to a first state, and after the allocation is completed, the signal device is set to a second state, wherein the first state is used to indicate that memory is allocated to the current device to be driven, and the second state is used to indicate that memory is allocated to the next device to be driven in the device queue after the current device to be driven.
[0128] In some optional implementations, the driving module 603 is further configured to: Based on the memory resources, the device to be driven is driven by the allocation thread corresponding to the device to be driven until the device queue is empty.
[0129] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0130] The device driver in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0131] The embodiment of the present invention also provides a computer device having the above Figure 6 The device driver shown.
[0132] See also Figure 7 , Figure 7is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 7 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 10 is taken as an example.
[0133] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0134] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0135] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0136] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0137] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0138] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0139] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0140] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A device driving method, characterized in that: The method comprises: During the startup of the target server, each to-be-driven device corresponding to the target server is obtained, and a device queue is determined based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server; Based on the allocation thread group, memory resources are allocated in the target server for each of the devices to be driven; Each of the devices to be driven is driven according to the memory resources.
2. The method according to claim 1, characterized in that The determining of the device queue based on the respective devices to be driven includes: When the target server includes multiple processors, traverse the data interface corresponding to the target processor currently driven to obtain an address identifier, wherein the address identifier is used to indicate a bus address allocated to the device to be driven connected to the data interface; Based on the bus address, the device queue is determined.
3. The method according to claim 2, characterized in that The method further comprises: After the devices to be driven in the device queue corresponding to the target processor are driven, the devices to be driven corresponding to the next processor in the multiple processors are initialized based on a preset initialization order until the devices to be driven corresponding to all processors of the target server are driven completely.
4. The method according to claim 1, characterized in that: The determining of the device queue based on the respective devices to be driven further includes: estimating the operating time of each of the devices to be driven, and sorting the devices to be driven in ascending or descending order of the operating time; The device queue of the device to be driven is determined according to the sorting result.
5. The method according to claim 1, characterized in that The allocating memory resources in the target server for each device to be driven based on the allocation thread group includes: Based on the device type of the device to be driven, determining a configuration space pre-allocated for the device type in the target server; Based on the allocation thread group, memory resources are allocated to the device to be driven according to the configuration space.
6. The method according to claim 5, characterized in that The method further comprises: Obtaining the device type of each to-be-driven device corresponding to the target server; A corresponding configuration space is set for the device type in the target server, and an association relationship between the configuration space and the device type is established.
7. The method according to claim 6, characterized in that The method further comprises: In the case where a newly added external device corresponding to the target server is detected, a corresponding configuration space is allocated to a device type of the newly added external device based on an idle configuration space of the target server.
8. The method according to claim 1, characterized in that The method further comprises: Determining the number of allocation threads in the allocation thread group based on a preset ratio value of the number of the devices to be driven; or The number of allocated threads in the allocated thread group is determined to be a preset number of threads.
9. The method according to claim 1, characterized in that: The method further comprises: Based on any allocation thread in the allocation thread group, a target thread is established, wherein the target thread is used to process the address allocation request of the device to be driven; In response to the address allocation request, a bus address is allocated to the device to be driven based on the target thread to obtain an address identifier.
10. The method according to claim 1, characterized in that The method further comprises: Setting a signaling device for the device queue; When allocating memory resources to the device to be driven in the device queue based on the allocation thread in the allocation thread group, the signal device is set to a first state, and after the allocation is completed, the signal device is set to a second state, wherein the first state is used to indicate memory allocation for the current device to be driven, and the second state is used to indicate memory allocation for the next device to be driven in the device queue after the current device to be driven.
11. The method according to claim 1, characterized in that: The step of driving each of the devices to be driven according to the memory resources includes: Based on the memory resources, the device to be driven is driven by an allocation thread corresponding to the device to be driven until the device queue is empty.
12. A device driving apparatus, characterized in that: The device comprises: A determination module, used for obtaining each to-be-driven device corresponding to the target server during the startup process of the target server, and determining a device queue based on each to-be-driven device, wherein the to-be-driven device is an external device mounted on the target server; An allocation module, configured to allocate memory resources in the target server to each of the devices to be driven based on an allocation thread group; A driving module is used to drive each of the devices to be driven according to the memory resources.
13. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the device driving method according to any one of claims 1 to 11 by executing the computer instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the device driving method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The device comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the device driving method according to any one of claims 1 to 11.
Citation Information
Patent Citations
UEFI firmware implementation method based on server
CN106909349A
Loading method, system and equipment of kernel driving module, medium and chip
CN115809127A
Server bus equipment driving method and device, storage medium and electronic equipment
CN117891530A
