WO2019091361A1 - 一种网卡模式切换方法、装置、电子设备及存储介质 - Google Patents

一种网卡模式切换方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2019091361A1
WO2019091361A1 PCT/CN2018/114077 CN2018114077W WO2019091361A1 WO 2019091361 A1 WO2019091361 A1 WO 2019091361A1 CN 2018114077 W CN2018114077 W CN 2018114077W WO 2019091361 A1 WO2019091361 A1 WO 2019091361A1
Authority
WO
WIPO (PCT)
Prior art keywords
network card
interrupt
worker thread
queue
mode
Prior art date
Application number
PCT/CN2018/114077
Other languages
English (en)
French (fr)
Inventor
李光伟
董玢
Original Assignee
北京金山云网络技术有限公司
北京金山云科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京金山云网络技术有限公司, 北京金山云科技有限公司 filed Critical 北京金山云网络技术有限公司
Publication of WO2019091361A1 publication Critical patent/WO2019091361A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/12Arrangements for remote connection or disconnection of substations or of equipment thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/403Bus networks with centralised control, e.g. polling

Definitions

  • the present application relates to the field of network communication technologies, and in particular, to a network card mode switching method, apparatus, electronic device, and storage medium.
  • the virtual switch runs on the compute node in the cloud environment and is used to connect to the virtual network interface of the virtual machine. It is a pure software implementation responsible for the isolation, link layer and network of the virtual machine. Network switch for layer packet forwarding, security processing, etc.
  • the traditional virtual switch When processing a data packet, the traditional virtual switch mainly processes the data packet through the interrupt polling processing mode of the kernel protocol stack itself, and the data packet processing of the data plane is processed in the kernel state, for example, for implementing the function of the virtual switch.
  • the process of processing the data packet by the open virtual switch (OVS) software is as follows: the stateless flow table is sent to the kernel state, and when the kernel table finds the flow table rule matching the data packet, the packet is forwarded.
  • the data packet otherwise, sends the data packet to the user state through the socket communication mechanism, and after the user state obtains the corresponding flow table rule, the flow table rule is re-issued to the kernel state, and the subsequent packet interaction is in the kernel. Forward in the state.
  • the related technology provides a high-performance Data Plane Development Kit (DPDK) software, which utilizes a large number of software and hardware features that contribute to packet forwarding efficiency, such as Large page, cache line alignment, thread binding, Intel Data Direct Input/Output (DDIO) technology, etc., by applying DPDK software to the virtual switch, you can use the polling mode driver of DPDK software.
  • DPDK Data Plane Development Kit
  • PMD Policy Mode Driver
  • the DPDK software adopts a polling method, that is, the processor always polls the network card queue corresponding to the physical network card and the network card queue corresponding to the virtual network card at a high speed, and concentrates all computing resources of the processor for processing the forwarding of the data packet. .
  • the processor In actual network applications, there may be tidal effects. In some time periods, the number of data packets in the NIC queue will be very low, or there is no data packet to be processed at all, but during these time periods, the processor is also at the high speed wheel. Querying the NIC queue corresponding to the physical NIC and the NIC queue corresponding to the virtual NIC obviously wastes processor resources.
  • the purpose of the embodiment of the present application is to provide a network card mode switching method, device, electronic device, and storage medium, so as to implement reasonable switching interruption and polling, and reduce processor resource waste.
  • the specific technical solutions are as follows:
  • the embodiment of the present application provides a NIC mode switching method, which is applied to a virtual switch, and the method includes:
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode.
  • the NIC mode switching method in the embodiment of the present application further includes:
  • the kernel state interrupt descriptor and the user state interrupt descriptor are bound, and the user state interrupt descriptor is added to the network card interrupt set.
  • the NIC mode switching method in the embodiment of the present application further includes:
  • the interrupt mode of the switching network card is the polling mode.
  • the readable user mode interrupt descriptor includes a network card number.
  • the virtual switch further stores a working thread flag bit array, and after parsing the readable user state interrupt descriptor to obtain the working thread number and the network card queue number corresponding to the readable user state interrupt descriptor,
  • a NIC mode switching method of the application embodiment further includes:
  • the flag bit corresponding to the network card queue number is set
  • the worker thread corresponding to the worker thread number is instructed, so that the worker thread obtains the data packet in the network card queue corresponding to the network card queue number, including:
  • the number of invalid acquisitions of the data packets in the NIC queue by the working thread includes:
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode, including:
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode.
  • the method for switching the network card mode in the embodiment of the present application includes :
  • the flag bit corresponding to the NIC queue is reset in the worker thread flag bit array.
  • the NIC mode switching method in the embodiment of the present application further includes:
  • the virtual switch further includes an interrupt thread indicating a worker thread corresponding to the worker thread number, so that the worker thread polls the worker thread flag bit array, including:
  • the worker thread corresponding to the worker thread number is indicated by the interrupt thread to cause the worker thread to poll the worker thread flag bit array.
  • the embodiment of the present application further provides a network card mode switching device, which is applied to a virtual switch, and the device includes:
  • An interrupt descriptor acquisition module is configured to obtain a readable user state interrupt descriptor in the network card interrupt set in the network card polling mode
  • the parsing module is configured to parse the readable user state interrupt descriptor to obtain a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor;
  • the indication module is configured to indicate a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number;
  • the statistics module is set to count the number of invalid acquisitions of the data packets in the network card queue by the working thread, wherein the invalid acquisition times indicates the number of times the worker thread does not obtain the data packets in the network card queue;
  • the mode switching module is configured to switch the polling mode of the network card corresponding to the network card queue to the interrupt mode when the number of invalid acquisitions is greater than the threshold of the preset invalid acquisition times.
  • a network card mode switching apparatus further includes:
  • the interrupt mode enable module is set to enable the network card interrupt mode
  • the interrupt descriptor add module is set to bind the kernel state interrupt descriptor and the user state interrupt descriptor, and adds the user state interrupt descriptor to the network card interrupt set.
  • a network card mode switching apparatus further includes:
  • the polling mode on module is configured to switch the interrupt mode of the network card to the polling mode when the monitoring network card receives the data packet.
  • the readable user mode interrupt descriptor includes a network card number.
  • the virtual switch further includes a working thread flag bit array.
  • the network card mode switching device in the embodiment of the present application further includes:
  • the mark position bit module is set to set a mark bit corresponding to the network card queue number in the worker thread mark bit array
  • the indicator module includes:
  • the indication submodule is set to indicate a worker thread corresponding to the worker thread number, so that the worker thread polls the worker thread flag bit array;
  • the NIC queue number obtaining submodule is configured to obtain a NIC queue number corresponding to the set flag bit in the worker thread flag bit array;
  • the packet acquisition sub-module is configured to acquire a data packet in the network card queue corresponding to the network card queue number.
  • the statistics module is set to:
  • the mode switching module is set to:
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode.
  • a network card mode switching apparatus further includes:
  • the flag bit reset module is set to reset the flag bit corresponding to the network card queue in the worker thread flag bit array.
  • a network card mode switching apparatus further includes:
  • the sleep state setting module is set to set the state of the worker thread to a sleep state after resetting all the flag bits in the worker thread flag bit array.
  • the virtual switch further includes an interrupt thread, and the indication submodule is set to:
  • the worker thread corresponding to the worker thread number is indicated by the interrupt thread to cause the worker thread to poll the worker thread flag bit array.
  • an embodiment of the present application further provides an electronic device, including a processor and a computer readable storage medium, where the executable program code executable by the processor is stored, and the processor reads the above
  • the executable program code stored in the computer readable storage medium runs a program corresponding to the executable program code to perform a network card mode switching method provided by the first aspect of the present application.
  • the embodiment of the present application further provides a computer readable storage medium, where the executable program code is stored in the computer readable storage medium, and when the executable program code is executed by the processor, the first aspect is provided.
  • a NIC mode switching method
  • the embodiment of the present application further provides a computer program product, including instructions, which, when run on a computer, causes the computer to perform a network card mode switching method provided by the above first aspect.
  • the embodiment of the present application further provides a computer program, when it is run on a computer, causing the computer to perform a network card mode switching method provided by the above first aspect.
  • the method, device, electronic device and storage medium for switching the network card mode provided by the embodiment of the present application firstly enable the network card polling mode, and parse the readable user state interrupt when there is a readable user state interrupt descriptor in the network card interrupt set. Descriptor, obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor, and then instructing the worker thread to acquire a data packet in the network card queue corresponding to the network card queue number, and collecting the working thread to the network card queue In the invalid acquisition number of the data packet, when the invalid acquisition number is greater than the preset invalid acquisition number threshold, the polling mode of the switching network card is the interrupt mode.
  • FIG. 1 is a schematic structural diagram of a system for switching a network card mode to a computer according to an embodiment of the present application
  • FIG. 2 is a flowchart of a first implementation manner of a network card mode switching method according to an embodiment of the present application
  • FIG. 3 is a flowchart of a second implementation manner of a network card mode switching method according to an embodiment of the present application
  • FIG. 4 is a flowchart of a third implementation manner of a network card mode switching method according to an embodiment of the present application.
  • FIG. 5 is a flowchart of a fourth implementation manner of a network card mode switching method according to an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a network card mode switching apparatus according to an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a network card mode switching method applied to an electronic device according to an embodiment of the present application.
  • Interrupt means that the processor interrupts the running program due to pre-arranged or various random internal or external events during the normal running of the program, and automatically transfers to the corresponding program after the interruption point is retained. After the service is completed, return to the reserved interrupt point, continue to execute the interrupted program, and if necessary, the interrupted program can be resumed at any later time and continue to execute.
  • Polling a way for a processor to decide how to provide peripheral device services, the processor periodically issues an inquiry, and sequentially asks whether each peripheral device needs a service. If a peripheral device requires a service, the processor gives the peripheral device corresponding Service, ask the next peripheral device after the service is over; if the peripheral device does not need service, ask the next peripheral device.
  • a thread an execution stream at runtime, is formed by the processor running the program code and manipulating the data.
  • the network card the connection between the computer and the external LAN, is a network interface board that is inserted into the computer.
  • the network interface board is also called a communication adapter, a network adapter or a network interface card, referred to as a network card.
  • the embodiment of the present application provides a network card mode switching method, device, electronic device, and storage medium.
  • the advantages of the interrupt and the polling can be fully utilized. In order to achieve reasonable switching interrupts and polling, reduce processor resource waste.
  • a network card mode switching method, apparatus, electronic device and storage medium in the embodiments of the present application may be applied to a computer, and the computer may include a server.
  • FIG. 1 a schematic diagram of a network card mode switching method applied to a computer in the embodiment of the present application, where the computer includes a virtual switch 101, a first virtual network card 102 of the first virtual machine, and a second The second virtual network card 103 of the virtual machine and the physical network card 104 of the computer.
  • the virtual switch 101 may be a device that applies a network card mode switching method in the embodiment of the present application.
  • the virtual switch 101 can send data packets to the first virtual network card 102, the second virtual network card 103, and the physical network card 104, respectively.
  • the virtual switch 101 can also receive the user state interrupt descriptor sent by the first virtual network card 102, the user state interrupt descriptor sent by the second virtual network card 103, and the user state interrupt descriptor sent by the physical network card 104, respectively.
  • the NIC polling mode may be first started to check whether the user mode interrupt descriptor in the NIC interrupt set has a readable user state interrupt descriptor, and the NIC interrupt set is included in the NIC interrupt set.
  • the user-mode interrupt descriptor is readable
  • the readable user state interrupt descriptor is parsed, and the worker thread number and the network card queue number corresponding to the readable user state interrupt descriptor are obtained, wherein the network card may include the first virtual network card 102, one or more of the second virtual network card 103 and the physical network card 104.
  • the worker thread corresponding to the worker thread number can then be instructed to cause the worker thread to obtain the data packet in the NIC queue corresponding to the NIC queue number.
  • the working thread acquires the data packet in the network card queue corresponding to the network card queue number
  • the number of invalid acquisitions of the data packet in the network card queue may be counted by the working thread.
  • the polling mode of the network card may be switched to the interrupt mode.
  • the readable user state interrupt descriptor in the NIC interrupt set may be first obtained, and the readable user state interrupt descriptor is parsed to obtain a corresponding
  • the worker thread number and the network card queue number may then indicate that the worker thread corresponding to the worker thread number obtains the data packet from the corresponding network card queue, and when the data packet is obtained from the network card queue, the data packet in the network card queue may be counted. If the number of invalid acquisitions is greater than the threshold of the number of invalid invalid acquisitions, it indicates that there is no data packet in the queue of the network card, and the polling mode of the network card corresponding to the network card queue can be switched to the interrupt mode in time. The interrupt mode and the polling mode of the network card are switched, so that the processor does not continue to poll the network card, thereby avoiding the waste of resources caused by the processor in the prior art polling the network card queue, and further reducing the waste of resources of the processor.
  • FIG. 2 is a flowchart of a first implementation manner of a network card mode switching method according to an embodiment of the present application, the method may include:
  • the network card may include a virtual network card and a physical network card, where the virtual network card is a virtual device obtained by simulating a physical network card by using an application, and the physical network card is a hardware device that exists in the computer.
  • the NIC polling mode may be started by using the NIC driver, that is, when the NIC driver is loaded into the NIC, The mode of the NIC is set to polling mode.
  • the interrupt mode and polling mode can be set for the network card.
  • the polling mode can be enabled by turning off the interrupt mode of the network card.
  • the polling mode of the first virtual network card 102, the second virtual network card 103, and the physical network card 104 can be respectively turned on by the network card driver.
  • the interrupt mode of the first virtual network card 102 can be turned off, the polling mode of the first virtual network card 102 is turned on, or the interrupt mode of the physical network card 104 is turned off.
  • a polling mode in which the physical network card 104 is turned on is implemented.
  • the NIC can store the data packet in the NIC queue corresponding to the NIC after receiving the data packet, and can also use the kernel processing program to change the state of the user state interrupt descriptor corresponding to the NIC. Set to a readable state.
  • the network card queue number of the network card queue may be recorded, and the network card number of the network card and the network card queue of the storage data packet are The NIC queue number is added to the user mode interrupt descriptor.
  • the data packet may be stored in the network card queue corresponding to the first virtual network card 102, and recorded and first.
  • the network card queue number of the network card queue corresponding to the virtual network card 102 is assumed to be 102.
  • the network card number of the first virtual network card 102 is 102, and the network card queue number of the network card queue corresponding to the first virtual network card 102 is 201.
  • the network card number 102 and the network card queue number 201 can be added to the user mode interrupt descriptor. Then, the state of the user state interrupt descriptor to which the network card number 102 and the network card queue number 201 are added can be set to the readable state.
  • the network card number and the network card queue number in the user mode interrupt descriptor of the readable state can be obtained in a subsequent step.
  • a network card interrupt set may be set, and when the readable user state interrupt descriptor is obtained, a readable user state interrupt descriptor may be obtained in the network card interrupt set.
  • an instruction may be sent to the processor, and the processor may obtain the readable user state interrupt descriptor in the network card interrupt set after receiving the instruction sent by the network card.
  • the processor may also periodically query the network card interrupt set to see if there is a readable user mode interrupt descriptor in the network card interrupt set.
  • a corresponding user mode interrupt descriptor can be set for each network card.
  • the network card interrupt set may be traversed to obtain a readable user state interrupt descriptor, and the state of each user state interrupt descriptor in the network card interrupt set may also be viewed, when the state of the user state interrupt descriptor is readable. , to obtain the user state interrupt descriptor of the readable state.
  • a first user mode interrupt descriptor may be set for the first virtual network card 102 shown in FIG. 1, a second user state interrupt descriptor is set for the second virtual network card 103, and a third user state interrupt descriptor is set for the physical network card 104. .
  • the user state interrupt descriptor After the state of the user state interrupt descriptor to which the network card number 102 and the network card queue number 201 are added is set to the readable state, the user state interrupt descriptor, that is, the first user state interrupt descriptor, may be obtained from the network card interrupt set. .
  • a corresponding worker thread may be set in advance for each network card. Therefore, the network card number corresponding to each network card also has a corresponding worker thread number.
  • the worker thread number corresponding to the network card number may be added to the user state interrupt descriptor.
  • the readable user state interrupt descriptor may be parsed to obtain the NIC queue number added in the readable user state interrupt descriptor. .
  • the readable user state interrupt descriptor can be parsed by the corresponding application.
  • the user mode interrupt descriptor may also include a network card number.
  • the user mode interrupt descriptor may be an N-bit integer, and the N-bit integer includes a first partial integer, a second partial integer, and a third partial integer.
  • the first partial integer represents a working thread number
  • the second partial integer represents a network card queue number.
  • the third part of the integer represents the network card number.
  • the N-bit integer may be a binary number, and N is an integer greater than 0.
  • the first part of the integer may be obtained to obtain the working thread number; the second part of the integer is obtained to obtain the network card queue number; and the third part of the integer is obtained, and the network card number is obtained.
  • the user mode interrupt descriptor corresponding to the first virtual network card 102 is a binary 32-bit integer.
  • the 32-bit integer is “00000000000100010110011011001001”
  • the first 16 bits are in the first part, that is, 32 in order from left to right.
  • "0000000000010001" in the bit integer is a first partial integer indicating the working thread number corresponding to the first virtual network card 102, and the conversion to a decimal number is "17”, and the working thread number corresponding to the first virtual network card 102 is " 17”.
  • the first 8 bits of the last 16 bits are the second part, that is, "01100110" of the 32-bit integer is the second part, indicating the network card number of the first virtual network card 102, and converting to a decimal number of "102", then the The network card number of the first virtual network card 102 is "102".
  • the last 8 bits of the last 16 bits are the third part, that is, "11001001" of the 32-bit integer is the third part, indicating the NIC queue number corresponding to the first virtual network card 102, and the decimal number is "201".
  • the network card queue number corresponding to the first virtual network card 102 is "201".
  • the flag value may also be set at a specific position in the N-bit integer to divide the N-bit integer.
  • the user mode interrupt descriptor corresponding to the first virtual network card 102 is a binary 32-bit integer, and the integer is “01000001000110011001101111001001”, and the working thread can be represented by the first to the second digits in order from left to right.
  • the first to second digits are "01", and when converted to a decimal number of "1", the worker thread can be represented;
  • the thirteenth to fourteenth digits represent the network card, that is, the thirteenth digit is The fourteenth digit is "10”, and the conversion to decimal number is "2", which can represent the network card;
  • the twenty-third to twenty-fourth digits represent the network card queue, that is, the twenty-third to the second The fourteen digits are "11”, and the conversion to decimal number is "3", which can represent the NIC queue.
  • the third to twelfth digits can represent the worker thread number
  • the fifteenth to the twenty-second digits can represent the network card number
  • the twenty-fifth to thirty-second digits can represent NIC queue number.
  • a worker thread can acquire packets from at least one NIC queue.
  • the worker thread 1 can obtain the data packet in the network card queue corresponding to the first virtual network card 102 shown in FIG. 1 , and can also obtain the data packet in the network card queue corresponding to the second virtual network card 103, and the worker thread 2 can obtain the data packet.
  • the corresponding worker thread can be found by the worker thread number.
  • An instruction can then be sent to the worker thread instructing the worker thread to retrieve the packet from the NIC queue.
  • the worker thread 1 may send an instruction instruction to the worker thread 1 to obtain a data packet from the network card queue corresponding to the first virtual network card 102 and the network card queue corresponding to the second virtual network card 103, respectively. It is assumed that the data packet is stored in the network card queue corresponding to the second virtual network card 103, and the data packet is not stored in the network card queue corresponding to the first virtual network card 102, and the worker thread 1 can obtain the data packet from the corresponding network card queue of the second virtual network card 103. .
  • the number of invalid acquisitions indicates the number of times the worker thread has not obtained the data packet in the NIC queue.
  • one worker thread can acquire at least one packet in the NIC queue, so one worker thread can correspond to at least one NIC queue.
  • one worker thread can correspond to at least one NIC queue.
  • there may be a network card queue in which no data packets are stored.
  • the worker thread When there is a network card queue in which no data packets are stored in a plurality of network card queues corresponding to one worker thread, if the related technology is used, the worker thread will always poll the network card queue of the unstored data packets, but the data packet cannot be obtained.
  • the plurality of network card queues corresponding to the worker thread 1 may be: a network card queue corresponding to the first virtual network card 102, and a network card queue corresponding to the second virtual network card 103. It is assumed that no data packet is stored in the NIC queue corresponding to the first virtual network card 102. If the related technology is adopted, the worker thread will always poll the NIC queue corresponding to the first virtual network card 102. This results in wasted processor resources.
  • the working thread when the working thread does not obtain the data packet from the NIC queue of the unstored data packet, the number of times the data packet is not acquired may be counted, and the working thread obtains the data packet in the NIC queue. Invalid acquisition times.
  • the number of invalid acquisitions of the data packets in the NIC queue corresponding to the first virtual NIC 102 and the number of invalid acquisitions of the data packets in the NIC queue corresponding to the second virtual NIC 103 may be counted.
  • the worker thread 1 may first obtain the data packet in the network card queue corresponding to the first virtual network card 102, and then obtain the data packet in the network card queue corresponding to the second virtual network card 103, and then obtain the corresponding data of the first virtual network card 102.
  • the packets in the NIC queue are looped in turn.
  • the working thread counts the number of invalid acquisitions of the data packets in the NIC queue, which can provide a basis for switching the polling mode of the network card to the interrupt mode.
  • the preset invalid acquisition number threshold may be preset according to experience, and may also be set according to processor utilization, network card utilization, and packet forwarding rate, wherein processor utilization and network card utilization may utilize an application.
  • the program gets.
  • the packet forwarding rate refers to the number of packets that the switch can forward at the same time.
  • the unit is usually pps (packets per second), which indicates the size of the switch's ability to forward packets.
  • the packet forwarding rate of a general switch ranges from tens of Kpps to several hundred Mpps.
  • processor utilization obtaining instruction may be sent to the processor to obtain the processor utilization rate
  • network card utilization obtaining instruction is sent to the network card to obtain the network card utilization rate
  • the preset invalid acquisition threshold may also be adjusted based on processor utilization, network card utilization, and packet forwarding rate.
  • this step After the number of invalid acquisitions of the data packet in the NIC queue is counted by the above-mentioned steps, in this step, whether the polling mode of the network card corresponding to the NIC queue needs to be switched to the interrupt mode is determined according to the invalid acquisition times.
  • the polling mode of the network card corresponding to the NIC queue may be switched to the interrupt mode.
  • the worker thread may not query the network card queue corresponding to the network card switched to the interrupt mode when polling the corresponding network card queue, thereby reducing the network card queue polled by the worker thread.
  • the amount of waste, reducing the waste of processor resources, can also achieve the goal of reducing energy consumption and saving energy.
  • the network card queue number of the network card queue corresponding to the first virtual network card 102 is 201, and the number of invalid acquisitions of the data packets in the network card queue corresponding to the network card queue number 201 by the working thread 1 is 120 times, and the preset is invalid.
  • the number of acquisition thresholds is 100. It is determined by this step that the polling mode of the first virtual network card 102 can be switched to the interrupt mode because the number of invalid acquisition times is greater than the preset invalid acquisition number threshold.
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode, the number of invalid invalid acquisitions may be cleared, and the network card may be restarted after being switched from the interrupt mode to the polling mode. Perform statistics.
  • the NIC polling mode is first turned on, and when the readable user state interrupt descriptor is in the NIC interrupt set, the readable user state interrupt descriptor is parsed, and the readable user descriptor is obtained.
  • the worker thread number corresponding to the user state interrupt descriptor and the network card queue number and then instructing the worker thread to obtain the data packet in the network card queue corresponding to the network card queue number, and collecting the invalid acquisition times of the data packets in the network card queue by the working thread.
  • the polling mode of the switching network card is the interrupt mode.
  • a NIC mode switching method of the application embodiment may further include:
  • the network card may include a virtual network card and a physical network card, where the virtual network card is a network card obtained by simulating a physical network card by using an application, and the physical network card is a hardware device that exists in the computer.
  • the network card interrupt mode can be turned on by the network card driver, that is, when the network card driver is loaded to the network card, the mode of the network card is set to the interrupt mode.
  • the interrupt mode of the first virtual network card 102 and the second virtual network card 103 is turned on by the network card driver.
  • the interrupt mode of the physical network card when the interrupt mode of the physical network card is turned on, the interrupt mode can be turned on by reading and writing the physical network card register.
  • the interrupt of the physical network card 104 can be turned on by reading and writing the network card register of the physical network card 104 shown in FIG. mode.
  • the interrupt number is first written into the memory, and then the interrupt request is sent to the processor, and after receiving the interrupt request, the processor reads the interrupt number from the memory. Then, the kernel state interrupt descriptor is queried according to the interrupt number, and an interrupt vector corresponding to the interrupt number is obtained. Finally, according to the interrupt vector, the corresponding interrupt handler is called for processing, wherein the external device refers to a device other than the processor.
  • hardware devices such as network cards, hard disk storage, and mobile storage.
  • the kernel state interrupt descriptor can be bound to the user mode interrupt descriptor.
  • the processor can directly obtain the worker thread number and the network card queue number from the user state interrupt descriptor. Then, the worker thread corresponding to the worker thread number is called to process the data packet in the network card queue corresponding to the network card queue number.
  • the network card after the network card interrupt mode is enabled, after the network card receives the data packet, the network card generates a kernel state interrupt descriptor.
  • the kernel interrupt handler can be used to perform the user state.
  • the interrupt descriptor is set, for example, by the kernel interrupt handler to set the state of the user mode interrupt descriptor to an unreadable state.
  • the interrupt number corresponding to the kernel state interrupt descriptor may not be sent to the processor. It can reduce the number of times the processor calls the interrupt handler and reduces the number of interrupts of the processor.
  • all kernel state interrupt descriptors of one network card can be bound to the user state interrupt descriptor of the network card.
  • all kernel mode interrupt descriptors of the physical network card 104 shown in FIG. 1 can be bound to the user mode interrupt descriptor of the physical network card 104.
  • kernel-mode interrupt handlers and user-mode interrupt descriptors can be implemented via VFIO (Virtual Function I/O) or UIO (Userspace I/O, User Space I/O). Binding is performed to bind the kernel-mode interrupt descriptor to the user-mode interrupt descriptor.
  • VFIO Virtual Function I/O
  • UIO Userspace I/O, User Space I/O
  • a user mode interrupt descriptor may be added to the network card interrupt set.
  • the user mode interrupt descriptor can be stored in the NIC interrupt set in the form of a list.
  • the number of the NIC queue of the virtual NIC and the number of the NIC queue of the physical NIC may be set, and
  • virtual machine memory information can also be mapped.
  • the physical address space of the virtual machine is mapped to the user space.
  • the queue ring address can also be shared.
  • the NIC queue may adopt a ring queue.
  • the virtual switch can obtain the address of the network card queue of the virtual network card, and the worker thread can find the network card queue through the address of the network card queue, thereby obtaining the data packet stored in the network card queue.
  • initialization of the physical NIC may occur immediately after the virtual switch is booted, and initialization of the virtual NIC may occur at any time after the virtual switch is booted.
  • the monitoring program may be used to monitor the network card.
  • the monitoring program can monitor that the network card receives the data packet.
  • the monitoring program can be an epoll mechanism in a Linux system that can monitor the readable and writable state of all user state interrupt descriptors, and when the state of the user state interrupt descriptor is readable, the application program
  • the virtual switch of the NIC mode switching method of the embodiment of the present application may obtain the working thread number in the user mode interrupt descriptor by using the first implementation manner of the embodiment of the present application, and then indicate the corresponding work thread number.
  • the worker thread forwards the packets in the NIC queue.
  • the interrupt mode of the network card is switched to a polling mode.
  • an interrupt vector may be generated, and the monitoring program may determine whether the network card is determined by monitoring whether an interrupt vector is generated. Received a packet.
  • the switching mode of the network card can be turned on by switching the interrupt mode of the network card to enable the network card polling mode.
  • the interrupt mode of the switching network card when the interrupt mode of the switching network card is the polling mode, the interrupt mode of the network card may be first turned off, and then the network card polling mode is turned on.
  • the virtual switch processes the data packet stored in the network card queue corresponding to the network card in time. Improve the processing speed of data packets by the virtual switch.
  • the application embodiment further provides a network card mode switching method, as shown in FIG. 4, which is a flowchart of a third implementation manner of a network card mode switching method according to an embodiment of the present application, in which a readable user mode interrupt descriptor is parsed.
  • the method for switching the network card mode in the embodiment of the present application may further include:
  • the virtual switch to which the NIC mode switching method of the embodiment of the present application is applied may further store an array of worker thread flag bits.
  • a worker thread may correspond to a worker thread tag bit array, and in the table, may include: a tag bit, a network card queue number, and a network card number.
  • the network card queue numbers corresponding to the network card number 102 are 201 and 202, respectively.
  • the network card queue numbers corresponding to the network card number 103 are 301 and 302, respectively, and the network card queue numbers corresponding to the network card number 104 are 401 and 402, respectively.
  • Each NIC queue number corresponds to one tag bit.
  • the NIC queue number 202 corresponds to a flag bit, which indicates that the NIC queue corresponding to the NIC queue number 202 stores a data packet.
  • the NIC corresponding to the NIC queue number 301 is 0, which may indicate that the NIC queue number 301 corresponds to the NIC queue number 301. No packets are stored in the NIC queue.
  • the corresponding worker thread may be found according to the worker thread number, and may be based on the network card.
  • the queue number finds the flag bit in the worker thread tag bit array of the worker thread that corresponds to the NIC queue number, and then sets the flag bit.
  • the network card queue number is 202, and then the worker thread flag bit array corresponding to the worker thread 1 can be found, as shown in Table 1, and then found according to the network card queue number 202.
  • the tag bit corresponding to the NIC queue number 202, and then the tag position corresponding to the NIC queue number 202 is set to 1. Setting the tag position corresponding to the network card queue number 202 to 1, it can be indicated that the data packet is stored in the network card queue corresponding to the network card queue number 202.
  • the worker thread tag bit array may be the first row content in Table 1, and the network card queue number and the network card number corresponding to each tag bit may be set by an application, for example, the tag bit is first.
  • the tag bit is first.
  • a worker thread tag bit array can be set for each worker thread.
  • the worker thread polls the worker thread tag bit array, the worker thread can poll the corresponding worker thread tag bit array to avoid multi-thread contention.
  • the worker thread tag bit array can be an array whose maximum capacity can be equal to the product of the total number of NICs and the number of NIC queues per NIC.
  • the tag bit can be obtained by multiplying the network card number by the network card queue number, and then the flag bit is set.
  • the worker thread corresponding to the worker thread number is indicated, so that the worker thread acquires the NIC queue corresponding to the NIC queue number.
  • the worker thread can be instructed to first poll the worker thread tag bit array. When there is a flag bit in the worker thread tag bit array, the packet is fetched from the NIC queue corresponding to the tag bit.
  • the instruction instruction may be sent to the worker thread corresponding to the worker thread number, and after receiving the instruction instruction, the worker thread may poll the worker thread flag bit array corresponding to the worker thread. View the flag bits set in the worker thread tag bit array.
  • the frequency at which the worker thread polls the worker thread flag bit array can be preset, for example, the worker thread can be pre-set to poll the worker thread flag bit array 100 times per second.
  • the virtual switch can also include an interrupt thread.
  • the worker thread corresponding to the worker thread number When the worker thread corresponding to the worker thread number is indicated, so that the worker thread polls the worker thread flag bit array, the worker thread corresponding to the worker thread number may be indicated by the interrupt thread, so that the worker thread polls the worker thread flag bit array.
  • the worker thread tag bit array when the worker thread flag bit array is polled by the above steps, when the set tag bit exists in the worker thread tag bit array, the worker thread tag bit array can be obtained, and the set tag is The corresponding network card queue number is used to facilitate subsequent steps to obtain data packets in the network card queue corresponding to the network card queue number.
  • the worker thread flag bit array can be polled to obtain the flag bit set in the worker thread tag bit array.
  • the tag bits set in the worker thread tag bit array shown in Table 1 respectively For: second, fourth and fifth. Then, by querying the table 1, the network card queue number corresponding to the second digit of the marking bit is 202, the network card queue number corresponding to the fourth digit of the marking digit is 302, and the network card queue number corresponding to the fifth digit of the marking digit is 401.
  • the network card queue corresponding to the network card queue number may be found by using the network card queue number.
  • the packet can then be obtained from the NIC queue corresponding to the NIC queue number.
  • the NIC queue number corresponding to the fourth digit of the flag bit is 302.
  • the data packet can be obtained from the NIC queue corresponding to the NIC queue number 302.
  • the flag bit in the worker thread flag bit array is set to indicate that a data packet is stored in the network card queue corresponding to the tag bit.
  • the working thread can collect the data packet in the network card queue. The number of invalid acquisitions. Then, whether the invalid acquisition number is greater than the preset invalid acquisition number threshold may be used to determine whether the polling mode of the network card can be switched to the interrupt mode.
  • the number of invalid acquisitions of the data packets in the NIC queue is counted by the worker thread, in order to improve the accuracy of the statistics, the number of consecutive invalid acquisitions of the data packets in the NIC queue by the worker thread may be counted.
  • the number of consecutive invalid acquisitions is the number of times the worker thread has not obtained the data packets in the network card queue continuously. For example, when the worker thread 1 acquires the data packet in the NIC queue 202 for the third time, the data packet is not acquired, and then the data packet is not acquired when the data packet in the NIC queue 202 is acquired from the 4th to the 109th, respectively. Then, it indicates that the number of consecutive invalid acquisitions of the thread Queue 202 by the worker thread 1 is 107 times.
  • the polling mode of the network card corresponding to the network card queue is interrupted, which may include:
  • the network card queue when the consecutive invalid acquisition times is greater than the preset invalid acquisition number threshold, it may be indicated that the network card queue does not store the data packet in the time corresponding to the consecutive invalid acquisition times, and may also indicate that the continuous invalid acquisition is During the time corresponding to the number of times, the network card corresponding to the NIC queue does not receive the data packet.
  • the polling mode of the network card can be switched to the interrupt mode.
  • the worker thread can poll, except for the NIC queues other than the NIC queue corresponding to the NIC in the interrupt mode.
  • the NIC mode switching method may further include:
  • S409 Reset the flag bit corresponding to the network card queue in the worker thread flag bit array.
  • the NIC when the polling mode of the network card corresponding to the NIC queue is switched to the interrupt mode, when the worker thread polls the worker thread flag bit array, the NIC may be marked only from the worker thread flag bit array. Get the packet in the queue.
  • the flag bit corresponding to the network card queue may be reset in the worker thread flag bit array.
  • the worker thread can only obtain the data packet in the NIC queue with the flag bit set after polling the flag bits in the worker thread flag bit array. Thereby, the occupation of the processing resources by the worker thread can be reduced, and the waste of the processor resources can be reduced.
  • the number of consecutive invalid acquisitions of the network card queue 202 by the worker thread 1 is 107 times, which is greater than the preset invalid acquisition number threshold 100.
  • the polling mode of the network card corresponding to the network card queue 202 can be switched to the interrupt mode by the above steps.
  • the flag bit corresponding to the NIC queue 202 can be reset, for example, the flag bit corresponding to the NIC queue 202 is set to "0" from "1".
  • the embodiment of the present application further provides a possible implementation manner. After all the flag bits in the working thread flag bit array are reset by the above steps, the work may be set and The state of the worker thread corresponding to the thread tag bit array is dormant. In the sleep state, the worker thread can perform no operations, thereby reducing the waste of processor resources.
  • the network card queue numbers corresponding to the working thread 1 are 201, 202, 301, 302, 401, and 402, respectively, and the network card queue number 201, the network card queue number 202, the network card queue number 301, the network card queue number 302, and the network card queue number. 401.
  • the tag bit corresponding to the network card queue number 402 is “0”, which can indicate that all the flag bits in the tag bit array corresponding to the worker thread 1 are reset. In this case, the state of the worker thread 1 can be set to sleep. status.
  • the worker thread in the sleep state may be woken up, so that the worker thread is in the working state again.
  • data may be written to the eventfd notification message, and the worker thread in the sleep state may notify the read data from the eventfd message.
  • the sleep state is changed to the working state.
  • the virtual switch to which the network card mode switching method of the embodiment of the present application is applied may include an interrupt thread and a worker thread.
  • FIG. 5 it is a flowchart of a fourth implementation manner of a network card mode switching method according to an embodiment of the present application, where the method may include:
  • the thread 51 and the worker thread 52 are interrupted, wherein the worker thread can be at least one.
  • Interrupt thread 51 can be set to perform the following steps:
  • the interrupt message of the network card may be monitored by the monitoring program.
  • the kernel state interrupt descriptor may be generated, and the user state interrupt descriptor may be set to a readable state. Therefore, the monitoring program can monitor the network card interrupt message by monitoring whether the network card generates a kernel state interrupt descriptor.
  • the eventfd notification message is an event notification file descriptor in the Linux system.
  • Worker thread 52 can be set to perform the following steps:
  • S524 Obtain a data packet in a network card queue corresponding to a network card queue number, and query a switch forwarding policy for forwarding.
  • step S523 and step S524 are repeated, and when the data packet is not obtained from the network card queue corresponding to the network card queue number, the number of invalid acquisitions of the data packet in the network card queue by the working thread is counted;
  • the detachment of the interrupted thread and the working thread can be completely separated, and the NIC mode switching method of the embodiment of the present application can be extended to multiple working threads to improve the work of the virtual switch. effectiveness. You can also switch the NIC mode in time and set the status of the worker thread in time. Under the premise of ensuring high performance, it can save computing resources and save energy and energy.
  • the embodiment of the present application further provides a network card mode switching device, which can be applied to a virtual switch, as shown in FIG. 6 , which is a schematic structural diagram of a network card mode switching device according to an embodiment of the present application.
  • the device can include:
  • the interrupt descriptor obtaining module 601 is configured to obtain a readable user state interrupt descriptor in the network card interrupt set in the network card polling mode;
  • the parsing module 602 is configured to parse the readable user state interrupt descriptor to obtain a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor;
  • the indication module 603 is configured to indicate a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number;
  • the statistics module 604 is configured to count the number of invalid acquisitions of the data packets in the network card queue by the working thread, where the number of invalid acquisitions indicates the number of times the worker thread does not obtain the data packets in the network card queue;
  • the mode switching module 605 is configured to switch the polling mode of the network card corresponding to the network card queue to an interrupt mode when the number of times of invalid acquisition is greater than the threshold of the number of invalid invalid acquisitions.
  • the NIC mode switching device may first enable the NIC polling mode, and when the readable user state interrupt descriptor is in the NIC interrupt set, parse the readable user state interrupt descriptor, and obtain the same Reading the worker thread number and the network card queue number corresponding to the user state interrupt descriptor, and then instructing the worker thread to obtain the data packet in the network card queue corresponding to the network card queue number, and collecting the invalid acquisition of the data packet in the network card queue by the working thread.
  • the number of times, when the number of invalid acquisitions is greater than the threshold of the number of invalid invalid acquisitions, the polling mode of the switching network card is the interrupt mode.
  • a NIC mode switching apparatus in the embodiment of the present application may further include:
  • the interrupt mode enable module is set to enable the network card interrupt mode
  • the interrupt descriptor add module is set to bind the kernel state interrupt descriptor and the user state interrupt descriptor, and adds the user state interrupt descriptor to the network card interrupt set.
  • a network card mode switching apparatus further includes: a polling mode enabling module, configured to switch the interrupt mode of the network card to polling when the monitoring network card receives the data packet mode.
  • the user mode interrupt descriptor may further include a network card number.
  • the virtual switch further includes a working thread tag bit array.
  • the NIC mode switching device in the embodiment of the present application may further include:
  • the mark position bit module is set to set a mark bit corresponding to the network card queue number in the worker thread mark bit array
  • the indication module 603 includes:
  • the indication submodule is set to indicate a worker thread corresponding to the worker thread number, so that the worker thread polls the worker thread flag bit array;
  • the NIC queue number obtaining submodule is configured to obtain a NIC queue number corresponding to the set flag bit in the worker thread flag bit array;
  • the packet acquisition sub-module is configured to acquire a data packet in the network card queue corresponding to the network card queue number.
  • the statistics module 604 is specifically configured to:
  • the mode switching module 605 is configured to:
  • the polling mode of the network card corresponding to the network card queue is switched to the interrupt mode.
  • the flag bit reset module is set to reset the flag bit corresponding to the network card queue in the worker thread flag bit array.
  • the sleep state setting module is set to set the state of the worker thread to sleep state after resetting all the flag bits in the worker thread flag bit array.
  • the virtual switch further includes an interrupt thread, and the indication submodule is set to:
  • the worker thread corresponding to the worker thread number is indicated by the interrupt thread to cause the worker thread to poll the worker thread flag bit array.
  • a schematic diagram of a network card mode switching method applied to an electronic device may include a processor 701 and a computer readable Storage medium 702.
  • the computer readable storage medium 702 stores executable program code executable by the processor 701, and the processor 701 runs the program corresponding to the executable program code by reading the executable program code stored in the computer readable storage medium described above.
  • a NIC mode switching method provided by the embodiment of the present application includes:
  • Step A In the network card polling mode, obtain a readable user state interrupt descriptor in the network card interrupt set.
  • Step B parsing the readable user state interrupt descriptor, and obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor.
  • Step C indicating a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number.
  • step D the number of invalid acquisitions of the data packets in the NIC queue by the worker thread is counted, wherein the number of invalid acquisitions indicates the number of times the worker thread does not obtain the data packets in the NIC queue.
  • step E when the invalid acquisition number is greater than the preset invalid acquisition number threshold, the polling mode of the switching network card is the interrupt mode.
  • the electronic device of the network card mode switching may first enable the network card polling mode, and when the readable user state interrupt descriptor is in the network card interrupt set, parse the readable user state interrupt descriptor, and obtain The working thread number and the network card queue number corresponding to the readable user state interrupt descriptor, and then instructing the worker thread to obtain a data packet in the network card queue corresponding to the network card queue number, and collecting the data packet of the working thread to the network card queue The number of invalid acquisitions.
  • the polling mode of the switching network card is the interrupt mode.
  • the above processor can execute the program corresponding to the executable program code by reading the executable program code stored in the computer readable storage medium, and can also perform a network card mode switching method provided by the embodiment of the present application. Any step.
  • the computer readable storage medium 702 described above may include a random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
  • RAM random access memory
  • NVM non-volatile memory
  • the memory may also be at least one storage device located away from the foregoing processor.
  • the processor 701 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., or may be a digital signal processing (DSP), dedicated. Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
  • CPU central processing unit
  • NP network processor
  • DSP digital signal processing
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • NIC mode switching method in an embodiment of the present application, a NIC mode switching method provided by the embodiment of the present application includes:
  • Step A In the network card polling mode, obtain a readable user state interrupt descriptor in the network card interrupt set.
  • Step B parsing the readable user state interrupt descriptor, and obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor.
  • Step C indicating a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number.
  • step D the number of invalid acquisitions of the data packets in the NIC queue by the worker thread is counted, wherein the number of invalid acquisitions indicates the number of times the worker thread does not obtain the data packets in the NIC queue.
  • step E when the invalid acquisition number is greater than the preset invalid acquisition number threshold, the polling mode of the switching network card is the interrupt mode.
  • the computer readable storage medium may first enable the network card polling mode, and when the readable user state interrupt descriptor is in the network card interrupt set, parse the readable user state interrupt descriptor, and obtain the readable The worker thread number corresponding to the user state interrupt descriptor and the network card queue number, then instruct the worker thread to obtain the data packet in the network card queue corresponding to the network card queue number, and count the number of invalid acquisition times of the data packet in the network card queue by the working thread.
  • the polling mode of the switching network card is the interrupt mode.
  • the embodiment of the present application further provides a computer program product including instructions, which when executed on a computer, causes the computer to perform a network card mode switching method provided by the embodiment of the present application; in an embodiment of the present application, A method for switching a network card mode provided by the embodiment of the present application includes:
  • Step A In the network card polling mode, obtain a readable user state interrupt descriptor in the network card interrupt set.
  • Step B parsing the readable user state interrupt descriptor, and obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor.
  • Step C indicating a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number.
  • step D the number of invalid acquisitions of the data packets in the NIC queue by the worker thread is counted, wherein the number of invalid acquisitions indicates the number of times the worker thread does not obtain the data packets in the NIC queue.
  • step E when the invalid acquisition number is greater than the preset invalid acquisition number threshold, the polling mode of the switching network card is the interrupt mode.
  • the computer program product including the instruction provided by the embodiment of the present application may first enable the network card polling mode when running on the computer, and parse the readable user state when there is a readable user state interrupt descriptor in the network card interrupt set. Interrupting the descriptor, obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor, and then instructing the worker thread to acquire a data packet in the network card queue corresponding to the network card queue number, and collecting the working thread to the network card The number of invalid acquisitions of the data packets in the queue. When the number of invalid acquisitions is greater than the threshold of the number of invalid invalid acquisitions, the polling mode of the switching network card is the interrupt mode. By properly and timely switching between interrupt mode and polling mode, you can take advantage of interrupts and polling to reduce processor resource waste.
  • the embodiment of the present application further provides a computer program, which when executed on a computer, causes the computer to perform a network card mode switching method provided by the embodiment of the present application; in an embodiment of the present application, the embodiment of the present application A NIC mode switching method provided includes:
  • Step A In the network card polling mode, obtain a readable user state interrupt descriptor in the network card interrupt set.
  • Step B parsing the readable user state interrupt descriptor, and obtaining a worker thread number and a network card queue number corresponding to the readable user state interrupt descriptor.
  • Step C indicating a worker thread corresponding to the worker thread number, so that the worker thread acquires the data packet in the network card queue corresponding to the network card queue number.
  • step D the number of invalid acquisitions of the data packets in the NIC queue by the worker thread is counted, wherein the number of invalid acquisitions indicates the number of times the worker thread does not obtain the data packets in the NIC queue.
  • step E when the invalid acquisition number is greater than the preset invalid acquisition number threshold, the polling mode of the switching network card is the interrupt mode.
  • the computer program provided by the embodiment of the present application may first enable the network card polling mode when running on the computer, and parse the readable user state interrupt descriptor when the network card interrupt set has a readable user state interrupt descriptor. Obtaining a work thread number and a network card queue number corresponding to the readable user state interrupt descriptor, and then instructing the worker thread to obtain a data packet in the network card queue corresponding to the network card queue number, and collecting data of the working thread to the network card queue The number of invalid acquisitions of the packet. When the number of invalid acquisitions is greater than the threshold of the number of invalid invalid acquisitions, the polling mode of the switching network card is the interrupt mode. By properly and timely switching between the interrupt mode and the polling mode, the advantages of interrupt and polling can be fully utilized to reduce processor resource waste.
  • the description is relatively simple, and the relevant method is referred to the method embodiment. Part of the description is fine.
  • the network card polling mode is first turned on, and when the readable user state interrupt descriptor is in the network card interrupt set, the readable user state interrupt descriptor is parsed, and the readable user state is obtained. Interrupt the descriptor corresponding to the worker thread number and the network card queue number, and then instruct the worker thread to obtain the data packet in the network card queue corresponding to the network card queue number, and count the number of invalid acquisitions of the data packet in the network card queue by the working thread. When the number of invalid acquisitions is greater than the preset invalid acquisition threshold, the polling mode of the switching network card is the interrupt mode. By properly and timely switching between the interrupt mode and the polling mode, the advantages of interrupt and polling can be fully utilized to reduce processor resource waste.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请实施例提供了一种网卡模式切换方法、装置、电子设备及存储介质,其中,该方法包括:在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号;指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包;统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费,节省能源。

Description

一种网卡模式切换方法、装置、电子设备及存储介质
本申请要求于2017年11月10日提交中国专利局、申请号为201711103396.2、发明名称为“一种网卡模式切换方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及网络通信技术领域,特别是涉及一种网卡模式切换方法、装置、电子设备及存储介质。
背景技术
虚拟交换机作为云环境下的核心组件,主要运行在云环境下的计算节点之上,用于连接虚拟机的虚拟网络接口,是一套纯软件实现的负责虚拟机的隔离、链路层和网络层数据包的转发、安全处理等的网络交换机。
传统的虚拟交换机在处理数据包时,主要是通过内核协议栈自身的中断轮询处理方式对数据包进行处理,数据平面的数据包处理均在内核态处理,例如,用于实现虚拟交换机功能的开放虚拟交换标准(open virtual switch,简称OVS)软件对数据包的处理过程为:将无状态的流表下发到内核态,在内核态找到与该数据包匹配的流表规则时,则转发该数据包,否则,通过套接字通信机制将数据包发送到用户态,在用户态获取到相应流表规则后,重新下发流表规则到内核态,保证之后的数据包交互均在内核态中转发。
然而,由于通用内核态没有对网络数据包的处理过程进行性能优化,使得数据包在通过内核态中转发时效率低下。为了提高网络数据包的转发效率,相关技术提供了一种高性能的数据平面开发套件(Data Plane Development Kit,简称DPDK)软件,它大量利用了有助于数据包转发效率的软硬件特性,如大页、缓存行对齐、线程绑定、Intel的数据直接输入/输出(Data Direct Input/Output,简称DDIO)技术等,通过将DPDK软件应用到虚拟交换机中,可以利用DPDK软件的轮询模式驱动程序(Poll Mode Driver,简称PMD)技术,使得数据包完全在用户态进行转发,加速物理网卡和虚拟网卡对数据包的处理速度,能够大幅度提升虚拟交换机转发性能。
其中,DPDK软件采用的是轮询的方法,即,处理器一直在高速轮询物 理网卡对应的网卡队列和虚拟网卡对应的网卡队列,集中了处理器的所有运算资源用于处理数据包的转发。在实际网络应用中,可能存在潮汐效应,在一些时间段内,网卡队列中数据包的数量会很低,甚至完全没有需要处理的数据包,但在这些时间段内,处理器也在高速轮询物理网卡对应的网卡队列和虚拟网卡对应的网卡队列,明显浪费了处理器资源。
发明内容
本申请实施例的目的在于提供一种网卡模式切换方法、装置、电子设备及存储介质,以实现合理切换中断和轮询,降低处理器资源浪费。具体技术方案如下:
第一方面,本申请实施例提供了一种网卡模式切换方法,应用于虚拟交换机,该方法包括:
在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符;
解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号;
指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包;
统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数;
在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在本申请实施例中,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符之前,本申请实施例的一种网卡模式切换方法,还包括:
开启网卡中断模式;
绑定内核态中断描述符与用户态中断描述符,并将用户态中断描述符添加到网卡中断集合。
在本申请实施例中,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符之前,本申请实施例的一种网卡模式切换方法,还包括:
在监测网卡接收到数据包时,切换网卡的中断模式为轮询模式。
在本申请实施例中,可读用户态中断描述符包括网卡号。
在本申请实施例中,虚拟交换机中还保存有工作线程标记位数组,在解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号之后,本申请实施例的一种网卡模式切换方法,还包括:
对工作线程标记位数组中,与网卡队列号对应的标记位进行置位;
在本申请实施例中,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包,包括:
指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组;
获取工作线程标记位数组中,与置位的标记位对应的网卡队列号;
获取与网卡队列号对应的网卡队列中的数据包。
在本申请实施例中,统计工作线程对网卡队列中的数据包的无效获取次数,包括:
统计工作线程对网卡队列中的数据包的连续无效获取次数;
在本申请实施例中,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式,包括:
在连续无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在本申请实施例中,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式之后,本申请实施例的一种网卡模式切换方法,还包括:
对工作线程标记位数组中,与网卡队列对应的标记位进行复位。
在本申请实施例中,在对工作线程标记位数组中,与网卡队列对应的标记位进行复位之后,本申请实施例的一种网卡模式切换方法,还包括:
在对工作线程标记位数组中的所有标记位进行复位后,设置工作线程的状态为休眠状态。
在本申请实施例中,虚拟交换机还包括中断线程,指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组,包括:
通过中断线程指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组。
第二方面,本申请实施例还提供了一种网卡模式切换装置,应用于虚拟交换机,该装置包括:
中断描述符获取模块,被设置为在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符;
解析模块,被设置为解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号;
指示模块,被设置为指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包;
统计模块,被设置为统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数;
模式切换模块,被设置为在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在本申请实施例中,本申请实施例的一种网卡模式切换装置,还包括:
中断模式开启模块,被设置为开启网卡中断模式;
中断描述符添加模块,被设置为绑定内核态中断描述符与用户态中断描述符,并将用户态中断描述符添加到网卡中断集合。
在本申请实施例中,本申请实施例的一种网卡模式切换装置,还包括:
轮询模式开启模块,被设置为在监测网卡接收到数据包时,切换网卡的中断模式为轮询模式。
在本申请实施例中,可读用户态中断描述符包括网卡号。
在本申请实施例中,虚拟交换机中还保存有工作线程标记位数组,本申请实施例的一种网卡模式切换装置,还包括:
标记位置位模块,被设置为对工作线程标记位数组中,与网卡队列号对应的标记位进行置位;
相应的,指示模块,包括:
指示子模块,被设置为指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组;
网卡队列号获取子模块,被设置为获取工作线程标记位数组中,与置位的标记位对应的网卡队列号;
数据包获取子模块,被设置为获取与网卡队列号对应的网卡队列中的数据包。
在本申请实施例中,统计模块,被设置为:
统计工作线程对网卡队列中的数据包的连续无效获取次数;
相应的,模式切换模块,被设置为:
在连续无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在本申请实施例中,本申请实施例的一种网卡模式切换装置,还包括:
标记位复位模块,被设置为对工作线程标记位数组中,与网卡队列对应的标记位进行复位。
在本申请实施例中,本申请实施例的一种网卡模式切换装置,还包括:
休眠状态设置模块,被设置为在对工作线程标记位数组中的所有标记位进行复位后,设置工作线程的状态为休眠状态。
在本申请实施例中,虚拟交换机还包括中断线程,指示子模块,被设置为:
通过中断线程指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组。
第三方面,本申请实施例还提供了一种电子设备,包括处理器和计算机可读存储介质,计算机可读存储介质存储有能够被处理器执行的可执行程序代码,处理器通过读取上述计算机可读存储介质中存储的可执行程序代码来运行与上述可执行程序代码对应的程序,以执行:本申请实施例第一方面所提供的一种网卡模式切换方法。
第四方面,本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质内存储有可执行程序代码,可执行程序代码被处理器执行时,实现上述第一方面所提供的一种网卡模式切换方法。
第五方面,本申请实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面所提供的一种网卡模式切换方法。
第六方面,本申请实施例还提供了一种计算机程序,当其在计算机上运 行时,使得计算机执行上述第一方面所提供的一种网卡模式切换方法。
本申请实施例提供的一种网卡模式切换方法、装置、电子设备及存储介质,首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。当然,实施本申请的任一产品或方法并不一定需要同时达到上述的所有优点。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例的一种网卡模式切换方法应用于计算机的系统结构示意图;
图2为本申请实施例的一种网卡模式切换方法第一种实施方式的流程图;
图3为本申请实施例的一种网卡模式切换方法第二种实施方式的流程图;
图4为本申请实施例的一种网卡模式切换方法第三种实施方式的流程图;
图5为本申请实施例的一种网卡模式切换方法第四种实施方式的流程图;
图6为本申请实施例的一种网卡模式切换装置的结构示意图;
图7为本申请实施例的一种网卡模式切换方法应用于电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
首先,对本申请实施例提供的一种网卡模式切换方法、装置、电子设备及存储介质中的名词的概念进行说明:
中断,指处理器在正常运行程序的过程中,由于预先安排或发生了各种随机的内部或外部事件,使处理器中断正在运行的程序,保留中断点后自动转到为相应的程序去服务,服务完成后回到保留的中断点处,继续执行被打断的程序,如果有必要,被中断的程序可以再以后的任一时间恢复,并继续执行。
轮询,一种处理器决策如何提供周边设备服务的方式,由处理器定时发出询问,依序询问每一个周边设备是否需要服务,如果一个周边设备需要服务,则处理器给予该周边设备相应的服务,服务结束后再询问下一个周边设备;如果该周边设备不需要服务,则询问下一个周边设备。
线程,程序运行时的一个执行流,是由处理器运行程序代码并操作数据所形成的。
网卡,计算机与外界局域网的连接,是插装在计算机上的一块网络接口板,网络接口板又称为通信适配器、网络适配器或网络接口卡,简称网卡。
为了解决现有技术存在的问题,本申请实施例提供了一种网卡模式切换方法、装置、电子设备及存储介质,通过及时切换中断模式和轮询模式,可以充分利用中断和轮询的优势,以实现合理切换中断和轮询,降低处理器资源浪费。
本申请实施例的一种网卡模式切换方法、装置、电子设备及存储介质可以应用于计算机,该计算机可以包括服务器。如图1所示,为本申请实施例的一种网卡模式切换方法应用于计算机的系统结构示意图,在该计算机中,可以包括虚拟交换机101、第一虚拟机的第一虚拟网卡102、第二虚拟机的第二虚拟网卡103和计算机的物理网卡104。其中,虚拟交换机101可以是应用本申请实施例的一种网卡模式切换方法的装置。
虚拟交换机101可以分别发送数据包给第一虚拟网卡102、第二虚拟网卡103和物理网卡104。虚拟交换机101还可以分别接收第一虚拟网卡102发送的用户态中断描述符、第二虚拟网卡103发送的用户态中断描述符和物理网卡104发送的用户态中断描述符。
在应用本申请实施例的一种网卡模式切换方法时,可以首先开启网卡轮询模式,查看网卡中断集合中的用户态中断描述符是否有可读用户态中断描述符,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,可以得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,其中,该网卡可以包括第一虚拟网卡102、第二虚拟网卡103以及物理网卡104中的一个或多个。
然后可以指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。在该工作线程获取与网卡队列号对应的网卡队列中的数据包时,可以统计该工作线程对网卡队列中的数据包的无效获取次数。在该无效获取次数大于预设无效获取次数阈值时,可以切换网卡的轮询模式为中断模式。通过将本申请实施例的一种网卡模式切换方法应用于虚拟交换机,可以首先获取网卡中断集合中的可读用户态中断描述符,并对该可读用户态中断描述符进行解析,得到对应的工作线程号和网卡队列号,然后可以指示与该工作线程号对应的工作线程从对应的网卡队列中获取数据包,在从该网卡队列中获取数据包时,可以统计该网卡队列中数据包的无效获取次数,在该无效获取次数大于预设无效获取次数阈值时,则说明该网卡队列中没有数据包,则可以及时将与该网卡队列对应的网卡的轮询模式切换为中断模式,实现合理切换网卡的中断模式和轮询模式,使得处理器不再继续轮询该网卡,进而避免现有技术中处理器一直轮询网卡队列而造成的资源浪费的情况,进一步降低处理器的资源浪费。
下面,对本申请实施例的一种网卡模式切换方法进行介绍,如图2所示,为本申请实施例的一种网卡模式切换方法第一种实施方式的流程图,该方法可以包括:
S201,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符。
其中,该网卡可以包括虚拟网卡和物理网卡,该虚拟网卡为通过应用程序模拟物理网卡得到的虚拟设备,物理网卡为在计算机中真实存在的硬件设备。
在一些示例中,当应用本申请实施例的一种网卡模式切换方法的虚拟交 换机在启动阶段时,可以通过网卡驱动程序开启网卡轮询模式,即,在将网卡驱动程序加载到网卡时,将该网卡的模式设置为轮询模式。
在一些示例中,可以对网卡设置中断模式和轮询模式。当应用本申请实施例的一种网卡模式切换方法的虚拟交换机为正常运行阶段时,可以通过关闭网卡的中断模式,实现开启轮询模式。
例如,在图1所示的虚拟交换机的启动阶段,可以通过网卡驱动程序分别开启第一虚拟网卡102、第二虚拟网卡103和物理网卡104的轮询模式。
又例如,在图1所示的虚拟交换机在正常运行阶段时,可以关闭第一虚拟网卡102的中断模式,实现开启第一虚拟网卡102的轮询模式,或者,关闭物理网卡104的中断模式,实现开启物理网卡104的轮询模式。
通过开启网卡轮询模式,网卡可以在接收到数据包后,将数据包存储在与该网卡对应的网卡队列中,还可以通过内核处理程序,将与该网卡对应的用户态中断描述符的状态设置为可读状态。
在本申请的一个实施例中,在将数据包存储在与该网卡对应的网卡队列中后,可以记录该网卡队列的网卡队列号,并将该网卡的网卡号、存储数据包的网卡队列的网卡队列号添加至用户态中断描述符中。
例如,图1所示的第一虚拟网卡102在开启网卡轮询模式后,接收到数据包,则可以将该数据包存储在与第一虚拟网卡102对应的网卡队列中,并记录与第一虚拟网卡102对应的网卡队列的网卡队列号,假设,第一虚拟网卡的网卡号为102,与第一虚拟网卡102对应的网卡队列的网卡队列号为201。可以将网卡号102和网卡队列号201,添加至用户态中断描述符中。然后,可以将添加有网卡号102和网卡队列号201的用户态中断描述符的状态设置为可读状态。
通过将用户态中断描述符的状态设置为可读状态,可以在后续步骤中,获取该可读状态的用户态中断描述符中的网卡号和网卡队列号。
在一些示例中,为了方便管理用户态中断描述符,可以设置网卡中断集合,在获取可读用户态中断描述符时,可以在该网卡中断集合中获取可读用户态中断描述符。
在一些示例中,当网卡接收到数据包后,可以发送一条指令给处理器,处理器可以在接收到网卡发送的指令后,获取网卡中断集合中的可读用户态 中断描述符。
在一些示例中,处理器还可以周期性的询问网卡中断集合,查看该网卡中断集合中是否有可读用户态中断描述符。
需要说明的是,可以对每个网卡设置对应的用户态中断描述符。在本步骤中,可以遍历网卡中断集合,获取可读用户态中断描述符,也可以查看网卡中断集合中每个用户态中断描述符的状态,在用户态中断描述符的状态为可读状态时,获取该可读状态的用户态中断描述符。
例如,可以对图1所示的第一虚拟网卡102设置第一用户态中断描述符,对第二虚拟网卡103设置第二用户态中断描述符,为物理网卡104设置第三用户态中断描述符。
在将添加有网卡号102和网卡队列号201的用户态中断描述符的状态设置为可读状态后,可以从网卡中断集合中获取到该用户态中断描述符,即第一用户态中断描述符。
S202,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号。
在一些示例中,可以预先对每个网卡设置对应的工作线程,因此,每个网卡对应的网卡号也具有对应的工作线程号。在步骤S201中,将网卡号添加至用户态中断描述符时,也可以将该网卡号对应的工作线程号添加至用户态中断描述符中。
在一些示例中,在通过上述步骤S201获取到可读用户态中断描述符后,可以对该可读用户态中断描述符进行解析,以获取该可读用户态中断描述符中添加的网卡队列号。
需要说明的是,在对可读用户态中断描述符进行解析时,可以通过对应的应用程序对可读用户态中断描述符进行解析。
在一些示例中,用户态中断描述符,还可以包括网卡号。例如,该用户态中断描述符可以为N位整数,该N位整数包括第一部分整数、第二部分整数、第三部分整数,第一部分整数表示工作线程号,第二部分整数表示网卡队列号,第三部分整数表示网卡号。其中,该N位整数可以是二进制数,N为大于0的整数。
在对可读用户态中断描述符进行解析时,可以获取第一部分整数,得到工作线程号;获取第二部分整数,得到网卡队列号;获取第三部分整数,得到网卡号。
假设,与第一虚拟网卡102对应的用户态中断描述符为二进制32位整数,例如,该32位整数为“00000000000100010110011011001001”,按照从左向右的顺序,前16位为第一部分,即,32位整数中的“0000000000010001”为第一部分整数,表示与该第一虚拟网卡102对应的工作线程号,转换为十进制数为“17”,则与该第一虚拟网卡102对应的工作线程号为“17”。
后16位中的前8位为第二部分,即,32位整数中的“01100110”为第二部分,表示该第一虚拟网卡102的网卡号,转换为十进制数为“102”,则该第一虚拟网卡102的网卡号为“102”。
后16位中的后8位为第三部分,即,32位整数中的“11001001”为第三部分,表示与该第一虚拟网卡102对应的网卡队列号,转换为十进制数为“201”,则与该第一虚拟网卡102对应的网卡队列号为“201”。
在一些示例中,还可以在N位整数中的特定位置设置标示值,对N位整数进行划分。例如,与第一虚拟网卡102对应的用户态中断描述符为二进制32位整数,该整数为“01000001000110011001101111001001”,按照从左向右的顺序,可以以第一位至第二位数表示工作线程,即,第一位至第二位为“01”,转换为十进制数为“1”,则可以表示工作线程;以第十三位至第十四位数表示网卡,即,第十三位至第十四位数为“10”,转换为十进制数为“2”,则可以表示网卡;以第二十三位至第二十四位数表示网卡队列,即第二十三位至第二十四位数为“11”,转换为十进制数为“3”,则可以表示网卡队列。
需要说明的是,第三位至第十二位数可以表示工作线程号,第十五位至第二十二位数可以表示网卡号,第二十五位至第三十二位数可以表示网卡队列号。
S203,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。
在一些示例中,一个工作线程可以获取至少一个网卡队列中的数据包。例如,工作线程1,可以获取图1所示的第一虚拟网卡102对应的网卡队列中的 数据包,还可以获取第二虚拟网卡103对应的网卡队列中的数据包,工作线程2可以获取图1所示的物理网卡104对应的网卡队列中的数据包。
在通过上述步骤得到工作线程号后,可以通过该工作线程号查找到对应的工作线程。然后可以发送指示指令给该工作线程,指示该工作线程从网卡队列中获取数据包。
例如,可以给工作线程1发送指示指令,指示工作线程1分别从第一虚拟网卡102对应的网卡队列、和第二虚拟网卡103对应的网卡队列中获取数据包。假设,第二虚拟网卡103对应的网卡队列中存储有数据包,第一虚拟网卡102对应的网卡队列中未存储数据包,则工作线程1可以从第二虚拟网卡103对应网卡队列中获取数据包。
S204,统计工作线程对网卡队列中的数据包的无效获取次数。
其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数。
在上述示例中,一个工作线程可以获取至少一个网卡队列中的数据包,因此,一个工作线程可以对应至少一个网卡队列。在一个工作线程对应的多个网卡队列中,可以存在未存储数据包的网卡队列。
当一个工作线程对应的多个网卡队列中存在未存储数据包的网卡队列时,若采用上述相关技术,则工作线程会一直轮询该未存储数据包的网卡队列,但是并不能获取到数据包。例如,与工作线程1对应的多个网卡队列可以是:第一虚拟网卡102对应的网卡队列、和第二虚拟网卡103对应的网卡队列。假设第一虚拟网卡102对应的网卡队列中未存储数据包。若采用相关技术,工作线程会一直轮询该第一虚拟网卡102对应的网卡队列。从而造成处理器资源的浪费。
因此,为了解决上述问题,可以在工作线程从该未存储数据包的网卡队列中未获取到数据包时,对未获取到数据包的次数进行统计,得到工作线程对网卡队列中的数据包的无效获取次数。
例如,可以统计工作线程1,对第一虚拟网卡102对应的网卡队列中的数据包的无效获取次数,和对第二虚拟网卡103对应的网卡队列中的数据包的无效获取次数。
在一些示例中,工作线程1可以首先获取第一虚拟网卡102对应的网卡队 列中的数据包,然后获取第二虚拟网卡103对应的网卡队列中的数据包,再获取第一虚拟网卡102对应的网卡队列中的数据包,依次循环。
通过本步骤,工作线程对网卡队列中的数据包的无效获取次数进行统计,可以为将网卡的轮询模式切换为中断模式提供依据。
S205,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在一些示例中,该预设无效获取次数阈值可以根据经验预先设置,还可以根据处理器利用率、网卡利用率以及数据包转发率进行设置,其中,处理器利用率和网卡利用率可以利用应用程序获取。
其中,数据包转发率是指交换机每秒能同时转发的数据包的数量,单位一般为pps(包每秒),标志交换机转发数据包能力的大小。一般交换机的包转发率在几十Kpps到几百Mpps不等。
需要说明的是,可以发送处理器利用率获取指令至处理器,以获取处理器利用率,发送网卡利用率获取指令至网卡,以获取网卡利用率。
在一些示例中,该预设无效获取次数阈值,还可以根据处理器利用率、网卡利用率以及数据包转发率进行调整。
在通过上述步骤统计工作线程对网卡队列中的数据包的无效获取次数后,在本步骤中,可以根据该无效获取次数判断是否需要将与网卡队列对应的网卡的轮询模式切换为中断模式。
需要说明的是,当工作线程对网卡队列中的数据包的无效获取次数,大于预设无效获取次数阈值时,可以切换与该网卡队列对应的网卡的轮询模式为中断模式。
通过将该网卡的轮询模式切换为中断模式,工作线程在轮询对应的网卡队列时,可以不询问与该切换为中断模式的网卡对应的网卡队列,从而可以减少工作线程轮询的网卡队列的数量,降低处理器资源的浪费,还可以达到减少能量消耗,节省能源的目的。
假设,第一虚拟网卡102对应的网卡队列的网卡队列号为201,通过步骤S204统计,工作线程1对网卡队列号201对应的网卡队列中的数据包的无效获取次数为120次,预设无效获取次数阈值为100次。通过本步骤判断,由于无 效获取次数大于预设无效获取次数阈值,可以将第一虚拟网卡102的轮询模式切换为中断模式。
在一些示例中,当将与网卡队列对应的网卡的轮询模式切换为中断模式后,可以对统计的无效获取次数清零,可以使得该网卡在由中断模式切换为轮询模式后,可以重新进行统计。
通过申请实施例提供的一种网卡模式切换方法,首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。
在本申请实施例的一种可能的实现方式中,当虚拟交换机首次应用本申请实施例提供的一种网卡模式切换方法,或当虚拟交换机重新启动后,可以对应用本申请实施例的一种网卡模式切换方法的虚拟交换机进行初始化。如图3所示,为本申请实施例的一种网卡模式切换方法第二种实施方式的流程图,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符之前,本申请实施例的一种网卡模式切换方法,还可以包括:
S301,开启网卡中断模式。
其中,该网卡可以包括虚拟网卡和物理网卡,该虚拟网卡为通过应用程序模拟物理网卡得到的网卡,物理网卡为在计算机中真实存在的硬件设备。
在一些示例中,可以通过网卡驱动程序开启网卡中断模式,即,在将网卡驱动程序加载到网卡时,将该网卡的模式设置为中断模式。例如,通过网卡驱动程序,开启第一虚拟网卡102和第二虚拟网卡103的中断模式。
在一些示例中,在开启物理网卡的中断模式时,可以通过读写物理网卡寄存器开启中断模式,例如,可以通过读写图1所示的物理网卡104的网卡寄存器,开启该物理网卡104的中断模式。
S302,绑定内核态中断描述符与用户态中断描述符,并将用户态中断描 述符添加到网卡中断集合。
在相关技术中,外部设备请求处理器处理数据包时,首先向内存中写入中断号,然后将中断请求发送至处理器,处理器接收到该中断请求后,从内存中读取中断号,再根据该中断号查询内核态中断描述符,得到与该中断号对应的中断向量,最后根据该中断向量,调用对应的中断处理程序进行处理,其中,该外部设备是指除处理器外的设备,例如,网卡、硬盘存储器、移动存储器等硬件设备。
为了提高虚拟交换机处理数据包的速度,减少虚拟交换机调用内核态应用程序的次数,可以将内核态中断描述符与用户态中断描述符进行绑定。
通过本步骤,处理器在接收到中断请求后,可以直接从用户态中断描述符中获取工作线程号、网卡队列号。然后调用与工作线程号对应的工作线程,对于网卡队列号对应的网卡队列中的数据包进行处理。
在一些示例中,在开启网卡中断模式,网卡接收到数据包后,网卡会产生内核态中断描述符,通过本步骤,当网卡产生内核态中断描述符后,可以通过内核中断处理程序对用户态中断描述符进行设置,例如,通过内核中断处理程序将用户态中断描述符的状态设置为不可读状态。
在一些示例中,通过将内核态中断描述符与用户态中断描述符进行绑定,当网卡产生内核态中断描述符后,可以不发送内核态中断描述符对应的中断号至处理器。可以减少处理器调用中断处理程序的次数,减少处理器的中断次数。
在绑定内核态中断描述符与用户态中断描述符时,可以将一个网卡的所有内核态中断描述符与该网卡的用户态中断描述符进行绑定。例如,可以将图1所示的物理网卡104的所有内核态中断描述符,与物理网卡104的用户态中断描述符进行绑定。
在一些示例中,可以通过VFIO(Virtual Function I/O,虚拟功能I/O)或者UIO(Userspace I/O,用户空间I/O),将内核态的中断处理程序与用户态的中断描述符进行绑定,以实现将内核态中断描述符与用户态中断描述符进行绑定。
在本申请实施例的一个方面,为了方便对用户态中断描述符的管理,可 以将用户态中断描述符添加至网卡中断集合。
将用户态中断描述符添加至网卡中断集合时,可以以列表的形式将用户态中断描述符存储在网卡中断集合中。
在本申请实施例的又一个方面,在对应用本申请实施例的一种网卡模式切换方法的虚拟交换机进行初始化时,可以设置虚拟网卡的网卡队列数量和物理网卡的网卡队列数量,还可以获取网卡特性信息,其中,该网卡特性信息表示网卡支持的功能类型,例如,TSO(TCP Segment Offload)功能,或者GSO(Generic Segmentation Offload,通用分片延后处理)功能。
在一些示例中,还可以映射虚拟机内存信息。在本申请的一个实施例中,将虚拟机的物理地址空间映射到用户空间。
在一些示例中,还可以共享队列环地址。在本申请的一个实施例中,在本申请实施例的一种网卡模式切换方法中,网卡队列可以采用环形队列。通过共享队列环地址,虚拟交换机可以得到虚拟网卡的网卡队列的地址,工作线程可以通过该网卡队列的地址查找到该网卡队列,从而获取存储在该网卡队列中的数据包。
通过上述步骤,可以实现对虚拟交换机、虚拟网卡以及物理网卡的初始化。
在一些示例中,物理网卡的初始化可以在虚拟交换机启动后立刻进行,虚拟网卡的初始化可以在虚拟交换机启动后的任一时间进行。
在本申请实施例的一种可能的实现方式中,在对应用本申请实施例的一种网卡模式切换方法的虚拟交换机进行初始化后,可以应用监测程序对网卡进行监测。当网卡接收到数据包时,监测程序可以监测到该网卡接收到数据包。
在一些示例中,该监测程序可以是Linux系统中的epoll机制,该机制可以监测所有用户态中断描述符的可读可写状态,在用户态中断描述符的状态为可读状态时,应用本申请实施例的一种网卡模式切换方法的虚拟交换机,可以通过本申请实施例的第一种实施方式获取到该用户态中断描述符中的工作线程号,然后,指示与该工作线程号对应的工作线程,对网卡队列中的数据包进行转发。
S303,在监测到网卡接收到数据包时,切换该网卡的中断模式为轮询模式。
在本申请实施例的一种可能的实现方式中,在通过上述步骤开启网卡中断模式后,当网卡接收到数据包时,可以产生中断向量,监测程序可以通过监测是否产生中断向量判断该网卡是否接收到数据包。在监测程序监测到该网卡接收到数据包时,可以通过切换网卡的中断模式为轮询模式,实现开启网卡轮询模式。
在一些示例中,在切换网卡的中断模式为轮询模式时,可以首先关闭网卡的中断模式,再开启网卡轮询模式。
通过本步骤,可以实现在网卡接收到数据包后,虚拟交换机及时对该网卡对应的网卡队列中存储的数据包进行处理。提高虚拟交换机对数据包的处理速度。
在本申请实施例的又一种可能的实现方式中,为了在保证虚拟交换机处理数据包的速度的前提下,减少工作线程对网卡队列的轮询,降低工作线程对处理器资源的占用,本申请实施例还提供了一种网卡模式切换方法,如图4所示,为本申请实施例的一种网卡模式切换方法第三种实施方式的流程图,在解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号之后,本申请实施例的一种网卡模式切换方法,还可以包括:
S403,对工作线程标记位数组中,与网卡队列号对应的标记位进行置位。
在一些示例中,应用本申请实施例的一种网卡模式切换方法的虚拟交换机,还可以保存有工作线程标记位数组。如表1所示,为工作线程标记位数组示意表,一个工作线程可以对应一个工作线程标记位数组,在该表中,可以包括:标记位、网卡队列号、网卡号。
假设,第一虚拟网卡102的网卡号为102,第二虚拟网卡103的网卡号为103,物理网卡的网卡号为104,在表1中,网卡号102对应的网卡队列号分别为201和202,网卡号103对应的网卡队列号分别为301和302,网卡号104对应的网卡队列号分别为401和402。每个网卡队列号分别对应一个标记位。例如,网卡队列号202对应的标记位为1,可以表示与网卡队列号202对应的网卡队列中存 储有数据包,网卡队列号301对应的标记位为0,可以表示与网卡队列号301对应的网卡队列中未存储数据包。
表1 工作线程标记位数组示意表
Figure PCTCN2018114077-appb-000001
在一些示例中,在解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号之后,可以根据工作线程号查找到对应的工作线程,可以根据网卡队列号查找到该工作线程的工作线程标记位数组中,与网卡队列号对应的标记位,然后可以对该标记位进行置位。
假设,解析得到的工作线程号为工作线程1,网卡队列号为202,然后可以查找到与工作线程1对应的工作线程标记位数组,如表1所示,再根据网卡队列号202查找到与网卡队列号202对应的标记位,然后将与网卡队列号202对应的标记位置位为1。将与网卡队列号202对应的标记位置位为1,可以表示与网卡队列号202对应的网卡队列中存储有数据包。
在一些示例中,上述的工作线程标记位数组可以是表1中的第一行内容,与各标记位对应的网卡队列号和网卡号可以通过应用程序进行设定,例如,标记位第一位表示网卡队列号201对应的网卡队列的标记位,第三位表示网卡队列号302对应的网卡队列的标记位。
在一些示例中,可以为每个工作线程设置一个工作线程标记位数组,工作线程在轮询工作线程标记位数组时,可以轮询对应的工作线程标记位数组,能够避免多线程竞争。
在一些示例中,该工作线程标记位数组可以是一个数组,该数组的最大容量可以等于总网卡数与每个网卡的网卡队列数的乘积。在置位工作线程标记位数组中的标记位时,可以通过网卡号与网卡队列号的乘积得到该标记位,然后对该标记位进行置位。
S404,指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组。
在一些示例中,为了减少工作线程对网卡队列的轮询,降低工作线程对 处理器资源的占用,在指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包时,可以指示工作线程首先轮询工作线程标记位数组。在工作线程标记位数组中有置位的标记位时,从与该标记位对应的网卡队列中获取数据包。
在本申请的一个实施例中,可以发送指示指令给与工作线程号对应的工作线程,该工作线程接收到指示指令后,可以轮询与该工作线程对应的工作线程标记位数组。查看该工作线程标记位数组中置位的标记位。
在一些示例中,工作线程轮询工作线程标记位数组的频率可以预先设定,例如,可以预先设定工作线程每秒钟轮询工作线程标记位数组100次。
在一些示例中,虚拟交换机还可以包括中断线程。在指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组时,可以通过中断线程指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组。
S405,获取工作线程标记位数组中,与置位的标记位对应的网卡队列号。
在一些示例中,在通过上述步骤对工作线程标记位数组进行轮询时,当工作线程标记位数组中存在置位的标记位时,可以获取该工作线程标记位数组中,与置位的标记位对应的网卡队列号,以方便后续步骤获取与该网卡队列号对应的网卡队列中的数据包。
在本申请的一个实施例中,可以轮询工作线程标记位数组,得到工作线程标记位数组中置位的标记位,例如,表1所示的工作线程标记位数组中置位的标记位分别为:第二位、第四位和第五位。然后可以通过查询表1,得到与标记位第二位对应的网卡队列号为202,与标记位第四位对应的网卡队列号为302,与标记位第五位对应的网卡队列号为401。
S406,获取与网卡队列号对应的网卡队列中的数据包。
在本申请的一个实施例中,在通过上述步骤,得到与置位的标记位对应的网卡队列号后,在本步骤中,可以通过网卡队列号查找到与该网卡队列号对应的网卡队列,然后可以从与网卡队列号对应的网卡队列中获取数据包。
例如,通过上述步骤得到,与标记位第四位对应的网卡队列号为302,在本步骤中,可以从与网卡队列号302对应的网卡队列中获取数据包。
在本申请实施例中,对工作线程标记位数组中的标记位进行置位,可以表示与该标记位对应的网卡队列中存储有数据包。在本申请实施例的一种可能的实现方式中,当通过上述步骤获取网卡队列中的数据包时,从该网卡队列中未获取到数据包时,可以统计工作线程对网卡队列中的数据包的无效获取次数。然后可以以该无效获取次数是否大于预设无效获取次数阈值,判断是否可以将网卡的轮询模式切换为中断模式。
S407,统计工作线程对网卡队列中的数据包的连续无效获取次数。
在一些示例中,在统计工作线程对网卡队列中的数据包的无效获取次数时,为了提高统计的准确度,可以统计工作线程对网卡队列中的数据包的连续无效获取次数。
其中,该连续无效获取次数为工作线程连续未获取到网卡队列中数据包的次数。例如,工作线程1在第3次获取网卡队列202中的数据包时,未获取到数据包,然后分别在第4次至109次获取网卡队列202中的数据包时,均未获取到数据包,则,表示工作线程1对网卡队列202的连续无效获取次数为107次。
相应的,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式,可以包括:
S408,在连续无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
在一些示例中,当连续无效获取次数大于预设无效获取次数阈值时,可以表示在与该连续无效获取次数对应的时间内,网卡队列未存储数据包,也可以表示,在与该连续无效获取次数对应的时间内,与网卡队列对应的网卡未接收到数据包。
因此,为了降低处理器资源的浪费,减少工作线程轮询的网卡队列的数量,可以将该网卡的轮询模式切换为中断模式。工作线程可以轮询,除中断模式的网卡对应的网卡队列之外的网卡队列。
在本申请实施例的又一种可能的实现方式中,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式之后,本申请实施例的一种网卡模式切换方法,还可以包括:
S409,对工作线程标记位数组中,与网卡队列对应的标记位进行复位。
在一些示例中,当与网卡队列对应的网卡的轮询模式切换为中断模式后,工作线程在轮询工作线程标记位数组时,可以只从工作线程标记位数组中标记位为置位的网卡队列中获取数据包。
因此,在将与网卡队列对应的网卡的轮询模式为中断模式之后,还可以将工作线程标记位数组中,与网卡队列对应的标记位进行复位。
在一些示例中,将与网卡队列对应的标记位进行复位后,工作线程在轮询工作线程标记位数组中的各标记位后,可以只获取标记位为置位的网卡队列中的数据包,从而可以减少工作线程对处理资源的占用,降低处理器资源的浪费。
例如,工作线程1对网卡队列202的连续无效获取次数为107次,大于预设无效获取次数阈值100,可以通过上述步骤将与该网卡队列202对应的网卡的轮询模式切换为中断模式,还可以对与该网卡队列202对应的标记位进行复位,例如,将与该网卡队列202对应的标记位由“1”设置为“0”。
为了进一步处理器资源的浪费,节省能源,本申请实施例还提供了一种可能的实现方式,当通过上述步骤对工作线程标记位数组中的所有标记位都进行复位后,可以设置与该工作线程标记位数组对应的工作线程的状态为休眠状态。在休眠状态下,该工作线程可以不进行任何操作,从而可以降低处理器资源的浪费。
例如,与工作线程1对应的网卡队列号分别为201、202、301、302、401、402,分别与网卡队列号201、网卡队列号202、网卡队列号301、网卡队列号302、网卡队列号401、网卡队列号402对应的标记位都为“0”,可以表示与工作线程1对应的标记位数组中的所有标记位都进行了复位,这时,可以将工作线程1的状态设置为休眠状态。
在与该工作线程对应的网卡重新接收到数据包时,可以将处于休眠状态的工作线程唤醒,使该工作线程重新处于工作状态。
在一些示例中,在Linux系统中,当与该工作线程对应的网卡重新接收到数据包时,可以向eventfd通知消息中写入数据,当处于休眠状态的工作线程可以从eventfd消息通知读取数据时,由休眠状态变更为工作状态。
在本申请实施例的一种可能的实现方式中,应用本申请实施例的一种网 卡模式切换方法的虚拟交换机可以包括中断线程和工作线程。如图5所示,为本申请实施例的一种网卡模式切换方法第四种实施方式的流程图,该方法可以包括:
中断线程51和工作线程52,其中,工作线程可以是至少一个。
中断线程51,可以被设置为执行以下步骤:
S510,监测网卡中断消息;
在本申请的一个实施例中,可以通过监测程序监测网卡的中断消息,在网卡接收到数据包时,可以产生内核态中断描述符,并且,可以设置用户态中断描述符为可读状态。因此,监测程序可以通过监测网卡是否产生内核态中断描述符实现对网卡中断消息的监测。
S511,遍历网卡中断集合,获取可读用户态中断描述符;
S512,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号;
S513,对工作线程标记位数组中,与网卡队列号对应的标记位进行置位;
S514,向eventfd通知消息中写入数据。
其中,eventfd通知消息为linux系统中的事件通知文件描述符。
工作线程52,可以被设置为执行以下步骤:
S520,从eventfd通知消息中读数据,唤醒处于休眠状态的工作线程
S521,轮询工作线程标记位数组中各标记位;
S522,标记位是否置位,在所有标记位未置位时,进入休眠状态。
S523,在标记位数组中存在置位的标记位时,获取工作线程标记位数组中、与置位的标记位对应的网卡队列号;
S524,获取与网卡队列号对应的网卡队列中的数据包,查询交换机转发策略进行转发;
S525,重复步骤S523和步骤S524,在从与网卡队列号对应的网卡队列中未获取到数据包时,统计工作线程对网卡队列中的数据包的无效获取次数;
S526,在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式;
S527,对工作线程标记位数组中,与网卡队列对应的标记位进行复位;
S528,在对工作线程标记位数组中的所有标记位都进行复位后,设置与该工作线程标记位数组对应的工作线程的状态为休眠状态。
通过本申请实施例的一种网卡模式切换方法,可以实现中断线程和工作线程的完全分离,可以实现将本申请实施例的一种网卡模式切换方法,扩展至多个工作线程,提高虚拟交换机的工作效率。还可以及时切换网卡模式,以及及时设置工作线程的状态。在保证高性能的前提下,既可以节省计算资源又可以省电节能。
相应于上述方法实施例,本申请实施例还提供了一种网卡模式切换装置,可以应用于虚拟交换机,如图6所示,为本申请实施例的一种网卡模式切换装置的结构示意图,该装置可以包括:
中断描述符获取模块601,被设置为在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符;
解析模块602,被设置为解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号;
指示模块603,被设置为指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包;
统计模块604,被设置为统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数;
模式切换模块605,被设置为在无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
本申请实施例提供的一种网卡模式切换装置,可以首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。
在本申请的一个实施例中,本申请实施例的一种网卡模式切换装置,还 可以包括:
中断模式开启模块,被设置为开启网卡中断模式;
中断描述符添加模块,被设置为绑定内核态中断描述符与用户态中断描述符,并将用户态中断描述符添加到网卡中断集合。
在本申请的一个实施例中,本申请实施例的一种网卡模式切换装置,还包括:轮询模式开启模块,被设置为在监测网卡接收到数据包时,切换网卡的中断模式为轮询模式。
在本申请的一个实施例中,用户态中断描述符还可以包括网卡号。
在本申请的一个实施例中,虚拟交换机中还保存有工作线程标记位数组,本申请实施例的一种网卡模式切换装置,还可以包括:
标记位置位模块,被设置为对工作线程标记位数组中,与网卡队列号对应的标记位进行置位;
在本申请的一个实施例中,指示模块603,包括:
指示子模块,被设置为指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组;
网卡队列号获取子模块,被设置为获取工作线程标记位数组中、与置位的标记位对应的网卡队列号;
数据包获取子模块,被设置为获取与网卡队列号对应的网卡队列中的数据包。
在本申请的一个实施例中,统计模块604,具体被设置为:
统计工作线程对网卡队列中的数据包的连续无效获取次数;
相应的,模式切换模块605,被设置为:
在连续无效获取次数大于预设无效获取次数阈值时,切换与网卡队列对应的网卡的轮询模式为中断模式。
本申请实施例的一种网卡模式切换装置,还可以包括:
标记位复位模块,被设置为对工作线程标记位数组中,与网卡队列对应的标记位进行复位。
本申请实施例的一种网卡模式切换装置,还可以包括:
休眠状态设置模块,被设置为在对工作线程标记位数组中的所有标记位 进行复位后,设置工作线程的状态为休眠状态。
在本申请的一个实施例中,虚拟交换机还包括中断线程,指示子模块,被设置为:
通过中断线程指示与工作线程号对应的工作线程,以使工作线程轮询工作线程标记位数组。
本申请实施例还提供了一种电子设备,如图7所示,为本申请实施例的一种网卡模式切换方法应用于电子设备的结构示意图,该电子设备可以包括处理器701、计算机可读存储介质702。
计算机可读存储介质702存储有能够被处理器701执行的可执行程序代码,处理器701通过读取上述计算机可读存储介质中存储的可执行程序代码来运行与上述可执行程序代码对应的程序,以执行:本申请实施例所提供的一种网卡模式切换方法;在本申请的一个实施例中,本申请实施例所提供的一种网卡模式切换方法,包括:
步骤A,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符。
步骤B,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号。
步骤C,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。
步骤D,统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数。
步骤E,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。
本申请实施例提供的一种网卡模式切换的电子设备,可以首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、 及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。
当然,上述处理器通过读取上述计算机可读存储介质中存储的可执行程序代码来运行与上述可执行程序代码对应的程序,还能够执行本申请实施例所提供的一种网卡模式切换方法的任意步骤。
上述的计算机可读存储介质702可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。在本申请实施例中,存储器还可以是至少一个位于远离前述处理器的存储装置。
上述的处理器701可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质内存储有可执行程序代码,该可执行程序代码被处理器执行时,实现本申请实施例所提供的一种网卡模式切换方法;在本申请的一个实施例中,本申请实施例所提供的一种网卡模式切换方法,包括:
步骤A,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符。
步骤B,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号。
步骤C,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。
步骤D,统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数。
步骤E,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。
本申请实施例提供的计算机可读存储介质,可以首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。
本申请实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行本申请实施例所提供的一种网卡模式切换方法;在本申请的一个实施例中,本申请实施例所提供的一种网卡模式切换方法,包括:
步骤A,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符。
步骤B,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号。
步骤C,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。
步骤D,统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数。
步骤E,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。
本申请实施例提供的包含指令的计算机程序产品,当其在计算机上运行时,可以首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用 中断和轮询的优势,降低处理器资源浪费。
本申请实施例还提供了一种计算机程序,当其在计算机上运行时,使得计算机执行本申请实施例所提供的一种网卡模式切换方法;在本申请的一个实施例中,本申请实施例所提供的一种网卡模式切换方法,包括:
步骤A,在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符。
步骤B,解析可读用户态中断描述符,得到与可读用户态中断描述符对应的工作线程号和网卡队列号。
步骤C,指示与工作线程号对应的工作线程,以使工作线程获取与网卡队列号对应的网卡队列中的数据包。
步骤D,统计工作线程对网卡队列中的数据包的无效获取次数,其中,无效获取次数表示工作线程未获取到网卡队列中数据包的次数。
步骤E,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。
本申请实施例提供的计算机程序,当其在计算机上运行时,可以首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。
对于网卡模式切换装置/电子设备/计算机可读存储介质/计算机程序产品/计算机程序的实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要 素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。
工业实用性
基于本申请实施例提供的上述技术方案,首先开启网卡轮询模式,在网卡中断集合中有可读用户态中断描述符时,解析该可读用户态中断描述符,得到与该可读用户态中断描述符对应的工作线程号和网卡队列号,然后指示该工作线程,获取与网卡队列号对应的网卡队列中的数据包,并统计工作线程对网卡队列中的数据包的无效获取次数,在无效获取次数大于预设无效获取次数阈值时,切换网卡的轮询模式为中断模式。通过合理地、及时地切换中断模式和轮询模式,可以充分利用中断和轮询的优势,降低处理器资源浪费。

Claims (22)

  1. 一种网卡模式切换方法,所述方法应用于虚拟交换机,包括:
    在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符;
    解析所述可读用户态中断描述符,得到与所述可读用户态中断描述符对应的工作线程号和网卡队列号;
    指示与所述工作线程号对应的工作线程,以使所述工作线程获取与所述网卡队列号对应的网卡队列中的数据包;
    统计所述工作线程对所述网卡队列中的数据包的无效获取次数,其中,所述无效获取次数表示所述工作线程未获取到所述网卡队列中数据包的次数;
    在所述无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式。
  2. 根据权利要求1所述的方法,其中,在所述在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符之前,所述方法还包括:
    开启网卡中断模式;
    绑定内核态中断描述符与用户态中断描述符,并将所述用户态中断描述符添加到所述网卡中断集合。
  3. 根据权利要求2所述的方法,其中,在所述在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符之前,所述方法还包括:
    在监测所述网卡接收到数据包时,切换所述网卡的中断模式为轮询模式。
  4. 根据权利要求1所述的方法,其中,所述可读用户态中断描述符包括网卡号。
  5. 根据权利要求1所述的方法,其中,所述虚拟交换机中还保存有工作线程标记位数组,在所述解析所述可读用户态中断描述符,得到与所述可读用户态中断描述符对应的工作线程号和网卡队列号之后,所述方法还包括:对所述工作线程标记位数组中,与所述网卡队列号对应的标记位进行置位;
    其中,所述指示与所述工作线程号对应的工作线程,以使所述工作线程获取与所述网卡队列号对应的网卡队列中的数据包,包括:指示与所述工作线程号对应的工作线程,以使所述工作线程轮询所述工作线程标记位数组;获取工作线程标记位数组中,与置位的标记位对应的网卡队列号;获取与所 述网卡队列号对应的网卡队列中的数据包。
  6. 根据权利要求1所述的方法,其中,所述统计所述工作线程对所述网卡队列中的数据包的无效获取次数,包括:统计所述工作线程对所述网卡队列中的数据包的连续无效获取次数;
    其中,所述在所述无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式,包括:在所述连续无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式。
  7. 根据权利要求5所述的方法,其中,在所述无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式之后,所述方法还包括:
    对所述工作线程标记位数组中,与所述网卡队列对应的标记位进行复位。
  8. 根据权利要求7所述的方法,其中,在所述对所述工作线程标记位数组中,与所述网卡队列对应的标记位进行复位之后,所述方法还包括:
    在对所述工作线程标记位数组中的所有标记位进行复位后,设置所述工作线程的状态为休眠状态。
  9. 根据权利要求5所述的方法,其中,所述虚拟交换机还包括中断线程,所述指示与所述工作线程号对应的工作线程,以使所述工作线程轮询所述工作线程标记位数组,包括:
    通过中断线程指示与所述工作线程号对应的工作线程,以使所述工作线程轮询所述工作线程标记位数组。
  10. 一种网卡模式切换装置,所述装置应用于虚拟交换机,包括:
    中断描述符获取模块,被设置为在网卡轮询模式中,获取网卡中断集合中的可读用户态中断描述符;
    解析模块,被设置为解析所述可读用户态中断描述符,得到与所述可读用户态中断描述符对应的工作线程号和网卡队列号;
    指示模块,被设置为指示与所述工作线程号对应的工作线程,以使所述工作线程获取与所述网卡队列号对应的网卡队列中的数据包;
    统计模块,被设置为统计所述工作线程对所述网卡队列中的数据包的无 效获取次数,其中,所述无效获取次数表示所述工作线程未获取到所述网卡队列中数据包的次数;
    模式切换模块,被设置为在所述无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式。
  11. 根据权利要求10所述的装置,其中,所述装置还包括:
    中断模式开启模块,被设置为开启网卡中断模式;
    中断描述符添加模块,被设置为绑定内核态中断描述符与用户态中断描述符,并将所述用户态中断描述符添加到所述网卡中断集合。
  12. 根据权利要求11所述的装置,其中,所述装置还包括:
    轮询模式开启模块,被设置为在监测所述网卡接收到数据包时,切换所述网卡的中断模式为轮询模式。
  13. 根据权利要求10所述的装置,其中,所述可读用户态中断描述符包括网卡号。
  14. 根据权利要求10所述的装置,其中,所述虚拟交换机中还保存有工作线程标记位数组,所述装置还包括:标记位置位模块,被设置为对所述工作线程标记位数组中,与所述网卡队列号对应的标记位进行置位;
    其中,所述指示模块,包括:指示子模块,被设置为指示与所述工作线程号对应的工作线程,以使所述工作线程轮询所述工作线程标记位数组;网卡队列号获取子模块,被设置为获取工作线程标记位数组中,与置位的标记位对应的网卡队列号;数据包获取子模块,被设置为获取与所述网卡队列号对应的网卡队列中的数据包。
  15. 根据权利要求10所述的装置,其中,所述统计模块,被设置为:统计所述工作线程对所述网卡队列中的数据包的连续无效获取次数;
    其中,所述模式切换模块,被设置为:在所述连续无效获取次数大于预设无效获取次数阈值时,切换与所述网卡队列对应的网卡的轮询模式为中断模式。
  16. 根据权利要求14所述的装置,其中,所述装置还包括:
    标记位复位模块,被设置为对所述工作线程标记位数组中,与所述网卡队列对应的标记位进行复位。
  17. 根据权利要求16所述的装置,其中,所述装置还包括:
    休眠状态设置模块,被设置为在对所述工作线程标记位数组中的所有标记位进行复位后,设置所述工作线程的状态为休眠状态。
  18. 根据权利要求14所述的装置,其中,所述虚拟交换机还包括中断线程,所述指示子模块,被设置为:
    通过中断线程指示与所述工作线程号对应的工作线程,以使所述工作线程轮询所述工作线程标记位数组。
  19. 一种电子设备,包括处理器和计算机可读存储介质,所述计算机可读存储介质存储有能被所述处理器执行的可执行程序代码,所述处理器通过读取上述计算机可读存储介质中存储的可执行程序代码来运行与上述可执行程序代码对应的程序,以执行:权利要求1-9任一所述的方法步骤。
  20. 一种计算机可读存储介质,所述计算机可读存储介质内存储有可执行程序代码,所述可执行程序代码被处理器执行时实现权利要求1-9任一所述的方法步骤。
  21. 一种包含可执行程序代码的计算机程序产品,所述可执行程序代码在计算机上运行时,使得计算机执行:权利要求1-9任一所述的方法步骤。
  22. 一种计算机程序,所述计算机程序在计算机上运行时,使得计算机执行:权利要求1-9任一所述的方法步骤。
PCT/CN2018/114077 2017-11-10 2018-11-06 一种网卡模式切换方法、装置、电子设备及存储介质 WO2019091361A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711103396.2 2017-11-10
CN201711103396.2A CN109787777B (zh) 2017-11-10 2017-11-10 一种网卡模式切换方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2019091361A1 true WO2019091361A1 (zh) 2019-05-16

Family

ID=66438195

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/114077 WO2019091361A1 (zh) 2017-11-10 2018-11-06 一种网卡模式切换方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN109787777B (zh)
WO (1) WO2019091361A1 (zh)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143032A (zh) * 2019-12-20 2020-05-12 上海交通大学 一种基于请求应答的半虚拟化i/o系统和方法
CN111343152A (zh) * 2020-02-07 2020-06-26 北京达佳互联信息技术有限公司 数据处理方法、装置及电子设备、存储介质
CN111371654A (zh) * 2020-03-18 2020-07-03 四川九州电子科技股份有限公司 一种智能融合产品网口自动化测试系统和方法
CN112068784A (zh) * 2020-09-14 2020-12-11 上海商米科技集团股份有限公司 一种云打印设备多网卡自动切换的方法及云打印设备
CN112732462A (zh) * 2021-01-07 2021-04-30 杭州立思辰安科科技有限公司 基于netmap网卡驱动防止网卡重启的方法
CN113300979A (zh) * 2021-02-05 2021-08-24 阿里巴巴集团控股有限公司 Rdma网络下的网卡队列创建方法以及装置
CN114157566A (zh) * 2021-11-08 2022-03-08 中信科移动通信技术股份有限公司 一种基站性能文件解析方法及系统
CN114697215A (zh) * 2022-03-31 2022-07-01 西安超越申泰信息科技有限公司 一种虚拟化网络性能提升的方法、系统、设备及介质
WO2024037482A1 (zh) * 2022-08-19 2024-02-22 华为技术有限公司 一种中断消息处理方法及装置

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110286743A (zh) * 2019-07-03 2019-09-27 浪潮云信息技术有限公司 一种数据中心节电方法、终端、计算机可读存储介质
CN110765064B (zh) * 2019-10-18 2022-08-23 山东浪潮科学研究院有限公司 一种异构计算架构的边缘端图像处理系统及方法
CN110851289B (zh) * 2019-10-23 2022-11-08 新华三信息安全技术有限公司 协议报文处理方法及交换机
CN112817772B (zh) * 2019-11-15 2023-12-29 深信服科技股份有限公司 一种数据通信方法、装置、设备及存储介质
CN111355637B (zh) * 2020-02-27 2023-11-07 深信服科技股份有限公司 网卡状态检测方法、装置、设备及存储介质
CN113377527B (zh) * 2021-04-26 2023-06-02 佳源科技股份有限公司 一种基于流量强度自适应的流媒体转发处理装置与方法
CN114448909B (zh) * 2021-12-27 2023-10-13 天翼云科技有限公司 基于ovs的网卡队列轮询方法、装置、计算机设备及介质
CN115756143B (zh) * 2022-11-30 2024-03-12 深圳市领创星通科技有限公司 数据包处理的节能方法、装置、计算机设备和存储介质
CN115632948B (zh) * 2022-12-19 2023-03-07 无锡沐创集成电路设计有限公司 应用于网卡的中断调控方法、装置、存储介质及电子设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003102770A1 (en) * 2002-05-31 2003-12-11 Advanced Micro Devices, Inc. Secure execution mode exceptions
CN101227341A (zh) * 2007-12-18 2008-07-23 浪潮电子信息产业股份有限公司 Linux系统上以太网卡快速捕包的方法
CN101557420A (zh) * 2009-03-31 2009-10-14 北京航空航天大学 虚拟机监控器高效网络通信的实现方法
CN101959290A (zh) * 2009-07-16 2011-01-26 北京中电华大电子设计有限责任公司 一种无线局域网卡功耗控制方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003102770A1 (en) * 2002-05-31 2003-12-11 Advanced Micro Devices, Inc. Secure execution mode exceptions
CN101227341A (zh) * 2007-12-18 2008-07-23 浪潮电子信息产业股份有限公司 Linux系统上以太网卡快速捕包的方法
CN101557420A (zh) * 2009-03-31 2009-10-14 北京航空航天大学 虚拟机监控器高效网络通信的实现方法
CN101959290A (zh) * 2009-07-16 2011-01-26 北京中电华大电子设计有限责任公司 一种无线局域网卡功耗控制方法

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143032A (zh) * 2019-12-20 2020-05-12 上海交通大学 一种基于请求应答的半虚拟化i/o系统和方法
CN111343152A (zh) * 2020-02-07 2020-06-26 北京达佳互联信息技术有限公司 数据处理方法、装置及电子设备、存储介质
CN111343152B (zh) * 2020-02-07 2023-01-24 北京达佳互联信息技术有限公司 数据处理方法、装置及电子设备、存储介质
CN111371654B (zh) * 2020-03-18 2022-10-14 四川九州电子科技股份有限公司 一种智能融合产品网口自动化测试系统和方法
CN111371654A (zh) * 2020-03-18 2020-07-03 四川九州电子科技股份有限公司 一种智能融合产品网口自动化测试系统和方法
CN112068784A (zh) * 2020-09-14 2020-12-11 上海商米科技集团股份有限公司 一种云打印设备多网卡自动切换的方法及云打印设备
CN112068784B (zh) * 2020-09-14 2024-03-12 上海商米科技集团股份有限公司 一种云打印设备多网卡自动切换的方法及云打印设备
CN112732462A (zh) * 2021-01-07 2021-04-30 杭州立思辰安科科技有限公司 基于netmap网卡驱动防止网卡重启的方法
CN112732462B (zh) * 2021-01-07 2024-02-09 杭州中电安科现代科技有限公司 基于netmap网卡驱动防止网卡重启的方法
CN113300979A (zh) * 2021-02-05 2021-08-24 阿里巴巴集团控股有限公司 Rdma网络下的网卡队列创建方法以及装置
CN114157566A (zh) * 2021-11-08 2022-03-08 中信科移动通信技术股份有限公司 一种基站性能文件解析方法及系统
CN114157566B (zh) * 2021-11-08 2023-09-08 中信科移动通信技术股份有限公司 一种基站性能文件解析方法及系统
CN114697215A (zh) * 2022-03-31 2022-07-01 西安超越申泰信息科技有限公司 一种虚拟化网络性能提升的方法、系统、设备及介质
WO2024037482A1 (zh) * 2022-08-19 2024-02-22 华为技术有限公司 一种中断消息处理方法及装置

Also Published As

Publication number Publication date
CN109787777B (zh) 2020-04-03
CN109787777A (zh) 2019-05-21

Similar Documents

Publication Publication Date Title
WO2019091361A1 (zh) 一种网卡模式切换方法、装置、电子设备及存储介质
US8635385B2 (en) Mechanism to handle peripheral page faults
US11489791B2 (en) Virtual switch scaling for networking applications
US7562366B2 (en) Transmit completion event batching
US9092275B2 (en) Store operation with conditional push of a tag value to a queue
US20110172968A1 (en) Distributed performance counters
US9588923B2 (en) Flow pinning in a server on a chip
US8996774B2 (en) Performing emulated message signaled interrupt handling
CN101727414A (zh) 用于在计算机系统中传递中断的技术
US20210334228A1 (en) Managing network interface controller-generated interrupts
US10969995B2 (en) Systems and methods for differentiating function performance by input parameters
EP3598310B1 (en) Network interface device and host processing device
WO2019153702A1 (zh) 一种中断处理方法、装置及服务器
CN110874336B (zh) 一种基于申威平台的分布式块存储低延迟控制方法及系统
US9288163B2 (en) Low-latency packet receive method for networking devices
US11429438B2 (en) Network interface device and host processing device
WO2024007934A1 (zh) 中断处理方法、电子设备和存储介质
WO2023104194A1 (zh) 一种业务处理方法及装置
WO2023226791A1 (zh) 一种控制装置、控制方法及相关设备
US20230362084A1 (en) Rational value rate limiter
CN110286743A (zh) 一种数据中心节电方法、终端、计算机可读存储介质
CN116745754A (zh) 一种访问远端资源的系统及方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18877048

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 30.09.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18877048

Country of ref document: EP

Kind code of ref document: A1