[go: up one dir, main page]

CN111580949A - Automatic network packet receiving mode adjusting method - Google Patents

Automatic network packet receiving mode adjusting method Download PDF

Info

Publication number
CN111580949A
CN111580949A CN202010361721.0A CN202010361721A CN111580949A CN 111580949 A CN111580949 A CN 111580949A CN 202010361721 A CN202010361721 A CN 202010361721A CN 111580949 A CN111580949 A CN 111580949A
Authority
CN
China
Prior art keywords
packet receiving
mode
processing thread
packet
processing
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202010361721.0A
Other languages
Chinese (zh)
Other versions
CN111580949B (en
Inventor
刘佳
范渊
吴永越
郑学新
刘韬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu DBAPPSecurity Co Ltd
Original Assignee
Chengdu DBAPPSecurity Co Ltd
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 Chengdu DBAPPSecurity Co Ltd filed Critical Chengdu DBAPPSecurity Co Ltd
Priority to CN202010361721.0A priority Critical patent/CN111580949B/en
Publication of CN111580949A publication Critical patent/CN111580949A/en
Application granted granted Critical
Publication of CN111580949B publication Critical patent/CN111580949B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a method for realizing automatic adjustment of a network packet receiving mode. Firstly, dividing a mode of receiving and processing network messages by software into four packet receiving modes of full interruption, interruption batch processing, interval polling, busy polling and the like; then, a network packet receiving scheduling program is designed, the current network load condition is calculated according to the read-write statistics of the packet receiving queue, and the packet receiving mode is adjusted according to the network load condition. According to the scheme, the network IO processing performance and the CPU utilization rate can be well balanced through automatic adjustment of the packet receiving mode.

Description

Automatic network packet receiving mode adjusting method
Technical Field
The invention belongs to the field of computer program operation, and particularly relates to an automatic network packet receiving mode adjusting method.
Background
With the improvement of the performance of the general-purpose processor and the rise of the cloud computing technology, more and more network devices gradually turn to the software implementation of the general-purpose processor. While flexibility and low cost are brought, a software package receiving processing mode based on kernel interruption gradually becomes a performance bottleneck. The reason for this is that when a network device receives a large amount of network messages, interrupts occur frequently, and interrupts execution of message processing logic frequently, so that a large amount of CPU processing time is consumed in context switching.
In order to solve the problem of low performance of interrupted packet reception, some high performance network solutions based on a polling mode such as busy have been proposed, such as PF _ RING and DPDK. The busy polling mode avoids the CPU overhead caused by frequent interruption, and when the network load is very high, the CPU obtains higher network message processing capacity. However, the polling mode also has a problem that when the network load is not high, a busy polling program or other polling programs still continuously occupy the CPU and continuously access the empty packet receiving queue, and the CPU cannot process other computing tasks, so that the performance of the whole computer is reduced and the power consumption is increased.
Some solutions attempt to combine the interrupt and polling modes in an attempt to gain the benefits of both modes. For example, the NAPI network driver of the Linux kernel allows the polling packet to be executed for a plurality of times after one interrupt, and the polling times and the polling time interval can be configured. This mode is referred to herein as an interrupt batch mode. In this way, a wider network load scene can be adapted through the configuration of the polling times and the polling intervals. However, the interrupt batch processing mode still lacks a mechanism for automatically adjusting the polling interval and the polling frequency according to the load, so that the polling adjustment is not timely enough, and the best performance balance of the CPU and the network cannot be obtained. The packet receiving load condition of the network equipment can change along with time, and the packet receiving mode of the current network equipment software packet receiving scheme is not flexible enough, so that the packet receiving mode cannot be adjusted in time when the network load changes, and the network IO performance is insufficient or the CPU utilization rate is not high. For example, when the network load is very low, the interruption packet receiving mode can be used to avoid the idle consumption of the CPU caused by polling the empty queue, and the use of polling busy mode and other modes can cause the reduction of the utilization rate of the CPU; when the network load is very high, the packet receiving modes such as the polling busy mode and the like can avoid the context switching expense caused by frequent occurrence of CPU interruption, and the highest network processing performance is obtained, while the interruption packet receiving mode can cause that the CPU is idle in the context switching interruption, and the network performance is reduced.
Description of terms:
interrupting: the interruption means that when some accident occurs and the host needs to intervene in the running process of the computer, the machine can automatically stop the running program and transfer to the program for processing the new condition, and after the processing is finished, the original suspended program is returned to continue running
Polling: the CPU sends out inquiry at regular time, and inquires whether each object needs its service in sequence, if so, the service is given, and after the service is over, the next object is inquired again and again.
Disclosure of Invention
Aiming at the problem that the prior art can not well balance the network IO processing performance and the CPU utilization rate, the invention provides the automatic adjustment method of the network packet receiving mode.
The specific implementation content of the invention is as follows:
the invention provides an automatic adjustment method of a network packet receiving mode, which sets four packet receiving processing modes according to the load of a packet receiving processing thread, namely the packet receiving processing rate of the packet receiving processing thread: a complete interrupt mode, an interrupt batch processing mode, an interval polling mode, a busy polling mode and other polling modes; and setting a packet receiving scheduler to switch the modes of a plurality of packet receiving processing threads at the same time.
In order to better implement the invention, further, the ranges of the processing loads are respectively set for the four modes of the packet receiving processing thread; for the mode switching of the packet receiving processing thread, the specific operation is as follows:
when the load of the packet receiving processing thread in the complete interrupt mode exceeds the set range of the complete interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the complete interrupt mode to an interrupt batch processing mode;
when the load of the packet receiving processing thread in the interrupted batch processing mode exceeds the set range of the interrupted batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupted batch processing mode to the interval polling mode; when the load of the packet receiving processing thread in the interrupt batch processing mode is lower than the set range of the interrupt batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupt batch processing mode to a complete interrupt mode;
when the load of the packet receiving processing thread in the interval polling mode exceeds the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to a polling mode such as busy; when the load of the packet receiving processing thread in the interval polling mode is lower than the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to the batch interruption processing mode;
when the load of the packet receiving processing thread in the busy and other polling mode is lower than the set range of the full interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the busy and other polling mode to the interval polling mode;
in addition, the shortest cycle of the switching mode is set for the packet receiving processing thread, and the packet receiving processing thread can be switched only when the packet receiving processing thread runs in one packet receiving mode for more than the shortest cycle.
In order to better implement the present invention, further, for the interrupt batch processing mode, an interrupt condition parameter N is set; the interrupt condition parameter N is the number of messages to be processed after the packet receiving process after each interrupt in the interrupt batch processing mode, and is the product of the actual load and the system scheduling period; and writing the interrupt condition parameter N into the memory by the packet receiving scheduler, and inquiring and using the interrupt condition parameter N by the packet receiving scheduler when the packet receiving processing process carries out packet receiving processing.
In order to better implement the present invention, further, for the interval polling mode, an intermittent polling condition parameter T is set, where the intermittent polling condition parameter T is a time interval at which the packet receiving processing thread needs to actively wait for sleep after processing all the messages in the network card receiving queue each time.
In order to better implement the present invention, further, the specific process of the packet receiving scheduler performing mode switching on the packet receiving processing thread is as follows:
(1) firstly, initializing a scheduling timer;
(2) then initializing a statistical timer;
(3) starting a packet receiving thread according to an initial mode of the packet receiving processing thread;
(4) then, starting to periodically execute packet receiving scheduling, namely switching a packet receiving mode of a packet receiving thread processing thread, and specifically comprising the following steps:
s1, firstly, calculating the message processing speed of each packet receiving processing thread;
s2, judging whether the packet receiving processing thread exceeds a load range corresponding to the current mode or not;
s3, if judging that the load range corresponding to the current mode is not exceeded, re-performing the operation in the step S1; if the judgment result is that the load range corresponding to the current mode is exceeded, judging whether the running time of the packet receiving processing thread in the current mode reaches the shortest cycle of switching the packet receiving mode or not;
s4, for the packet receiving processing thread of which the current mode running time is judged not to exceed the shortest period, the processing in the step S1 is carried out again; and if the current mode running time is judged to exceed the packet receiving processing thread with the shortest cycle, switching the packet receiving modes according to the current load condition and the set load range corresponding to each hand packet mode.
In order to better implement the present invention, there are two statistical counters for each packet receiving processing thread, which are respectively a P counter for recording the processing number of the data packet at the current time and an N counter for recording the number of the data packets that have been processed at the previous statistical time.
In order to better implement the present invention, further, the execution cycle of the packet receiving scheduler is set as T scheduling, and the value of the load of the packet receiving processing thread is the difference value obtained by subtracting the value recorded by the P counter from the value recorded by the N counter and then dividing the difference value by T scheduling.
To better implement the present invention, further, the periodic execution of the packet receiving scheduler relies on a system clock trigger, and the initialization scheduling timer is operable to: and setting a timer according to the configured packet receiving scheduler execution period.
In order to better implement the present invention, further, each packet receiving processing thread needs to process data of one packet receiving queue, and the specific workflow mainly includes:
firstly, reading the data packet of the packet receiving queue, then processing the read data packet, after the read data packet is processed, updating the statistical counter corresponding to the packet receiving processing thread of the data packet receiving queue, then continuously reading the data packet of the packet receiving queue, and circulating the above operations.
In order to better implement the present invention, further, in the complete interrupt mode, the packet receiving interrupt of each network card is sent to the packet receiving processing thread;
in the interrupt batch processing mode, after receiving the packet receiving interrupt of the network card for many times, the driver collects and sends the packet to a packet receiving processing thread;
under the interruption batch processing mode, calculating and setting the number of messages to be processed by a packet receiving processing thread in one interruption;
in the interval polling mode, completely closing the network card interruption, actively yielding the central processing unit CPU after the packet receiving processing thread processes the message of the packet receiving queue, sleeping for a time interval, interrupting the execution of other threads again, and preempting the central processing unit CPU to execute the packet receiving queue scanning polling;
in the busy polling mode and the like, the network card interruption is completely closed, and after the packet receiving processing thread processes the message of the packet receiving queue, the central processing unit CPU is not yielded, and the central processing unit CPU is continuously preempted to execute the packet receiving queue scanning polling;
the number of times of interruption of the network card is the number of messages to be processed by reading the packet receiving queue once by the packet receiving processing thread.
Compared with the prior art, the invention has the following advantages and beneficial effects:
better balance between the network IO processing performance and the CPU utilization rate is realized; the packet receiving load condition of the network equipment can change along with time, and the network equipment has corresponding optimal network packet receiving modes under different network loads.
Drawings
FIG. 1 is a diagram illustrating the switching of four packet receiving modes;
FIG. 2 is a schematic diagram of the work flow of a packet receiving scheduler;
FIG. 3 is a schematic diagram of a work flow of a packet receiving processing thread;
fig. 4 is a schematic processing flow diagram of four packet receiving modes.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it should be understood that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments, and therefore should not be considered as a limitation to the scope of protection. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
Example 1:
the invention provides a network packet receiving mode automatic adjusting method, as shown in fig. 1 and 4, the method sets four packet receiving processing modes according to the load of a packet receiving processing thread, namely the packet receiving processing rate of the packet receiving processing thread: a complete interrupt mode, an interrupt batch processing mode, an interval polling mode, a busy polling mode and other polling modes; and setting a packet receiving scheduler to switch the mode switching of a plurality of packet receiving processing threads at the same time.
In order to better implement the invention, further, the ranges of the processing loads are respectively set for the four modes of the packet receiving processing thread; for the mode switching of the packet receiving processing thread, the specific operation is as follows:
when the load of the packet receiving processing thread in the complete interrupt mode exceeds the set range of the complete interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the complete interrupt mode to an interrupt batch processing mode;
when the load of the packet receiving processing thread in the interrupted batch processing mode exceeds the set range of the interrupted batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupted batch processing mode to the interval polling mode; when the load of the packet receiving processing thread in the interrupt batch processing mode is lower than the set range of the interrupt batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupt batch processing mode to a complete interrupt mode;
when the load of the packet receiving processing thread in the interval polling mode exceeds the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to a polling mode such as busy; when the load of the packet receiving processing thread in the interval polling mode is lower than the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to the batch interruption processing mode;
when the load of the packet receiving processing thread in the busy and other polling mode is lower than the set range of the full interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the busy and other polling mode to the interval polling mode;
in addition, the shortest cycle of the switching mode is set for the packet receiving processing thread, and the packet receiving processing thread can be switched only when the packet receiving processing thread runs in one packet receiving mode and exceeds the shortest cycle;
in the complete interruption mode, transmitting each packet receiving interruption of the network card to a packet receiving processing thread;
in the interrupt batch processing mode, after receiving the packet receiving interrupt of the network card for many times, the driver collects and sends the packet to a packet receiving processing thread;
under the interruption batch processing mode, calculating and setting the number of messages to be processed by a packet receiving processing thread in one interruption;
in the interval polling mode, completely closing the network card interruption, actively yielding the central processing unit CPU after the packet receiving processing thread processes the message of the packet receiving queue, sleeping for a time interval, interrupting the execution of other threads again, and preempting the central processing unit CPU to execute the packet receiving queue scanning polling;
in the busy polling mode and the like, the network card interruption is completely closed, and after the packet receiving processing thread processes the message of the packet receiving queue, the central processing unit CPU is not yielded, and the central processing unit CPU is continuously preempted to execute the packet receiving queue scanning polling;
the number of times of interruption of the network card is the number of messages to be processed by reading the packet receiving queue once by the packet receiving processing thread.
The working principle is as follows: as shown in fig. 1, the core of the solution of the present invention is that a packet reception scheduler and a packet reception processing thread jointly maintain a packet reception mode state machine. When the packet receiving scheduler detects that the load of the packet receiving processing thread, namely the packet receiving processing rate, changes, the mode to which the packet receiving scheduler needs to be switched is judged according to the load condition. The mode switching is completed by a packet receiving scheduler, and the switching process mainly comprises switching interruption and setting parameters of batch processing and polling. It should be noted that the packet receiving scheduler and the packet receiving processing thread need to be bound to different CPU cores, so as to avoid the influence of the packet receiving scheduler thread on the packet receiving processing thread.
Interrupting the batch mode requires setting a parameter: namely the number of messages to be processed in each interruption; the parameter value is calculated from the actual load and the interruption batch processing mode parameter, and is written into the memory by the packet receiving scheduler, and is inquired and used by the packet receiving program. If the number of network card interrupts in batch processing is N, the calculation formula of N is: n = load x operating system scheduling period.
The same interval polling mode requires setting a parameter: and the packet receiving processing thread needs to actively sleep for waiting for a time interval after processing all the messages of the network card receiving queue each time. If the polling interval of interval polling is "T polling", the calculation formula is: tpround = 2 × operating system scheduling period [ (busy equal load-current load)/(busy equal load-minimum load) ].
Example 2:
in order to better implement the present invention based on the above embodiment 1, as shown in fig. 2, an interrupt condition parameter N is set for the interrupt batch processing mode; the interrupt condition parameter N is the number of messages to be processed after the packet receiving process after each interrupt in the interrupt batch processing mode, and is the product of the actual load and the system scheduling period; and writing the interrupt condition parameter N into the memory by the packet receiving scheduler, and inquiring and using the interrupt condition parameter N by the packet receiving scheduler when the packet receiving processing process carries out packet receiving processing.
And setting an intermittent polling condition parameter T for the interval polling mode, wherein the intermittent polling condition parameter T is a time interval in which the packet receiving processing thread needs to actively sleep and wait after processing all messages of the network card receiving queue each time.
The specific process of the packet receiving scheduling program for carrying out mode switching on the packet receiving processing thread is as follows:
(1) firstly, initializing a scheduling timer;
(2) then initializing a statistical timer;
(3) starting a packet receiving processing thread according to an initial mode of the packet receiving processing thread;
(4) then, starting to periodically execute packet receiving scheduling, namely switching a packet receiving mode of a packet receiving processing thread, and specifically comprising the following steps:
s1, firstly, calculating the message processing speed of each packet receiving processing thread;
s2, judging whether the packet receiving processing thread exceeds a load range corresponding to the current mode or not;
s3, if judging that the load range corresponding to the current mode is not exceeded, re-performing the operation in the step S1; if the judgment result is that the load range corresponding to the current mode is exceeded, judging whether the running time of the packet receiving processing thread in the current mode reaches the shortest cycle of switching the packet receiving mode or not;
s4, for the packet receiving processing thread of which the current mode running time is judged not to exceed the shortest period, the processing in the step S1 is carried out again; and if the current mode running time is judged to exceed the packet receiving processing thread with the shortest cycle, switching the packet receiving modes according to the current load condition and the set load range corresponding to each hand packet mode.
The number of the statistical counters of each packet receiving processing thread is two, and the two statistical counters are respectively a P counter for recording the processing number of the data packets at the current time and an N counter for recording the number of the data packets which are processed at the previous statistical time;
and setting the execution cycle of the packet receiving scheduler as T scheduling, wherein the value of the load of the packet receiving processing thread is the difference value obtained by subtracting the value recorded by the P counter from the value recorded by the N counter and then dividing the difference value by the T scheduling.
The periodic execution of the packet receiving scheduler is triggered by a system clock, and the initialization scheduling timer is operable to: and setting a timer according to the configured packet receiving scheduler execution period.
The working principle is as follows: for the packet receiving scheduler, the configuration items are specifically shown in table 1 below:
Figure 275204DEST_PATH_IMAGE001
TABLE 1
The periodic execution of the packet receiving scheduler is triggered by depending on a system clock, and the initialization of the scheduling timer is to set the timer according to the configured execution period of the packet receiving scheduler. Each packet receiving processing thread processes data of one packet receiving queue, two statistical counters are arranged, and the total number of the statistical counters is equal to twice of the number of the packet receiving processing threads. The two statistical counters are named as a "P counter" and an "N counter" and respectively record the packet processing number at the current time and the packet number which has been processed at the previous statistical time. Initializing the statistics counter refers to clearing the value of the statistics counter. If the execution cycle of the scheduler is "T scheduling", the packet receiving processing speed, that is, the calculation formula of the load is: load = (N counter-P counter)/T schedule. The unit of load is "number/second". After the load is calculated, the scheduler updates the value of the N counter into the P counter. After initialization, the N counter is updated by a packet receiving processing thread, and a packet receiving scheduler only performs reading operation on the N counter. When the calculated load exceeds the current mode range, the packet receiving scheduler does not immediately switch the packet receiving mode of the packet receiving processing thread, but first judges whether the running time of the current mode reaches the shortest period for switching the packet receiving mode. The shortest cycle of the packet receiving mode switching is far longer than the execution cycle of the packet receiving scheduling program, so that the switching overhead caused by mode switching is avoided frequently.
Other parts of this embodiment are the same as those of embodiment 1, and thus are not described again.
Example 3:
on the basis of any of the foregoing embodiments 1-2, in order to better implement the present invention, as shown in fig. 3, further, each packet receiving processing thread needs to process data of one packet receiving queue, and a specific workflow mainly includes:
firstly, reading the data packet of the packet receiving queue, then processing the read data packet, after the read data packet is processed, updating the statistical counter corresponding to the packet receiving processing thread of the data packet receiving queue, then continuously reading the data packet of the packet receiving queue, and circulating the above operations.
The working principle is as follows: the packet receiving processing thread is an independent execution unit, and the packet receiving scheduler only controls the execution mode and does not interfere with the specific packet receiving process. And secondly, the packet receiving processing thread only updates the N counter, and the P counter is updated by the packet receiving scheduler.
Other parts of this embodiment are the same as any of embodiments 1-2 described above, and thus are not described again.
Example 4:
in the present invention, on the basis of any one of the above embodiments 1 to 3, the load threshold when the mode switching occurs is determined by a configuration parameter "packet receiving rate range corresponding to each packet receiving mode", for example, in a certain embodiment, the packet receiving rate ranges of the various modes determined according to the CPU and the software load are as shown in table 2 below:
Figure 254661DEST_PATH_IMAGE002
TABLE 2
The current packet receiving rate is 1.5MPPS, and the corresponding packet receiving mode is a full interruption mode. When the network load becomes heavy, the packet reception rate becomes 3 MPPS. The receive packet scheduler switches the mode to the interrupt batch mode.
Other parts of this embodiment are the same as any of embodiments 1 to 3, and thus are not described again.
Example 5:
on the basis of any one of the above embodiments 1 to 4, the present invention can be specifically applied to the following scenarios:
scene 1: the Linux kernel NAPI packet receiving processing module is improved: and adding a kernel thread to carry out IO scheduling, configuring the netdev _ budget/netdev _ budget _ uses value of the NAPI in real time, and solving the problem of limited scene in the practical use of the NAPI.
Scene 2: improving the default busy polling modes in the DPDK packet receiving process: the packet receiving processing thread adds a plurality of packet receiving modes and a packet receiving mode scheduling program. The idle consumption of the CPU when the network load is low in polling such as busy is avoided, and the energy efficiency is improved.
Scene 3: in a dedicated network processor: besides a software implementation mode, the mode scheduling method can be applied to a special hardware network processor, and higher network performance and CPU utilization rate can be obtained.
Other parts of this embodiment are the same as any of embodiments 1 to 4, and thus are not described again.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and all simple modifications and equivalent variations of the above embodiments according to the technical spirit of the present invention are included in the scope of the present invention.

Claims (10)

1. A network packet receiving mode automatic regulating method is characterized in that four packet receiving processing modes are set according to the load of a packet receiving processing thread, namely the packet receiving processing rate of the packet receiving processing thread: a complete interrupt mode, an interrupt batch processing mode, an interval polling mode, a busy polling mode and other polling modes; and setting a packet receiving scheduler to switch the modes of a plurality of packet receiving processing threads at the same time.
2. The method as claimed in claim 1, wherein the four modes of the packet receiving processing thread are respectively set with a range of processing load; for the mode switching of the packet receiving processing thread, the specific operation is as follows:
(1) when the load of the packet receiving processing thread in the complete interrupt mode exceeds the set range of the complete interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the complete interrupt mode to an interrupt batch processing mode;
(2) when the load of the packet receiving processing thread in the interrupted batch processing mode exceeds the set range of the interrupted batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupted batch processing mode to the interval polling mode; when the load of the packet receiving processing thread in the interrupt batch processing mode is lower than the set range of the interrupt batch processing mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interrupt batch processing mode to a complete interrupt mode;
(3) when the load of the packet receiving processing thread in the interval polling mode exceeds the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to a polling mode such as busy; when the load of the packet receiving processing thread in the interval polling mode is lower than the set range of the interval polling mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the interval polling mode to the batch interruption processing mode;
(4) when the load of the packet receiving processing thread in the busy and other polling mode is lower than the set range of the full interrupt mode, the packet receiving scheduler switches the mode of the packet receiving processing thread from the busy and other polling mode to the interval polling mode;
in addition, the shortest cycle of the switching mode is set for the packet receiving processing thread, and the packet receiving processing thread can be switched only when the packet receiving processing thread runs in one packet receiving mode for more than the shortest cycle.
3. The method as claimed in claim 1, wherein for the interrupt batch processing mode, an interrupt condition parameter N is set; the interrupt condition parameter N is the number of messages to be processed by a packet receiving process after each interrupt of the interrupt batch processing mode, and is the product of the actual load and the system scheduling period; and writing the interrupt condition parameter N into the memory by the packet receiving scheduler, and inquiring and using the interrupt condition parameter N by the packet receiving scheduler when the packet receiving processing process carries out packet receiving processing.
4. The method according to claim 1, wherein for the interval polling mode, an intermittent polling condition parameter T is set, and the intermittent polling condition parameter T is a time interval during which the packet reception processing thread needs to actively wait for sleep after processing all the messages in the network card reception queue each time.
5. The method as claimed in claim 2, wherein the specific process of the packet receiving scheduler performing mode switching on the packet receiving processing thread includes:
(1) firstly, initializing a scheduling timer;
(2) then initializing a statistical timer;
(3) starting a packet receiving thread according to an initial mode of the packet receiving processing thread;
(4) then, starting to periodically execute packet receiving scheduling, namely switching a packet receiving mode of a packet receiving thread processing thread, and specifically comprising the following steps:
s1, firstly, calculating the message processing speed of each packet receiving processing thread;
s2, judging whether the packet receiving processing thread exceeds a load range corresponding to the current mode or not;
s3, if judging that the load range corresponding to the current mode is not exceeded, re-performing the operation in the step S1; if the judgment result is that the load range corresponding to the current mode is exceeded, further judging whether the running time of the packet receiving processing thread in the current mode reaches the shortest cycle of switching the packet receiving mode;
s4, for the packet receiving processing thread of which the current mode running time is judged not to exceed the shortest period, the processing in the step S1 is carried out again; and if the current mode running time is judged to exceed the packet receiving processing thread with the shortest cycle, switching the packet receiving modes according to the current load condition and the set load range corresponding to each packet receiving mode.
6. The method as claimed in claim 5, wherein the two statistical counters for each packet receiving processing thread are respectively a P counter for recording the processing number of the data packets at the current time and an N counter for recording the number of the data packets that have been processed at the previous statistical time.
7. The method as claimed in claim 6, wherein the execution cycle of the packet receiving scheduler is set as T scheduling, and the load of the packet receiving processing thread is obtained by dividing the difference between the value recorded by the N counter and the value recorded by the P counter by T scheduling.
8. The method as claimed in claim 5, wherein the periodic execution of the packet reception scheduler relies on a system clock trigger, and the initialization scheduling timer is operative to: and setting a timer according to the configured packet receiving scheduler execution period.
9. The method according to claim 5, wherein each of the packet receiving processing threads needs to process data of a packet receiving queue, and a specific workflow mainly comprises:
firstly, reading the data packet of the packet receiving queue, then processing the read data packet, after the read data packet is processed, updating the statistical counter corresponding to the packet receiving processing thread of the data packet receiving queue, then continuously reading the data packet of the packet receiving queue, and circulating the above operations.
10. The method according to any one of claims 1 to 9, wherein in the full interrupt mode, each packet reception interrupt of the network card is sent to a packet reception processing thread;
in the interrupt batch processing mode, after receiving the packet receiving interrupt of the network card for many times, the driver collects and sends the packet to a packet receiving processing thread;
under the interruption batch processing mode, calculating and setting the number of messages to be processed by a packet receiving processing thread in one interruption;
in the interval polling mode, completely closing the network card interruption, actively yielding the central processing unit CPU after the packet receiving processing thread processes the message of the packet receiving queue, sleeping for a time interval, interrupting the execution of other threads again, and preempting the central processing unit CPU to execute the packet receiving queue scanning polling;
in the busy polling mode and the like, the network card interruption is completely closed, and after the packet receiving processing thread processes the message of the packet receiving queue, the central processing unit CPU is not yielded, and the central processing unit CPU is continuously preempted to execute the packet receiving queue scanning polling;
the number of times of interruption of the network card is the number of messages to be processed by reading the packet receiving queue once by the packet receiving processing thread.
CN202010361721.0A 2020-04-30 2020-04-30 Automatic regulating method for network packet receiving mode Active CN111580949B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010361721.0A CN111580949B (en) 2020-04-30 2020-04-30 Automatic regulating method for network packet receiving mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010361721.0A CN111580949B (en) 2020-04-30 2020-04-30 Automatic regulating method for network packet receiving mode

Publications (2)

Publication Number Publication Date
CN111580949A true CN111580949A (en) 2020-08-25
CN111580949B CN111580949B (en) 2023-08-22

Family

ID=72123028

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010361721.0A Active CN111580949B (en) 2020-04-30 2020-04-30 Automatic regulating method for network packet receiving mode

Country Status (1)

Country Link
CN (1) CN111580949B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113079114A (en) * 2021-06-04 2021-07-06 鹏城实验室 Data packet receiving method, device, terminal and storage medium
CN113176950A (en) * 2021-04-09 2021-07-27 杭州迪普科技股份有限公司 Message processing method, device, equipment and computer readable storage medium
CN113688076A (en) * 2021-10-25 2021-11-23 浙江国利信安科技有限公司 EPA-based data communication method, computing device and medium
CN114371942A (en) * 2021-12-24 2022-04-19 锐捷网络股份有限公司 Data packet receiving method, device, electronic equipment and storage medium

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB9906501D0 (en) * 1999-03-23 1999-05-12 Ibm Data processing systems and method for processing work items in such systems
JP2001216170A (en) * 2000-01-31 2001-08-10 Mitsubishi Electric Corp Operation method incorporating exclusive polling processing, operating system incorporating exclusive polling processing
US20030025686A1 (en) * 2001-08-03 2003-02-06 Via Technologies, Inc. Method of automatically refreshing the display screen of a terminal and the computer program thereof
CN1408161A (en) * 1999-12-06 2003-04-02 艾利森电话股份有限公司 Batched fair exhaustive polling scheduler
CN1956438A (en) * 2005-10-28 2007-05-02 中兴通讯股份有限公司 Automatic switching method of message process mode
CN101247275A (en) * 2008-03-18 2008-08-20 杭州华三通信技术有限公司 Interrupt reporting method and network appliance
CN101855624A (en) * 2007-09-17 2010-10-06 苹果公司 Methods and apparatus for decreasing power consumption and bus activity
CN102075451A (en) * 2009-11-25 2011-05-25 Lg电子株式会社 Mobile terminal and method of providing email services in the mobile terminal
CN103179619A (en) * 2013-04-07 2013-06-26 北京邮电大学 Transmission mode adaptive switching method and device for LTE multi-antenna system
CN107368178A (en) * 2017-08-21 2017-11-21 湖南大学 Power consumption optimization method based on DPDK processing data packets platforms
CN107454003A (en) * 2017-08-18 2017-12-08 南京航空航天大学 It is a kind of can dynamic switching working mode network-on-chip router and method
CN107659512A (en) * 2017-10-18 2018-02-02 盛科网络(苏州)有限公司 A kind of method and apparatus for handling network interface card message
CN110278052A (en) * 2018-03-15 2019-09-24 大唐移动通信设备有限公司 A kind of data receiver method and device
CN110968403A (en) * 2018-09-28 2020-04-07 深信服科技股份有限公司 CPU work control method, device, equipment and storage medium

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB9906501D0 (en) * 1999-03-23 1999-05-12 Ibm Data processing systems and method for processing work items in such systems
CN1408161A (en) * 1999-12-06 2003-04-02 艾利森电话股份有限公司 Batched fair exhaustive polling scheduler
JP2001216170A (en) * 2000-01-31 2001-08-10 Mitsubishi Electric Corp Operation method incorporating exclusive polling processing, operating system incorporating exclusive polling processing
US20030025686A1 (en) * 2001-08-03 2003-02-06 Via Technologies, Inc. Method of automatically refreshing the display screen of a terminal and the computer program thereof
CN1956438A (en) * 2005-10-28 2007-05-02 中兴通讯股份有限公司 Automatic switching method of message process mode
CN101855624A (en) * 2007-09-17 2010-10-06 苹果公司 Methods and apparatus for decreasing power consumption and bus activity
CN101247275A (en) * 2008-03-18 2008-08-20 杭州华三通信技术有限公司 Interrupt reporting method and network appliance
CN102075451A (en) * 2009-11-25 2011-05-25 Lg电子株式会社 Mobile terminal and method of providing email services in the mobile terminal
CN103179619A (en) * 2013-04-07 2013-06-26 北京邮电大学 Transmission mode adaptive switching method and device for LTE multi-antenna system
CN107454003A (en) * 2017-08-18 2017-12-08 南京航空航天大学 It is a kind of can dynamic switching working mode network-on-chip router and method
CN107368178A (en) * 2017-08-21 2017-11-21 湖南大学 Power consumption optimization method based on DPDK processing data packets platforms
CN107659512A (en) * 2017-10-18 2018-02-02 盛科网络(苏州)有限公司 A kind of method and apparatus for handling network interface card message
CN110278052A (en) * 2018-03-15 2019-09-24 大唐移动通信设备有限公司 A kind of data receiver method and device
CN110968403A (en) * 2018-09-28 2020-04-07 深信服科技股份有限公司 CPU work control method, device, equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
K. SALAH等: ""Implementation and experimental performance evaluation of a hybrid interrupt-handling scheme"", 《COMPUTER COMMUNICATIONS》, pages 179 *
TOMAŽ BUH等: ""Adaptive network-traffic balancing on multi-core software networking devices"", 《COMPUTER NETWORKS》, vol. 69, pages 19 - 34 *
赵欢欢等: ""基于DPDK 混合中断轮询模式的报文传输框架"", vol. 44, no. 44, pages 319 - 322 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113176950A (en) * 2021-04-09 2021-07-27 杭州迪普科技股份有限公司 Message processing method, device, equipment and computer readable storage medium
CN113176950B (en) * 2021-04-09 2023-10-27 杭州迪普科技股份有限公司 Message processing method, device, equipment and computer readable storage medium
CN113079114A (en) * 2021-06-04 2021-07-06 鹏城实验室 Data packet receiving method, device, terminal and storage medium
CN113079114B (en) * 2021-06-04 2021-08-27 鹏城实验室 Data packet receiving method, device, terminal and storage medium
CN113688076A (en) * 2021-10-25 2021-11-23 浙江国利信安科技有限公司 EPA-based data communication method, computing device and medium
CN114371942A (en) * 2021-12-24 2022-04-19 锐捷网络股份有限公司 Data packet receiving method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111580949B (en) 2023-08-22

Similar Documents

Publication Publication Date Title
CN111580949A (en) Automatic network packet receiving mode adjusting method
US20210240252A1 (en) Platform and processor power management
KR100550195B1 (en) Power aware adaptive polling
US6430593B1 (en) Method, device and article of manufacture for efficient task scheduling in a multi-tasking preemptive priority-based real-time operating system
CN101354661B (en) System and method to optimize OS scheduling decisions for power savings based on temporal characteristics of the scheduled entity and system workload
KR101565865B1 (en) Method, apparatus, and system for scheduling processor core in multiprocessor core system
US6128672A (en) Data transfer using software interrupt service routine between host processor and external device with queue of host processor and hardware queue pointers on external device
US9772879B2 (en) System and method for isolating I/O execution via compiler and OS support
US7953906B2 (en) Multiple interrupt handling method, devices and software
US7191446B2 (en) Method for resource management in a real-time embedded system
JPH117429A (en) Interrupt load distribution method for shared bus type multiprocessor system
CN101366012A (en) Methods and system for interrupt distribution in a multiprocessor system
CN106557369A (en) A kind of management method and system of multithreading
CN111200541B (en) Network data processing method and device
US6173343B1 (en) Data processing system and method with central processing unit-determined peripheral device service
WO2015052501A1 (en) Scheduling function calls
JP6955163B2 (en) Information processing equipment, information processing methods and programs
EP3926452A1 (en) Norflash sharing
US7415559B1 (en) Data processing systems and method for processing work items in such systems
CN115686863A (en) Hybrid polling method, device, equipment and readable storage medium
WO2016058149A1 (en) Method for predicting utilization rate of processor, processing apparatus and terminal device
WO2023165485A1 (en) Scheduling method and computer system
CN116848508A (en) Scheduling tasks for computer execution based on reinforcement learning model
JP2015041199A (en) Information processing apparatus
CN116932227B (en) Task scheduling method and device based on single thread

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant