WO2023109338A1 - Load control method and apparatus for kernel, and computer-readable storage medium - Google Patents

Load control method and apparatus for kernel, and computer-readable storage medium Download PDF

Info

Publication number
WO2023109338A1
WO2023109338A1 PCT/CN2022/128718 CN2022128718W WO2023109338A1 WO 2023109338 A1 WO2023109338 A1 WO 2023109338A1 CN 2022128718 W CN2022128718 W CN 2022128718W WO 2023109338 A1 WO2023109338 A1 WO 2023109338A1
Authority
WO
WIPO (PCT)
Prior art keywords
time
thread
kernel
cpu
load control
Prior art date
Application number
PCT/CN2022/128718
Other languages
French (fr)
Chinese (zh)
Inventor
徐阳
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2023109338A1 publication Critical patent/WO2023109338A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • 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]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5022Workload threshold
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/508Monitor
    • 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 embodiments of the present application relate to the field of computer technology, and in particular, to a method and device for controlling kernel load, and a computer-readable storage medium.
  • Embodiments of the present application provide a kernel load control method and device, and a computer-readable storage medium.
  • the embodiment of the present application provides a method for controlling the load of a kernel.
  • the method includes: obtaining the first time of the thread, and obtaining the first time of the thread.
  • the second time of the thread the first time is the CPU time consumed by the thread in the corresponding kernel, and the second time is the CPU time consumed by the thread in the corresponding kernel
  • process the CPU time consumed by effective services determine the CPU occupancy rate of the core corresponding to the thread according to the first time and the second time of the thread;
  • the CPU usage performs load control on multiple cores.
  • the embodiment of the present application also provides a load control device, including: a memory, a processor, and a computer program stored in the memory and operable on the processor, and the processor implements the computer program when executing the computer program.
  • a load control device including: a memory, a processor, and a computer program stored in the memory and operable on the processor, and the processor implements the computer program when executing the computer program.
  • the embodiment of the present application further provides a computer-readable storage medium, storing computer-executable instructions, and the computer-executable instructions are used to execute the method for controlling the load of a kernel as described in the first aspect above.
  • Fig. 1 is a flow chart of the load control method of the kernel provided by one embodiment of the present application
  • Fig. 2 is a flow chart of obtaining the second time of the thread in the load control method of the kernel provided by one embodiment of the present application;
  • FIG. 3 is a flow chart of obtaining a second time of a thread according to an effective service in a load control method of the kernel provided by an embodiment of the present application;
  • Fig. 4 is a flow chart of obtaining the forwarding rate of the thread at the first time in the load control method of the kernel provided by an embodiment of the present application;
  • FIG. 5 is a flow chart of obtaining a fourth time of a thread in a kernel load control method provided by an embodiment of the present application
  • FIG. 6 is a flow chart of determining the CPU usage of the kernel in a method for controlling the load of the kernel provided by an embodiment of the present application;
  • FIG. 7 is a schematic diagram of a CPU processor provided by an embodiment of the present application.
  • FIG. 8 is a flow chart of performing load control on multiple cores in a core load control method provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of an execution flow of a kernel load control method provided by an embodiment of the present application.
  • FIG. 10 is a flow chart after determining the CPU usage of the kernel in the load control method of the kernel provided by an embodiment of the present application.
  • FIG. 11 is a schematic diagram of the execution flow of a kernel load control method provided by another embodiment of the present application.
  • Fig. 12 is a schematic diagram of a load control device provided by an embodiment of the present application.
  • the application provides a kernel load control method and device, and a computer-readable storage medium.
  • For each thread by obtaining the first time and the second time of the thread, it is possible to show the actual cyclic execution of the thread in the bound kernel.
  • the CPU occupancy rate of the core bound by the thread is accurately known.
  • the parallelism of the kernel architecture realizes multi-core load balancing control and improves device performance.
  • Figure 1 is a flowchart of a method for controlling the load of a kernel provided by an embodiment of the present application, wherein there are multiple kernels, and the kernels are individually bound to threads, and the method for controlling the load of the kernel includes but is not limited to step S100 to S300.
  • Step S100 obtain the first time of the thread, and the second time of obtaining the thread, the first time is the CPU time consumed by the thread in the corresponding core, and the second time is the thread in the corresponding kernel. Next, the CPU time consumed by processing valid services.
  • the actual overhead of the thread's loop execution in the bound core can be displayed. Since each core is bound to a thread independently, the application A thread running in an endless loop, so the relevant CPU time occupied by the thread in the kernel is equivalent to the relevant CPU time required by the kernel, so that it can be determined according to the obtained first time and second time in subsequent steps The CPU usage of the kernel.
  • the first time and the second time of the thread are actually obtained by superimposing the time consumed by each cycle, so in determining the first time of each cycle After the corresponding components of the first time and the second time, that is, after determining that the thread is in the corresponding core, the CPU time consumed by executing a cycle and the thread is executed in the corresponding core in the case of a cycle, after the CPU time consumed by processing valid services , then the first time and the second time of the thread can be further determined, and an embodiment will be given below for illustration.
  • the "obtaining the second time of the thread" in step S100 includes but not limited to steps S110 to S120.
  • Step S110 Obtain the feedback result of processing the business of each instance when the thread executes a cycle in the kernel
  • Step S120 According to all feedback results and preset service evaluation conditions, determine valid services from each example service
  • Step S130 Obtain the second time of the thread according to the effective service.
  • each instance service can feed back the corresponding result after execution, it is possible to determine the effective service from each instance service based on the corresponding relationship between the feedback result and the preset service evaluation conditions, and further according to The CPU time consumed by the effective service is processed by the active service acquisition thread in the case of cyclic execution in the corresponding core, so the second time of the thread can be acquired accurately and reliably.
  • the preset service evaluation conditions can be set according to different application scenarios, and there is no uniform standard. For example, if there is time for processing packets in a thread, it can be considered as valuable time for the entire device. That is, the effective time, if there is no message processing in the thread, even if it calls the driver to receive or send a package (actually does not receive or send a package), it is considered to be idle time, and correspondingly, it is judged that there is a processing message
  • the conditions of the time or situation are the preset business evaluation conditions.
  • the instance business can be any business under the thread, or any business related to the thread, as long as it is executed in the thread, it can be regarded as the instance business processed by the thread; in addition, the form of the feedback result is not It is not limited, and may be represented by a numerical value or a symbol, but no matter what the form is, as long as it corresponds to the preset service evaluation condition.
  • step S130 includes but not limited to steps S131 to S134.
  • Step S131 According to the effective service, determine the effective functional unit for executing the effective service from the thread;
  • Step S132 Obtain the first initial time and the first end time when the effective functional unit executes the effective business
  • Step S133 subtracting the first initial time from the first end time to obtain the third time
  • Step S134 Obtain the added value of all the third times to obtain the second time of the thread.
  • each instance service is executed by a corresponding functional unit.
  • the effective functional unit used to execute the effective service can be determined from the thread, and the execution time of the effective functional unit is the effective processing time. Therefore, by obtaining the first initial moment and the first end moment when the effective functional unit executes the effective service, the effective time for the thread to execute a cycle can be determined, and finally the second time of the thread can be obtained by superimposing the effective time of each cycle. Time, it can be seen that the second time obtained based on the method of this embodiment is accumulated based on the effective time of each cycle determined separately, so the accuracy is high, and it can well represent the thread in the corresponding core. CPU time consumed by processing valid services in the case of mid-cycle execution.
  • the first initial moment and the first end moment when the effective functional unit executes the effective service may be the same or different, and the correspondingly determined third time may also be can be different, which is not limited in this embodiment.
  • the "acquiring the first time of the thread" in step S100 includes but not limited to steps S140 to S150.
  • Step S140 Obtain the fourth time of the thread, the fourth time is the CPU time consumed by the thread executing a cycle in the kernel;
  • Step S150 add up all the fourth times to obtain the first time of the thread.
  • the first time of the thread can be accurately obtained by obtaining the CPU time consumed by each cycle executed by the thread in the kernel, determining the fourth time of the thread, and then superimposing the CPU time consumed by all cycles.
  • the CPU time consumed by each thread may be the same or different, and the correspondingly determined fourth time may also be different, which is not shown in this embodiment. limit.
  • step S140 includes but not limited to steps S141 to S142.
  • Step S141 Obtain the second initial moment and the second end moment when the thread executes a cycle in the kernel
  • Step S142 Subtract the second initial time from the second end time to obtain a fourth time.
  • the thread since the thread will execute in a loop after completing the initialization, and then call each execution function body repeatedly, so based on each execution function body, the second initial moment and the second end moment when the thread executes a cycle in the kernel can be determined , and then by obtaining the difference between the second end time and the second initial time, the fourth time is obtained through precise calculation.
  • Step S200 Determine the CPU usage of the core corresponding to the thread according to the first time and the second time of the thread.
  • the execution parameter of the thread is equivalent to the execution parameter of the kernel. Therefore, the thread corresponding to the thread can be further accurately determined according to the first time and the second time of the thread. Compared with related technologies, the CPU usage rate of the kernel does not always appear as 100% of the calculated CPU usage rate of the kernel, and the calculation result is more accurate and reliable.
  • step S200 includes but not limited to steps S210 to S220.
  • Step S210 when the first time is greater than the preset threshold time, divide the second time by the first time to obtain the CPU usage rate of the thread;
  • Step S220 Determine the CPU usage rate of the kernel as the CPU usage rate of the thread.
  • the CPU time consumed by the cyclic execution of the thread in the corresponding core exceeds the preset threshold time
  • the CPU time of the thread is obtained by dividing the second time by the first time. Occupancy rate, where the purpose of setting the preset threshold time is to ensure that the calculated first time can meet the duration requirement, that is, the number of thread loop executions corresponding to the first time should reach the corresponding value, so as not to cause calculation due to too few samples The result is inaccurate, reducing the calculation error.
  • the preset threshold time can be set correspondingly according to different scenarios, which is not limited in this embodiment.
  • step S210 is only used to characterize the basic principle of calculating the CPU usage of the thread without any limitation.
  • the result of dividing the first time by the second time can be Add the set coefficient to multiply, for example, multiply the original 0.5 by 100 to get 50, then the CPU usage of the thread is 50, or directly use the original 0.5 as the CPU usage of the thread, only need to ensure its
  • the calculation principle is the same interface, which is not limited in this embodiment.
  • Step S300 Perform load control on multiple cores according to the CPU usage rates of the multiple cores.
  • the actual cost of the thread's loop execution in the bound core can be displayed, and then according to the first time and the second time of the thread, Accurately know the CPU occupancy rate of the thread-bound cores.
  • the upper system based on the accurately determined CPU occupancy rates of multiple cores, it is convenient for the upper system to make full use of the parallelism of the multi-core architecture, realize multi-core load balancing control, and improve device performance.
  • this embodiment is not only applicable to native Linux and The data plane development kit (Data Plane Development Kit, DPDK) provided by Intel, etc., can also be applied to other similar exclusive core application scenarios, such as application scenarios that can be used for storage processing, or can also be used for computing software.
  • the overhead of each module in the total CPU is not limited in this embodiment.
  • FIG. 7 is a schematic diagram of a CPU processor provided by an embodiment of the present application.
  • the CPU processor includes 4 cores, wherein CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slave threads, and the main thread is bound to CORE0, Share the core CORE0 with the operating system, perform non-infinite loop execution, and be able to complete some control-related work.
  • the CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies, so I won’t go into details here; three slave threads perform APP For the business processing of the program, these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop. In this case, the CPU usage result obtained by using the standard calculation method in related technologies for these three COREs is 100%. , in order to calculate the actual overhead of the three COREs, it is necessary to use the calculation method of the embodiment of the present application to calculate the CPU usage.
  • steps S310 to S320 are also included after step S200 .
  • Step S310 Determine the load weight of each core according to the CPU usage of multiple cores
  • Step S320 For each core, assign instance tasks corresponding to the load weight to the core.
  • the proportion of the CPU occupancy rate of each core can be determined, and the proportion is the load weight of each core, which represents the load capacity that each core can bear.
  • the instance tasks corresponding to the load weight are assigned to the core to realize the adjustment of the load balancing strategy, so as to achieve better load sharing, so that the overall device performance is better improved, and the actual load of a single core is avoided. A situation where its load capacity degrades overall equipment performance.
  • FIG. 9 is a schematic diagram of an execution flow of a kernel load control method provided by an embodiment of the present application.
  • the corresponding system architecture can be vEPC, including a CPU, the CPU includes 4 cores, where CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slaves Thread, the main thread is bound to CORE0, shares core CORE0 with the operating system, performs non-infinite loop execution, and can complete some control-related work.
  • the CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies; three The slave threads perform the business processing of the APP program, and these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop.
  • the main thread can read the result, store the result in the local memory, and report the result to the control plane through the corresponding transmission channel, and the load balancer in the control plane
  • the load weight of each instance is formed according to the CPU overhead of the core bound to each instance, and then the user traffic is allocated to different instances according to the load weight, so as to complete the load control and sharing of the instances, so that CORE1 to CORE3 can coordinate and balance the work, so that Equipment performance is optimal.
  • the CPU overhead of uploading the kernel through the transmission channel can be periodic.
  • the allocation of user traffic to different instances according to the load weight can also be periodic, so as to achieve more stable and reliable load balancing control Effect.
  • step S300 includes but is not limited to step S400.
  • Step S400 When the CPU usage of the core exceeds the preset overhead threshold, an alarm prompt message is issued.
  • a preset overhead threshold can be preset according to the kernel component performance, application environment and other parameters, representing the upper limit of the overhead that the kernel can bear.
  • the calculated CPU usage of the kernel exceeds the preset overhead threshold, It means that the actual overhead of the kernel at this time has exceeded the upper limit of the overhead that it can bear, and there is a dangerous situation for the kernel. Therefore, by setting an alarm prompt message in this scenario, it can remind external personnel of the actual usage of the kernel. In order to adjust and control the kernel.
  • FIG. 11 is a schematic diagram of an execution flow of a kernel load control method provided by another embodiment of the present application.
  • the corresponding system architecture can be vEPC, including a CPU, which includes 4 cores, where CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slave cores. Thread, the main thread is bound to CORE0, shares core CORE0 with the operating system, performs non-infinite loop execution, and can complete some control-related work.
  • the CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies; three The slave threads perform the business processing of the APP program, and these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop.
  • the setup and calculation process includes the following steps:
  • Step 1 set CORE1 to CORE3 as exclusive cores, which can be done but not limited to by modifying the grub file. Since this method is the basic content of linux, it will not be described in detail;
  • Step 2 bind threads 1 to 3 to CORE1 to CORE3 respectively, which can be completed by using related commands, such as taskset-cp cpu-list pid, or by calling the interface of the operating system in the program, which is not mentioned here to repeat;
  • Step 3 determining the evaluation standard, wherein, in this embodiment, the evaluation is performed based on the message forwarding process of the user plane of the vEPC. Then, if there is time for processing packets in the program, it is considered as valuable time for vEPC. If there is no packet processing in the program, even if it calls the driver to receive or send packets (actually no packets are received or sent) , which is also considered to be idle time;
  • Step 4 implement the method of this embodiment, calculate required value, take from thread 1 as example, only need to calculate these two times of second time Usedtick and first time Alltick, then can calculate the CPU of core Occupancy rate Cpurate, the formula is as follows:
  • Alltick add up the total duration of the thread's single execution loop to get Alltick, namely:
  • Step 5 set a timing duration (such as 1s), and judge at the last moment of one of the while loops, if the timing duration is exceeded, the calculation of Usedtick can be performed, and then the CPUrate of thread 1 can be calculated, and the CPU rate of thread 1 can be calculated. It is exclusive to CORE1, so the Cpurate is the CPU usage of CORE1;
  • Step 6 Store the calculated CORE overhead in the local memory, and judge with the preset overhead threshold to decide whether to send an alarm to the background, or report the CPU usage of CORE1 to 3 to the background through the transmission channel to show.
  • an embodiment of the present application also provides a load control device 100, the load control device 100 includes: a memory 110, a processor 120, and an Computer program.
  • the processor 120 and the memory 110 may be connected through a bus or in other ways.
  • the non-transitory software programs and instructions required to realize the load control method of the core of the above-mentioned embodiments are stored in the memory 110, and when executed by the processor 120, the load control methods of the core of the above-mentioned embodiments are executed, for example, the above Described method steps S100 to S300 in Fig. 1, method steps S110 to S130 in Fig. 2, method steps S131 to S134 in Fig. 3, method steps S140 to S150 in Fig. 4, method steps S141 to S150 in Fig. 5 S142, method steps S210 to S220 in FIG. 6 , method steps S310 to S320 in FIG. 8 or method step S400 in FIG. 10 .
  • the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • an embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor 120 or a controller, for example, by Execution by a processor 120 in the above-mentioned device embodiment can make the above-mentioned processor 120 execute the load control method of the kernel in the above-mentioned embodiment, for example, execute the method steps S100 to S300 in FIG. 1 described above, and the method in FIG. 2 Method steps S110 to S130, method steps S131 to S134 among Fig. 3, method steps S140 to S150 among Fig. 4, method steps S141 to S142 among Fig. 5, method steps S210 to S220 among Fig. 6, Fig. 8 Method steps S310 to S320 or method step S400 in FIG. 10 .
  • the embodiment of the present application includes: the first time to obtain the thread, and the second time to obtain the thread, the first time is the CPU time consumed by the thread in the corresponding kernel, and the loop execution is executed, and the second time is the thread in the corresponding kernel.
  • execution process the CPU time consumed by effective business; determine the CPU usage of the core corresponding to the thread according to the first time and the second time of the thread; control the load of multiple cores according to the CPU usage of multiple cores .
  • the actual overhead of the thread's loop execution in the bound kernel can be displayed, and then according to the first time and the second time of the thread Second, accurately know the CPU occupancy rate of the thread-bound core.
  • the upper system based on the accurately determined CPU occupancy rate of multiple cores, it is convenient for the upper system to make full use of the parallelism of the multi-core architecture to achieve multi-core load balancing. Control and improve equipment performance.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, tape, magnetic disk storage or other magnetic storage devices, or can Any other medium used to store desired information and which can be accessed by a computer.
  • communication media typically embody computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Multi Processors (AREA)

Abstract

A load control method and apparatus for a kernel, and a computer-readable storage medium. The method comprises: acquiring a first time of a thread, and acquiring a second time of the thread, wherein the first time is a CPU time consumed by circularly executing the thread in a corresponding kernel, and the second time is a CPU time consumed by processing an effective service when the thread is circularly executed in the corresponding kernel (100); according to the first time and the second time of the thread, determining a CPU occupancy rate of the kernel corresponding to the thread (200); and performing load control on a plurality of kernels according to the CPU occupancy rates of the plurality of kernels (300).

Description

内核的负荷控制方法及装置、计算机可读存储介质Kernel load control method and device, computer-readable storage medium
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202111528005.8、申请日为2021年12月14日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202111528005.8 and a filing date of December 14, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本申请实施例涉及计算机技术领域,尤其涉及一种内核的负荷控制方法及装置、计算机可读存储介质。The embodiments of the present application relate to the field of computer technology, and in particular, to a method and device for controlling kernel load, and a computer-readable storage medium.
背景技术Background technique
在计算机领域,随着多内核CPU的出现,针对高吞吐量并行软件进行处理,通用做法是将业务负荷分担到多个线程上以并行处理,每个并行执行的线程分别绑定到单独的一个内核上,从而让多个内核并行工作,以提升设备整体的处理能力。基于上述设置方式,在特定的内核上运行的则只有这种业务的用户态程序,按照Linux中的相关计算方法而确定的该内核的CPU占用率则一直呈现为100%,但在实际场景中,业务程序的实际负载通常并不保持为恒定的100%,甚至有可能为0,因此获取到的内核开销不准确,使得上层系统无法精确地实现负载分配,影响设备性能。In the computer field, with the emergence of multi-core CPUs, for high-throughput parallel software processing, the general practice is to share the business load on multiple threads for parallel processing, and each parallel execution thread is bound to a separate Core, so that multiple cores work in parallel to improve the overall processing capability of the device. Based on the above setting method, only the user mode program of this business runs on a specific kernel, and the CPU usage rate of the kernel determined according to the relevant calculation method in Linux is always displayed as 100%, but in the actual scene , the actual load of the business program is usually not kept at a constant 100%, and may even be 0, so the obtained kernel overhead is inaccurate, making the upper system unable to accurately implement load distribution, affecting device performance.
发明内容Contents of the invention
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics described in detail in this article. This summary is not intended to limit the scope of the claims.
本申请实施例提供了一种内核的负荷控制方法及装置、计算机可读存储介质。Embodiments of the present application provide a kernel load control method and device, and a computer-readable storage medium.
第一方面,本申请实施例提供了一种内核的负荷控制方法,所述内核为多个,所述内核单独绑定线程,所述方法包括:获取所述线程的第一时间,以及获取所述线程的第二时间,所述第一时间为所述线程在对应的所述内核中,循环执行消耗的CPU时间,所述第二时间为所述线程在对应的所述内核中循环执行的情况下,处理有效业务消耗的CPU时间;根据所述线程的所述第一时间和所述第二时间,确定与所述线程对应的所述内核的CPU占用率;根据多个所述内核的CPU占用率对多个所述内核进行负荷控制。In the first aspect, the embodiment of the present application provides a method for controlling the load of a kernel. There are multiple kernels, and the kernels are individually bound to threads. The method includes: obtaining the first time of the thread, and obtaining the first time of the thread. The second time of the thread, the first time is the CPU time consumed by the thread in the corresponding kernel, and the second time is the CPU time consumed by the thread in the corresponding kernel In this case, process the CPU time consumed by effective services; determine the CPU occupancy rate of the core corresponding to the thread according to the first time and the second time of the thread; The CPU usage performs load control on multiple cores.
第二方面,本申请实施例还提供了一种负荷控制装置,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上第一方面所述的内核的负荷控制方法。In the second aspect, the embodiment of the present application also provides a load control device, including: a memory, a processor, and a computer program stored in the memory and operable on the processor, and the processor implements the computer program when executing the computer program. The method for controlling the load of the kernel as described in the first aspect above.
第三方面,本申请实施例还提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行如上第一方面所述的内核的负荷控制方法。In a third aspect, the embodiment of the present application further provides a computer-readable storage medium, storing computer-executable instructions, and the computer-executable instructions are used to execute the method for controlling the load of a kernel as described in the first aspect above.
本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Additional features and advantages of the application will be set forth in the description which follows, and, in part, will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
附图说明Description of drawings
附图用来提供对本申请技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本申请的技术方案,并不构成对本申请技术方案的限制。The accompanying drawings are used to provide a further understanding of the technical solution of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the technical solution of the present application, and do not constitute a limitation to the technical solution of the present application.
图1是本申请一个实施例提供的内核的负荷控制方法的流程图;Fig. 1 is a flow chart of the load control method of the kernel provided by one embodiment of the present application;
图2是本申请一个实施例提供的内核的负荷控制方法中,获取线程的第二时间的流程图;Fig. 2 is a flow chart of obtaining the second time of the thread in the load control method of the kernel provided by one embodiment of the present application;
图3是本申请一个实施例提供的内核的负荷控制方法中,根据有效业务获取线程的第二时间的流程图;FIG. 3 is a flow chart of obtaining a second time of a thread according to an effective service in a load control method of the kernel provided by an embodiment of the present application;
图4是本申请一个实施例提供的内核的负荷控制方法中,获取线程的第一时间的转发速率的流程图;Fig. 4 is a flow chart of obtaining the forwarding rate of the thread at the first time in the load control method of the kernel provided by an embodiment of the present application;
图5是本申请一个实施例提供的内核的负荷控制方法中,获取线程的第四时间的流程图;FIG. 5 is a flow chart of obtaining a fourth time of a thread in a kernel load control method provided by an embodiment of the present application;
图6是本申请一个实施例提供的内核的负荷控制方法中,确定内核的CPU占用率的流程图;FIG. 6 is a flow chart of determining the CPU usage of the kernel in a method for controlling the load of the kernel provided by an embodiment of the present application;
图7是本申请一个实施例提供的CPU处理器的示意图;FIG. 7 is a schematic diagram of a CPU processor provided by an embodiment of the present application;
图8是本申请一个实施例提供的内核的负荷控制方法中,对多个内核进行负荷控制的流程图;FIG. 8 is a flow chart of performing load control on multiple cores in a core load control method provided by an embodiment of the present application;
图9是本申请一个实施例提供的内核的负荷控制方法的执行流程示意图;FIG. 9 is a schematic diagram of an execution flow of a kernel load control method provided by an embodiment of the present application;
图10是本申请一个实施例提供的内核的负荷控制方法中,确定内核的CPU占用率之后的流程图;FIG. 10 is a flow chart after determining the CPU usage of the kernel in the load control method of the kernel provided by an embodiment of the present application;
图11是本申请另一个实施例提供的内核的负荷控制方法的执行流程示意图;FIG. 11 is a schematic diagram of the execution flow of a kernel load control method provided by another embodiment of the present application;
图12是本申请一个实施例提供的负荷控制装置的示意图。Fig. 12 is a schematic diagram of a load control device provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments described here are only used to explain the present application, not to limit the present application.
需要注意的是,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although the functional modules are divided in the schematic diagram of the device, and the logical sequence is shown in the flowchart, in some cases, it can be executed in a different order than the module division in the device or the flowchart in the flowchart. steps shown or described. The terms "first", "second" and the like in the specification and claims and the above drawings are used to distinguish similar objects, and not necessarily used to describe a specific sequence or sequence.
本申请提供了一种内核的负荷控制方法及装置、计算机可读存储介质,对于每个线程,通过获取线程的第一时间和第二时间,可以展示线程在绑定的内核中循环执行的实际开销,进而根据线程的第一时间和第二时间,精确获知线程绑定的内核的CPU占用率,相比于相关技术,基于精准确定的多个内核的CPU占用率,便于上层系统充分利用多内核架构的并行性,实现多内核负荷均衡控制,提升设备性能。The application provides a kernel load control method and device, and a computer-readable storage medium. For each thread, by obtaining the first time and the second time of the thread, it is possible to show the actual cyclic execution of the thread in the bound kernel. According to the first time and the second time of the thread, the CPU occupancy rate of the core bound by the thread is accurately known. Compared with related technologies, based on the accurately determined CPU occupancy rate of multiple cores, it is convenient for the upper system to make full use of multiple cores. The parallelism of the kernel architecture realizes multi-core load balancing control and improves device performance.
下面结合附图,对本申请实施例作进一步阐述。The embodiments of the present application will be further described below in conjunction with the accompanying drawings.
如图1所示,图1是本申请一个实施例提供的内核的负荷控制方法的流程图,其中,内核为多个,内核单独绑定线程,该内核的负荷控制方法包括但不限于步骤S100至S300。As shown in Figure 1, Figure 1 is a flowchart of a method for controlling the load of a kernel provided by an embodiment of the present application, wherein there are multiple kernels, and the kernels are individually bound to threads, and the method for controlling the load of the kernel includes but is not limited to step S100 to S300.
步骤S100:获取线程的第一时间,以及获取线程的第二时间,第一时间为线程在对应的内核中,循环执行消耗的CPU时间,第二时间为线程在对应的内核中循环执行的情况下,处 理有效业务消耗的CPU时间。Step S100: obtain the first time of the thread, and the second time of obtaining the thread, the first time is the CPU time consumed by the thread in the corresponding core, and the second time is the thread in the corresponding kernel. Next, the CPU time consumed by processing valid services.
在一实施例中,对于每个线程,通过获取线程的第一时间和第二时间,可以展示线程在绑定的内核中循环执行的实际开销,由于每个内核单独绑定一个线程,应用程序处于死循环运行的线程,因此线程在内核中所占用的相关CPU时间,相当于为内核所需占用的相关CPU时间,以便于在后续步骤中根据获取到的第一时间和第二时间以确定内核的CPU占用率。In an embodiment, for each thread, by obtaining the first time and the second time of the thread, the actual overhead of the thread's loop execution in the bound core can be displayed. Since each core is bound to a thread independently, the application A thread running in an endless loop, so the relevant CPU time occupied by the thread in the kernel is equivalent to the relevant CPU time required by the kernel, so that it can be determined according to the obtained first time and second time in subsequent steps The CPU usage of the kernel.
需要说明的是,针对不同内核中的线程,其分别处理的有效业务可以是不同的,且内核的数量根据设备来确定,这在本实施例中并未限制。It should be noted that, for threads in different cores, the effective services they respectively process may be different, and the number of cores is determined according to the device, which is not limited in this embodiment.
可以理解地是,由于线程在排他绑定的内核中进行死循环运行,因此线程的第一时间和第二时间实际是由各个循环所消耗时间相叠加而得到的,因此在确定各个循环中第一时间与第二时间的相应分量之后,即在确定线程在对应的内核中,执行一次循环消耗的CPU时间以及线程在对应的内核中执行一次循环的情况下,处理有效业务消耗的CPU时间之后,则可以进一步确定线程的第一时间和第二时间,以下将给出实施例进行说明。It can be understood that since the thread runs in an endless loop in the exclusively bound core, the first time and the second time of the thread are actually obtained by superimposing the time consumed by each cycle, so in determining the first time of each cycle After the corresponding components of the first time and the second time, that is, after determining that the thread is in the corresponding core, the CPU time consumed by executing a cycle and the thread is executed in the corresponding core in the case of a cycle, after the CPU time consumed by processing valid services , then the first time and the second time of the thread can be further determined, and an embodiment will be given below for illustration.
在图2的示例中,步骤S100中的“获取线程的第二时间”包括但不限于步骤S110至S120。In the example of FIG. 2 , the "obtaining the second time of the thread" in step S100 includes but not limited to steps S110 to S120.
步骤S110:获取线程在内核中执行一次循环的情况下,处理每个实例业务的反馈结果;Step S110: Obtain the feedback result of processing the business of each instance when the thread executes a cycle in the kernel;
步骤S120:根据所有反馈结果和预设业务评估条件,从各个实例业务中确定有效业务;Step S120: According to all feedback results and preset service evaluation conditions, determine valid services from each example service;
步骤S130:根据有效业务获取线程的第二时间。Step S130: Obtain the second time of the thread according to the effective service.
在一实施例中,由于每个实例业务在执行后均可以反馈相应的结果,因此可以基于反馈结果和预设业务评估条件之间的对应关系,从各个实例业务中确定有效业务,进一步地根据有效业务获取线程在对应的内核中循环执行的情况下处理有效业务消耗的CPU时间,因此能够精确可靠地获取线程的第二时间。In one embodiment, since each instance service can feed back the corresponding result after execution, it is possible to determine the effective service from each instance service based on the corresponding relationship between the feedback result and the preset service evaluation conditions, and further according to The CPU time consumed by the effective service is processed by the active service acquisition thread in the case of cyclic execution in the corresponding core, so the second time of the thread can be acquired accurately and reliably.
需要说明的是,预设业务评估条件可以根据不同应用场景进行相应设置,并不存在统一的标准,例如线程中如果存在处理报文的时间,则可以认为其是对整个设备有价值的时间,即有效时间,若线程中没有报文处理,即使其去调用了驱动收包或者发包(实际并没有收到包或者发出去包),则认为其是空闲时间,对应地,判断存在处理报文的时间或情况的条件即为预设业务评估条件。It should be noted that the preset service evaluation conditions can be set according to different application scenarios, and there is no uniform standard. For example, if there is time for processing packets in a thread, it can be considered as valuable time for the entire device. That is, the effective time, if there is no message processing in the thread, even if it calls the driver to receive or send a package (actually does not receive or send a package), it is considered to be idle time, and correspondingly, it is judged that there is a processing message The conditions of the time or situation are the preset business evaluation conditions.
在一实施例中,实例业务可以为线程下的任意业务,也可以为相关于线程的任意业务,只要其处于线程中执行,均可以视为线程处理的实例业务;此外,反馈结果的形式并未限定,可以以数值或符号等进行表示,但无论为何种形式,只要其与预设业务评估条件进行对应即可。In one embodiment, the instance business can be any business under the thread, or any business related to the thread, as long as it is executed in the thread, it can be regarded as the instance business processed by the thread; in addition, the form of the feedback result is not It is not limited, and may be represented by a numerical value or a symbol, but no matter what the form is, as long as it corresponds to the preset service evaluation condition.
在图3的示例中,步骤S130包括但不限于步骤S131至S134。In the example of FIG. 3 , step S130 includes but not limited to steps S131 to S134.
步骤S131:根据有效业务,从线程中确定用于执行有效业务的有效功能单元;Step S131: According to the effective service, determine the effective functional unit for executing the effective service from the thread;
步骤S132:获取有效功能单元执行有效业务的第一初始时刻和第一结束时刻;Step S132: Obtain the first initial time and the first end time when the effective functional unit executes the effective business;
步骤S133:将第一结束时刻减去第一初始时刻,得到第三时间;Step S133: subtracting the first initial time from the first end time to obtain the third time;
步骤S134:获取所有第三时间的相加值,得到线程的第二时间。Step S134: Obtain the added value of all the third times to obtain the second time of the thread.
在一实施例中,每个实例业务由相应的功能单元进行执行,通过确定有效业务,从而能够从线程中确定用于执行有效业务的有效功能单元,而有效功能单元的执行时间即为处理有效业务的时间,因此通过获取有效功能单元执行有效业务的第一初始时刻和第一结束时刻,从而能够确定线程执行一次循环的有效时间,最后通过叠加各个循环的有效时间即可得到线程的第二时间,可以看出,基于本实施例的方式获得第二时间,由于是基于所分别确定的各 个循环下的有效时间而累加得到的,因此精确度较高,能够良好地表征线程在对应的内核中循环执行的情况下处理有效业务消耗的CPU时间。In one embodiment, each instance service is executed by a corresponding functional unit. By determining the effective service, the effective functional unit used to execute the effective service can be determined from the thread, and the execution time of the effective functional unit is the effective processing time. Therefore, by obtaining the first initial moment and the first end moment when the effective functional unit executes the effective service, the effective time for the thread to execute a cycle can be determined, and finally the second time of the thread can be obtained by superimposing the effective time of each cycle. Time, it can be seen that the second time obtained based on the method of this embodiment is accumulated based on the effective time of each cycle determined separately, so the accuracy is high, and it can well represent the thread in the corresponding core. CPU time consumed by processing valid services in the case of mid-cycle execution.
可以理解地是,在线程执行每次循环的过程中,有效功能单元执行有效业务的第一初始时刻和第一结束时刻可以是相同的,也可以为不相同的,相应确定的第三时间也可以不同,这在本实施例中并未限制。It can be understood that, in the process of executing each loop of the thread, the first initial moment and the first end moment when the effective functional unit executes the effective service may be the same or different, and the correspondingly determined third time may also be can be different, which is not limited in this embodiment.
在图4的示例中,步骤S100中的“获取线程的第一时间”包括但不限于步骤S140至S150。In the example of FIG. 4 , the "acquiring the first time of the thread" in step S100 includes but not limited to steps S140 to S150.
步骤S140:获取线程的第四时间,第四时间为线程在内核中执行一次循环消耗的CPU时间;Step S140: Obtain the fourth time of the thread, the fourth time is the CPU time consumed by the thread executing a cycle in the kernel;
步骤S150:将所有第四时间相加,得到线程的第一时间。Step S150: add up all the fourth times to obtain the first time of the thread.
在一实施例中,通过获取线程在内核中执行每次循环消耗的CPU时间,确定线程的第四时间,进而将所有循环所消耗的CPU时间进行叠加,可以精确得到线程的第一时间。In one embodiment, the first time of the thread can be accurately obtained by obtaining the CPU time consumed by each cycle executed by the thread in the kernel, determining the fourth time of the thread, and then superimposing the CPU time consumed by all cycles.
可以理解地是,在线程执行每次循环的过程中,各自消耗的CPU时间可以是相同的,也可以为不相同的,相应确定的第四时间也可以不同,这在本实施例中并未限制。It can be understood that, in the process of executing each loop of the thread, the CPU time consumed by each thread may be the same or different, and the correspondingly determined fourth time may also be different, which is not shown in this embodiment. limit.
在图5的示例中,步骤S140包括但不限于步骤S141至S142。In the example of FIG. 5 , step S140 includes but not limited to steps S141 to S142.
步骤S141:获取线程在内核中执行一次循环的第二初始时刻和第二结束时刻;Step S141: Obtain the second initial moment and the second end moment when the thread executes a cycle in the kernel;
步骤S142:将第二结束时刻减去第二初始时刻,得到第四时间。Step S142: Subtract the second initial time from the second end time to obtain a fourth time.
在一实施例中,由于线程完成初始化后会一直循环执行,进而周而复始的调用各个执行函数体,因此基于各个执行函数体能够确定线程在内核中执行一次循环的第二初始时刻和第二结束时刻,进而通过获取第二结束时刻与第二初始时刻的差值,精确计算得到第四时间。In one embodiment, since the thread will execute in a loop after completing the initialization, and then call each execution function body repeatedly, so based on each execution function body, the second initial moment and the second end moment when the thread executes a cycle in the kernel can be determined , and then by obtaining the difference between the second end time and the second initial time, the fourth time is obtained through precise calculation.
步骤S200:根据线程的第一时间和第二时间,确定与线程对应的内核的CPU占用率。Step S200: Determine the CPU usage of the core corresponding to the thread according to the first time and the second time of the thread.
在一实施例中,由于线程在内核中单独循环执行,因此线程的执行参数即相当于内核的执行参数,因此可以根据线程的第一时间和第二时间,以进一步精确地确定与线程对应的内核的CPU占用率,相比于相关技术,不会出现计算得到的内核的CPU占用率总为100%的情况,计算结果更加精确可靠。In one embodiment, since the thread is executed in a separate cycle in the kernel, the execution parameter of the thread is equivalent to the execution parameter of the kernel. Therefore, the thread corresponding to the thread can be further accurately determined according to the first time and the second time of the thread. Compared with related technologies, the CPU usage rate of the kernel does not always appear as 100% of the calculated CPU usage rate of the kernel, and the calculation result is more accurate and reliable.
在图6的示例中,步骤S200包括但不限于步骤S210至S220。In the example of FIG. 6 , step S200 includes but not limited to steps S210 to S220.
步骤S210:当第一时间大于预设阈值时间,将第二时间与第一时间相除,得到线程的CPU占用率;Step S210: when the first time is greater than the preset threshold time, divide the second time by the first time to obtain the CPU usage rate of the thread;
步骤S220:确定内核的CPU占用率为线程的CPU占用率。Step S220: Determine the CPU usage rate of the kernel as the CPU usage rate of the thread.
在一实施例中,由于内核单独绑定线程,因此当线程在对应的内核中循环执行消耗的CPU时间超过预设阈值时间,则通过将第二时间与第一时间相除,得到线程的CPU占用率,其中,设置预设阈值时间的目的在于确保所计算的第一时间能够符合时长要求,即第一时间所对应的线程循环执行次数应该达到相应值,以免因样本数量太少而导致计算结果不精确,减小计算误差。In one embodiment, since the core is bound to the thread separately, when the CPU time consumed by the cyclic execution of the thread in the corresponding core exceeds the preset threshold time, the CPU time of the thread is obtained by dividing the second time by the first time. Occupancy rate, where the purpose of setting the preset threshold time is to ensure that the calculated first time can meet the duration requirement, that is, the number of thread loop executions corresponding to the first time should reach the corresponding value, so as not to cause calculation due to too few samples The result is inaccurate, reducing the calculation error.
可以理解地是,预设阈值时间可以根据场景的不同而相应设置,这在本实施例中并未限制。It can be understood that the preset threshold time can be set correspondingly according to different scenarios, which is not limited in this embodiment.
需要说明的是,步骤S210中的计算方式仅用于表征计算得到线程的CPU占用率的基本原理,并无任何限制,在应用场景中,可以在第一时间与第二时间相除的结果上添加所设定的系数进行相乘,例如将原有的0.5乘以100,得到50,则线程的CPU占用率为50,或者直接将原有的0.5作为线程的CPU占用率,只需要保证其计算原理是相同的接口,这在本实施例 中并未限制。It should be noted that the calculation method in step S210 is only used to characterize the basic principle of calculating the CPU usage of the thread without any limitation. In the application scenario, the result of dividing the first time by the second time can be Add the set coefficient to multiply, for example, multiply the original 0.5 by 100 to get 50, then the CPU usage of the thread is 50, or directly use the original 0.5 as the CPU usage of the thread, only need to ensure its The calculation principle is the same interface, which is not limited in this embodiment.
步骤S300:根据多个内核的CPU占用率对多个内核进行负荷控制。Step S300: Perform load control on multiple cores according to the CPU usage rates of the multiple cores.
在一实施例中,对于每个线程,通过获取线程的第一时间和第二时间,可以展示线程在绑定的内核中循环执行的实际开销,进而根据线程的第一时间和第二时间,精确获知线程绑定的内核的CPU占用率,相比于相关技术,基于精准确定的多个内核的CPU占用率,便于上层系统充分利用多内核架构的并行性,实现多内核负荷均衡控制,提升设备性能。In an embodiment, for each thread, by obtaining the first time and the second time of the thread, the actual cost of the thread's loop execution in the bound core can be displayed, and then according to the first time and the second time of the thread, Accurately know the CPU occupancy rate of the thread-bound cores. Compared with related technologies, based on the accurately determined CPU occupancy rates of multiple cores, it is convenient for the upper system to make full use of the parallelism of the multi-core architecture, realize multi-core load balancing control, and improve device performance.
需要说明的是,通过绑定线程到固定的内核,可以减少任务切换和进程刷新,从而减少相关开销,能够达到提升应用性能的目的,在应用场景下,本实施例不仅可以适用于原生Linux以及Intel提供的数据平面开发工具集(Data Plane Development Kit,DPDK)等,还能够适用于其他类似的排他绑核的应用场景,例如可以为存储处理的应用场景,或者,也可以用于计算软件的各个模块在总CPU中的开销等,这在本实施例中并未限制。It should be noted that by binding threads to a fixed kernel, task switching and process refreshing can be reduced, thereby reducing related overhead and achieving the purpose of improving application performance. In application scenarios, this embodiment is not only applicable to native Linux and The data plane development kit (Data Plane Development Kit, DPDK) provided by Intel, etc., can also be applied to other similar exclusive core application scenarios, such as application scenarios that can be used for storage processing, or can also be used for computing software. The overhead of each module in the total CPU is not limited in this embodiment.
以下给出示例以说明上述各实施例的工作原理及流程。Examples are given below to illustrate the working principles and processes of the above-mentioned embodiments.
示例一:Example one:
如图7所示,图7是本申请一个实施例提供的CPU处理器的示意图。As shown in FIG. 7 , FIG. 7 is a schematic diagram of a CPU processor provided by an embodiment of the present application.
在图7的示例中,该CPU处理器包括4个内核,其中,CORE0为共享核,CORE1至CORE3为排他核;APP程序起一个主线程和三个从线程,主线程绑定到CORE0上,与操作系统共享核CORE0,进行非死循环执行,并能够完成一些控制相关的工作,CORE0的CPU占用率计算可以参考相关技术中的标准计算方式,在此不做赘述;三个从线程进行APP程序的业务处理,这三个从线程分别绑定到CORE1至CORE3上面,进行死循环运行,此种情况下,这三个CORE使用相关技术中的标准计算方式得到的CPU占用率结果就是100%,为了计算这三个CORE的实际开销,因此需要采用本申请实施例的计算方法来对其进行CPU占用率计算。In the example of FIG. 7, the CPU processor includes 4 cores, wherein CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slave threads, and the main thread is bound to CORE0, Share the core CORE0 with the operating system, perform non-infinite loop execution, and be able to complete some control-related work. The CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies, so I won’t go into details here; three slave threads perform APP For the business processing of the program, these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop. In this case, the CPU usage result obtained by using the standard calculation method in related technologies for these three COREs is 100%. , in order to calculate the actual overhead of the three COREs, it is necessary to use the calculation method of the embodiment of the present application to calculate the CPU usage.
在图8的示例中,步骤S200之后还包括但不限于步骤S310至S320。In the example of FIG. 8 , steps S310 to S320 are also included after step S200 .
步骤S310:根据多个内核的CPU占用率确定各个内核的负荷权重;Step S310: Determine the load weight of each core according to the CPU usage of multiple cores;
步骤S320:对于每个内核,向内核分配与负荷权重对应的实例任务。Step S320: For each core, assign instance tasks corresponding to the load weight to the core.
在一实施例中,在确定多个内核的CPU占用率之后,进而能够确定每个内核的CPU占用率所占比例,该比例即为各个内核的负荷权重,表征各个内核能够承担的负载容量,在这种情况下,向内核分配与负荷权重对应的实例任务,实现负荷均衡策略的调整,从而达到更加良好的负荷分担,使得整体设备性能有较好提升,避免出现由于单个内核的实际负载超出其负载容量而拉低整体设备性能的情况。In one embodiment, after determining the CPU occupancy rate of multiple cores, the proportion of the CPU occupancy rate of each core can be determined, and the proportion is the load weight of each core, which represents the load capacity that each core can bear. In this case, the instance tasks corresponding to the load weight are assigned to the core to realize the adjustment of the load balancing strategy, so as to achieve better load sharing, so that the overall device performance is better improved, and the actual load of a single core is avoided. A situation where its load capacity degrades overall equipment performance.
以下给出示例以说明上述各实施例的工作原理及流程。Examples are given below to illustrate the working principles and processes of the above-mentioned embodiments.
示例二:Example two:
如图9所示,图9是本申请一个实施例提供的内核的负荷控制方法的执行流程示意图。As shown in FIG. 9 , FIG. 9 is a schematic diagram of an execution flow of a kernel load control method provided by an embodiment of the present application.
在图9的示例中,对应的系统架构可以为vEPC,包括一个CPU,该CPU包括4个内核,其中,CORE0为共享核,CORE1至CORE3为排他核;APP程序起一个主线程和三个从线程,主线程绑定到CORE0上,与操作系统共享核CORE0,进行非死循环执行,并能够完成一些控制相关的工作,CORE0的CPU占用率计算可以参考相关技术中的标准计算方式;三个从线程进行APP程序的业务处理,这三个从线程分别绑定到CORE1至CORE3上面,进行死循环运行。In the example in Figure 9, the corresponding system architecture can be vEPC, including a CPU, the CPU includes 4 cores, where CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slaves Thread, the main thread is bound to CORE0, shares core CORE0 with the operating system, performs non-infinite loop execution, and can complete some control-related work. The CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies; three The slave threads perform the business processing of the APP program, and these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop.
待CORE1至CORE3的CPU占用率计算出来后,主线程可以读取其结果,并将该结果存放在本地的存储器中,并通过相应的传输通道将结果上报控制面,控制面中的负载均衡器根据 各个实例绑定的内核的CPU开销形成各个实例的负荷权重,进而根据负荷权重将用户流量分配到不同的实例,从而完成实例的负荷控制和分担,使得CORE1至CORE3可以协同均衡工作,从而使设备性能达到最优。After the CPU usage of CORE1 to CORE3 is calculated, the main thread can read the result, store the result in the local memory, and report the result to the control plane through the corresponding transmission channel, and the load balancer in the control plane The load weight of each instance is formed according to the CPU overhead of the core bound to each instance, and then the user traffic is allocated to different instances according to the load weight, so as to complete the load control and sharing of the instances, so that CORE1 to CORE3 can coordinate and balance the work, so that Equipment performance is optimal.
需要说明的是,通过传输通道上传内核的CPU开销可以是周期性的,相应地,根据负荷权重将用户流量分配到不同的实例也可以是周期性的,以便于取得更加稳定可靠的负荷均衡控制效果。It should be noted that the CPU overhead of uploading the kernel through the transmission channel can be periodic. Correspondingly, the allocation of user traffic to different instances according to the load weight can also be periodic, so as to achieve more stable and reliable load balancing control Effect.
在图10的示例中,步骤S300包括但不限于步骤S400。In the example of FIG. 10, step S300 includes but is not limited to step S400.
步骤S400:当内核的CPU占用率超过预设开销阈值,发出告警提示信息。Step S400: When the CPU usage of the core exceeds the preset overhead threshold, an alarm prompt message is issued.
在一实施例中,可以根据内核的部件性能、应用环境等参数来预先设置一个预设开销阈值,表征内核能够承受的开销占用上限,当计算得到的内核的CPU占用率超过预设开销阈值,则说明内核此时的实际开销已经超过其能够承受的开销占用上限,对于内核而言存在危险情况,因此通过在这种场景下设置发出告警提示信息,能够提示外部人员该内核的实际使用情况,以便于对该内核进行调整控制。In one embodiment, a preset overhead threshold can be preset according to the kernel component performance, application environment and other parameters, representing the upper limit of the overhead that the kernel can bear. When the calculated CPU usage of the kernel exceeds the preset overhead threshold, It means that the actual overhead of the kernel at this time has exceeded the upper limit of the overhead that it can bear, and there is a dangerous situation for the kernel. Therefore, by setting an alarm prompt message in this scenario, it can remind external personnel of the actual usage of the kernel. In order to adjust and control the kernel.
以下给出示例以说明上述各实施例的工作原理及流程。Examples are given below to illustrate the working principles and processes of the above-mentioned embodiments.
示例三:Example three:
如图11所示,图11是本申请另一个实施例提供的内核的负荷控制方法的执行流程示意图。As shown in FIG. 11 , FIG. 11 is a schematic diagram of an execution flow of a kernel load control method provided by another embodiment of the present application.
在图11的示例中,对应的系统架构可以为vEPC,包括一个CPU,该CPU包括4个内核,其中,CORE0为共享核,CORE1至CORE3为排他核;APP程序起一个主线程和三个从线程,主线程绑定到CORE0上,与操作系统共享核CORE0,进行非死循环执行,并能够完成一些控制相关的工作,CORE0的CPU占用率计算可以参考相关技术中的标准计算方式;三个从线程进行APP程序的业务处理,这三个从线程分别绑定到CORE1至CORE3上面,进行死循环运行。In the example shown in Figure 11, the corresponding system architecture can be vEPC, including a CPU, which includes 4 cores, where CORE0 is a shared core, and CORE1 to CORE3 are exclusive cores; the APP program starts a main thread and three slave cores. Thread, the main thread is bound to CORE0, shares core CORE0 with the operating system, performs non-infinite loop execution, and can complete some control-related work. The CPU usage calculation of CORE0 can refer to the standard calculation method in related technologies; three The slave threads perform the business processing of the APP program, and these three slave threads are respectively bound to CORE1 to CORE3 to run in an endless loop.
设置及计算流程包括以下步骤:The setup and calculation process includes the following steps:
步骤1,将CORE1至CORE3设置为排他核,可以但不限于通过修改grub文件完成,由于该方式为linux的基础内容,因此对其不做赘述;Step 1, set CORE1 to CORE3 as exclusive cores, which can be done but not limited to by modifying the grub file. Since this method is the basic content of linux, it will not be described in detail;
步骤2,将从线程1至3分别绑定到CORE1至CORE3,可以但不限于使用相关命令完成,例如taskset-cp cpu-list pid,或者,在程序中调用操作系统的接口完成,在此不做赘述;Step 2, bind threads 1 to 3 to CORE1 to CORE3 respectively, which can be completed by using related commands, such as taskset-cp cpu-list pid, or by calling the interface of the operating system in the program, which is not mentioned here to repeat;
步骤3,确定评价标准,其中,本实施例是以vEPC的用户面的报文转发过程进行评价的。那么程式中如果存在处理报文的时间,则认为是对vEPC有价值的时间,若程式中没有报文处理,即使其调用了驱动收包或者发包(实际并没有收到包或者发出去包),也认为其属于空闲时间;Step 3, determining the evaluation standard, wherein, in this embodiment, the evaluation is performed based on the message forwarding process of the user plane of the vEPC. Then, if there is time for processing packets in the program, it is considered as valuable time for vEPC. If there is no packet processing in the program, even if it calls the driver to receive or send packets (actually no packets are received or sent) , which is also considered to be idle time;
步骤4,实施本实施例的方法,计算出所需值,以从线程1为例,到此只需计算出第二时间Usedtick和第一时间Alltick的这两个时间,则可以计算内核的CPU占用率Cpurate,公式如下:Step 4, implement the method of this embodiment, calculate required value, take from thread 1 as example, only need to calculate these two times of second time Usedtick and first time Alltick, then can calculate the CPU of core Occupancy rate Cpurate, the formula is as follows:
Cpurate=Usedtick*100/Alltick;Cpurate = Usedtick*100/Alltick;
其中,针对Alltick的计算考虑:Among them, the calculation considerations for Alltick:
线程完成初始化后会一直在一个while循环中执行,在这个循环中会周而复始的调用各个执行函数体,因此在一个循环一开始的时候取一个系统时间tick1,循环末端取一个系统 时间tick2,则这两个时间差为本次循环的总时间,公式如下:After the thread is initialized, it will always execute in a while loop. In this loop, each execution function body will be called repeatedly. Therefore, a system time tick1 is taken at the beginning of a loop, and a system time tick2 is taken at the end of the loop. Then this The difference between the two times is the total time of this cycle, and the formula is as follows:
DivTick=tick2-tick1;DivTick=tick2-tick1;
再将线程单次执行循环的总时长进行累加得到Alltick,即:Then add up the total duration of the thread's single execution loop to get Alltick, namely:
Alltick+=DivTick;Alltick+=DivTick;
针对Usedtick的计算考虑:Considerations for the calculation of Usedtick:
线程的所有执行功能单元都有一个返回值,标示执行了有效的报文处理或者其他的定时处理,还是空操作,因此可以在功能单元执行初始阶段取一个系统时间tick3,在执行末段取一个系统时间tick4,并判断返回值ret1是否表示了是有效动作,如果是有效的则将差值累加到Usedtick,公式如下:All execution functional units of a thread have a return value, which indicates that effective message processing or other timing processing has been executed, and it is still a no-op. Therefore, a system time tick3 can be taken at the initial stage of functional unit execution, and a tick3 at the end of execution. System time tick4, and judge whether the return value ret1 indicates a valid action, if it is valid, add the difference to Usedtick, the formula is as follows:
Usedtick+=tick4-tick3;Usedtick+=tick4-tick3;
步骤5,设定一个定时时长(例如1s),在其中一个while循环的最后时刻进行判断,若超过了定时时长,则进行Usedtick的计算,进而能够计算出从线程1的Cpurate,而从线程1是独享于CORE1的,因此该Cpurate即为CORE1的CPU占用率;Step 5, set a timing duration (such as 1s), and judge at the last moment of one of the while loops, if the timing duration is exceeded, the calculation of Usedtick can be performed, and then the CPUrate of thread 1 can be calculated, and the CPU rate of thread 1 can be calculated. It is exclusive to CORE1, so the Cpurate is the CPU usage of CORE1;
步骤6,将计算得到的CORE开销存储在本地的存储器中,并跟预设开销阈值进行判断,以决定是否该向后台进行告警,也可以通过传输通道将CORE1至3的CPU占用率上报到后台进行展示。Step 6: Store the calculated CORE overhead in the local memory, and judge with the preset overhead threshold to decide whether to send an alarm to the background, or report the CPU usage of CORE1 to 3 to the background through the transmission channel to show.
另外,参照图12,本申请的一个实施例还提供了一种负荷控制装置100,该负荷控制装置100包括:存储器110、处理器120及存储在存储器110上并可在处理器120上运行的计算机程序。In addition, referring to FIG. 12 , an embodiment of the present application also provides a load control device 100, the load control device 100 includes: a memory 110, a processor 120, and an Computer program.
处理器120和存储器110可以通过总线或者其他方式连接。The processor 120 and the memory 110 may be connected through a bus or in other ways.
实现上述实施例的内核的负荷控制方法所需的非暂态软件程序以及指令存储在存储器110中,当被处理器120执行时,执行上述各实施例的内核的负荷控制方法,例如,执行以上描述的图1中的方法步骤S100至S300、图2中的方法步骤S110至S130、图3中的方法步骤S131至S134、图4中的方法步骤S140至S150、图5中的方法步骤S141至S142、图6中的方法步骤S210至S220、图8中的方法步骤S310至S320或图10中的方法步骤S400。The non-transitory software programs and instructions required to realize the load control method of the core of the above-mentioned embodiments are stored in the memory 110, and when executed by the processor 120, the load control methods of the core of the above-mentioned embodiments are executed, for example, the above Described method steps S100 to S300 in Fig. 1, method steps S110 to S130 in Fig. 2, method steps S131 to S134 in Fig. 3, method steps S140 to S150 in Fig. 4, method steps S141 to S150 in Fig. 5 S142, method steps S210 to S220 in FIG. 6 , method steps S310 to S320 in FIG. 8 or method step S400 in FIG. 10 .
以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
此外,本申请的一个实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个处理器120或控制器执行,例如,被上述设备实施例中的一个处理器120执行,可使得上述处理器120执行上述实施例中的内核的负荷控制方法,例如,执行以上描述的图1中的方法步骤S100至S300、图2中的方法步骤S110至S130、图3中的方法步骤S131至S134、图4中的方法步骤S140至S150、图5中的方法步骤S141至S142、图6中的方法步骤S210至S220、图8中的方法步骤S310至S320或图10中的方法步骤S400。In addition, an embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor 120 or a controller, for example, by Execution by a processor 120 in the above-mentioned device embodiment can make the above-mentioned processor 120 execute the load control method of the kernel in the above-mentioned embodiment, for example, execute the method steps S100 to S300 in FIG. 1 described above, and the method in FIG. 2 Method steps S110 to S130, method steps S131 to S134 among Fig. 3, method steps S140 to S150 among Fig. 4, method steps S141 to S142 among Fig. 5, method steps S210 to S220 among Fig. 6, Fig. 8 Method steps S310 to S320 or method step S400 in FIG. 10 .
本申请实施例包括:获取线程的第一时间,以及获取线程的第二时间,第一时间为线程在对应的内核中,循环执行消耗的CPU时间,第二时间为线程在对应的内核中循环执行的情况下,处理有效业务消耗的CPU时间;根据线程的第一时间和第二时间,确定与线程对应的内核的CPU占用率;根据多个内核的CPU占用率对多个内核进行负荷控制。根据本申请实施 例提供的方案,对于每个线程,通过获取线程的第一时间和第二时间,可以展示线程在绑定的内核中循环执行的实际开销,进而根据线程的第一时间和第二时间,精确获知线程绑定的内核的CPU占用率,相比于相关技术,基于精准确定的多个内核的CPU占用率,便于上层系统充分利用多内核架构的并行性,实现多内核负荷均衡控制,提升设备性能。The embodiment of the present application includes: the first time to obtain the thread, and the second time to obtain the thread, the first time is the CPU time consumed by the thread in the corresponding kernel, and the loop execution is executed, and the second time is the thread in the corresponding kernel. In the case of execution, process the CPU time consumed by effective business; determine the CPU usage of the core corresponding to the thread according to the first time and the second time of the thread; control the load of multiple cores according to the CPU usage of multiple cores . According to the solution provided by the embodiment of this application, for each thread, by obtaining the first time and the second time of the thread, the actual overhead of the thread's loop execution in the bound kernel can be displayed, and then according to the first time and the second time of the thread Second, accurately know the CPU occupancy rate of the thread-bound core. Compared with related technologies, based on the accurately determined CPU occupancy rate of multiple cores, it is convenient for the upper system to make full use of the parallelism of the multi-core architecture to achieve multi-core load balancing. Control and improve equipment performance.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统可以被实施为软件、固件、硬件及其适当的组合。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包括计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those skilled in the art can understand that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware and an appropriate combination thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit . Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As known to those of ordinary skill in the art, the term computer storage media includes both volatile and nonvolatile media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules, or other data. permanent, removable and non-removable media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, tape, magnetic disk storage or other magnetic storage devices, or can Any other medium used to store desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embody computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .
以上是对本申请的若干实施方式进行的说明,但本申请并不局限于上述实施方式,熟悉本领域的技术人员在不违背本申请精神的前提下还可作出种种的等同变形或替换,这些等同的变形或替换均包括在本申请权利要求所限定的范围内。The above is a description of several implementations of the application, but the application is not limited to the above implementations. Those skilled in the art can also make various equivalent deformations or replacements without violating the spirit of the application. These equivalents Any modification or substitution is included within the scope defined by the claims of the present application.

Claims (10)

  1. 一种内核的负荷控制方法,所述内核为多个,所述内核单独绑定线程,所述方法包括:A method for controlling the load of a kernel, wherein there are multiple kernels, and the kernels are individually bound to threads, and the method includes:
    获取所述线程的第一时间,以及获取所述线程的第二时间,所述第一时间为所述线程在对应的所述内核中,循环执行消耗的CPU时间,所述第二时间为所述线程在对应的所述内核中循环执行的情况下,处理有效业务消耗的CPU时间;Acquire the first time of the thread and the second time of the thread, the first time is the CPU time consumed by the thread in the corresponding kernel, and the second time is the When the above-mentioned thread is executed cyclically in the corresponding kernel, the CPU time consumed by processing valid services;
    根据所述线程的所述第一时间和所述第二时间,确定与所述线程对应的所述内核的CPU占用率;determining the CPU usage of the core corresponding to the thread according to the first time and the second time of the thread;
    根据多个所述内核的CPU占用率对多个所述内核进行负荷控制。Perform load control on multiple cores according to the CPU usage of multiple cores.
  2. 根据权利要求1所述的内核的负荷控制方法,其中,所述根据所述线程的所述第一时间和所述第二时间,确定与所述线程对应的所述内核的CPU占用率,包括:The load control method of a kernel according to claim 1, wherein said determining the CPU occupancy rate of the kernel corresponding to the thread according to the first time and the second time of the thread includes :
    当所述第一时间大于预设阈值时间,将所述第二时间与所述第一时间相除,得到所述线程的CPU占用率;When the first time is greater than the preset threshold time, dividing the second time by the first time to obtain the CPU usage of the thread;
    确定所述内核的CPU占用率为所述线程的CPU占用率。Determine the CPU occupancy rate of the kernel as the CPU occupancy rate of the thread.
  3. 根据权利要求1或2所述的内核的负荷控制方法,其中,所述根据多个所述内核的CPU占用率对多个所述内核进行负荷控制,包括:The load control method for cores according to claim 1 or 2, wherein the load control of multiple cores according to the CPU occupancy rates of multiple cores includes:
    根据多个所述内核的CPU占用率确定各个所述内核的负荷权重;determining the load weight of each of the cores according to the CPU usage of multiple cores;
    对于每个所述内核,向所述内核分配与所述负荷权重对应的实例任务。For each of the kernels, the instance tasks corresponding to the load weights are assigned to the kernels.
  4. 根据权利要求1所述的内核的负荷控制方法,其中,所述获取所述线程的第二时间,包括:The load control method of the kernel according to claim 1, wherein said acquiring the second time of said thread comprises:
    获取所述线程在所述内核中执行一次循环的情况下,处理每个实例业务的反馈结果;Obtain the feedback result of processing each instance business when the thread executes a cycle in the kernel;
    根据所有所述反馈结果和预设业务评估条件,从各个所述实例业务中确定所述有效业务;determining the effective service from each of the example services according to all the feedback results and preset service evaluation conditions;
    根据所述有效业务获取所述线程的第二时间。Acquire the second time of the thread according to the effective service.
  5. 根据权利要求4所述的内核的负荷控制方法,其中,所述根据所述有效业务获取所述线程的第二时间,包括:The load control method of the kernel according to claim 4, wherein said obtaining the second time of the thread according to the effective service comprises:
    根据所述有效业务,从所述线程中确定用于执行所述有效业务的有效功能单元;determining an effective functional unit for executing the effective service from the thread according to the effective service;
    获取所述有效功能单元执行所述有效业务的第一初始时刻和第一结束时刻;Obtaining a first initial moment and a first end moment when the effective functional unit executes the effective service;
    将所述第一结束时刻减去所述第一初始时刻,得到第三时间;subtracting the first initial time from the first end time to obtain a third time;
    获取所有所述第三时间的相加值,得到所述线程的第二时间。Obtain the added value of all the third times to obtain the second time of the thread.
  6. 根据权利要求1所述的内核的负荷控制方法,其中,所述获取所述线程的第一时间,包括:The load control method of the kernel according to claim 1, wherein said obtaining the first time of said thread comprises:
    获取所述线程的第四时间,所述第四时间为所述线程在所述内核中执行一次循环消耗的CPU时间;Obtaining the fourth time of the thread, the fourth time being the CPU time consumed by the thread executing a cycle in the kernel;
    将所有所述第四时间相加,得到所述线程的第一时间。All the fourth times are added together to obtain the first time of the thread.
  7. 根据权利要求6所述的内核的负荷控制方法,其中,所述获取所述线程的第四时间,包括:The load control method of the kernel according to claim 6, wherein said acquiring the fourth time of said thread comprises:
    获取所述线程在所述内核中执行一次循环的第二初始时刻和第二结束时刻;Obtaining a second initial moment and a second end moment when the thread executes a cycle in the kernel;
    将所述第二结束时刻减去所述第二初始时刻,得到第四时间。Subtracting the second initial time from the second end time to obtain a fourth time.
  8. 根据权利要求1或2所述的一种内核的负荷控制方法,其中,所述根据所述线程的所 述第一时间和所述第二时间,确定与所述线程对应的所述内核的CPU占用率之后,还包括:The method for controlling the load of a core according to claim 1 or 2, wherein, according to the first time and the second time of the thread, determining the CPU of the core corresponding to the thread After occupancy, it also includes:
    当所述内核的CPU占用率超过预设开销阈值,发出告警提示信息。When the CPU usage of the kernel exceeds the preset overhead threshold, an alarm prompt message is sent.
  9. 一种负荷控制装置,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如权利要求1至8中任意一项所述的内核的负荷控制方法。A load control device, comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor. When the processor executes the computer program, the computer program described in any one of claims 1 to 8 is realized. The load control method of the kernel described above.
  10. 一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1至8中任意一项所述的内核的负荷控制方法。A computer-readable storage medium storing computer-executable instructions, the computer-executable instructions being used to execute the method for controlling the load of a kernel according to any one of claims 1-8.
PCT/CN2022/128718 2021-12-14 2022-10-31 Load control method and apparatus for kernel, and computer-readable storage medium WO2023109338A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111528005.8A CN116263705A (en) 2021-12-14 2021-12-14 Load control method and device for kernel and computer readable storage medium
CN202111528005.8 2021-12-14

Publications (1)

Publication Number Publication Date
WO2023109338A1 true WO2023109338A1 (en) 2023-06-22

Family

ID=86723492

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/128718 WO2023109338A1 (en) 2021-12-14 2022-10-31 Load control method and apparatus for kernel, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN116263705A (en)
WO (1) WO2023109338A1 (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070101326A1 (en) * 2005-10-27 2007-05-03 Hewlett-Packard Development Company, L.P. Dynamic change of thread contention scope assignment
CN105045652A (en) * 2015-07-07 2015-11-11 深圳市云舒网络技术有限公司 Method for processing multi-parallel-thread program by multi-terminals and processing system
CN106528318A (en) * 2016-11-29 2017-03-22 迈普通信技术股份有限公司 Thread endless loop detection method and device
CN108829510A (en) * 2018-05-04 2018-11-16 天津猎鹰网络技术有限公司 Thread binds treating method and apparatus
CN109960637A (en) * 2019-03-20 2019-07-02 苏州浪潮智能科技有限公司 A kind of method and system for analyzing network interface card CPU usage
CN112559242A (en) * 2019-09-25 2021-03-26 无锡江南计算技术研究所 Method for compressing computational core memory of domestic many-core processor

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070101326A1 (en) * 2005-10-27 2007-05-03 Hewlett-Packard Development Company, L.P. Dynamic change of thread contention scope assignment
CN105045652A (en) * 2015-07-07 2015-11-11 深圳市云舒网络技术有限公司 Method for processing multi-parallel-thread program by multi-terminals and processing system
CN106528318A (en) * 2016-11-29 2017-03-22 迈普通信技术股份有限公司 Thread endless loop detection method and device
CN108829510A (en) * 2018-05-04 2018-11-16 天津猎鹰网络技术有限公司 Thread binds treating method and apparatus
CN109960637A (en) * 2019-03-20 2019-07-02 苏州浪潮智能科技有限公司 A kind of method and system for analyzing network interface card CPU usage
CN112559242A (en) * 2019-09-25 2021-03-26 无锡江南计算技术研究所 Method for compressing computational core memory of domestic many-core processor

Also Published As

Publication number Publication date
CN116263705A (en) 2023-06-16

Similar Documents

Publication Publication Date Title
CN110333937B (en) Task distribution method, device, computer equipment and storage medium
US9378032B2 (en) Information processing method, information processing apparatus, recording medium, and system
US9218203B2 (en) Packet scheduling in a multiprocessor system using inter-core switchover policy
US11876731B2 (en) System and methods for sharing memory subsystem resources among datacenter applications
US20120072624A1 (en) Numa i/o framework
US20170359271A1 (en) Multi-tenant based system and method for providing services
CN111104208B (en) Process scheduling management method, device, computer equipment and storage medium
CN108205469B (en) MapReduce-based resource allocation method and server
KR101553650B1 (en) Apparatus and method for load balancing in multi-core system
US11095531B2 (en) Service-aware serverless cloud computing system
CN109491788A (en) A kind of virtual platform implementation of load balancing and device
CN114327843A (en) Task scheduling method and device
US10733022B2 (en) Method of managing dedicated processing resources, server system and computer program product
CN109039933B (en) Cluster network optimization method, device, equipment and medium
WO2023109338A1 (en) Load control method and apparatus for kernel, and computer-readable storage medium
US9229716B2 (en) Time-based task priority boost management using boost register values
CN115640113A (en) Multi-plane flexible scheduling method
CN112948113A (en) Cluster resource management scheduling method, device, equipment and readable storage medium
CN111400241B (en) Data reconstruction method and device
JP5751372B2 (en) Data processing system, computer program thereof, and data processing method
CN117519956A (en) Resource quota determination method, device, computing equipment and medium
CN115344350A (en) Node equipment of cloud service system and resource processing method
CN115269131A (en) Task scheduling method and device
CN112416826A (en) Special computing chip, DMA data transmission system and method
CN114546279B (en) IO request prediction method and device, storage node and readable storage medium

Legal Events

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

Ref document number: 22906090

Country of ref document: EP

Kind code of ref document: A1