Network card resource processing method and device, computer equipment and storage medium

By handling the hot-swap incident of RDMA network cards, ensuring the rapid release or addition of network card resources, the problem of affecting the stability of the operating system during hot-swap of RDMA network cards is solved and the stability of the system is improved.

CN120216168APending Publication Date: 2025-06-27DAWNING INFORMATION IND (BEIJING) CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510212829.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

When hot plugging, RDMA network card may affect the stability of the operating system, resulting in system stagnation or abnormal functions.

Method used

By obtaining the target hot-swap event of the RDMA network card, determine the network port information and event type, and process the network card resources corresponding to the target hot-swap event based on the network port information, preset network port information and event type to ensure the rapid release or addition of network card resources.

Benefits of technology

In the hot plug-in state of RDMA network card, improve the stability of the operating system and prevent the system from being sluggish or function abnormal.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216168A_ABST
    Figure CN120216168A_ABST
Patent Text Reader

Abstract

The invention relates to a network card resource processing method and device, computer equipment and a storage medium. The method comprises the steps of obtaining a target hot plug event of a remote direct memory access (RDMA) network card, determining network port information and an event type corresponding to the target hot plug event, and processing network card resources corresponding to the target hot plug event according to the network port information, preset network port information and the event type; the preset network port information comprises information of all network ports corresponding to the operating system. By adopting the scheme, the stability of the operating system can be ensured when the RDMA network card is hot-plugged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technologies, and in particular, to a method and apparatus for processing network card resources, a computer device, and a storage medium. Background Art

[0002] A Remote Direct Memory Access (RDMA) network card is a high-performance network interface device that is widely used in various scenarios that require high-speed data transmission and low latency.

[0003] In traditional technologies, hot-plugging an RDMA network card may affect the stability of the operating system. For example, when hot-plugging an RDMA network card, if multiple processes in the user space that use the resources of the RDMA network card do not synchronously perceive it, the created network card resources will always be occupied, and the kernel-mode driver uninstallation process will wait for the resource reference to be released because of the upper-layer process occupation, ultimately resulting in the system hanging, and at the same time, the user-space functions will also hang or malfunction, affecting the stability of the operating system.

[0004] Therefore, how to improve the stability of the operating system when hot-plugging an RDMA network card has become an urgent problem to be solved currently. Summary of the Invention

[0005] Based on this, in view of the above technical problems, it is necessary to provide a method and apparatus for processing network card resources, a computer device, and a storage medium that can improve the stability of the operating system when hot-plugging an RDMA network card.

[0006] In a first aspect, this application provides a method for processing network card resources, including:

[0007] Obtaining a target hot-plug event of a Remote Direct Memory Access (RDMA) network card;

[0008] Determining the network port information and event type corresponding to the target hot-plug event;

[0009] Processing the network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and event type; the preset network port information includes information on all network ports corresponding to the operating system.

[0010] In the above method for processing network card resources, when a target hot-plug event of an RDMA network card is obtained, by analyzing to determine the network port information and event type corresponding to the target hot-plug event, it is possible to process the network card resources of the network port corresponding to the target hot-plug event according to the network port information corresponding to the target hot-plug event, the information of all network ports corresponding to the operating system, and the event type of the target hot-plug event. It is possible to process the network card resources of the network port corresponding to the target hot-plug event in a timely manner when performing hot-plug of the RDMA network card, ensuring that the network card resources corresponding to the target hot-plug event in the operating system can be quickly released or added, thereby ensuring the stability of the operating system in the hot-plug state of the RDMA network card.

[0011] In one embodiment, the above-mentioned processing of the network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and event type includes:

[0012] Compare the network port information with the preset network port information to determine the target network port corresponding to the target hot-plug event;

[0013] Process the network card resources of the target network port according to the event type.

[0014] In the embodiments of the present application, by comparing the network port resources corresponding to the target hot-plug event with the preset network port information, it is possible to determine the target network port corresponding to the target hot-plug event, and thus the network card resources of the target network port can be processed according to the event type of the target hot-plug event. In this way, corresponding processing can be performed on the network card resources based on different event types, improving the processing efficiency of the network card resources while improving the processing accuracy of the network card resources.

[0015] In one embodiment, the above-mentioned processing of the network card resources of the target network port according to the event type includes:

[0016] If the event type is a network card removal start event, release the network card resources corresponding to the target network port.

[0017] In the embodiments of the present application, for the network card removal start event, the network card resources corresponding to the target network port can be released in a timely manner, thereby ensuring the stability of the operating system during the hot-plugging process.

[0018] In one embodiment, the above-mentioned processing of the network card resources of the target network port according to the event type includes:

[0019] If the event type is a network card addition end event, add the network card resources corresponding to the target network port.

[0020] In the embodiments of the present application, for the network card addition end event, the network card resources corresponding to the target network port can be added in a timely manner, thereby ensuring the stability of the operating system during the hot-plugging process.

[0021] In one embodiment, obtaining the target hot-plug event of the remote direct memory access (RDMA) network card includes:

[0022] Obtaining the interaction events between the user space and the kernel space in the operating system according to the parsing function;

[0023] When it is determined that the interaction event includes a hot-plug event, filtering the hot-plug event according to a preset filtering condition to obtain a target hot-plug event; the preset filtering condition includes keywords related to the target hot-plug event.

[0024] In the embodiment of the present application, by filtering the interaction events between the user space and the kernel space in the operating system, compared with the method of analyzing the interaction events between the kernel space and the user space one by one to obtain the target hot-plug event, the method for obtaining the target hot-plug event provided by the present application only needs one filtering to complete, greatly improving the acquisition efficiency of the target hot-plug event.

[0025] In one embodiment, obtaining the interaction events between the user space and the kernel space in the operating system according to the parsing function includes:

[0026] When the initialization operation of the operating system is completed, calling the parsing function; the initialization operation includes initializing the event processing function of the operating system and the interaction information between the user space and the kernel space in the operating system;

[0027] Controlling the parsing function to poll the event handles between the user space and the kernel space to obtain interaction events.

[0028] In the embodiment of the present application, by calling the parsing function to poll the event handles between the user space and the kernel space, and then obtaining the interaction events between the user space and the kernel space, it avoids the situation of missed detection and misdetection in manual monitoring of interaction events. The method for obtaining interaction events provided by the present application greatly improves the acquisition accuracy of interaction events.

[0029] In one embodiment, the method further includes:

[0030] Updating the record log according to the processing information of the network card resources corresponding to the target network interface; the record log is used to record the network card resource information of all network interfaces corresponding to the operating system.

[0031] In the embodiment of the present application, by recording the processing information of the network card resources corresponding to the target hot-plug event after the target hot-plug event processing is completed to obtain the record log, it provides a data basis for subsequent processing of the network card resources corresponding to the target hot-plug event.

[0032] Second aspect, the present application further provides a processing device for network card resources, including:

[0033] An obtaining module, configured to obtain a target hot-plug event of a Remote Direct Memory Access (RDMA) network card;

[0034] A determining module, configured to determine network port information and an event type corresponding to the target hot-plug event;

[0035] A processing module, configured to process network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and the event type; the preset network port information includes information of all network ports corresponding to the operating system.

[0036] Third aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0037] Obtain a target hot-plug event of a Remote Direct Memory Access (RDMA) network card;

[0038] Determine network port information and an event type corresponding to the target hot-plug event;

[0039] Process network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and the event type; the preset network port information includes information of all network ports corresponding to the operating system.

[0040] Fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0041] Obtain a target hot-plug event of a Remote Direct Memory Access (RDMA) network card;

[0042] Determine network port information and an event type corresponding to the target hot-plug event;

[0043] Process network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and the event type; the preset network port information includes information of all network ports corresponding to the operating system.

[0044] Fifth aspect, the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0045] Obtain a target hot-plug event of a Remote Direct Memory Access (RDMA) network card;

[0046] Determine network port information and an event type corresponding to the target hot-plug event;

[0047] Process the network card resources corresponding to the target hot plug event according to the network port information, preset network port information, and event type; the preset network port information includes information on all network ports corresponding to the operating system.

[0048] The above-mentioned method, device, computer device, and storage medium for processing network card resources, when obtaining the target hot plug event of the RDMA network card, can determine the network port information and event type corresponding to the target hot plug event by analysis, and can process the network card resources of the network port corresponding to the target hot plug event according to the network port information corresponding to the target hot plug event, the information on all network ports corresponding to the operating system, and the event type of the target hot plug event. It can process the network card resources corresponding to the target hot plug event in a timely manner when performing hot plug of the RDMA network card, ensuring that the network card resources corresponding to the target hot plug event in the operating system can be quickly released or added, thereby ensuring the stability of the operating system in the hot plug state of the RDMA network card. Description of the Drawings

[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0050] Figure 1 It is an application environment diagram of the method for processing network card resources in an embodiment;

[0051] Figure 2 It is a flowchart of the method for processing network card resources in an embodiment;

[0052] Figure 3 It is a flowchart of the process for processing the network card resources of the target network port in an embodiment;

[0053] Figure 4 It is a flowchart of the process for obtaining the target hot plug event in an embodiment;

[0054] Figure 5 It is a flowchart of the interaction event process between the user mode and the kernel mode in an embodiment;

[0055] Figure 6 It is a flowchart of the process for updating and recording logs based on the processing information of network card resources in an embodiment;

[0056] Figure 7 It is a flowchart of the method for processing network card resources in an embodiment;

[0057] Figure 8Schematic flowchart of a method for processing network card resources in an embodiment;

[0058] Figure 9 Block diagram of a device for processing network card resources in an embodiment;

[0059] Figure 10 Block diagram of a device for processing network card resources in an embodiment;

[0060] Figure 11 Block diagram of a device for processing network card resources in an embodiment;

[0061] Figure 12 Block diagram of a device for processing network card resources in an embodiment. Detailed implementation manners

[0062] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0063] A Remote Direct Memory Access (RDMA) network card is a high-performance network interface device, which is widely used in various scenarios that require high-speed data transmission and low latency. In traditional technologies, when an RDMA network card is hot-plugged, it may affect the stability of the operating system. If multiple processes using RDMA network card resources in the user space do not synchronously perceive it, the created network card resources will always be occupied, and the kernel-mode driver uninstallation process will wait for the resource reference to be released because of the upper-layer process occupation, ultimately leading to system hang. At the same time, the user-space functions will also hang or malfunction, affecting the stability of the operating system. Therefore, how to improve the stability of the operating system when an RDMA network card is hot-plugged has become an urgent problem to be solved currently. The present application aims to provide a method for processing network card resources that can improve the stability of the operating system when an RDMA network card is hot-plugged, so as to solve the problem of poor stability of the operating system in traditional technologies.

[0064] The method for processing network card resources provided in the embodiments of the present application can be applied to a computer device as shown in Figure 1 and the internal structure diagram of the computer device can be as shown in Figure 1As shown in the figure. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store hot-plug data of the RDMA network card. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. The computer program, when executed by the processor, implements a method for processing network card resources. The communication interface of the computer device may include an RDMA interface, and the RDMA network card can be connected or disconnected from the computer device through the RDMA interface.

[0065] Among them, the operating system of the computer device has two states, namely the kernel state and the user state. In the kernel state, the operating system can access all resources of the operating system and hardware devices. The user state is a restricted state when a program runs in the operating system. In the user state, the program can only access the memory areas and hardware devices explicitly permitted by the operating system, and cannot directly access the operating system kernel or the memory space of other programs. It should be noted that interaction can occur between the kernel state and the user state. For the user state, in the case of an RDMA network card hot-plug event, if the user state has established a good connection with the kernel state in advance, it can receive the event sent by the kernel state, determine the network port where the hot-plug event occurs based on the event sent by the kernel state, and process the network card resources corresponding to the network port to ensure the stability of the operating system when the RDMA network card has a hot-plug event.

[0066] The following uses specific embodiments to elaborate in detail on the technical solution of the present application and how the technical solution of the present application solves the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of the present application with reference to the accompanying drawings.

[0067] In an exemplary embodiment, as Figure 2 shown, a method for processing network card resources is provided. Taking the computer device in Figure 1 as an example for illustration, the method includes the following steps:

[0068] S201. Obtain the target hot-plug event of the remote direct memory access (RDMA) network card.

[0069] Among them, the target hot plug event includes the removal start event of the RDMA network card and the addition end event of the RDMA network card.

[0070] In the embodiments of the present application, a monitoring tool is pre-installed in the operating system of the computer device. Through this monitoring tool, the interaction events between the kernel mode and the user mode in the operating system can be monitored. Optionally, when the operating system is in the kernel mode, a monitoring tool for monitoring the user mode can be installed to obtain the interaction events sent from the user mode to the kernel mode. Alternatively, when the operating system is in the user mode, a monitoring tool for monitoring the kernel mode can be installed to obtain the interaction events sent from the kernel mode to the user mode.

[0071] In the embodiments of the present application, for the user mode of the operating system, after the monitoring tool monitors the interaction events sent by the kernel mode, the interaction events sent by the kernel mode can be obtained, and the interaction events can be filtered to obtain the events related to the RDMA network card, and then the events related to the RDMA network card are filtered again to obtain the target hot plug events of the RDMA network card. It should be noted that the interaction events in this embodiment may include network card hot plug events and resource call information events, and the events related to the RDMA network card may include: the removal start event of the RDMA network card, the removal end event of the RDMA network card, the addition start event of the RDMA network card, and the addition end event of the RDMA network card, etc.

[0072] S202. Determine the network port information and event type corresponding to the target hot plug event.

[0073] Among them, the network port information includes the network port identifier or the network port name. The event type includes the network card removal start event and the network card addition end event.

[0074] In the embodiments of the present application, after the target hot plug event is obtained, the network port information corresponding to the target hot plug event can be determined from the identification information of the target hot plug event, and the event type corresponding to the target hot plug event can be identified.

[0075] Optionally, the identification information of the target hot-plug event can be filtered according to the information of all network interfaces corresponding to the operating system in sequence to obtain the network interface information corresponding to the target hot-plug event. For example, there are three network interfaces in the operating system, namely network interface 1, network interface 2, and network interface 3. Taking the information corresponding to network interface 1 including the identification np1 of network interface 1, the information corresponding to network interface 2 including the identification np2 of network interface 2, and the information corresponding to network interface 3 including the identification np3 of network interface 3 as an example, when filtering the network interface information, np1, np2, and np3 can be input in sequence to filter the information carried in the target hot-plug event. If the information carried in the target hot-plug event includes np1, it means that the network interface information corresponding to the target hot-plug event is network interface 1.

[0076] Optionally, the keyword information corresponding to different event types can be input in sequence to filter the information carried in the target hot-plug event to obtain the event type corresponding to the target hot-plug event. For example, the keyword information for the network card removal start event is remove start, and the keyword information for the network card addition end event is add end. When filtering the event type, remove start and add end can be input in sequence to filter the information carried in the target hot-plug event. If the information carried in the target hot-plug event includes remove start, it means that the event type corresponding to the target hot-plug event is the removal start event.

[0077] S203. Process the network card resources corresponding to the target hot-plug event according to the network interface information, the preset network interface information, and the event type; wherein, the preset network interface information includes the information of all network interfaces corresponding to the operating system.

[0078] Among them, the network interface information may include the identification of the network interface, the network card resource information corresponding to the network interface, and the like.

[0079] In the embodiment of the present application, after obtaining the network interface information corresponding to the target hot-plug event and the event type corresponding to the target hot-plug event, the processing strategy corresponding to the target hot-plug event can be determined according to the event type corresponding to the target hot-plug event. Based on the network interface information corresponding to the target hot-plug event and the preset network interface information, the target network interface corresponding to the target hot-plug event is determined, and then the network card resources of the target network interface are processed according to the processing strategy of the target hot-plug event. For example, if the target hot-plug event is a network card removal start event, when it is determined that the target network interface corresponding to the target hot-plug event is network interface B according to the network interface information corresponding to the target hot-plug event and the preset network interface information, the network card resources corresponding to network interface B are removed.

[0080] In the above method for processing network card resources, when a target hot-plug event of an RDMA network card is obtained, by analyzing to determine the network port information and event type corresponding to the target hot-plug event, it is possible to process the network card resources of the network port corresponding to the target hot-plug event according to the network port information corresponding to the target hot-plug event, the information of all network ports corresponding to the operating system, and the event type of the target hot-plug event. It is possible to process the network card resources of the network port corresponding to the target hot-plug event in a timely manner when performing hot-plug of the RDMA network card, ensuring that the network card resources corresponding to the target hot-plug event in the operating system can be quickly released or added, thereby ensuring the stability of the operating system in the hot-plug state of the RDMA network card.

[0081] In this embodiment, the detailed process of processing the network card resources corresponding to the target hot-plug event will be explained. In an exemplary embodiment, as Figure 3 shown, the above S203 includes:

[0082] S301. Compare the network port information with preset network port information to determine the target network port corresponding to the target hot-plug event.

[0083] In the embodiment of the present application, after obtaining the network port information corresponding to the target hot-plug event, the network port information corresponding to the target hot-plug event can be compared with the preset network port information, and the network port corresponding to the network port information that does not exist in the preset network port information can be determined as the target network port corresponding to the target hot-plug event, or the network port corresponding to the network port information that is repeated with the network port information corresponding to the target hot-plug event in the preset network port information can be determined as the target network port corresponding to the target hot-plug event.

[0084] It should be noted that if the network port information corresponding to the target hot-plug event does not exist in the preset network port information, it means that the target hot-plug event is the network card addition end event. Then, directly determine the network port information corresponding to the target hot-plug event as the network port information corresponding to the network card addition end event, and the network port identified in the network port information is the target network port.

[0085] It should be noted that if the network port information corresponding to the target hot-plug event exists in the preset network port information, it means that the target hot-plug event is the network card removal start event. Then, the network port information corresponding to the target hot-plug event exists in the preset network port information, and this network port information is the target network port corresponding to the network card removal start event.

[0086] S302. Process the network card resources of the target network port according to the event type.

[0087] Among them, the network card resources of the target network port refer to the resources corresponding to the network card set at the target network port position.

[0088] In the embodiments of the present application, after determining the event type corresponding to the target hot plug event and the target network interface corresponding to the target hot plug event, the event handling strategy corresponding to the event type can be determined according to different network interface event handling strategies corresponding to different event types, and the network card resources of the target network interface can be processed based on the event handling strategy corresponding to the event type.

[0089] It should be noted that the event handling strategy corresponding to the network card addition end event refers to obtaining the network card resources of the network interface corresponding to the network card addition end event from the operating system and restoring the addition of the network card resources of the network interface corresponding to the network card addition end event. The event handling strategy corresponding to the network card removal start event refers to obtaining the network card resources of the network interface corresponding to the network card removal start event from the operating system and releasing the network card resources of the network interface corresponding to the network card removal start event.

[0090] In this embodiment, by comparing the network interface resources corresponding to the target hot plug event with the preset network interface information, the target network interface corresponding to the target hot plug event can be determined, so that the network card resources of the target network interface can be processed according to the event type of the target hot plug event. In this way, the network card resources can be processed correspondingly based on different event types, improving the processing efficiency of the network card resources while improving the processing accuracy of the network card resources.

[0091] In this embodiment, the detailed process of processing the network card resources of the target network interface according to the event type will be explained. In an exemplary embodiment, the above S302 includes:

[0092] Step A: If the event type is the network card removal start event, release the network card resources corresponding to the target network interface.

[0093] In the embodiments of the present application, when it is recognized that the event type is the network card removal start event, the network card resources corresponding to the target network interface are directly released. For example, after determining the target network interface, determine the network card resources corresponding to the target network interface, release the network card resources corresponding to the target network interface, and then save the network card resources of other network interfaces after releasing the network card resources corresponding to the target network interface.

[0094] Optionally, for the hot plug processing of existing connections, after detecting the network card removal start event, the disconnection process is immediately performed, and then the release of relevant connection resources is processed in the REMOVE coroutine task.

[0095] Step B: If the event type is the network card addition end event, add the network card resources corresponding to the target network interface.

[0096] In the embodiment of the present application, in the case where the event type is identified as the network card addition end event, the network card resources corresponding to the target network port are directly added. For example, after determining the target network port, determine the network card resources corresponding to the target network port, add the network card resources corresponding to the target network port, and then save the network card resources of other network ports after adding the network card resources corresponding to the target network port.

[0097] Optionally, for the hot plugging and unplugging processing of existing connections, after detecting the network card addition end event, perform the reconnection operation based on the hardware connection request after the ADD coroutine task restores the resources to ensure the stability of the system.

[0098] In this embodiment, when it is determined that the target hot plugging event is the network card removal start event, the network card resources corresponding to the target network port are released, and when it is determined that the target hot plugging event is the network card addition end event, the network card resources corresponding to the target network port are added, which can timely add or release the network card resources corresponding to the target network port, so as to ensure that during the hot plugging and unplugging process of the RDMA network card, the network card resources in the operating system can be timely processed, thus ensuring the stability of the operating system.

[0099] In this embodiment, the process of obtaining the target hot plugging event of the RDMA network card will be described in detail. In an exemplary embodiment, as Figure 4 shown, the above S201 includes:

[0100] S401. Obtain the interaction events between the user mode and the kernel mode in the operating system according to the parsing function.

[0101] Among them, the parsing function refers to a function that is preset in the user mode of the operating system and is used to identify and receive the interaction events sent from the kernel mode to the user mode in the operating system.

[0102] In the embodiment of the present application, various functions in the operating system can be initialized in advance, including event receiving functions, event parsing functions, communication functions between the kernel mode and the user mode, etc., and after the initialization is completed, call the parsing function to obtain the interaction events between the user mode and the kernel mode in the operating system.

[0103] Optionally, the parsing function can be preset as a polling parsing function, call the polling parsing function to poll the events received in the user mode, and after polling the interaction events between the user mode and the kernel mode in the operating system, obtain the interaction events between the user mode and the kernel mode in the operating system.

[0104] For example, if the parsing function is pre-set to a polling parsing function with a precision of 1 millisecond, then the polling parsing function polls the events received in the user state every 1 millisecond, and after polling the interaction events between the user state and the kernel state in the operating system, a non-blocking multicast pre-set in the user state of the operating system is used to obtain the interaction events between the user state and the kernel state in the operating system.

[0105] S402. When it is determined that the interaction event includes a hot plug event, filter the hot plug event according to a preset filtering condition to obtain a target hot plug event; wherein, the preset filtering condition includes keywords related to the target hot plug event.

[0106] Among them, the hot plug events include a network card removal start event, a network card removal end event, a network card addition start event, and a network card addition end event.

[0107] For example, the keywords related to the target hot plug event are "unbind", "eth", "bind", "rdma", etc.

[0108] In the embodiment of the present application, after receiving the interaction event between the user state and the kernel state in the operating system, keywords related to the hot plug event can be used to screen the interaction event to obtain a hot plug event, and then the hot plug event is filtered again using the keywords related to the target hot plug event to obtain the target hot plug event.

[0109] For example, the interaction event includes various types of events. First, keywords such as remove start, remove end, add start, and add end are used to determine whether the interaction event includes a hot plug event, and when the interaction event includes a hot plug event, the keywords remove start and add end are used to filter the hot plug event to obtain the target hot plug event.

[0110] The embodiment of the present application provides a method for obtaining a target hot plug event. Compared with the method of analyzing the interaction events between the kernel state and the user state one by one to obtain the target hot plug event, the present application filters the interaction events between the user state and the kernel state in the operating system to obtain the target hot plug event. The method for obtaining the target hot plug event provided by the present application only requires one filtering to complete, greatly improving the efficiency of obtaining the target hot plug event.

[0111] In this embodiment, the process of obtaining the interaction events between the user state and the kernel state in the operating system will be described in detail. In an exemplary embodiment, as Figure 5 shown, the above S401 includes:

[0112] S501. When the initialization operation of the operating system is completed, call the parsing function; the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system.

[0113] Among them, the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system. The event handling function includes an event receiving function and an event analyzing function. The interaction information includes the communication handle between the kernel mode and the user mode and the event receiving multicast in the user mode. The communication handle among them can be a PF-NETLINK connection handle for receiving interaction events created by Socket, and the receiving multicast can be a multi-group non-blocking multicast bound by bind.

[0114] In the embodiment of the present application, before analyzing the target hot-plug event, the operating system can be initialized first. The main initialization is the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system. And when the initialization operation of the operating system is completed, call the parsing function after initialization to complete polling the event handles between the user mode and the kernel mode to obtain the interaction events between the user mode and the kernel mode.

[0115] S502. Control the parsing function to poll the event handles between the user mode and the kernel mode to obtain interaction events.

[0116] Among them, the interaction event can be a uevent event. It should be noted that when a computer device detects the insertion or removal of a device (for example, an RDMA network card), a uevent event will be generated.

[0117] In the embodiment of the present application, after the above-mentioned parsing function is called, the computer device can control the parsing function to poll the event handles between the kernel mode and the user mode, and when the event handles between the kernel mode and the user mode include the interaction events between the kernel mode and the user mode, obtain the interaction events between the kernel mode and the user mode.

[0118] For example, the computer device calls the parsing function, controls the parsing function to poll the event handles between the kernel mode and the user mode, and when the event handles between the kernel mode and the user mode include the uevent event between the kernel mode and the user mode, obtain the uevent event between the kernel mode and the user mode.

[0119] The method for obtaining interaction events provided in the embodiment of the present application polls the event handles between the user mode and the kernel mode by calling the parsing function, and then obtains the interaction events between the user mode and the kernel mode, avoiding the situation of missed detection and misdetection in manual monitoring of interaction events. The method for obtaining interaction events provided in the present application greatly improves the accuracy of obtaining interaction events.

[0120] In this embodiment, the detailed process of processing the network card resources corresponding to the further target hot-plug event will be explained. In an exemplary embodiment, as Figure 6 shown, the above method further includes:

[0121] S303. Update the record log according to the processing information of the network card resources corresponding to the target network port; wherein, the record log is used to record the network card resource information of all network ports corresponding to the operating system.

[0122] In the embodiment of the present application, after processing the network card resources of the target network port according to the event type, obtain the processing information of the network card resources of the target network port and the processing information of the network card resources of all network ports in the operating system, and generate the current record log according to the processing information of the network card resources of the target network port and the processing information of the network card resources of all network ports in the operating system, and update the historical record log according to the current record log. It should be noted that after each processing of the network card resources of the network port, the record log needs to be obtained according to the network card resources of all network ports, and the historical record log is the most recent record log obtained before this processing.

[0123] Next, refer to Figure 7 to illustrate each process of log recording during the processing of the hot-plug event. The following will respectively illustrate the processes of forcefully unplugging the card and forcefully inserting the card:

[0124] For the forceful unplugging event, when a forceful unplugging occurs, after the Peripheral Component Interconnect Express (PCI-Express) of the kernel in the kernel mode of the operating system senses the unloading of the driver, the kernel mode sends a REMOVE START event to the user mode. The user mode receives and parses the forceful unplugging start event sent by the kernel mode and records the log, which includes information such as the forceful unplugging start time and the forceful unplugging network port identifier. Further, the kernel mode sends a REMOVE END event to the user mode. The user mode receives and parses the forceful unplugging end event sent by the kernel mode and records the log, which includes information such as the forceful unplugging end time and the forceful unplugging network port identifier. Further, the user mode processes the forceful unplugging event to cause the operating system to destroy the resources of the network card corresponding to the forceful unplugging event, update the log record, and recycle the resources of the network card corresponding to the forceful unplugging event, and the process ends.

[0125] For a brute-force card insertion event, when a brute-force card insertion occurs, after the Peripheral Component Interconnect Express (PCI-Express) in the kernel in the kernel mode of the operating system senses the loading of the driver, the kernel mode sends an ADD START event to the user mode. The user mode receives and parses the brute-force insertion start event sent by the kernel mode, and records a log. The log includes information such as the brute-force insertion start time and the brute-force insertion network port identifier. Further, the kernel mode sends an ADD END event to the user mode. The user mode receives and parses the brute-force insertion end event sent by the kernel mode, and records a log. The log includes information such as the brute-force insertion end time and the brute-force removal network port identifier. Further, the user mode processes the brute-force card insertion event to enable the operating system to add the resources of the network card corresponding to the brute-force card insertion event, update the log record, and recycle the resources of the network card corresponding to the brute-force card insertion event, and the process ends.

[0126] In the embodiments of the present application, by recording the processing information of the network card resources corresponding to the target network port and updating the record log, a data basis is provided for subsequent processing of the network card resources corresponding to the target hot-plug event.

[0127] For the convenience of understanding by those skilled in the art, see Figure 8 , the following provides a detailed introduction to the method for processing network card resources provided by the present application. The method may include:

[0128] S10. When the initialization operation of the operating system is completed, call the parsing function;

[0129] S11. Control the parsing function to poll the event handle between the user mode and the kernel mode to obtain the interaction event between the user mode and the kernel mode;

[0130] S12. When it is determined that the interaction event includes a hot-plug event, filter the hot-plug event according to the keyword related to the target hot-plug event to obtain the target hot-plug event; wherein, the target hot-plug event includes a network card removal start event and a network card addition end event;

[0131] S13. Determine the network port information and event type corresponding to the target hot-plug event;

[0132] S14. Compare the network port information with the information of all network ports corresponding to the operating system to determine the target network port corresponding to the target hot-plug event;

[0133] S15. If the event type is a network card removal start event, release the network card resources corresponding to the target network port;

[0134] S16. If the event type is a network card addition end event, add the network card resources corresponding to the target network port.

[0135] It should be noted that for the descriptions in S1 - S16 above, reference can be made to the relevant descriptions in the above embodiments, and their effects are similar. Therefore, the details will not be repeated in this embodiment.

[0136] It should be understood that although the steps in the flowcharts involved in the above - mentioned embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above - mentioned embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0137] Based on the same inventive concept, an embodiment of the present application also provides a processing device for network card resources for implementing the processing method of network card resources involved above. The solution provided by this device for solving problems is similar to the solution described in the above - mentioned method. Therefore, the specific limitations in one or more embodiments of the processing device for network card resources provided below can refer to the limitations on the processing method of network card resources in the above text, and will not be repeated here.

[0138] In an exemplary embodiment, as Figure 9 shown, a processing device for network card resources is provided, including: an acquisition module 10, a determination module 11, and a processing module 12, where:

[0139] The acquisition module 10 is configured to acquire a target hot - plug event of a Remote Direct Memory Access (RDMA) network card;

[0140] The determination module 11 is configured to determine the network port information and event type corresponding to the target hot - plug event;

[0141] The processing module 12 is configured to process the network card resources corresponding to the target hot - plug event according to the network port information, preset network port information, and event type; the preset network port information includes information of all network ports corresponding to the operating system.

[0142] The request processing device provided in this embodiment can execute the above - mentioned method embodiment, and its implementation principle and technical effects are similar, and will not be repeated here.

[0143] In an exemplary embodiment, as Figure 10 shown, the above - mentioned processing module 12 includes: a determination unit 121 and a processing unit 122, where:

[0144] A determination unit 121, configured to compare the network port information with preset network port information to determine a target network port corresponding to a target hot-plug event;

[0145] A processing unit 122, configured to process the network card resources of the target network port according to the event type.

[0146] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0147] In an exemplary embodiment, please continue to refer to Figure 10 , specifically, the above processing unit 122 is configured to release the network card resources corresponding to the target network port when the event type is a network card removal start event.

[0148] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0149] In an exemplary embodiment, please continue to refer to Figure 10 , specifically, the above processing unit 122 is configured to add the network card resources corresponding to the target network port when the event type is a network card addition end event.

[0150] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0151] In an exemplary embodiment, refer to Figure 11 , the above acquisition module 10 includes: an acquisition unit 101 and a processing unit 102, where:

[0152] The acquisition unit 101 is configured to acquire an interaction event between user mode and kernel mode in the operating system according to a parsing function;

[0153] The processing unit 102 is configured to, when it is determined that the interaction event includes a hot-plug event, filter the hot-plug event according to a preset filtering condition to obtain a target hot-plug event; the preset filtering condition includes keywords related to the target hot-plug event.

[0154] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0155] In an exemplary embodiment, please continue to refer to Figure 11, the above-mentioned obtaining unit 101 is specifically configured to call a parsing function when the initialization operation of the operating system is completed; the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system; controlling the parsing function to poll the event handles between the user mode and the kernel mode to obtain interaction events.

[0156] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0157] In an exemplary embodiment, refer to Figure 12 , the above-mentioned processing module 12 further includes: an updating unit 123, configured to update the record log according to the processing information of the network card resources corresponding to the target network interface; the record log is used to record the network card resource information of all network interfaces corresponding to the operating system.

[0158] The request processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here.

[0159] Each module in the above-mentioned processing device for network card resources can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above-mentioned modules.

[0160] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:

[0161] Obtain the target hot-plug event of the remote direct memory access (RDMA) network card;

[0162] Determine the network interface information and event type corresponding to the target hot-plug event;

[0163] Process the network card resources corresponding to the target hot-plug event according to the network interface information, preset network interface information and event type; the preset network interface information includes the information of all network interfaces corresponding to the operating system.

[0164] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0165] Compare the network interface information with the preset network interface information to determine the target network interface corresponding to the target hot-plug event;

[0166] Process the network card resources of the target network interface according to the event type.

[0167] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0168] If the event type is a network card removal start event, release the network card resources corresponding to the target network port.

[0169] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0170] If the event type is a network card addition end event, add the network card resources corresponding to the target network port.

[0171] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0172] Obtain the interaction events between the user mode and the kernel mode in the operating system according to the parsing function;

[0173] In the case where it is determined that the interaction event includes a hot plug event, filter the hot plug event according to a preset filtering condition to obtain a target hot plug event; the preset filtering condition includes keywords related to the target hot plug event.

[0174] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0175] In the case where the initialization operation of the operating system is completed, call the parsing function; the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system;

[0176] Control the parsing function to poll the event handles between the user mode and the kernel mode to obtain interaction events.

[0177] In an exemplary embodiment, when the processor executes the computer program, the following steps are further implemented:

[0178] Update the record log according to the processing information of the network card resources corresponding to the target network port; the record log is used to record the network card resource information of all network ports corresponding to the operating system.

[0179] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0180] Obtain the target hot plug event of the remote direct memory access (RDMA) network card;

[0181] Determine the network port information and event type corresponding to the target hot plug event;

[0182] Process the network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and event type; the preset network port information includes information about all network ports corresponding to the operating system.

[0183] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0184] Compare the network port information with the preset network port information to determine the target network port corresponding to the target hot-plug event;

[0185] Process the network card resources of the target network port according to the event type.

[0186] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0187] If the event type is the network card removal start event, release the network card resources corresponding to the target network port.

[0188] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0189] If the event type is the network card addition end event, add the network card resources corresponding to the target network port.

[0190] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0191] Obtain the interaction events between the user mode and the kernel mode in the operating system according to the parsing function;

[0192] In the case where it is determined that the interaction event includes a hot-plug event, filter the hot-plug event according to the preset filtering conditions to obtain the target hot-plug event; the preset filtering conditions include keywords related to the target hot-plug event.

[0193] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0194] In the case where the initialization operation of the operating system is completed, call the parsing function; the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system;

[0195] Control the parsing function to poll the event handles between the user mode and the kernel mode to obtain the interaction events.

[0196] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0197] Update the record log according to the processing information of the network card resources corresponding to the target network port; the record log is used to record the network card resource information of all network ports corresponding to the operating system.

[0198] In an exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the following steps:

[0199] Obtain the target hot-plug event of the Remote Direct Memory Access (RDMA) network card;

[0200] Determine the network port information and event type corresponding to the target hot-plug event;

[0201] Process the network card resources corresponding to the target hot-plug event according to the network port information, preset network port information, and event type; the preset network port information includes the information of all network ports corresponding to the operating system.

[0202] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are also implemented:

[0203] Compare the network port information with the preset network port information to determine the target network port corresponding to the target hot-plug event;

[0204] Process the network card resources of the target network port according to the event type.

[0205] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are also implemented:

[0206] If the event type is the network card removal start event, release the network card resources corresponding to the target network port.

[0207] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are also implemented:

[0208] If the event type is the network card addition end event, add the network card resources corresponding to the target network port.

[0209] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are also implemented:

[0210] Obtain the interaction events between the user mode and the kernel mode in the operating system according to the parsing function;

[0211] When it is determined that the interaction events include hot-plug events, filter the hot-plug events according to the preset filtering conditions to obtain the target hot-plug events; the preset filtering conditions include keywords related to the target hot-plug events.

[0212] In an exemplary embodiment, when the computer program is executed by the processor, the following steps are also implemented:

[0213] When the initialization operation of the operating system is completed, a parsing function is called; the initialization operation includes initializing the event handling function of the operating system and the interaction information between the user mode and the kernel mode in the operating system;

[0214] Control the parsing function to poll the event handles between the user mode and the kernel mode to obtain interaction events.

[0215] In an exemplary embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0216] Update the record log according to the processing information of the network card resources corresponding to the target network interface; the record log is used to record the network card resource information of all network interfaces corresponding to the operating system.

[0217] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.

[0218] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this application.

[0219] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A method for processing network card resources, characterized in that: The method comprises: Get the target hot plug event of the remote direct memory access RDMA network card; Determine the network port information and event type corresponding to the target hot plug event; The network card resources corresponding to the target hot-plug event are processed according to the network port information, the preset network port information and the event type; the preset network port information includes information of all network ports corresponding to the operating system.

2. The method according to claim 1, characterized in that The processing of the network card resources corresponding to the target hot plug event according to the network port information, the preset network port information and the event type includes: Compare the network port information with the preset network port information to determine the target network port corresponding to the target hot plug event; According to the event type, the network card resources of the target network port are processed.

3. The method according to claim 2, characterized in that The processing of the network card resources of the target network port according to the event type includes: If the event type is a network card removal start event, the network card resources corresponding to the target network port are released.

4. The method according to claim 2, characterized in that: The processing of the network card resources of the target network port according to the event type includes: If the event type is a network card addition completion event, the network card resources corresponding to the target network port are added.

5. The method according to any one of claims 1 to 4, characterized in that: The step of obtaining a target hot-plug event of a remote direct memory access (RDMA) network card includes: According to the parsing function, obtaining the interaction event between the user state and the kernel state in the operating system; In the case where it is determined that the interaction event includes a hot plug event, the hot plug event is filtered according to a preset filtering condition to obtain the target hot plug event; the preset filtering condition includes a keyword related to the target hot plug event.

6. The method according to claim 5, characterized in that The step of obtaining the interaction event between the user state and the kernel state in the operating system according to the parsing function includes: In the case where the initialization operation of the operating system is completed, calling the parsing function; the initialization operation includes initializing the event processing function of the operating system and the interaction information between the user state and the kernel state in the operating system; The parsing function is controlled to poll the event handle between the user state and the core state to obtain the interaction event.

7. The method according to claim 2, characterized in that: The method further comprises: The record log is updated according to the processing information of the network card resources corresponding to the target network port; the record log is used to record the network card resource information of all network ports corresponding to the operating system.

8. A network card resource processing device, characterized in that: The device comprises: An acquisition module is used to obtain a target hot-plug event of a remote direct memory access (RDMA) network card; A determination module, used to determine the network port information and event type corresponding to the target hot plug event; The processing module is used to process the network card resources corresponding to the target hot plug event according to the network port information, the preset network port information and the event type; the preset network port information includes information of all network ports corresponding to the operating system.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.