WO2017162096A1 - 一种调度方法及电子设备 - Google Patents

一种调度方法及电子设备 Download PDF

Info

Publication number
WO2017162096A1
WO2017162096A1 PCT/CN2017/076962 CN2017076962W WO2017162096A1 WO 2017162096 A1 WO2017162096 A1 WO 2017162096A1 CN 2017076962 W CN2017076962 W CN 2017076962W WO 2017162096 A1 WO2017162096 A1 WO 2017162096A1
Authority
WO
WIPO (PCT)
Prior art keywords
processor
data
electronic device
time slice
time
Prior art date
Application number
PCT/CN2017/076962
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 华为技术有限公司
Priority to EP17769373.6A priority Critical patent/EP3428801B1/en
Publication of WO2017162096A1 publication Critical patent/WO2017162096A1/zh
Priority to US16/139,817 priority patent/US10929179B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • 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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/301Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is a virtual computing platform, e.g. logically partitioned systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3419Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time
    • G06F11/3423Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time where the assessed time is active or idle time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3428Benchmarking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3433Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment for load management
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30181Instruction operation extension or modification
    • G06F9/30189Instruction operation extension or modification according to execution mode, e.g. mode flag
    • 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/5038Allocation 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 execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • 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
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a scheduling method and an electronic device.
  • NFV Network Functions Virtualization
  • IT Information Technology
  • VNF Virtualized Network Function
  • VM virtual machine
  • NFV technology usually runs a host (HOST) operating system (OS) in a physical host, and runs a guest operating system (OS) in a virtual machine; one or more physical hosts can contain one or more operating systems (OS) Virtual machine.
  • a physical host is a hardware device and belongs to an electronic device.
  • a virtual machine is a device obtained by software virtualization. Taking a virtual machine that includes a network card as an example, a device that uses Poll Mode Drivers (PMD) data processing performs a PMD cycle: receiving data packets, processing data packets, and transmitting data packets.
  • PMD Poll Mode Drivers
  • the loop execution process is executed in the form of an infinite loop after the virtual machine is started, which causes the processor to be in a busy state and has high energy consumption.
  • the embodiment of the invention provides a scheduling method and an electronic device for reducing energy consumption.
  • the embodiment of the present invention provides a scheduling method, which is applied to an electronic device, and the method specifically includes:
  • the processor of the electronic device being configured to be in a first working mode, wherein the processor uses a polling mode to drive a PMD mode in the first working mode Data processing;
  • the processor Determining, according to the amount of data processed by the electronic device during the first monitoring period, that the processor is idle during the first monitoring period, switching the processor from the first working mode to the first In a second mode of operation, the processor processes data in a PMD and sleep mode in the second mode of operation.
  • the processor processes data in a PMD and sleep mode.
  • the processor may alternately process data in a PMD and sleep mode; the processor processes data in two ways: PMD processing data. And dormancy, the two ways of processing data alternately.
  • the data processing may be a receiving data message, a sending data message, or other data processing.
  • the content of the specific data processing is not limited by the embodiment of the present invention; the data is processed based on different data processing content.
  • the quantity will have different measurement methods; for example, the received data message can be determined by the number of received data messages.
  • the method for determining whether the processor is idle during the time period is determined by the amount of data processed by the processor in a certain period of time, and the method for receiving and/or transmitting the data packet is as follows: If the data traffic in the first monitoring period is less than or equal to the first threshold, determining that the processor is idle during the first monitoring period; the first threshold corresponds to the amount of data received in the unit time.
  • the threshold value may be: if it is monitored that the amount of data processed by the electronic device during the first monitoring period is less than or equal to the first threshold, determining that the processor is idle during the first monitoring period;
  • the first threshold corresponds to a threshold value of the amount of data processed in the first monitoring period.
  • the first threshold is to distinguish whether the processor is relatively idle threshold, and switch to a lower power consumption mode when the processor is idle.
  • the processor adopts the second working mode in a first basic time slice; and the processor processes data in a PMD and a sleep mode in the second working mode, including:
  • the first base time slice includes a first time period and a second time period
  • the processor sleeps during the first time period and operates during the second time period.
  • the first base time slice and the second base time slice in the subsequent embodiment are classifications of the basic time slice, wherein the first basic time slice may be that the processor switches from the first working mode to the second.
  • the first basic time slice after the working mode, or the second working mode the processor works by default in the basic time slice mode in each basic time slice; the second working mode may be the first one except the above
  • a specific implementation scheme for increasing the flexibility of the working state control is further provided. The method is as follows: after the processor ends the first basic time slice, the method further includes:
  • the processor determines a busy state of the processor when the first base time slice is in a busy state, when the processor is in a busy state in the first base time slice, the processor is at The first time period of the second base time piece works.
  • whether the processor works in the first time period depends on the current busy state of the processor
  • the data processing capability of the processor can be dynamically adjusted to make the data processing of the processor without switching the working mode of the processor.
  • the ability can match the actual demand, improve the response speed to the data processing demand, make the energy consumption and the actual data traffic have a linear positive correlation; and can avoid the switching of the working mode of the processor due to the sudden change of the instantaneous data traffic.
  • the working in the second time period includes:
  • the processor does not end in the second period of the first base time slice and the data processing is completed, ending the second time period of the first base time slice early, or in the second The time remaining in the time period is dormant.
  • the processor since the processor does not always have data to process in the second time period, there may be more time in the second time period when the processor is in the process of no data to be processed; Further increase the sleep time based on the actual demand of data processing, further reducing the power consumption of the processor.
  • the processor determines that the first base time slice of the processor is busy Status includes:
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first base time slice is a busy state.
  • the first threshold and the second threshold are both thresholds for determining whether the processor is busy in the first base time slice, wherein the first threshold is used as a reference for processing data consumption time, and the data is processed. The longer the time is, the more busy the processor is.
  • the second threshold is referenced by the amount of data. The larger the amount of data, the more busy the processor is; the specific value is not limited by the embodiment of the present invention.
  • the method further includes:
  • the electronic device determines that the busy state of the first base time slice is an idle state; the third threshold is less than Or equal to the first threshold;
  • the processor if the processor is in a sleep state at the end of the second time period of the first base time slice, or if the processor ends the second time period of the first base time slice early, then Determining, by the electronic device, that the busy state of the first basic time slice is an idle state;
  • the electronic device determines that the busy state of the first base time slice is an idle state;
  • the threshold is less than or equal to the second threshold.
  • the third threshold and the fourth threshold are both thresholds for determining whether the processor is busy in the first base time slice, wherein the third threshold is taken as a reference for processing the data, and the data is consumed. The longer the time is, the more busy the processor is.
  • the fourth threshold is referenced by the amount of data. The larger the amount of data, the more busy the processor is; the specific value is not limited by the embodiment of the present invention.
  • the method further includes:
  • the data traffic is used as the standard for measuring whether the processor is idle.
  • the embodiment may be: when the processor is in the second working mode, monitoring the electronic device in the second monitoring period. Data flow within the system; if the data flow of the electronic device during the second monitoring period is greater than or equal to the second threshold, the processor is switched from the second working mode to the first Working mode; the first threshold is greater than or equal to the second threshold.
  • the second threshold is used to determine that the processor is relatively busy, or that there are currently more data packets to be processed. In this case, the processor needs to maximize its data processing capability.
  • the second threshold is greater than the first threshold, and can be used as a preferred implementation.
  • the actual data processing amount is between the first threshold and the second threshold, the current working mode can be maintained, and the actual data processing amount is prevented from being at the first threshold. And the change in the vicinity of the second threshold In this case, the processor frequently switches between the first working mode and the second working mode.
  • the second embodiment of the present invention further provides an electronic device, including:
  • a data quantity detecting unit configured to monitor an amount of data processed by the electronic device during the first monitoring period
  • a switching control unit configured to: according to the data amount processed by the electronic device in the first monitoring period, that the processing unit is idle during the first monitoring period, switch the processing unit from the first working mode To the second mode of operation;
  • a processing unit configured to: when the processing unit is configured to be in a first working mode, in a first working mode, the processing unit processes data in a PMD manner; in the second working mode, the processing unit adopts PMD and sleep mode handle data.
  • the processing unit is specifically configured to adopt the second working mode in a first basic time slice in a second working mode; the first basic time slice includes a first time period And a second time period; the processing unit sleeps during the first time period and operates during the second time period.
  • processing unit further includes:
  • a busyness judging unit configured to determine, after the end of the first basic time slice, a busy state of the processing unit at the first basic time slice;
  • a work control unit configured to: when the busy determination unit determines that the busy state of the processing unit is busy in the first basic time slice, control the first time of the processing unit in the second basic time slice Paragraph work.
  • the processing unit is specifically configured to: if the processing unit does not end in the second period of the first basic time slice and the data processing is completed, end the foregoing A second time period of a base time slice, or a sleep time remaining in the second time period.
  • the busy determining unit is configured to: if the processing unit processes data in the first base time slice for a time greater than a first threshold, the electronic device determines the first The busy state of a basic time slice is busy;
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first base time slice is a busy state.
  • the busy determination unit is further configured to determine the first if the processing unit processes data in the first base time slice for less than the third threshold.
  • the busy state of the base time slice is an idle state; the third threshold is less than or equal to the first threshold;
  • the busy state of the first basic time slice is an idle state
  • the data volume detecting unit is further configured to monitor, when the processing unit is in the second working mode, the amount of data processed by the electronic device in the second monitoring period;
  • the switching control unit is further configured to determine, according to the amount of data processed by the electronic device in the second monitoring period, that the processing unit is busy during the second monitoring period, then the processing unit is configured by the The second mode of operation switches to the first mode of operation.
  • the data traffic is used as the standard for measuring whether the processing unit is idle.
  • the switching control unit is specifically configured to monitor the electronic device during the second monitoring period. When the data traffic is greater than or equal to the second threshold, the processing unit is switched from the second working mode to the first working mode; the first threshold is greater than or equal to the second threshold.
  • the third embodiment of the present invention further provides another electronic device, including: a processor, a communication module, and a memory; wherein the memory can provide a cache required by the processor to perform data processing;
  • the processor can perform the steps in the foregoing method embodiments to implement corresponding functions of the electronic device.
  • the specific implementation process of each step in the method embodiment may be stored in a memory in the form of software, and the processor executes the software to implement the steps in the foregoing method embodiments. This is not repeated in this embodiment.
  • the embodiment of the present invention has the following advantages: in an electronic device operating in a polling mode driving mode, two working modes are provided for the processor of the electronic device; wherein the first working mode power consumption Higher, the second operating mode consumes less power; by monitoring the amount of data processed by the processor, when the amount of data actually processed is small, using a lower energy operating mode can reduce energy consumption.
  • FIG. 1 is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a method according to an embodiment of the present invention.
  • 5A is a schematic structural diagram of a system according to an embodiment of the present invention.
  • 5B is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 6 is a schematic flowchart of a method according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of test results according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • FIG. 1 it is an example of a system structure of an embodiment of the present invention.
  • a physical host can use linux as an operating system, and a virtual machine running inside a physical host can replace proprietary hardware.
  • the virtual machine is like a real hardware device. It has a Data Plane (DP), a Control Plane (CP), and a Virtual Network Interface Controller (VNIC), that is, a virtual network card.
  • DP and CP are the concept of protocol layering, one is user data level, the other is control level, where DP is related to the processing and transmission of user data; corresponding to the structure CP shown in Figure 1 is related to The monitoring and control of the PMD in the VM, please refer to Figure 2 for the specific structure.
  • the virtual network card cannot directly communicate with the physical host outside the network interface controller (NIC), that is, the physical network card, there is a virtual data channel between the physical network card and the virtual network card, and then The physical NIC communicates with the outside of the physical host.
  • the data channel can be obtained by hardware virtualization technology such as Single Root I/O Virtualization (SR-IOV).
  • SR-IOV Single Root I/O Virtualization
  • the application (Application, APP) running in the virtual machine has the data packet receiving requirement, and the data packet is received in batch by the Poll Mode Drivers (PMD).
  • PMD Poll Mode Drivers
  • the system structure shown in Figure 1 mainly consists of two parts: the physical host running the host operating system and the virtual machine VM running the guest operating system; the physical host includes the physical network card NIC and SR-IOV, and the SR-IOV can also be located on the VM side.
  • VM includes DP APP, PMD, Linux User Space I/O Drivers, Userspace I/O (UIO) and VNIC; DP APP and PMD belong to user space.
  • UIO is a kernel space.
  • the data message sent in the PMD mode is as follows: the PMD is executed in an infinite loop: the data packet of the APP is attempted to be received, and the received data is processed. Data message, send processed data message. The data message sent by the PMD is sent to the VNIC, and then the VNIC sends it to the NIC through the SR-IOV, and the NIC sends the data packet to the outside of the physical host.
  • the APP stores the data packets to be sent in the shared memory, and then transfers the data from the PMD to the NIC.
  • the address information of the message in the shared memory for example, a pointer to the storage address of the data message in the shared memory.
  • the data packets between the physical host and the virtual machine are transparently transmitted, and the OS scheduling is less.
  • the data packet is not required to pass the physical memory card to the user-mode APP through the shared memory mechanism. Copy; based on user-mode DP isolation, NFV has better scalability; in addition, user-mode APP does not need to call the kernel to receive data messages.
  • the PMD mode has some advantages, such as: basically no power consumption and process control, so the implementation is relatively simple.
  • the data message can be equivalently replaced with the address information of the data message in the shared memory.
  • the APP does not send data packets, or the data volume of the data packets sent by the APP is small, the following conditions may occur: some loops are executed without receiving data packets, or once The amount of data received during the execution of the loop is lower than the maximum amount of data that can be processed in one cycle; that is, the number of data packets per unit time is small, that is, the data traffic is small.
  • the processor still performs an infinite loop and maintains 100% utilization, the power consumption of the processor will remain at a fixed high level, and power consumption is extremely wasteful. To put it another way: the utilization rate of the processor is 100%, but the actual received data packets are few, so the power consumption is large and the efficiency is low.
  • the embodiment of the present invention provides a more refined power consumption management scheme, so that the APP receives less data packets (ie, the data traffic is smaller).
  • the processor power is reduced by the control plane.
  • the manner of reducing the power consumption of the processor may include: reducing the main frequency of the processor, or letting the processor be in a non-working state at certain times. The way to reduce the processor's main frequency can be achieved by configuring the processor's main frequency or reducing the processor's voltage.
  • Supporting the implementation of reducing the main frequency is determined; letting the processor be in a non-working state at certain times may be: letting the processor sleep intermittently, or intermittently stopping the execution of the dead loop; the dormant implementation scheme is in different application scenarios. There may be different sleep options. For example, in the application scenario of a single-core processor, the entire processor can be hibernated. In a scenario where the processor has multiple cores or many cores, all cores of the processor can be dormant. It can be part of the core sleep of the processor. The embodiment of the present invention mainly uses the latter method to reduce processor power consumption.
  • the embodiment of the present invention provides a scheduling method, which is applied to an electronic device. As shown in FIG. 2, the method specifically includes:
  • the power consumption may be lower.
  • the grading of the working mode of the processor may not be limited to two working modes.
  • the “first working mode” and the “second working mode” are used only for distinguishing processing.
  • the two modes of operation of the device should not be understood as being able to divide only two modes of operation.
  • processing data by PMD refers to a technical means for driving an electronic device to perform data processing by means of polling.
  • the technical means is characterized by performing an infinite loop to try to receive a data message or asking whether There is data to process; it will cause the processor to be running at full capacity.
  • the processor in the embodiment of the present invention should not be limited to only the physical processor of the electronic device, but should also be extended to the data processing resource allocated to the virtual machine. .
  • the second working mode may theoretically reduce the data processing resources allocated to the VM, or the VM may reduce the occupancy of the allocated data processing resources.
  • the processed data may be a received data message, and the amount of data may be measured by the amount of the received data message; after monitoring the amount of data processed by the electronic device, the data amount may be calculated.
  • the step may be more specifically: monitoring data traffic received by the electronic device, the processor of the electronic device is configured to be in a first working mode, and the processor receives the datagram by using a PMD mode in the first working mode.
  • Data traffic refers to the amount of data actually received in a unit of time.
  • the amount of data can be measured by data packet data. Therefore, the number of data packets received during the first monitoring period and the first monitoring period can be The ratio of the length of time.
  • first and second in the embodiment of the present invention to distinguish the technical names does not represent other technical meanings; for example, “first working mode” and “second working mode” represent two types of processors. Different working modes, wherein the second working mode increases the sleep time compared to the first working mode.
  • the “first threshold” and the “second threshold” represent threshold values of two different data flows, respectively, for distinguishing between a threshold that the processor needs to switch to the power-saving mode and a threshold that needs to be switched to the performance mode.
  • the step may be more specifically: when the data flow of the electronic device in the first monitoring period is less than or equal to the first threshold, the processor is configured by the first The working mode is switched to the second working mode.
  • the amount of data processed by the monitoring electronic device can be implemented by using periodic monitoring, so
  • the first monitoring period may be a period of time for periodic monitoring, and the time of each monitoring period is equal.
  • the embodiment may be specifically as follows: during the first working mode of the processor of the electronic device, monitoring the electronic device in the first monitoring The number of data packets received in the time period is changed by the first working mode when the number of data packets received by the electronic device in the first monitoring time period is less than or equal to a predetermined threshold. Go to the second working mode. It can be seen that if the first monitoring time period is a fixed value, the data quantity is used as a measure and the data flow is used as a standard, and the technical effects are the same, and have an equivalent relationship.
  • the first threshold may be a set value, which is used to measure the size of the data traffic. Due to different processors, the speed of receiving data packets may be different, so the data traffic that can be withheld will be different; the first threshold is for The threshold value can be set according to the experience. The threshold value can be set according to the experience. In addition, based on the embodiment of the present invention, after the actual test, it is determined that the first threshold is more specific, and the specific value is The embodiments of the invention are not limited by definition.
  • the executor of the embodiment of the present invention may be an electronic device, and the electronic device may be a physical host as in the foregoing embodiment, such as a server, a terminal host, or the like; or any other electronic device that processes data by using a PMD; If the data is applied to the NFV technology, if the VM processes the data in the manner of the PMD, the electronic device may be an electronic device that provides hardware resources for the VM.
  • the embodiment of the present invention does not uniquely define the specific expression of the electronic device.
  • two working modes are provided for the processor of the electronic device; wherein the first operating mode consumes higher power and the second operating mode consumes relatively lower power.
  • the energy consumption can be reduced by using a lower energy consumption mode when the amount of data actually processed is small.
  • the data is processed alternately by using the PMD and the dormant mode, which may be an arbitrary alternate mode.
  • the energy saving effect can be achieved by increasing the sleep time compared to the first working mode.
  • how to alternate data processing is as follows: the processor adopts the foregoing second working mode in the first basic time slice; and in the second working mode, the processor processes the data by using the PMD and the dormant mode, including:
  • the first base time slice includes a first time period and a second time period
  • the processor sleeps during the first time period and operates during the second time period.
  • the time period when the processor is in the second working mode, the time period may be composed of a plurality of first basic time periods, and each of the basic time periods may be longer or shorter, and the first basic time is The slice is divided into a first time period and a second time period to control the working mode.
  • the processor operation refers to processing data by using the PMD method, and processing data by using the PMD method does not necessarily mean that the data is processed. Whether the data is processed depends on whether there is actually data to be processed; the processor sleep refers to the processor. The data is not processed, that is, the operation of processing the data in the PMD mode is not performed when the processor sleeps regardless of whether or not data needs to be processed.
  • the embodiment of the present invention is used to control the working mode by dividing the basic time slice into the first time segment and the second time segment.
  • the embodiment of the present invention further provides a specific implementation scheme for increasing the flexibility of the working mode control, which is specifically as follows: After the first basic time slice ends, the above method further includes:
  • the processor determines a busy state of the processor at the first base time slice, and when the busy state of the processor in the first base time slice is busy, the processor is in the second base time slice Work in the first time period.
  • the busy state means that the amount of data received and processed is greater than a certain threshold, which means that the processor is busy and the actual load rate is high. , data traffic is large;
  • the idle state is that the processor is relatively idle, the actual load rate is relatively small, and the data traffic is small.
  • the data traffic received may be when the processor is in sleep or when the processor is in the working state. Less than another threshold.
  • whether the processor works in the first time period depends on the current busy state of the processor, dynamically adjusts the data processing capability of the processor, and enables the data processing capability of the processor without switching the working mode of the processor.
  • the embodiment of the present invention further provides a working mode control of the processor in the second time period of the basic time slice, which is specifically as follows: the foregoing working in the second time period includes:
  • the scheme of the embodiment can preferably set the basic time slice to be shorter, if the method of “prematurely ending the second time of the first basic time slice” is adopted, The second time period can be configured longer, and the setting is shorter. If the "sleeping in the remaining time in the second time period" is adopted, the first time period and the second time period are preferably configured to be shorter to improve the pair. The response speed of receiving data message requests.
  • the embodiment further provides a specific implementation scenario of determining a busy state of the processor in the first basic time slice according to the specific application scenario of the embodiment of the present invention, where the processor determines the first base time of the processor.
  • the busy status of the film includes:
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first base time slice is a busy state.
  • the first threshold and the second threshold are both thresholds for determining whether the processor is busy in the first base time slice, wherein the first threshold is used as a reference for processing data consumption time, and the data is processed. The longer the time is, the more busy the processor is.
  • the second threshold is referenced by the amount of data. The larger the amount of data, the more busy the processor is; the specific value is not limited by the embodiment of the present invention.
  • the embodiment further provides a specific implementation scenario of the processor in the busy state of the first basic time slice according to the specific application scenario of the embodiment of the present invention.
  • the method further includes:
  • the electronic device determines that the busy state of the first base time slice is an idle state; the third threshold is less than or equal to the first Threshold value
  • the electronic device determines the The busy state of the first basic time slice is an idle state
  • the electronic device determines that the busy state of the first base time slice is an idle state; the fourth threshold is less than or equal to the Second threshold.
  • the third threshold and the fourth threshold are both thresholds for determining whether the processor is busy in the first base time slice, wherein the third threshold is taken as a reference for processing the data, and the data is consumed. The longer the time is, the more busy the processor is.
  • the fourth threshold is referenced by the amount of data. The larger the amount of data, the more busy the processor is; the specific value is not limited by the embodiment of the present invention.
  • the embodiment of the present invention further provides a specific implementation of switching from the second working mode to the first working mode according to the foregoing embodiment, where the method further includes:
  • the processor After detecting the amount of data processed by the electronic device in the second monitoring period, and determining, according to the amount of data processed by the electronic device in the second monitoring period, that the processor is busy during the second monitoring period, The processor switches from the second mode of operation to the first mode of operation; the first threshold is greater than or equal to the second threshold.
  • the data traffic is used as the standard for measuring whether the processor is idle.
  • the embodiment may be: when the processor is in the second working mode, monitor the data of the electronic device during the second monitoring period.
  • the traffic is switched from the second working mode to the first working mode when the data flow of the electronic device in the second monitoring period is greater than or equal to the second threshold; the first threshold Greater than or equal to the second threshold.
  • the second threshold is used to determine that the processor is busy, or that there are currently more data packets to be received. In this case, the processor needs to maximize its data packet receiving capability.
  • the second threshold is greater than the first threshold, and can be used as a preferred implementation.
  • the actual data traffic is between the first threshold and the second threshold, the current working mode can be maintained, that is, no switching; thus, the actual data can be avoided.
  • the processor frequently switches between the first mode of operation and the second mode of operation.
  • the “first monitoring time period” and the “second monitoring time period” which will be mentioned later are all concepts of the time period, and the upper two segments of the monitoring may be time periods; The two monitoring periods can use different periods, so the first monitoring period and the second monitoring period can be different or the same.
  • the embodiment of the invention is not limited to this. The shorter the monitoring time period is set, the more sensitive the switching and the faster the response. The longer the setting, the lower the switching frequency.
  • the solution of the embodiment of the present invention can be applied to a virtual device.
  • the virtual device there is a need to use a polling mode to drive receiving data packets.
  • the software adopts an infinite loop mode.
  • the electronic device is a virtual device, and the processed data is a received data message and/or a data message.
  • the second working mode is exemplified in more detail, wherein the data processing takes the receiving of the data packet as an example, and measures whether the processor is busy with data traffic as a reference; the data traffic is the receiving amount of the data packet per unit time.
  • the first monitoring time period is defined as a time window, and each time window includes a plurality of basic time slices, each of the basic time slices includes a first time period that can sleep and a second time that is scheduled to be scheduled. Paragraph, see the detailed description for details.
  • Embodiments of the present invention may include the following three parts:
  • the first part by default, the data plane receives the data packet in the first working mode, and maintains the high performance of the data packet of the VM.
  • the DP receiving is performed.
  • the packet model switches to the second mode of operation; otherwise, the data plane DP continues to be in the first mode of operation.
  • N can be set arbitrarily The smaller the setting, the smaller the number of switching, the smaller the setting, the finer the energy consumption control; after the actual test, a more balanced N can be determined.
  • the timing of the timing period is fixed, the data processing capability of the processor in one timing period, that is, the maximum data traffic that the processor can bear is fixed; in a timing period, the actual occurrence occurs.
  • the actual data traffic during this timing period can be equal to The number of data packets actually processed during the period, for example, the number of received data packets or the number of data packets sent.
  • the control plane CP starts a timer, the timer expires, restarts the timer, and executes 302.
  • control plane CP starts the timer, and then starts the following steps:
  • the control plane CP obtains, according to the data plane DP, the packet receiving amount of the data plane DP in the timing period in which the timer expires;
  • 403 Determine whether the actually processed data amount is lower than a certain threshold, if not, enter 404; if yes, enter 405;
  • the data plane DP will remain in the first working mode.
  • the control plane CP notifies the data plane DP to switch from the first working mode to the second working mode.
  • a time window for example: a time window of 10ms, and divide a time window into multiple base time slices; schedule in units of basic time slices, for example: 500us per base time slice; The slice is divided into two parts: 100us sleep time, 400us attempts to schedule (ie: processing data messages in the first working mode).
  • the basic time slice and the time window time can be set arbitrarily, and different setting energy saving effects will be different.
  • the time window and the base time slice are set longer and more accurate. If the time is set shorter, the scheduling is more sensitive; the time of the base time slice, the sleep time is set longer, the energy saving effect is better, and the first working mode is received. If the data message time is set longer, you can get faster data packet reception speed.
  • the scheduling process for performing data processing is as follows:
  • the first basic time slice 500us scheduling process is as follows:
  • the first working mode receives data packets to receive data packets in batches. If no data packets are received, the time for attempting to receive data packets is 0us. If there is a data packet received, the longer the number of data packets, the longer the maximum time is 400us, and then the next base time slice will be entered.
  • the number of data packets corresponding to the first working mode 400us is not actually received, and the actual consumption of 400us is not actually consumed; therefore, when the data packet receiving demand is low,
  • the sleep time will occupy a higher proportion of the entire base time slice; from the entire time window, the sleep time ratio will be higher, in this way, the load of the processor can be reduced, and the sleep time is processed with the output.
  • the amount of decrease is linearly changed.
  • the actual load in the base time slice can be determined to be idle.
  • the subsequent basic time slice can be determined according to the idle state or busy state of the previous basic time slice. How to schedule the basic time slice, as follows:
  • the second and subsequent basic time slice 500us scheduling process is as follows:
  • the busy state of the processor in the previous basic time slice is idle state. If the busy state of the processor in the previous basic time slice is idle state, then sleep 100us, and then try to receive the datagram in the first working mode. If the busy idle state of the processor in the previous basic time slice is busy, it can attempt to receive the data message directly in the first working mode without sleeping.
  • the busy state of the processor in the basic time slice can be determined by the time taken by the processor to process the data, and specifically: determining to try to receive the data report in the first working mode. Whether the time of the text reaches 400us, or whether it is up to 300us, this time can be set; if yes, then the busy state is determined, otherwise it is idle state; it can also be determined by the actual load rate of the processor in the base time slice, due to In the first working mode, the maximum number of data packets received by the processor at 400us is determinable, so a set ratio, for example, 80% of the maximum number is determined to be busy, and less than 60% is determined to be idle.
  • the specific reference standard can be set; the reasonable reference standard can also be determined by the actual test method.
  • the subsequent base time slice can use the second basic time slice scheduling method. Since the base time slice is short, when the load is small, the sleep time is more. When the load is large, the sleep time is less. Thus, the macro load point, the load rate of the data plane DP processor and the actual processed data amount will be There is a linear relationship that allows precise control of the processor's load rate.
  • the data plane DP can be switched from the second working mode to the first working mode.
  • a basic time slice is included in a time window, and each basic time slice performs "determining whether to sleep according to feedback, and detecting whether the processor is in an idle state in the base time slice" and "feedback", The content of the feedback is whether the processor is idle in the base time slice;
  • the subsequent basic time slice within a time window will try to schedule no sleep, in this case, if a time window is used as a whole, the processor is determined. Whether it is idle in the entire time window, then it is still possible to determine that the processor is idle in the time window within the time window, and the scheduling model will still stay in the second working mode, thus preventing the actual amount of data processed. Mutations cause the illusion of an increase in the amount of data actually processed, avoiding an immediate switch to the first mode of operation.
  • the lower layer implementation is as shown in FIG. 6, and the energy management function is started. After the control plane CP starts the timer, the following steps are performed:
  • 602 the first basic time slice, sleeping 100us
  • the first basic time slice in the first working mode, attempts to receive the data message, and may receive N1 data messages, and the time used is T1;
  • T1 is less than 400us, then the step ends after the data packet is received. Or, if T1 is equal to 400us, because the time of the basic time slice is exhausted, then T1 ends when it reaches 400us, and the data message may have been received. It may also not be received; therefore T1 should be less than or equal to 400us here.
  • 604 Calculate, according to the sleep time or the actual received data message time, the proportion of the time of a basic time slice, whether the processor is in an idle state in the first basic time slice, and then enter the next and base time slices;
  • the sleep time or the actual received data packet time is used as a proportion of the time of a basic time slice.
  • the ratio can also be used to indicate the actual load rate of the processor, that is, the larger the sleep time ratio is, the actual load rate.
  • 605 Determine whether the processor is in an idle state in the last basic time slice, if yes, enter 606, otherwise enter 607;
  • 607 Try to receive the data packet in the first working mode, and may receive N2 data packets, and the time used is T2;
  • T2 is less than 400us, then the step ends after the data message is received. Or, if T2 is equal to 400us, because the time of the basic time slice is exhausted, then T2 ends when it reaches 400us, and the data message may have been received. It may also not be received; therefore T2 should be less than or equal to 400us here.
  • the ratio of the time of a basic time slice is calculated whether the processor is in an idle state in the current base time slice, if yes, enter 609, if not, enter 610;
  • the tag processor is idle in the current base time slice, and enters 611;
  • the tag processor is busy in the current base time slice, enter 611;
  • the scheduling algorithm shown in Figure 6 switches a time window to a smaller granularity of the base time slice, so that the processor completes the function of receiving data messages in some basic time slices, if the processor is idle in the last base time slice. State, then the processor will sleep in the current base time slice. When the actual amount of data processed is small, the time of receiving/transmitting data messages is less, and the chance of the processor sleeping in the base time slice is relatively more. When the amount of processed data increases, the chance of the processor sleeping in the base time slice is relatively small. Finally, in a macroscopic time period, the power of the processor is basically proportional to the amount of data actually processed. The way to achieve horizontal / vertical expansion of the system (scale up / down). In addition, since the sleep time of the processor in each basic time slice is short, the delay of the response service processing can be ensured to be small.
  • this part provides an implementation scheme for switching from the first working mode to the second working mode.
  • each basic time slice executes 701: calculating a busy state of the processor in the base time slice;
  • the data amount actually processed by the processor in the second working mode during the time of the basic time slice is obtained from the data plane DP, and then it is determined whether the processor is in a busy state or an idle state in the basic time slice.
  • execution 702 Statistics the busy state of the processor in the time window.
  • the control data plane DP is switched from the second working mode to the first working mode; it can be understood that if the current working mode is in the first working mode, The processor is in an idle state during the time window, and then the control data plane DP is switched from the first operating mode to the second operating mode.
  • FIG. 5B differs from FIG. 5A in the control portion setting of the time window.
  • FIG. 5B reference may be made to the corresponding text in FIG. 5A, and details are not described herein again.
  • the actual processed data amount of the processor has a linear relationship with the overall utilization of the processor, as shown in FIG. 8 , which is the result graph after the actual test.
  • the horizontal axis is the amount of data actually processed
  • the vertical axis is the utilization of the processor
  • the utilization of the processor corresponds to the corresponding power consumption.
  • the power consumption of the processor is also linear with the actual amount of data processed.
  • An embodiment of the present invention further provides an electronic device.
  • the electronic device includes:
  • the data amount detecting unit 901 is configured to monitor an amount of data processed by the electronic device during the first monitoring period;
  • the switching control unit 902 is configured to determine, according to the amount of data processed by the electronic device in the first monitoring period, that the processing unit 903 is idle during the first monitoring period, and then the processing unit 903 is configured by the first working mode. Switch to the second working mode;
  • the processing unit 903 is configured to: when the processing unit 903 is configured to be in a first working mode, in the first working mode, the processing unit 903 processes data in a PMD manner; in the second working mode, the processing unit 903 adopts PMD and sleep mode handle data.
  • two working modes are provided for the processing unit 903 of the electronic device; wherein the first operating mode consumes higher power and the second operating mode consumes relatively lower power;
  • the amount of data processed by the processing unit 903 can reduce the energy consumption by using a lower power consumption mode when the amount of data actually processed is small.
  • the processing unit 903 is specifically configured to adopt the second working mode in the first basic time slice in the second working mode; the first basic time slice includes a first time period and a second time period; The processing unit 903 sleeps during the first time period and operates during the second time period.
  • the processing unit 903 further includes:
  • the busyness judging unit 1001 is configured to determine, after the end of the first basic time slice, the busy state of the processing unit 903 at the first basic time slice;
  • a work control unit configured to control the processing unit 903 to be in a busy state when the busy state of the first base time slice is a busy state, and control the processing unit 903 to be in a first time period of the second basic time slice jobs.
  • the processing unit 903 is specifically configured to: if the processing unit 903 does not end the second time period of the first basic time slice and the data processing is completed, end the second time of the first basic time slice early The segment, or, sleeps during the remaining time in the second time period.
  • the busy idle determining unit 1001 is configured to: if the processing unit 903 processes the data in the first basic time slice for a time greater than the first threshold, the electronic device determines that the first basic time slice is busy. The status is busy state;
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first base time slice is a busy state.
  • the busy idle determining unit 1001 is further configured to: if the processing unit 903 processes the data in the first basic time slice, the time is less than the third threshold, determining that the busy state of the first basic time slice is An idle state; the third threshold is less than or equal to the first threshold;
  • the processing unit 903 determines whether the processing unit 903 is in a sleep state at the end of the second time period of the first base time slice, or if the processing unit 903 preliminarily ends the second time period of the first base time slice, determine the first The busy state of a basic time slice is an idle state;
  • the fourth threshold is less than or equal to the second Threshold.
  • the data amount detecting unit 901 is further configured to monitor, when the processing unit 903 is in the second working mode, the amount of data processed by the electronic device in the second monitoring period;
  • the switching control unit 902 is further configured to determine, according to the amount of data processed by the electronic device in the second monitoring period, that the processing unit 903 is busy during the second monitoring period, and then the processing unit 903 is configured by the second working The mode is switched to the first working mode.
  • the data traffic is used as the standard for measuring whether the processing unit 903 is idle.
  • the switching control unit 902 is further configured to monitor the electronic device during the second monitoring period. When the data traffic is greater than or equal to the second threshold, the processing unit 903 is switched from the second working mode to the first working mode; the first threshold is greater than or equal to the second threshold.
  • the embodiment of the present invention further provides another electronic device, as shown in FIG. 11, including: a processor 1101, and a memory 1102; and may further include a receiving device, a sending device, an output device, and the like; the processor 1101 and the memory 1102 may Connected via bus 1103, other hardware interfaces can also be used for connection;
  • the function of the processor 1101 is as follows: monitoring the amount of data processed by the electronic device during the first monitoring period, the processor 1101 of the electronic device is configured as a first working mode, and the processor is in the first working mode 1101: processing data by using a PMD method; determining, according to the amount of data processed by the electronic device in the first monitoring period, that the processor is idle during the first monitoring period, and switching the processor 1101 from the first working mode to In a second mode of operation, the processor 1101 processes data in a PMD and sleep mode.
  • the above second working mode increases the sleep time compared to the first working mode, so the power consumption is relatively low, and the ability to receive data messages is correspondingly low.
  • the method for determining whether the processor is idle during the time period is determined by the amount of data processed by the processor in a certain period of time.
  • the device receives and/or sends a data packet, which may be: monitoring the electronic device in the first If the data traffic in the monitoring period is less than or equal to the first threshold, determining that the processor is idle during the first monitoring period; the first threshold corresponds to the data traffic being the threshold of the amount of data received per unit time Or: monitoring that the amount of data processed by the electronic device during the first monitoring period is less than or equal to the first threshold, determining that the processor is idle during the first monitoring period; the first threshold corresponds to The threshold value of the amount of data processed in the first monitoring period.
  • the first threshold is to distinguish whether the processor is relatively idle threshold, and switch to a lower power consumption mode when the processor is idle.
  • the processor 1101 adopts the second working mode in the first basic time slice;
  • the processing of the data by the processor 1101 in the PDM and the sleep mode in the second working mode includes:
  • the first base time slice includes a first time period and a second time period
  • the processor 1101 sleeps during the first time period and operates during the second time period.
  • the first base time slice and the second base time slice in the subsequent embodiment are classifications of the basic time slice, wherein the first basic time slice may be that the processor 1101 switches from the first working mode to the first The first basic time slice after the second working mode, or the second working mode, the processor 1101 works by default in the working mode of the first basic time slice in each basic time slice; the second working mode may be in addition to the first working mode A representative of other basic time slices outside the base time slice, then the first basic time slice can be regarded as the previous basic time slice of the second basic time slice; the time length of the basic time slice can be arbitrarily set, usually If the setting is shorter, the first time period and the second time period may also be correspondingly shorter, so that the scheduling precision can be improved.
  • the processor 1101 can sleep for a shorter time, and the response speed of the processor 1101 can be improved.
  • the function of the processor 1101 is as follows: the processor 1101 determines the processor after the end of the first basic time slice In the busy state of the first basic time slice, when the busy state of the processor 1101 is busy in the first basic time slice, the processor 1101 is in the first time period of the second basic time slice. jobs.
  • whether the processor 1101 operates in the first time period depends on the current busy state of the processor 1101, and the data processing capability of the processor 1101 can be dynamically adjusted to enable processing without changing the working mode of the processor 1101.
  • the data processing capability of the device 1101 can be matched with the actual requirements, the response speed to the data processing requirements is increased, and the energy consumption is linearly positively correlated with the actual data processing requirements; and the processor 1101 can be avoided due to sudden changes in the instantaneous data processing requirements. Work mode switching.
  • the foregoing working in the second time period includes:
  • the processor 1101 does not end and the data processing is completed in the second time period of the first basic time slice, the second time period of the first basic time slice is ended early, or is remaining in the second time period. Time to sleep.
  • the processor 1101 since the processor 1101 does not always have data to process in the second time period, there may be more time in the second time period.
  • the processor 1101 is in the case of no data to be processed;
  • the sleep time can be further increased based on the actual demand of the data processing, further reducing the power consumption of the processor 1101.
  • the processor 1101 determines that the busy state of the first base time slice of the processor 1101 includes:
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first basic time slice is a busy state
  • the electronic device determines that the busy state of the first base time slice is a busy state.
  • the first threshold and the second threshold are both thresholds for determining whether the processor 1101 is busy in the first base time slice, wherein the first threshold is used as a reference for processing data consumption time, and the data is processed.
  • the second threshold is referenced by the amount of data, and the larger the amount of data indicates the more busy the processor 1101; which value is specifically used in the embodiment of the present invention is not limited.
  • the processor 1101 is further configured to determine a busy state as follows:
  • the electronic device Determining that the busy state of the first basic time slice is an idle state; the third threshold is less than or equal to the first threshold;
  • the electronic device Determining that the busy state of the first base time slice is an idle state
  • the electronic device determines that the busy state of the first base time slice is an idle state; the fourth threshold is less than or equal to The second threshold.
  • the third threshold and the fourth threshold are both thresholds for determining whether the processor 1101 is busy in the first base time slice, wherein the third threshold is used as a reference for processing the data, and the data is processed.
  • the processor 1101 is further configured to monitor, according to the electronic device, the amount of data processed by the electronic device during the second monitoring period when the processor 1101 is in the second working mode; And the amount of data processed in the second monitoring period determines that the processor is busy during the second monitoring period, and then switches the processor from the second working mode to the first working mode; the first threshold is greater than Or equal to the second threshold.
  • the data traffic is used as the standard for measuring whether the processor is idle.
  • the embodiment may be: when the processor 1101 is in the second working mode, monitoring the electronic device during the second monitoring period. Data traffic; in the case that the data traffic of the electronic device during the second monitoring period is greater than or equal to the second threshold, the processor 1101 is switched from the second working mode to the first working mode; A threshold is greater than or equal to the second threshold.
  • the second threshold is used to determine that the processor 1101 is relatively busy, or that there are currently more data packets to be processed. In this case, the processor needs to maximize its data processing capability.
  • the second threshold is greater than the first threshold, and can be used as a preferred implementation.
  • the current working mode can be maintained, and the actual data processing amount is prevented from being at the first threshold.
  • the processor 1101 is in the first working mode and the second working mode. Switch frequently.
  • the electronic device is a virtual device.
  • the hardware entity of the electronic device application of the embodiment of the present invention may correspond to the physical host shown in FIG. 1 , and the electronic device corresponds to the virtual machine; the processor may be a processor of the physical host, or may be a physical device.
  • the storage medium may be a read only memory, a magnetic disk or an optical disk or the like.

Abstract

本发明实施例公开了一种调度方法及电子设备,以方法的实现为例包括:监控电子设备在第一监控时间段内处理的数据量,所述电子设备的处理器配置为第一工作模式,在所述第一工作模式下所述处理器采用轮询模式驱动PMD方式处理数据;根据所述电子设备在所述第一监控时间段内处理的数据量确定所述处理器在所述第一监控时间段内空闲,则将所述处理器由所述第一工作模式切换到第二工作模式,在所述第二工作模式下所述处理器采用PMD和休眠的方式处理数据。为电子设备的处理器提供了两种工作模式;其中第一工作模式功耗较高,第二工作模式功耗相对较低;通过监测处理器处理的数据量,在实际处理的数据量较小时,使用较低能耗的工作模式,可以降低能耗。

Description

一种调度方法及电子设备
本申请要求于2016年3月24日提交中国专利局、申请号为CN 201610176197.3、发明名称为“一种调度方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信技术领域,特别涉及一种调度方法及电子设备。
背景技术
网络运营商的网络充斥着大量不同类型的专有硬件设备,而且品类还在持续增加中。发布新的网络设备经常要求引入新的硬件品类,要找到适合这些硬件的空间和电力供应越来越困难。网络功能虚拟化(Network Functions Virtualization,NFV)的目的是通过利用标准的信息技术(Information Technology,IT)虚拟化技术,将网络设备类型归一化为工业标准大容量服务器、交换机和存储设备。NFV可以适用于固定和移动网络基础设施中的数据面报文处理和控制面功能。目前NFV技术正处于飞速发展的过程中。
虚拟网络功能(Virtualized Network Function,VNF)是运行在NFV架构内并完成特定网络功能的模块,可以包括:路由、交换、服务、云计算等等功能。更具体可以是运行在虚拟机(Virtual Machine,VM)中并完成特定网络功能的模块。
NFV技术通常采用在物理主机中运行主机(HOST)操作系统(operating system,OS),在虚拟机中运行客(GEUST)操作系统(operating system,OS);一个物理主机内可以包含一个或一个以上的虚拟机。物理主机是硬件设备,属于电子设备;虚拟机是通过软件虚拟化后得到的设备。以包含网卡的虚拟机为例,采用轮询模式驱动(Poll Mode Drivers,PMD)数据处理的设备,会采用PMD循环执行:接收数据报文、处理数据报文、发送数据报文。为了及时接收数据报文,该循环执行过程在虚拟机启动后以死循环的形式执行,会导致处理器一直处于繁忙状态,能耗较高。
发明内容
本发明实施例提供了一种调度方法及电子设备,用于降低能耗。
一方面本发明实施例提供了一种调度方法,应用于电子设备,方法具体包括:
监控所述电子设备在第一监控时间段内处理的数据量,所述电子设备的处理器配置为第一工作模式,在所述第一工作模式下所述处理器采用轮询模式驱动PMD方式处理数据;
根据所述电子设备在所述第一监控时间段内处理的数据量确定所述处理器在所述第一监控时间段内空闲,则将所述处理器由所述第一工作模式切换到第二工作模式,在所述第二工作模式下所述处理器采用PMD和休眠的方式处理数据。
更具体地,所述处理器采用PMD和休眠的方式处理数据可以是:所述处理器交替地采用PMD和休眠的方式处理数据;所述处理器处理数据的方式有两种:PMD方式处理数据和休眠,这两种处理数据的方式处理器交替采用。
在本实施例中,数据处理可以是接收数据报文、发送数据报文或者其他的数据处理,具体执行数据处理的内容本发明实施例不作唯一性限定;基于不同的数据处理内容,处理的数据量会有不同的度量方式;例如:接收数据报文可以用接收到的数据报文的数量来确定。
通过某一时间段内处理器处理的数据量来确定处理器在该时间段内是否空闲的方式较多,以接收和/或发送数据报文为例,可以是:监控到所述电子设备在第一监控时间段内的数据流量小于或等于第一门限,则确定所述处理器在所述第一监控时间段内空闲;该第一门限对应于数据流量是单位时间内接收的数据量的门限值;也可以是:监控到所述电子设备在第一监控时间段内处理的数据量小于或等于第一门限,则确定所述处理器在所述第一监控时间段内空闲;该第一门限则对应于第一监控时间段处理的数据量的门限值。该第一门限是为了区分处理器是不是比较空闲的阈值,在处理器比较空闲的情况下切换到较低能耗的工作模式。
在一个可选的实现方式中,所述处理器在第一基础时间片内采用所述第二工作模式;所述第二工作模式下所述处理器采用PMD和休眠的方式处理数据包括:
所述第一基础时间片包含第一时间段和第二时间段;
所述处理器在所述第一时间段休眠,在所述第二时间段工作。
在本实施例中,第一基础时间片和后续实施例中的第二基础时间片,是对基础时间片的分类,其中第一基础时间片可以是处理器从第一工作模式切换到第二工作模式后的第一个基础时间片,或者是第二工作模式下处理器在各基础时间片都默认采用第一基础时间片的工作模式进行工作;第二工作模式可以是除了上述第一个基础时间片外的其他基础时间片的代表,那么第一基础时间片可以认为是第二基础时间片的前一个基础时间片;基础时间片的时间长度可以任意设定,通常来说可以设置得较短一点,第一时间段和第二时间段也可以相应的较短,那么可以提高调度精度;另外,处理器每次休眠的时间较短,可以提高处理器的响应速度。
在一个可选的实现方式中还提供了增加工作状态控制的弹性的具体实现方案,具体如下:所述处理器在第一基础时间片结束之后,所述方法还包括:
所述处理器判断所述处理器在所述第一基础时间片时的忙闲状态,当所述处理器在所述第一基础时间片的忙闲状态为繁忙状态,则所述处理器在第二基础时间片的第一时间段工作。
本实施例,处理器在第一时间段是否工作取决于处理器当前的忙闲状态,在不切换处理器工作模式的前提下,可以动态调整处理器的数据处理能力,使处理器的数据处理能力能够和实际需求匹配,提高对数据处理需求的响应速度,使能耗与实际数据流量呈线性的正相关关系;并且可以避免因为瞬时数据流量突变导致处理器的工作模式切换。
在一个可选的实现方式中,所述在所述第二时间段工作包括:
若所述处理器在所述第一基础时间片的所述第二时间段未结束且数据处理完毕,则提前结束所述第一基础时间片的第二时间段,或者,在所述第二时间段中剩余的时间休眠。
在本实施例中,由于处理器在第二时间段并不一定一直有数据需要处理,因此第二时间段可能存在较多的时间处理器处于无数据需要处理的情况;采用本实施例,可以进一步基于数据处理的实际需求增加休眠时间,进一步降低处理器的功耗。
在一个可选的实现方式中,所述处理器判断所述处理器的所述第一基础时间片的忙闲 状态包括:
若所述处理器在所述第一基础时间片内处理数据的时间大于第一阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
或者,若所述处理器在所述第一基础时间片的第二时间段结束时处于处理数据的状态,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
或者,若所述处理器在所述第一基础时间片内处理的数据量大于第二阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态。
在本实施例中,第一阈值和第二阈值均是用于确定处理器在第一基础时间片内是否繁忙的阈值,其中第一阈值以处理数据耗费的时间作为参考,处理数据所耗费的时间越长表示处理器越繁忙,第二阈值以数据量作为参考,数据量越大则表示处理器越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
在一个可选的实现方式中,所述方法还包括:
若所述处理器在所述第一基础时间片内处理数据的时间小于第三阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为空闲状态;所述第三阈值小于或等于所述第一阈值;
或者,若所述处理器在所述第一基础时间片的第二时间段结束时处在休眠状态,或者若所述处理器提前结束所述第一基础时间片的第二时间段,则所述电子设备确定所述第一基础时间片的忙闲状态为空闲状态;
或者,若所述处理器在所述第一基础时间片内处理的数据量小于第四阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为空闲状态;所述第四阈值小于或等于所述第二阈值。
在本实施例中,第三阈值和第四阈值均是用于确定处理器在第一基础时间片内是否繁忙的阈值,其中第三阈值以处理数据所耗费的时间作为参考,处理数据所耗费的时间越长表示处理器越繁忙,第四阈值以数据量作为参考,数据量越大则表示处理器越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
在一个可选的实现方式中,所述方法还包括:
所述处理器处于所述第二工作模式时,监控所述电子设备在第二监控时间段内处理的数据量;
根据所述电子设备在所述第二监控时间段内处理的数据量确定所述处理器在所述第二监控时间段内繁忙,则将所述处理器由所述第二工作模式切换到所述第一工作模式;所述第一门限大于或等于所述第二门限。
仍然以数据流量为例,采用数据流量作为衡量处理器是否空闲的标准,本实施例具体可以是:所述处理器处于所述第二工作模式时,监控所述电子设备在第二监控时间段内的数据流量;在监控到所述电子设备在第二监控时间段内的数据流量大于或等于第二门限的情况下,将所述处理器由所述第二工作模式切换到所述第一工作模式;所述第一门限大于或等于所述第二门限。
在本实施例中,第二门限是用于确定处理器比较繁忙,或者当前有较多的数据报文需要被处理,此时需要处理器尽量发挥其最大的数据处理能力的应用场景。该第二门限大于第一门限,可以作为一个优选实现方案,实际的数据处理量在第一门限和第二门限之间时,可以保持当前的工作模式,避免实际的数据处理量在第一门限和第二门限值附近变化的情 况下,处理器在第一工作模式和第二工作模式之间进行频繁切换。
二方面本发明实施例还提供了一种电子设备,包括:
数据量检测单元,用于监控所述电子设备在第一监控时间段内处理的数据量;
切换控制单元,用于根据所述电子设备在第一监控时间段内处理的数据量确定处理单元在所述第一监控时间段内空闲,则将所述处理单元由所述第一工作模式切换到第二工作模式;
处理单元,用于在所述处理单元被配置为第一工作模式时,在所述第一工作模式下所述处理单元采用PMD方式处理数据;在所述第二工作模式下所述处理单元采用PMD和休眠的方式处理数据。
在一个可选的实现方式中,所述处理单元,具体用于在第二工作模式下的第一基础时间片内采用所述第二工作模式;所述第一基础时间片包含第一时间段和第二时间段;所述处理单元在所述第一时间段休眠,在所述第二时间段工作。
在一个可选的实现方式中,所处理单元还包括:
忙闲判断单元,用于在第一基础时间片结束之后,判断所述处理单元在所述第一基础时间片时的忙闲状态;
工作控制单元,用于当所述忙闲判断单元判断所述处理单元在所述第一基础时间片的忙闲状态为繁忙状态,则控制所述处理单元在第二基础时间片的第一时间段工作。
在一个可选的实现方式中,所述处理单元,具体用于若所述处理单元在所述第一基础时间片的所述第二时间段未结束且数据处理完毕,则提前结束所述第一基础时间片的第二时间段,或者,在所述第二时间段中剩余的时间休眠。
在一个可选的实现方式中,所忙闲判断单元,具体用于若所述处理单元在所述第一基础时间片内处理数据的时间大于第一阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
或者,若所述处理单元在所述第一基础时间片的第二时间段结束时处于处理数据的状态,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
或者,若所述处理单元在所述第一基础时间片内处理的数据量大于第二阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态。
在一个可选的实现方式中,所述忙闲判断单元,还用于若所述处理单元在所述第一基础时间片内处理数据的时间小于所述第三阈值,则确定所述第一基础时间片的忙闲状态为空闲状态;所述第三阈值小于或等于所述第一阈值;
或者,若所述处理单元在所述第一基础时间片的第二时间段结束时处在休眠状态,或者若所述处理单元提前结束所述第一基础时间片的第二时间段,则确定所述第一基础时间片的忙闲状态为空闲状态;
或者,若所述处理单元在所述第一基础时间片内处理的数据量小于第四阈值,则确定所述第一基础时间片的忙闲状态为空闲状态;所述第四阈值小于或等于所述第二阈值。
在一个可选的实现方式中,所述数据量检测单元,还用于在处理单元处于所述第二工作模式时,监控所述电子设备在第二监控时间段内处理的数据量;
所述切换控制单元,还用于根据所述电子设备在第二监控时间段内处理的数据量确定所述处理单元在所述第二监控时间段内繁忙,则将所述处理单元由所述第二工作模式切换到所述第一工作模式。
仍然以数据流量为例,采用数据流量作为衡量处理单元是否空闲的标准,本实施例具体可以是:所述切换控制单元,具体用于在监控到所述电子设备在第二监控时间段内的数据流量大于或等于第二门限的情况下,将所述处理单元由所述第二工作模式切换到所述第一工作模式;所述第一门限大于或等于所述第二门限。
三方面本发明实施例还提供了另一种电子设备,包括:处理器、通信模块以及存储器;其中存储器可以提供处理器执行数据处理所需的缓存;
其中处理器可以执行以上方法实施例中的步骤实现电子设备的相应功能。方法实施例中的各步骤的具体实现流程,可以以软件的形似存储在存储器中,由处理器执行软件实现以上方法实施例中的步骤。在本实施例中不再赘述。
从以上技术方案可以看出,本发明实施例具有以下优点:在采用轮询模式驱动方式工作的电子设备中,为该电子设备的处理器提供了两种工作模式;其中第一工作模式功耗较高,第二工作模式功耗相对较低;通过监测处理器处理的数据量,在实际处理的数据量较小时,使用较低能耗的工作模式,可以降低能耗。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例系统结构示意图;
图2为本发明实施例方法流程示意图;
图3为本发明实施例系统结构示意图;
图4为本发明实施例方法流程示意图;
图5A为本发明实施例系统结构示意图;
图5B为本发明实施例系统结构示意图;
图6为本发明实施例方法流程示意图;
图7为本发明实施例系统结构示意图;
图8为本发明实施例测试结果示意图
图9为本发明实施例电子设备结构示意图;
图10为本发明实施例电子设备结构示意图;
图11为本发明实施例电子设备结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部份实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
如图1所示,是本发明实施例的一个系统结构的举例。物理主机可以使用linux作为操作系统,物理主机内运行的虚拟机可以取代专有硬件。虚拟机像真实的硬件设备一样, 具有数据面(Data Plane,DP)、控制面(Control Plane,CP),以及虚拟网络接口控制器(Virtual Network Interface Controller,VNIC)即虚拟网卡。其中,DP和CP是协议分层的概念,一类是用户数据层面,一类是控制层面,其中DP涉及的是用户数据的处理和传递;对应到图1所示的结构CP涉及的是对VM中对PMD的监测和控制,具体结构请参阅图2所示。
由于虚拟网卡并不能像网络接口控制器(Network Interface Controller,NIC)即物理网卡,一样直接与物理主机外部进行数据通信,因此在物理网卡和虚拟网卡之间会有虚拟的数据通道,然后借助于物理网卡与物理主机外部进行数据通信。数据通道可以是采用单根I/O虚拟化(Single Root I/O Virtualization,SR-IOV)等硬件虚拟化技术获得。在虚拟机中运行的应用(Application,APP)有数据报文的接收需求,通过轮询模式驱动(Poll Mode Drivers,PMD)进行数据报文的批量接收。
图1所示的系统结构主要包含两部分:运行主机操作系统的物理主机,以及运行客操作系统的虚拟机VM;物理主机包含物理网卡NIC以及SR-IOV,SR-IOV也可以位于VM一侧;VM包含DP的APP、PMD、linux用户态IO驱动(Linux User Space I/O Drivers),用户空间输入/输出(Userspace I/O,UIO)以及VNIC;其中DP的APP以及PMD属于用户空间,UIO属于内核空间。
基于以上图1所示的系统架构,以APP外发数据报文为例,在PMD模式下的发数据报文如下:PMD以死循环执行:尝试收该APP的数据报文、处理接收到的数据报文、发送处理后的数据报文。PMD发送的数据报文会发送给VNIC,然后VNIC通过SR-IOV发送给NIC,NIC则会将数据报文发往物理主机外部。
为了减少数据报文从APP发往NIC的过程中进行数据报文拷贝,可以采用共享内存的方式,具体如下:APP将需要发送的数据报文存储在共享内存中,然后从PMD到NIC传递数据报文在共享内存中的地址信息,例如:数据报文在共享内存中的存储地址的指针。在以上图1所示的系统架构下,物理主机和虚拟机之间数据报文是透传的,OS调度较少;通过共享内存的机制从物理网卡到用户态的APP,数据报文不需要拷贝;基于用户态DP的隔离性,NFV的扩展性较好;另外用户态的APP接收数据报文不需要系统调用内核。另外,PMD模式也有一些好处,例如:基本没有功耗和流程控制,因此实现较为简单。基于以上说明可知,在PMD的死循环执行过程中,数据报文可以等同替换为数据报文在共享内存中的地址信息。
以上死循环执行过程中,如果APP没有数据报文发送,或者APP发送的数据报文的数据量较少,那么会出现以下状况:某些循环的执行过程没有收到数据报文,或者在一次循环的执行过程中接收的数据量低于一次循环能够处理的最大数据量;即单位时间内数据报文的数量少,也就是说数据流量较小。这种情况下,如果处理器仍然执行死循环,保持100%的利用率,那么处理器的功耗将会一直维持在固定的较高水平,功耗存在极大的浪费。换一种说法:该处理器的利用率是100%,但是实际接收到的数据报文很少,因此功耗大、效率低。
为了解决处理器保持100%利用率执行死循环导致的功耗浪费,本发明实施例提供更加精细化的功耗管理方案,使APP接收数据报文较少的情况下(即:数据流量较小的情况下),通过控制面降低处理器功耗。在本发明实施例中,降低处理器功耗的方式,可以包括:降低处理器的主频,或者,让处理器在某些时间处于非工作状态。降低处理器主频的方式可以通过对处理器的主频进行配置或降低处理器的电压等方式实现,具体参考处理器 支持降低主频的实现方式确定;让处理器在某些时间处于非工作状态具体可以是:让处理器间歇式的休眠,或者间歇式的停止执行该死循环;休眠的实现方案在不同的应用场景下可以有不同的休眠选择,例如:在单核处理器的应用场景下可以是整个处理器休眠,在处理器具有多核或者众核的应用场景下,可以是处理器的所有核心都休眠,也可以是处理器的部分核心休眠。本发明实施例主要采用后一种方式降低处理器功耗。
基于前述实施例记载的应用场景举例,本发明实施例提供了一种调度方法,应用于电子设备,如图2所示,方法具体包括:
在本发明实施例中,对于同一个处理器而言,其功耗越高,在单位时间内能能够处理的数据量就越多,第一工作模式的功耗会较高,第二工作模式功耗会较低;在本实施例中,处理器的工作模式的分级可以不限于两种工作模式,本发明实施例中使用“第一工作模式”和“第二工作模式”只是为了区分处理器的两种工作模式,不应理解为仅能分两种工作模式。
在本实施例中,“采用PMD方式处理数据”,是指采用轮询的方式,驱动电子设备执行数据处理的技术手段,该技术手段的特点是执行死循环来尝试接收数据报文或者询问是否有数据需要处理;会导致处理器一直处于满负荷运行的状态。
由于本发明实施例的技术方案可以应用于VM以及硬件实体设备,因此本发明实施例中的处理器不应当仅局限于电子设备物理的处理器,还应当扩展到分配给虚拟机的数据处理资源。那么对应于VM,第二工作模式理论上可以是分配给VM的数据处理资源减少,也可以是VM减少对已分配的数据处理资源的占用量。
201:监控该电子设备在第一监控时间段内处理的数据量,该电子设备的处理器配置为第一工作模式,在该第一工作模式下该处理器采用PMD方式处理数据;
在本实施例中,处理的数据可以是接收数据报文,相应地数据量则可以使用接收到的数据报文的量来衡量;监控到电子设备处理的数据量以后,可以使用该数据量计算得到数据流量,那么本步骤更具体可以是:监控该电子设备接收的数据流量,该电子设备的处理器配置为第一工作模式,在该第一工作模式下该处理器采用PMD方式接收数据报文;
数据流量是指单位时间内实际接收到的数据量,该数据量可以通过数据报文数据来衡量,因此这里可以是在该第一监控时间段接收到的数据报文数量与第一监控时间段的时间长度的比值。
在本发明实施例中使用“第一”和“第二”对技术名称进行区分,并不代表其他技术含义;例如:“第一工作模式”和“第二工作模式”代表处理器的两种不同的工作模式,其中第二工作模式相比于第一工作模式增加了休眠的时间。“第一门限”和“第二门限”代表两种不同的数据流量的门限值,分别用于区分处理器需要切换到节能模式的门限和需要切换到性能模式的门限。
202:根据该电子设备在该第一监控时间段内处理的数据量确定该处理器在该第一监控时间段内空闲,则将该处理器由该第一工作模式切换到第二工作模式,在该第二工作模式下该处理器采用PMD和休眠的方式处理数据。
基于前面采用数据流量的举例,本步骤更具体地可以是:在监控到该电子设备在第一监控时间段内的数据流量小于或等于第一门限的情况下,将该处理器由该第一工作模式切换到第二工作模式。
在本实施例中,监控电子设备处理的数据量,可以采用周期性监控的方式实现,因此 第一监控时间段,可以是周期性监控的时间周期,每个监控周期的时间相等。另外,如果第一监控时间段的时间长度是固定值,例如:一个时间周期;那么本实施例可以具体如下:在电子设备的处理器处于第一工作模式期间,监控该电子设备在第一监控时间段接收的数据报文数量,在监控到该电子设备在该第一监控时间段接收的数据报文数量小于或等于某一预定门限的情况下,将该处理器由该第一工作模式切换到第二工作模式。可见,如果第一监控时间段为固定值,以数据量为衡量标准与以数据流量为衡量标准,技术效果相同的,具有等同关系。
该第一门限可以是设定的值,用于衡量数据流量的大小,由于处理器不同,接收数据报文的快慢会有区别,因此能够承受的数据流量也会不同;该第一门限是为了区分处理器是不是比较空闲的阈值,因此该阈值可以依据经验设定;另外,也可以基于本发明实施例,进行实际测试以后确定该第一门限具体如何取值更好,具体的取值本发明实施例不作唯一性限定。
本发明实施例的执行主体可以是电子设备,电子设备可以是如前述实施例中所称的物理主机,例如:服务器、终端主机等;也可以是其他任意采用PMD的方式处理数据的电子设备;若应用于NFV技术领域,如果VM采用PMD的方式处理数据,那么电子设备可以是为该VM提供硬件资源的电子设备,本发明实施例对电子设备的具体表现形式不作唯一性限定。
本实施例,在采用轮询模式驱动数据处理的电子设备中,为该电子设备的处理器提供了两种工作模式;其中第一工作模式功耗较高,第二工作模式功耗相对较低;通过监测处理器处理的数据量,在实际处理的数据量较小时,使用较低能耗的工作模式,可以降低能耗。
在以上实施例中,交替地采用PMD和休眠的方式处理数据,可以是任意的交替方式,由于相比于第一工作模式增加了休眠的时间就可以实现节能的效果,本发明实施例进一步提供了具体如何交替进行数据处理,如下:上述处理器在第一基础时间片内采用上述第二工作模式;上述在该第二工作模式下该处理器采用PMD和休眠的方式处理数据包括:
该第一基础时间片包含第一时间段和第二时间段;
该处理器在该第一时间段休眠,在该第二时间段工作。
在本实施例中,在处理器处于第二工作模式的时间段,该时间段可以由众多第一基础时间段组成,每一个基础时间段时间可以较长也可以较短,将第一基础时间片分为了第一时间段和第二时间段,进行工作模式的控制。在本实施例中,处理器工作是指采用PMD方式处理数据,采用PMD方式处理数据并不代表一定处理了数据,是否处理了数据取决于实际是否有数据需要处理;处理器休眠是指处理器不处理数据,即:处理器休眠时不管是否有数据需要处理都不执行PMD方式处理数据的操作。
基于本发明实施例采用将基础时间片分为了第一时间段和第二时间段进行工作模式的控制,本发明实施例还提供了增加工作模式控制的弹性的具体实现方案,具体如下:上述处理器在第一基础时间片结束之后,上述方法还包括:
该处理器判断该处理器在该第一基础时间片时的忙闲状态,当该处理器在该第一基础时间片的忙闲状态为繁忙状态,则该处理器在第二基础时间片的第一时间段工作。
忙闲状态分为两种:一种是繁忙状态,另一种是空闲状态;繁忙状态是指接收并且处理的数据量大于某一阈值,表现为处理器比较繁忙、此时实际负载率较高、数据流量较大; 空闲状态表现为处理器比较空闲、此时实际负载率比较小、数据流量较小,在本发明实施例中可以是处理器休眠时,也可能是处理器处于工作状态时,接收到的数据流量小于另一阈值。
本实施例,处理器在第一时间段是否工作取决于处理器当前的忙闲状态,在不切换处理器工作模式的前提下,动态调整处理器的数据处理能力,使处理器的数据处理能力能够和实际需求匹配,提高对数据处理需求的响应速度;并且可以避免因为瞬时数据处理需求突变导致处理器的工作模式切换。
本发明实施例还提供了基础时间片的第二时间段处理器的工作方式控制,具体如下:上述在该第二时间段工作包括:
若该处理器在该第一基础时间片的该第二时间段未结束且数据处理完毕,则提前结束该第一基础时间片的第二时间段,或者,在该第二时间段中剩余的时间休眠。
由于处理器在第二时间段并不一定一直有数据需要处理,因此第二时间段可能存在较多的时间处理器处于无数据需要处理的情况;因此采用本实施例,可以进一步基于数据处理的实际需求增加休眠时间,进一步降低处理器的功耗;采用本实施例方案可以优选将基础时间片设置得较短,如果采用“提前结束该第一基础时间片的第二时间”的方式,第二时间段可以配置得较长,设置得较短也可以;如果采用“在该第二时间段中剩余的时间休眠”优选将第一时间段和第二时间段都配置得较短以提高对接收数据报文需求的响应速度。
本实施例还提供了基于本发明实施例的具体应用场景,如何确定处理器在第一基础时间片的忙闲状态的具体实现方案,如下:上述处理器判断该处理器的该第一基础时间片的忙闲状态包括:
若该处理器在该第一基础时间片内处理数据的时间大于第一阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态;
或者,若该处理器在该第一基础时间片的第二时间段结束时处于处理数据的状态,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态;
或者,若该处理器在该第一基础时间片内处理的数据量大于第二阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态。
在本实施例中,第一阈值和第二阈值均是用于确定处理器在第一基础时间片内是否繁忙的阈值,其中第一阈值以处理数据耗费的时间作为参考,处理数据所耗费的时间越长表示处理器越繁忙,第二阈值以数据量作为参考,数据量越大则表示处理器越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
本实施例还提供了基于本发明实施例的具体应用场景,如何确定处理器在第一基础时间片的忙闲状态的具体实现方案,如下:上述方法还包括:
若该处理器在该第一基础时间片内处理数据的时间小于第三阈值,则该电子设备确定该第一基础时间片的忙闲状态为空闲状态;该第三阈值小于或等于该第一阈值;
或者,若该处理器在该第一基础时间片的第二时间段结束时处在休眠状态,或者若该处理器提前结束该第一基础时间片的第二时间段,则该电子设备确定该第一基础时间片的忙闲状态为空闲状态;
或者,若该处理器在该第一基础时间片内处理的数据量小于第四阈值,则该电子设备确定该第一基础时间片的忙闲状态为空闲状态;该第四阈值小于或等于该第二阈值。
在本实施例中,第三阈值和第四阈值均是用于确定处理器在第一基础时间片内是否繁忙的阈值,其中第三阈值以处理数据所耗费的时间作为参考,处理数据所耗费的时间越长表示处理器越繁忙,第四阈值以数据量作为参考,数据量越大则表示处理器越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
基于以上实施例提供的从第一工作模式切换到第二工作模式,本发明实施例还提供了从第二工作模式切换回第一工作模式的具体实现方案,如下:上述方法还包括:
该处理器处于该第二工作模式时,监控该电子设备在第二监控时间段内处理的数据量;
在检测到该电子设备在第二监控时间段内处理的数据量,并根据该电子设备在第二监控时间段内处理的数据量确定该处理器在该第二监控时间段内繁忙,则将该处理器由该第二工作模式切换到该第一工作模式;该第一门限大于或等于该第二门限。
仍然以数据流量为例,采用数据流量作为衡量处理器是否空闲的标准,本实施例具体可以是:该处理器处于该第二工作模式时,监控该电子设备在第二监控时间段内的数据流量;在监控到该电子设备在第二监控时间段内的数据流量大于或等于第二门限的情况下,将该处理器由该第二工作模式切换到该第一工作模式;该第一门限大于或等于该第二门限。
第二门限是用于确定处理器比较繁忙,或者当前有较多的数据报文需要被接收,此时需要处理器尽量发挥其最大的数据报文接收能力的应用场景。该第二门限大于第一门限,可以作为一个优选实现方案,实际的数据流量在第一门限和第二门限之间时,可以保持当前的工作模式,即:不切换;这样可以避免实际的数据流量在第一门限和第二门限值附近变化的情况下,处理器在第一工作模式和第二工作模式之间进行频繁切换。
另外,在本发明实施例中“第一监控时间段”和后续将会提到的“第二监控时间段”均为时间段的概念,以上两个监控之间段均可以是时间周期;以上两个监控时间段可以使用不同的周期,因此第一监控时间段和第二监控时间段可以是不同的,也可以是相同的。对此本发明实施例不作唯一性限定。监控时间段设置得越短则切换更灵敏,响应速度更快,设置得越长则可以减少切换频率。
作为一个更为具体的应用举例,本发明实施例的方案可以应用于虚拟设备中,在虚拟设备中会有较多采用轮询模式驱动接收数据报文的需求,例如:软件采用死循环的方式尝试收/发数据报文,那么上述电子设备为虚拟设备,上述处理数据为接收数据报文和/或发送数据报文。
在实施例将对第二工作模式进行更详细举例说明,其中数据处理以接收数据报文为例,衡量处理器是否繁忙以数据流量作为参考;数据流量是单位时间内数据报文的接收量。在第二工作模式下设置将第一监控时间段定义为时间窗,每个时间窗包含多个基础时间片,每个基础时间片包含可以休眠的第一时间段和尝试进行调度的第二时间段,具体见后续详细说明。本发明实施例可以包括如下三部分:
第一部分:默认在数据面DP采用第一工作模式接收数据报文,保持VM的数据报文接收高性能;
监听数据面DP在定时周期内的实际处理的数据量,标记该定制周期数据面DP的忙闲状态,若监听到连续N个定时周期的数据面DP的状态都为空闲状态,则将DP接收包模型切换为第二工作模式;否则,数据面DP继续处于第一工作模式。以上N可以任意设 定,设定得越大切换的次数越少,设置得越小能耗控制越精细;可以通过实际测试以后,确定一个较为平衡的N。在本实施例中,由于定时周期的时间是固定的,处理器在一个定时周期内的数据处理能力,即:处理器最大能够承受的数据流量是固定的;在一个定时周期内,实际发生的数据流量越高那么处理器越繁忙,越低则越空闲;由于在定时周期内,处理器最大能够承受的数据流量是固定的,那么在该定时周期内,实际发生的数据流量,可以等同于该周期内实际处理的数据报文数量,例如:接收到的数据报文数量或者发送出去的数据报文数量。
具体流程,如图3所示,包括:
301:控制面CP启动定时器,定时器超时,重启定时器并执行302;
302:计算在本次定时器超时所在定时周期内,数据面DP的实际报文接收量;若实际报文接收量超过某一阈值,则确定本定时周期为繁忙状态,若报文接收量低于另一阈值,则确定本定时周期的数据面DP的状态为空闲状态;
303:统计是否连续有N个定时周期的忙闲状态均为空闲状态,若是,那么可以控制第一工作模式切换到第二工作模式;继续执行301。
在执行303时,还有另外一种情况:有连续M个定时周期的数据面DP的忙闲状态均为繁忙状态,控制从第二工作模式切换到第一工作模式。
更具体地,相比于图3所示流程更为底层的实现方案,如图4所示,能效管理的功能启动后控制面CP启动定时器,然后开始执行如下步骤:
401:定时器超时,重启定时器并执行402;
402:控制面CP从数据面DP获取本次定时器超时所在定时周期内数据面DP的报文接收量;
403:确定该实际处理的数据量是否低于某一阈值,如果否,进入404;如果是,进入405;
404;空闲状态次数计数清零,并进入401;
本步骤执行完毕,数据面DP仍然会停留在第一工作模式。
405:空闲状态次数计数加1;
406:判定空闲状态次数的计数是否大于或等于阈值N,如果是,进入407;如果否,进入401;
407:控制面CP通知数据面DP从第一工作模式切换至第二工作模式。
第二部分:由于在第一工作模式下,VNIC最大能够承受的数据流量是固定的,因此在一定时间内能够处理的数据报文数量也是固定的,基于这个前提,在第二工作模式下,可以有如下的调度实现方案:
首先,定义时间窗,例如:一个时间窗10ms,并将一个时间窗划分为多个基础时间片;以基础时间片为单元进行调度,例如:每个基础时间片为500us;将每个基础时间片分为两部分:100us休眠时间,400us尝试调度(即:在第一工作模式下处理数据报文)。这里基础时间片以及时间窗的时间都是可以任意设定的,不同的设定节能效果会有所不同。时间窗和基础时间片的时间设置得较长会更精确,设置得较短则调度更灵敏;基础时间片的时间,休眠时间设置得较长节能效果更好,尝试在第一工作模式下接收数据报文时间设置得较长则可以得到更快的接收数据报文速度。具体执行数据处理的调度过程如下:
第一个基础时间片500us调度过程如下:
首先休眠100us,然后以第一工作模式尝试接收数据报文,第一工作模式接收数据报文是批量接收数据报文的,如果没有数据报文接收,那么尝试接收数据报文的时间为0us,如果有数据报文接收,那么数据报文数量越多时间越长,最长时间为400us,然后会进入下一个基础时间片。
在以上调度过程中,当实际处理的数据量较低时,实际没有接收第一工作模式400us对应的数据报文数量,不会实际消耗400us;因此,在数据报文接收需求较低的情况下,休眠时间在整个基础时间片所占的比重就会较高;从整个时间窗来看,休眠的时间比例也会较高,通过这种方式可以降低处理器的负载,并且休眠时间随输出处理量的减少而减少呈线性变化;另外,还可以通过这种方式确定该基础时间片内实际负载是否是空闲状态,后续基础时间片可以根据上一基础时间片的空闲状态或繁忙状态确定在当前基础时间片如何调度,具体如下:
第二个以及后续基础时间片500us调度过程如下:
首先确定处理器在前一个基础时间片的忙闲状态是否为空闲状态,如果处理器在前一个基础时间片的忙闲状态是空闲状态,那么休眠100us,然后以第一工作模式尝试接收数据报文;如果处理器在前一个基础时间片的忙闲状态是繁忙状态,可以不休眠直接以第一工作模式尝试接收数据报文。
如果每个基础时间片时间是固定的,那么处理器在基础时间片的忙闲状态可以通过该处理器处理数据所耗费的时间来确定,具体可以是:确定以第一工作模式尝试接收数据报文的时间是否到400us,或者是否到300us,这个时间可以设定;如果是,那么确定繁忙状态,否则为空闲状态;也可以采用处理器在该基础时间片内实际负载率来确定,由于在第一工作模式下处理器在400us接收数据报文的最大数量是可以确定的,因此以一个设定的比例,比如:达到80%最大数量则确定为繁忙状态,低于60%确定为空闲状态;具体参考标准可以设定;也可以通过实际测试的方式确定较为合理的参考标准。
除了第一个基础时间片以外,后续的基础时间片都可以使用第二个基础时间片的调度方式。由于基础时间片时间较短,当负载较小时,休眠时间较多,当负载较大时,休眠时间较少,这样宏观上来看,数据面DP的处理器的负载率与实际处理的数据量会有线性的关系,可以达到对处理器的负载率的精确控制。
另外,如果处理器在一个时间窗内的实际处理的数据量较大,可以确定处理器的在该时间窗内为繁忙状态,那么可以在数据面DP从第二工作模式切换到第一工作模式。具体如图5A所示,在一个时间窗内包含基础时间片,每个基础时间片执行“根据反馈确定是否休眠,并检测处理器在本基础时间片内是否为空闲状态”以及“反馈”,反馈的内容是处理器在本基础时间片内是否为空闲状态;
采用本实施例方案,当实际处理的数据量有突变时,在一个时间窗内的后续基础时间片内会尽力调度不会休眠,在这种情况下如果以一个时间窗作为整体,确定处理器在整个时间窗内是否为空闲状态,那么在该时间窗内仍然可能会确定处理器在该时间窗内为空闲状态,调度模型仍然会停留在第二工作模式,这样可以防止实际处理的数据量突变造成实际处理的数据量增加的假象,避免立即切换到第一工作模式。
更具体地,更为底层的实现方案如图6所示,能效管理的功能启动,控制面CP启动定时器后开始执行如下步骤:
601:10ms时间窗开始;
602:第一个基础时间片,休眠100us;
603:第一个基础时间片,以第一工作模式尝试接收数据报文,可能接收了N1个数据报文,使用的时间为T1;
如果T1小于400us,那么该步骤在数据报文接收完毕后结束,或者,如果T1等于400us,由于该基础时间片的时间耗尽,那么T1到达400us时结束,此时数据报文可能已经接收完毕也可能未接收完毕;因此此处T1应当小于或等于400us。
604:根据休眠时间或实际接收数据报文时间,占一个基础时间片的时间的比例计算处理器在第一个基础时间片内是否为空闲状态,并然后进入下一和基础时间片;
本步骤中使用休眠时间或实际接收数据报文时间,占一个基础时间片的时间的比例,该占比也可以用于表示处理器的实际负载率,即:休眠时间占比例越大实际负载率越低;
605:确定处理器在上一基础时间片是否为空闲状态,如果是,进入606,否则进入607;
606:休眠100us;
607:以第一工作模式尝试接收数据报文,可能接收了N2个数据报文,使用的时间为T2;
如果T2小于400us,那么该步骤在数据报文接收完毕后结束,或者,如果T2等于400us,由于该基础时间片的时间耗尽,那么T2到达400us时结束,此时数据报文可能已经接收完毕也可能未接收完毕;因此此处T2应当小于或等于400us。
608:根据休眠时间或实际接收数据报文时间,占一个基础时间片的时间的比例计算处理器在当前基础时间片内是否为空闲状态,如果是,进入609,如果否,进入610;
609:标记处理器在当前基础时间片内为空闲状态,进入611;
610;标记处理器在当前基础时间片内为繁忙状态,进入611;
611:确定10ms时间窗是否完毕,如果否,进入605;如果是,进入612;
612:确定10ms时间窗内处理器的负载率是否小于阈值,如果是进入601;如果否,进入613;
613:退出第二工作模式,切换到第一工作模式。
图6所示的调度算法将一个时间窗切换成更小粒度的基础时间片,这样处理器在有些基础时间片内除了完成接收数据报文的功能,如果处理器在上个基础时间片为空闲状态,那么处理器在当前基础时间片会进行休眠,当实际处理的数据量较少时,收/发数据报文消耗时间少,处理器在基础时间片休眠的机会相对会比较多,当实际处理的数据量增大时,处理器在基础时间片休眠的机会相对会少,最终在一个宏观的时间段来看,处理器的功率与实际处理的数据量的大小基本成正比,通过这种方式实现了系统的横向/纵向扩展(scale up/down)。另外,由于处理器在每个基础时间片的休眠时间很短,因此也可以保证响应业务处理的时延较小。
第三部分,基于第二部分的实现方式,本部分提供从第一工作模式切换到第二工作模式的实现方案。
如图7所示:
在控制面CP,每个基础时间片执行701:计算处理器在基础时间片的忙闲状态;
本步骤,从数据面DP获取处理器在基础时间片的时间内处于第二工作模式下实际处理的数据量,然后据此确定处理器在该基础时间片内是繁忙状态,还是空闲状态。
在每个时间窗的时间结束后,执行702:统计处理器在该时间窗的忙闲状态。
在本步骤统计结果出来以后,如果处理器在该时间窗为繁忙状态,那么控制数据面DP从第二工作模式切换到第一工作模式;可以理解的是,如果当前处于第一工作模式,如果处理器在该时间窗为空闲状态,那么控制数据面DP从第一工作模式切换到第二工作模式。
如果由数据面DP控制处理器从第二工作模式切换回第一工作模式或者从第一工作模式切换到第二工作模式,可以参考图5B,相比于图5A区别在于时间窗的控制部分设置于数据面DP;图5B的说明可以参阅图5A对应的文字说明,在此不再赘述。
基于采用时间窗结合基础时间片的能耗控制以后,处理器的实际处理的数据量与处理器的利用率整体呈线性关系,如图8所示,为实际测试后的结果图。其中横轴为实际处理的数据量,纵轴为处理器的利用率,处理器的利用率对应相应的功耗,处理器的功耗与实际处理的数据量整体上也呈线性关系。
本发明实施例还提供了一种电子设备,如图9所示,上述电子设备包括:
数据量检测单元901、切换控制单元902以及处理单元903;
其中,该数据量检测单元901,用于监控该电子设备在第一监控时间段内处理的数据量;
该切换控制单元902,用于根据该电子设备在第一监控时间段内处理的数据量确定该处理单元903在该第一监控时间段内空闲,则将该处理单元903由该第一工作模式切换到第二工作模式;
该处理单元903,用于在该处理单元903被配置为第一工作模式时,在该第一工作模式下该处理单元903采用PMD方式处理数据;在该第二工作模式下该处理单元903采用PMD和休眠的方式处理数据。
在采用轮询模式驱动方式工作的电子设备中,为该电子设备的处理单元903提供了两种工作模式;其中第一工作模式功耗较高,第二工作模式功耗相对较低;通过监测处理单元903处理的数据量,在实际处理的数据量较小时,使用较低能耗的工作模式,可以降低能耗。
电子设备实施例中,各技术名词以及相应的介绍可以参考方法实施例的具体说明在此不再一一赘述。
可选地,该处理单元903,具体用于在第二工作模式下的第一基础时间片内采用该第二工作模式;该第一基础时间片包含第一时间段和第二时间段;该处理单元903在该第一时间段休眠,在该第二时间段工作。
进一步地,如图10所示,所处理单元903还包括:
忙闲判断单元1001,用于在第一基础时间片结束之后,判断该处理单元903在该第一基础时间片时的忙闲状态;
工作控制单元,用于当该忙闲判断单元1001判断该处理单元903在该第一基础时间片的忙闲状态为繁忙状态,则控制该处理单元903在第二基础时间片的第一时间段工作。
可选地,该处理单元903,具体用于若该处理单元903在该第一基础时间片的该第二时间段未结束且数据处理完毕,则提前结束该第一基础时间片的第二时间段,或者,在该第二时间段中剩余的时间休眠。
可选地,所忙闲判断单元1001,具体用于若该处理单元903在该第一基础时间片内处理数据的时间大于第一阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状 态;
或者,若该处理单元903在该第一基础时间片的第二时间段结束时处于处理数据的状态,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态;
或者,若该处理单元903在该第一基础时间片内处理的数据量大于第二阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态。
可选地,该忙闲判断单元1001,还用于若该处理单元903在该第一基础时间片内处理数据的时间小于该第三阈值,则确定该第一基础时间片的忙闲状态为空闲状态;该第三阈值小于或等于该第一阈值;
或者,若该处理单元903在该第一基础时间片的第二时间段结束时处在休眠状态,或者若该处理单元903提前结束该第一基础时间片的第二时间段,则确定该第一基础时间片的忙闲状态为空闲状态;
或者,若该处理单元903在该第一基础时间片内处理的数据量小于第四阈值,则确定该第一基础时间片的忙闲状态为空闲状态;该第四阈值小于或等于该第二阈值。
进一步地,该数据量检测单元901,还用于在处理单元903处于该第二工作模式时,监控该电子设备在第二监控时间段内处理的数据量;
该切换控制单元902,还用于根据该电子设备在第二监控时间段内处理的数据量确定该处理单元903在该第二监控时间段内繁忙,则将该处理单元903由该第二工作模式切换到该第一工作模式。
仍然以数据流量为例,采用数据流量作为衡量处理单元903是否空闲的标准,本实施例具体可以是:该切换控制单元902,还用于在监控到该电子设备在第二监控时间段内的数据流量大于或等于第二门限的情况下,将该处理单元903由该第二工作模式切换到该第一工作模式;该第一门限大于或等于该第二门限。
本发明实施例还提供了另一种电子设备,如图11所示,包括:处理器1101,以及存储器1102;可能还可以包含接收设备、发送设备、输出设备等;处理器1101与存储器1102可以通过总线1103连接,也可以采用其他硬件接口进行连接;
其中,该处理器1101的功能如下:监控该电子设备在第一监控时间段内处理的数据量,该电子设备的处理器1101配置为第一工作模式,在该第一工作模式下该处理器1101采用PMD方式处理数据;根据该电子设备在该第一监控时间段内处理的数据量确定该处理器在该第一监控时间段内空闲,将该处理器1101由该第一工作模式切换到第二工作模式,在该第二工作模式下该处理器1101采用PMD和休眠的方式处理数据。
以上第二工作模式相比于第一工作模式增加了休眠的时间,因此功耗相对较低,接收数据报文的能力也相应较低。通过某一时间段内处理器处理的数据量来确定处理器在该时间段内是否空闲的方式较多,以接收和/或发送数据报文为例,可以是:监控到该电子设备在第一监控时间段内的数据流量小于或等于第一门限,则确定该处理器在该第一监控时间段内空闲;该第一门限对应于数据流量是单位时间内接收的数据量的门限值;也可以是:监控到该电子设备在第一监控时间段内处理的数据量小于或等于第一门限,则确定该处理器在该第一监控时间段内空闲;该第一门限则对应于第一监控时间段处理的数据量的门限值。该第一门限是为了区分处理器是不是比较空闲的阈值,在处理器比较空闲的情况下切换到较低能耗的工作模式。
在一个可选的实现方式中,该处理器1101在第一基础时间片内采用该第二工作模式; 上述在该第二工作模式下该处理器1101采用PMD和休眠的方式处理数据包括:
该第一基础时间片包含第一时间段和第二时间段;
该处理器1101在该第一时间段休眠,在该第二时间段工作。
在本实施例中,第一基础时间片和后续实施例中的第二基础时间片,是对基础时间片的分类,其中第一基础时间片可以是处理器1101从第一工作模式切换到第二工作模式后的第一个基础时间片,或者是第二工作模式下处理器1101在各基础时间片都默认采用第一基础时间片的工作模式进行工作;第二工作模式可以是除了该第一个基础时间片外的其他基础时间片的代表,那么第一基础时间片可以认为是第二基础时间片的前一个基础时间片;基础时间片的时间长度可以任意设定,通常来说可以设置得较短一点,第一时间段和第二时间段也可以相应的较短,那么可以提高调度精度;另外,处理器1101每次休眠的时间较短,可以提高处理器1101的响应速度。
在一个可选的实现方式中还提供了增加工作模式控制的弹性的具体实现方案,具体如下:该处理器1101的功能如下:该处理器1101在第一基础时间片结束之后,判断该处理器1101在该第一基础时间片时的忙闲状态,当该处理器1101在该第一基础时间片的忙闲状态为繁忙状态,则该处理器1101在第二基础时间片的第一时间段工作。
本实施例,处理器1101在第一时间段是否工作取决于处理器1101当前的忙闲状态,在不切换处理器1101工作模式的前提下,可以动态调整处理器1101的数据处理能力,使处理器1101的数据处理能力能够和实际需求匹配,提高对数据处理需求的响应速度,使能耗与实际数据处理需求呈线性的正相关关系;并且可以避免因为瞬时数据处理需求突变导致处理器1101的工作模式切换。
在一个可选的实现方式中,上述在该第二时间段工作包括:
若该处理器1101在该第一基础时间片的该第二时间段未结束且数据处理完毕,则提前结束该第一基础时间片的第二时间段,或者,在该第二时间段中剩余的时间休眠。
在本实施例中,由于处理器1101在第二时间段并不一定一直有数据需要处理,因此第二时间段可能存在较多的时间处理器1101处于无数据需要处理的情况;采用本实施例,可以进一步基于数据处理的实际需求增加休眠时间,进一步降低处理器1101的功耗。
在一个可选的实现方式中,该处理器1101判断该处理器1101的该第一基础时间片的忙闲状态包括:
若该处理器1101在该第一基础时间片内处理数据的时间大于第一阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态;
或者,若该处理器1101在该第一基础时间片的第二时间段结束时处于处理数据的状态,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态;
或者,若该处理器1101在该第一基础时间片内处理的数据量大于第二阈值,则该电子设备确定该第一基础时间片的忙闲状态为繁忙状态。
在本实施例中,第一阈值和第二阈值均是用于确定处理器1101在第一基础时间片内是否繁忙的阈值,其中第一阈值以处理数据耗费的时间作为参考,处理数据所耗费的时间越长表示处理器1101越繁忙,第二阈值以数据量作为参考,数据量越大则表示处理器1101越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
在一个可选的实现方式中,处理器1101还用于确定忙闲状态具体如下:
若上述处理器1101在该第一基础时间片内处理数据的时间小于第三阈值,则该电子设 备确定该第一基础时间片的忙闲状态为空闲状态;该第三阈值小于或等于该第一阈值;
或者,若该处理器1101在该第一基础时间片的第二时间段结束时处在休眠状态,或者若该处理器1101提前结束该第一基础时间片的第二时间段,则该电子设备确定该第一基础时间片的忙闲状态为空闲状态;
或者,若该处理器1101在该第一基础时间片内处理的数据量小于第四阈值,则该电子设备确定该第一基础时间片的忙闲状态为空闲状态;该第四阈值小于或等于该第二阈值。
在本实施例中,第三阈值和第四阈值均是用于确定处理器1101在第一基础时间片内是否繁忙的阈值,其中第三阈值以处理数据所耗费的时间作为参考,处理数据所耗费的时间越长表示处理器1101越繁忙,第四阈值以数据量作为参考,数据量越大则表示处理器1101越繁忙;具体采用哪一数值本发明实施例不作唯一性限定。
在一个可选的实现方式中,该处理器1101,还用于在该处理器1101处于该第二工作模式时,监控上述电子设备在第二监控时间段内处理的数据量;根据该电子设备在该第二监控时间段内处理的数据量确定上述处理器在该第二监控时间段内繁忙,则将该处理器由上述第二工作模式切换到上述第一工作模式;该第一门限大于或等于该第二门限。
仍然以数据流量为例,采用数据流量作为衡量处理器是否空闲的标准,本实施例具体可以是:上述处理器1101处于该第二工作模式时,监控该电子设备在第二监控时间段内的数据流量;在监控到该电子设备在第二监控时间段内的数据流量大于或等于第二门限的情况下,将该处理器1101由该第二工作模式切换到该第一工作模式;该第一门限大于或等于该第二门限。
在本实施例中,第二门限是用于确定处理器1101比较繁忙,或者当前有较多的数据报文需要被处理,此时需要处理器尽量发挥其最大的数据处理能力的应用场景。该第二门限大于第一门限,可以作为一个优选实现方案,实际的数据处理量在第一门限和第二门限之间时,可以保持当前的工作模式,避免实际的数据处理量在第一门限和第二门限之间时,可以保持当前的工作模式,避免实际的数据流量在第一门限和第二门限值附近变化的情况下,处理器1101在第一工作模式和第二工作模式之间进行频繁切换。
可选地,上述电子设备为虚拟设备。如果电子设备为虚拟设备,本发明实施例的电子设备应用的硬件实体可以对应到图1所示的物理主机,电子设备对应到虚拟机;处理器可以是物理主机的处理器,也可以是物理主机分配给虚拟机的数据处理资源。
值得注意的是,上述装置只是按照功能逻辑进行划分的,但并不局限于上述的划分,只要能够实现相应的功能即可;另外,各功能单元的具体名称也只是为了便于相互区分,并不用于限制本发明的保护范围。
另外,本领域普通技术人员可以理解实现上述各方法实施例中的全部或部分步骤是可以通过程序来指令相关的硬件完成,相应的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明实施例揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。

Claims (12)

  1. 一种调度方法,其特征在于,应用于电子设备,包括:
    监控所述电子设备在第一监控时间段内处理的数据量,所述电子设备的处理器配置为第一工作模式,在所述第一工作模式下所述处理器采用轮询模式驱动PMD方式处理数据;
    根据所述电子设备在所述第一监控时间段内处理的数据量确定所述处理器在所述第一监控时间段内空闲,则将所述处理器由所述第一工作模式切换到第二工作模式,在所述第二工作模式下所述处理器采用PMD和休眠的方式处理数据。
  2. 根据权利要求1所述方法,其特征在于,所述处理器在第一基础时间片内采用所述第二工作模式;所述第二工作模式下所述处理器采用PMD和休眠的方式处理数据包括:
    所述第一基础时间片包含第一时间段和第二时间段;
    所述处理器在所述第一时间段休眠,在所述第二时间段工作。
  3. 根据权利要求2所述方法,其特征在于,所述处理器在第一基础时间片结束之后,所述方法还包括:
    所述处理器判断所述处理器在所述第一基础时间片时的忙闲状态,当所述处理器在所述第一基础时间片的忙闲状态为繁忙状态,则所述处理器在第二基础时间片的第一时间段工作。
  4. 根据权利要求2或3所述方法,其特征在于,所述在所述第二时间段工作包括:
    若所述处理器在所述第一基础时间片的所述第二时间段未结束且数据处理完毕,则提前结束所述第一基础时间片的第二时间段,或者,在所述第二时间段中剩余的时间休眠。
  5. 根据权利要求3或4所述的方法,其特征在于,所述处理器判断所述处理器的所述第一基础时间片的忙闲状态包括:
    若所述处理器在所述第一基础时间片内处理数据的时间大于第一阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
    或者,若所述处理器在所述第一基础时间片的第二时间段结束时处于处理数据的状态,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
    或者,若所述处理器在所述第一基础时间片内处理的数据量大于第二阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态。
  6. 根据权利要求1至5任一所述方法,其特征在于,所述方法还包括:
    所述处理器处于所述第二工作模式时,监控所述电子设备在第二监控时间段内的处理的数据量;
    根据所述电子设备在所述第二监控时间段内处理的数据量确定所述处理器在所述第二监控时间段内繁忙,则将所述处理器由所述第二工作模式切换到所述第一工作模式。
  7. 一种电子设备,其特征在于,包括:
    数据量检测单元,用于监控所述电子设备在第一监控时间段内处理的数据量;
    切换控制单元,用于根据所述电子设备在第一监控时间段内处理的数据量确定处理单元在所述第一监控时间段内空闲,则将所述处理单元由所述第一工作模式切换到第二工作模式;
    处理单元,用于在所述处理单元被配置为第一工作模式时,在所述第一工作模式下所述处理单元采用轮询模式驱动PMD方式处理数据;在所述第二工作模式下所述处理单元采用PMD和休眠的方式处理数据。
  8. 根据权利要求7所述电子设备,其特征在于,
    所述处理单元,具体用于在第二工作模式下的第一基础时间片内采用所述第二工作模式;所述第一基础时间片包含第一时间段和第二时间段;所述处理单元在所述第一时间段休眠,在所述第二时间段工作。
  9. 根据权利要求8所述电子设备,其特征在于,所处理单元还包括:
    忙闲判断单元,用于在第一基础时间片结束之后,判断所述处理单元在所述第一基础时间片时的忙闲状态;
    工作控制单元,用于当所述忙闲判断单元判断所述处理单元在所述第一基础时间片的忙闲状态为繁忙状态,则控制所述处理单元在第二基础时间片的第一时间段工作。
  10. 根据权利要求8或9所述电子设备,其特征在于,
    所述处理单元,具体用于若所述处理单元在所述第一基础时间片的所述第二时间段未结束且数据处理完毕,则提前结束所述第一基础时间片的第二时间段,或者,在所述第二时间段中剩余的时间休眠。
  11. 根据权利要求9或10所述的电子设备,其特征在于,
    所忙闲判断单元,具体用于若所述处理单元在所述第一基础时间片内处理数据的时间大于第一阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
    或者,若所述处理单元在所述第一基础时间片的第二时间段结束时处于处理数据的状态,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态;
    或者,若所述处理单元在所述第一基础时间片内处理的数据量大于第二阈值,则所述电子设备确定所述第一基础时间片的忙闲状态为繁忙状态。
  12. 根据权利要求7至11任一所述电子设备,其特征在于,
    所述数据量检测单元,还用于在处理单元处于所述第二工作模式时,监控所述电子设备在第二监控时间段内的处理的数据量;
    所述切换控制单元,还用于根据所述电子设备在第二监控时间段内处理的数据量确定所述处理单元在所述第二监控时间段内繁忙,则将所述处理单元由所述第二工作模式切换到所述第一工作模式。
PCT/CN2017/076962 2016-03-24 2017-03-16 一种调度方法及电子设备 WO2017162096A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP17769373.6A EP3428801B1 (en) 2016-03-24 2017-03-16 Scheduling method and electronic device
US16/139,817 US10929179B2 (en) 2016-03-24 2018-09-24 Scheduling method and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610176197.3 2016-03-24
CN201610176197.3A CN105786674B (zh) 2016-03-24 2016-03-24 一种调度方法及电子设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/139,817 Continuation US10929179B2 (en) 2016-03-24 2018-09-24 Scheduling method and electronic device

Publications (1)

Publication Number Publication Date
WO2017162096A1 true WO2017162096A1 (zh) 2017-09-28

Family

ID=56391973

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/076962 WO2017162096A1 (zh) 2016-03-24 2017-03-16 一种调度方法及电子设备

Country Status (4)

Country Link
US (1) US10929179B2 (zh)
EP (1) EP3428801B1 (zh)
CN (1) CN105786674B (zh)
WO (1) WO2017162096A1 (zh)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105786674B (zh) 2016-03-24 2018-11-16 华为技术有限公司 一种调度方法及电子设备
CN106527653A (zh) * 2016-10-12 2017-03-22 东软集团股份有限公司 调整cpu频率的方法及装置
CN110278052B (zh) * 2018-03-15 2020-10-09 大唐移动通信设备有限公司 一种数据接收方法及装置
CN109086128B (zh) * 2018-08-28 2021-06-18 迈普通信技术股份有限公司 任务调度方法及装置
CN110968403A (zh) * 2018-09-28 2020-04-07 深信服科技股份有限公司 一种cpu工作控制方法、装置、设备及存储介质
CN109743207B (zh) * 2018-12-29 2021-09-14 联想(北京)有限公司 服务器性能调节方法和服务器
US11455024B2 (en) * 2019-04-10 2022-09-27 Red Hat, Inc. Idle state estimation by scheduler
US10856331B1 (en) * 2019-09-10 2020-12-01 Cypress Semiconductor Corporation Devices, systems, and methods for mitigating aggressive medium reservations
CN112579513B (zh) * 2020-12-08 2023-04-25 成都海光微电子技术有限公司 芯片自适应控制电路、方法和系统级芯片
CN112968965B (zh) * 2021-02-25 2022-12-09 网宿科技股份有限公司 Nfv网络节点的元数据服务方法、服务器及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1924761A (zh) * 2005-08-31 2007-03-07 松下电器产业株式会社 数据处理装置、程序、记录介质和内容回放装置
CN103891361A (zh) * 2011-07-29 2014-06-25 勃来迪环球股份有限公司 用于功率节省和管理的usb设备侧唤醒
CN103906462A (zh) * 2011-08-03 2014-07-02 德雷格医疗系统股份有限公司 基于吞吐量的活跃模式触发
CN104469905A (zh) * 2014-11-14 2015-03-25 惠州Tcl移动通信有限公司 降低nfc芯片闲置时功耗的方法及系统
CN105786674A (zh) * 2016-03-24 2016-07-20 华为技术有限公司 一种调度方法及电子设备

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005083940A1 (en) * 2004-02-19 2005-09-09 Koninklijke Philips Electronics, N.V. Method and associated system for wireless medical monitoring and patient monitoring device
US8286169B2 (en) * 2005-06-17 2012-10-09 Intel Corporation Dynamic scheduling an interval for polling devices based on a current operational power mode in an extensible firmware interface architecture
JP4983033B2 (ja) * 2006-02-08 2012-07-25 ソニー株式会社 通信装置および方法、並びにプログラム
US8135346B2 (en) * 2008-12-04 2012-03-13 Broadcom Corporation Method and system for a reduced USB polling rate to save power on a Bluetooth host
US8509694B2 (en) * 2010-08-31 2013-08-13 Apple Inc. Techniques for facilitating communication between a portable media device and an accessory using multiple communication paths
EP2941056B1 (en) * 2012-12-25 2019-07-31 LG Electronics Inc. Improved scanning method and apparatus in wireless lan system
CN103731364B (zh) 2014-01-16 2017-02-01 赛特斯信息科技股份有限公司 基于x86平台实现万兆大流量快速收包的方法
WO2016101099A1 (en) 2014-12-22 2016-06-30 Intel Corporation Techniques for power management associated with processing received packets at a network device
US9961033B2 (en) * 2015-11-09 2018-05-01 Red Hat Israel, Ltd. Memory-mapped input/output (I/O) channel
US10908941B2 (en) * 2016-03-11 2021-02-02 Tektronix Texas, Llc Timestamping data received by monitoring system in NFV

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1924761A (zh) * 2005-08-31 2007-03-07 松下电器产业株式会社 数据处理装置、程序、记录介质和内容回放装置
CN103891361A (zh) * 2011-07-29 2014-06-25 勃来迪环球股份有限公司 用于功率节省和管理的usb设备侧唤醒
CN103906462A (zh) * 2011-08-03 2014-07-02 德雷格医疗系统股份有限公司 基于吞吐量的活跃模式触发
CN104469905A (zh) * 2014-11-14 2015-03-25 惠州Tcl移动通信有限公司 降低nfc芯片闲置时功耗的方法及系统
CN105786674A (zh) * 2016-03-24 2016-07-20 华为技术有限公司 一种调度方法及电子设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3428801A4 *

Also Published As

Publication number Publication date
EP3428801A1 (en) 2019-01-16
US20190034229A1 (en) 2019-01-31
CN105786674A (zh) 2016-07-20
CN105786674B (zh) 2018-11-16
EP3428801A4 (en) 2019-03-27
EP3428801B1 (en) 2023-05-03
US10929179B2 (en) 2021-02-23

Similar Documents

Publication Publication Date Title
WO2017162096A1 (zh) 一种调度方法及电子设备
WO2021008543A1 (zh) 一种资源调度的方法和电子设备
US10628216B2 (en) I/O request scheduling method and apparatus by adjusting queue depth associated with storage device based on hige or low priority status
US10990407B2 (en) Dynamic interrupt reconfiguration for effective power management
US9329671B2 (en) Power-efficient inter processor communication scheduling
CN101916207B (zh) 桌面虚拟化环境下的节能方法、装置及系统
CN101739113B (zh) 在虚拟化集群系统中进行能效管理的方法及装置
WO2010060289A1 (zh) 一种多核处理器的任务分配方法、系统及设备
TWI439850B (zh) 電子裝置及平台管理方法
WO2021233261A1 (zh) 一种多任务动态资源调度方法
WO2016101099A9 (en) Techniques for power management associated with processing received packets at a network device
JP2014513877A (ja) 電力しきい値を使用したモバイル通信端末のためのスマート電力マネージメントの方法および装置
US20120297216A1 (en) Dynamically selecting active polling or timed waits
US11567556B2 (en) Platform slicing of central processing unit (CPU) resources
WO2020228289A1 (zh) 日志获取方法、装置、终端及存储介质
US9489223B2 (en) Virtual machine wakeup using a memory monitoring instruction
JP2016523399A (ja) エネルギー効率的なモバイルプラットフォームのための適応的割り込みコアレッシング
CN111200541A (zh) 网络数据处理方法和装置
WO2020253641A1 (zh) 一种信道状态测量参数指示方法及装置
Zhang et al. Leveraging the tail time for saving energy in cellular networks
US11113216B2 (en) Dispatching interrupts in a multi-processor system based on power and performance factors
US11243603B2 (en) Power management of an event-based processing system
CN115309507B (zh) 一种cpu资源占用率的计算方法、装置、设备及介质
WO2013159464A1 (zh) 一种多核处理器时钟控制装置及控制方法
CN115686863A (zh) 一种混合轮询方法、装置、设备及可读存储介质

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2017769373

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2017769373

Country of ref document: EP

Effective date: 20181008

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

Ref document number: 17769373

Country of ref document: EP

Kind code of ref document: A1