WO2021022964A1 - Task processing method, device, and computer-readable storage medium based on multi-core system - Google Patents

Task processing method, device, and computer-readable storage medium based on multi-core system Download PDF

Info

Publication number
WO2021022964A1
WO2021022964A1 PCT/CN2020/100834 CN2020100834W WO2021022964A1 WO 2021022964 A1 WO2021022964 A1 WO 2021022964A1 CN 2020100834 W CN2020100834 W CN 2020100834W WO 2021022964 A1 WO2021022964 A1 WO 2021022964A1
Authority
WO
WIPO (PCT)
Prior art keywords
core
service
business
task
cpu
Prior art date
Application number
PCT/CN2020/100834
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 WO2021022964A1 publication Critical patent/WO2021022964A1/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
    • 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
    • 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]

Definitions

  • the present invention relates to the field of computer technology, and in particular to a task processing method, device and computer-readable storage medium based on a multi-core system.
  • multi-core CPU systems especially in the embedded field, in addition to basic functions such as system management and control, the system has an increasing demand for simultaneous completion of high real-time, large data volume business processing tasks.
  • multi-core CPUs coordinate with each other to prevent system jitter and interference to improve business processing performance.
  • the present invention aims to solve one of the technical problems in the related art at least to a certain extent. To this end, the present invention provides a task processing method, device and computer-readable storage medium based on a multi-core system.
  • the task processing method based on the multi-core system includes: dividing a CPU core into a service core collection domain and a control core collection domain; binding service processing tasks to the service cores in the service core collection domain, The business processing task is processed by the business core.
  • the task processing device based on the multi-core system includes: a dividing module for dividing a CPU core into a service core collection domain and a control core collection domain; a task processing module for binding service processing tasks to all On the business core in the business core collection domain, the business core processes the business processing tasks.
  • the electronic device includes: a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor Implement the steps of the task processing method based on the multi-core system as described above.
  • a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the steps of the task processing method based on the multi-core system as described above are realized.
  • Figure 1 is a schematic diagram of the comparison between the existing symmetric pair processing system and the asymmetric multiprocessing system
  • FIG. 2 is a schematic structural diagram of a task processing device based on a multi-core system according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a task processing method based on a multi-core system according to an embodiment of the present invention
  • FIG. 4 is a flowchart of a method for dividing a service core set domain and a control core set domain according to an embodiment of the present invention
  • Fig. 5 is a schematic diagram of a logic state transition of a CPU core according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a system call proxy using a shared memory layout according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a system call agent flow diagram of a service core and a control core according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of the flow of an integrated system for management and forwarding of communication equipment according to an embodiment of the present invention.
  • Fig. 9 is a schematic structural diagram of a task processing device based on a multi-core system according to an embodiment of the present invention.
  • AMP Asymmetric Multi-Processing
  • SMP Symmetrical Multi-Processing
  • each CPU core handles different tasks, or even runs a system separately, and the CPU cores will not affect each other.
  • this kind of system has high complexity and difficult business program development and transplantation. Rarely applied in.
  • the SMP method is widely used, and its characteristic is that each CPU core shares processing and runs a single copy of the operating system. Tasks are fairly scheduled and load balanced among multiple CPU cores.
  • shut down unnecessary system service processes further, migrate ordinary tasks running in the business core to other CPU cores, and further, migrate all interrupts to other non-business cores, and further, bind business processing tasks Scheduled to the business CPU core for execution.
  • the time to execute the business processing program on the business CPU core is as unaffected as possible.
  • the main disadvantages of the above methods are: because of the inherent symmetrical processing characteristics of the SMP solution, it cannot completely solve the system jitter problem, especially in the application scenario where the CPU service core is dynamically isolated after the CPU core is started for service binding.
  • the optimization method cannot be completely isolated.
  • the business processing tasks are not only vulnerable to the task processes, timers, and interrupt lower-half programs that have been bound to the CPU core before the CPU core where they are located, but also unnecessary system clocks.
  • a task processing method based on a multi-core system includes:
  • control core in the control core set domain may be a CPU core used for management control; the service core may be a CPU core used for service processing.
  • the control core and the business core can be isolated from each other without affecting each other, and an asymmetric multiprocessing system in business logic can be realized.
  • S102 Bind the business processing task to the business core in the business core collection domain, and the business core processes the business processing task.
  • the service processing tasks are bound to the service cores, and the service cores process the service processing tasks.
  • a symmetric multi-processing system it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that business processing tasks completely monopolize the operation of the business core, and will not cause bottlenecks due to system jitter, which will affect business performance and indicators. It can make full use of the single-core CPU processing capacity of the business core to improve business processing performance.
  • dividing the CPU core into a service core collection domain and a control core collection domain includes:
  • S203 Use the remaining CPU cores as service cores, and process the service cores to go offline and then go online to form a service core set domain.
  • the logic state of the CPU core has two types: CPU_ONLINE and CPU_OFFLINE.
  • the present invention proposes a new CPU core logic state CPU_ONLINE_EXCLUSIVE.
  • the service core can switch from the traditional state to the third logical state CPU_ONLINE_EXCLUSIVE by going offline and then online, as shown in the figure
  • the operating system divides the business core into a completely different scheduling set domain from the control core, independently scheduling, avoiding mutual influence, and achieving asymmetric processing effects in business logic.
  • the method may further include:
  • the method further includes: before the service core goes online again, turning on the clock interrupt of the service core, and sending an online notification to the operating system.
  • the method further includes: after binding the service processing task to the service core in the service core set domain, turning off the clock interruption of the service core. Therefore, by turning off the clock interrupt for scheduling on the service core, it can avoid interrupting the service processing task, thereby further improving the service processing performance.
  • the method may further include:
  • the business core makes system calls based on the running results of the system call agent task running on the control core.
  • the present invention proposes a method of system call proxy.
  • the system call proxy task is run on the control core in advance, and the system call is not directly called on the business core, but through The shared memory method informs the agent that the task is completed indirectly, avoiding the system performance loss caused by system blockage and context switching of the business core.
  • the business core makes system calls according to the system call agent tasks, including:
  • Allocate shared memory which includes system call descriptors. As shown in Figure 6, you can pre-allocate two shared memory that can be accessed by the control core and the business core. One of them is used to represent the set of system call descriptors. Each descriptor contains fields such as status, system call number, parameters, and results. , Each description character is equal in length, continuous in the address space, organized in a ring.
  • the service core When the business core makes a system call, it first obtains the position of the write pointer in the description ring. After legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and fill in the system call number and the parameter or parameter memory address. In the descriptor, further, the status of the descriptor is changed to requesting, the loop waits for the status of the descriptor to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
  • the control core searches for the descriptor whose status is in the request, and executes the system call based on the system call parameter information in the descriptor. As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query finds that the status is changed to the request. , First modify the status to executing, and then take out the system call number and parameters to execute the system call. After the analysis and execution, if the parameter needs a large block of memory to save the result, apply from the parameter memory pool and copy the result to the parameter memory. Further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
  • the specific steps of dividing the CPU core into a control core and a service core include:
  • Step 1 After the CPU is initialized, the CPU normally enters the CPU_ONLINE logic state. In this state, the CPU checks all tasks in parallel and symmetric processing, fair scheduling, and load balancing;
  • Step 2 On the basis of the above steps, send the service core ready offline notification to the operating system core, and migrate all programs or services running in the service core to the control core, including management control tasks, timers, work queues, interrupts, and Interrupt the lower half of the program.
  • the CPU logic state of the service core changes to the CPU_OFFLINE state. In this state, the service core is powered off and offline.
  • Step 3 On the basis of the above steps, the operating environment of the business core has been cleaned up. Further, turn on the clock interrupt of the corresponding business core, send the CPU ready to go online notification to the operating system kernel, wake up the business core and send the CPU of the business core.
  • the logical state state transition CPU_ONLINE_EXCLUSIVE in this state, the business core is in an independent scheduling set domain, the process scheduler starts execution in a completely different way from the control core, the run queue is empty, no task is performed, and no work is performed Queues, timers, etc. interrupt the lower half of the program.
  • Step 4 On the basis of the above steps, the clock interrupt of the service core has been turned on, and its scheduler starts to run. At this time, the service processing task is started and bound to the corresponding service core to run.
  • the service core is in the CPU_ONLINE_EXCLUSIVE logic state set
  • the control core is in the CPU_ONLINE logic state set.
  • the two enter different scheduling set domains.
  • the control core runs ordinary management control, work queues, timers, interrupts, and the second half of interrupts.
  • Department and other tasks the business core runs business processing tasks separately, and different tasks will not be load balanced between the control core and the business core: the business core will not actively pull up the tasks of the control core task queue, and the control core scheduler cannot The task is put into the task scheduling queue of the business core.
  • Step 5 the business processing task is already running.
  • Step 6 Optionally, on the basis of step 4, run the system call proxy task on the control core in advance.
  • the business processing task running on the business core does not directly call the system call, but informs through the shared memory queue
  • the agent task is completed indirectly to avoid system performance loss caused by system blockage and context switching.
  • the task processing device based on the multi-core system according to the embodiment of the present invention includes: a division module and a task processing module.
  • the dividing module may be used to divide the CPU core into a service core set domain and a control core set domain.
  • control core in the control core set domain may be a CPU core used for management control; the service core may be a CPU core used for service processing.
  • the control core and the business core can be isolated from each other without affecting each other, and an asymmetric multiprocessing system in business logic can be realized.
  • the task processing module is used to bind the business processing tasks to the business cores in the business core collection domain, and the business cores process the business processing tasks.
  • the task processing device in the symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that the business processing task completely monopolizes the operation of the business core.
  • the bottleneck caused by system jitter affects business performance and indicators.
  • the division module is specifically used for:
  • the remaining CPU cores are used as business cores, and the business cores are processed offline and then online to form a business core set domain.
  • the service core can switch from the traditional state to the third logical state CPU_ONLINE_EXCLUSIVE by offline and then online, as shown in Figure 5. After introducing this new state, the operating system will The core is divided into a completely different scheduling set domain from the control core, independent scheduling, avoiding mutual influence, and achieving asymmetric processing effects in business logic.
  • the task processing module is also used to:
  • the device further includes: a control module.
  • the control module is used to turn on the clock interrupt of the service core before the service core goes online again, and send an online notification to the operating system.
  • control module is further configured to: after binding the service processing task to the service core in the service core set domain, turn off the clock interruption of the service core. Therefore, by turning off the clock interrupt for scheduling on the service core, it can avoid interrupting the service processing task, thereby further improving the service processing performance.
  • the device may further include: a system call proxy module, which is used to run a system call proxy task on the control core;
  • the business core makes system calls based on the running results of the system call agent task running on the control core.
  • the present invention proposes a method of system call proxy.
  • the system call proxy task is run on the control core in advance, and the system call is not directly called on the business core, but through The shared memory method informs the agent that the task is completed indirectly, avoiding the system performance loss caused by system blockage and context switching of the business core.
  • system call proxy module can be specifically used for:
  • Allocate shared memory which includes system call descriptors. As shown in Figure 6, you can pre-allocate two shared memory that can be accessed by the control core and the business core. One of them is used to represent the set of system call descriptors. Each descriptor contains fields such as status, system call number, parameters, and results. , Each description character is equal in length, continuous in the address space, organized in a ring.
  • the service core When the business core makes a system call, it first obtains the position of the write pointer in the description ring. After legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and fill in the system call number and the parameter or parameter memory address. In the descriptor, further, the status of the descriptor is changed to requesting, the loop waits for the status of the descriptor to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
  • the control core searches for the descriptor whose status is in the request, and executes the system call based on the system call parameter information in the descriptor. As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query finds that the status is changed to the request. , First modify the status to executing, and then take out the system call number and parameters to execute the system call. After the analysis and execution, if the parameter needs a large block of memory to save the result, apply from the parameter memory pool and copy the result to the parameter memory. Further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
  • the specific steps of dividing the CPU core into a control core and a service core include:
  • Step 1 After the CPU is initialized, the CPU normally enters the CPU_ONLINE logic state. In this state, the CPU checks all tasks in parallel and symmetric processing, fair scheduling, and load balancing;
  • Step 2 On the basis of the above steps, send the service core ready offline notification to the operating system core, and migrate all programs or services running in the service core to the control core, including management control tasks, timers, work queues, interrupts, and Interrupt the lower half of the program.
  • the CPU logic state of the service core changes to the CPU_OFFLINE state. In this state, the service core is powered off and offline.
  • Step 3 On the basis of the above steps, the operating environment of the business core has been cleaned up. Further, turn on the clock interrupt of the corresponding business core, send the CPU ready to go online notification to the operating system kernel, wake up the business core and send the CPU of the business core
  • the logical state transitions to CPU_ONLINE_EXCLUSIVE. In this state, the business core is in an independent scheduling set domain, and the process scheduler starts execution in a completely different way from the control core.
  • the run queue is empty, and no task or work is performed. Queues, timers, etc. interrupt the lower half of the program.
  • Step 4 On the basis of the above steps, the clock interrupt of the service core has been turned on, and its scheduler starts to run. At this time, the service processing task is started and bound to the corresponding service core to run.
  • the service core is in the CPU_ONLINE_EXCLUSIVE logic state set
  • the control core is in the CPU_ONLINE logic state set.
  • the two enter different scheduling set domains.
  • the control core runs ordinary management control, work queues, timers, interrupts, and the second half of interrupts.
  • Department and other tasks the business core runs business processing tasks separately, and different tasks will not be load balanced between the control core and the business core: the business core will not actively pull up the tasks of the control core task queue, and the control core scheduler cannot The task is put into the task scheduling queue of the business core.
  • Step 5 the business processing task is already running.
  • Step 6 Optionally, on the basis of step 4, run the system call proxy task on the control core in advance.
  • the business processing task running on the business core does not directly call the system call, but informs through the shared memory queue
  • the agent task is completed indirectly to avoid system performance loss caused by system blockage and context switching.
  • Step 1 Add a new set of CPU_ONLINE_EXCLUSIVE.
  • This set uses a CPU bitmap to indicate the CPU core in this logical state.
  • the BIT position represents the index of the CPU core. 1 means that the CPU core is in the logical state, and 0 means not here.
  • Logical state The initial state of the collection is empty.
  • Step 2 The control core sends a offline notification to perform offline processing on one or more business cores.
  • the operating system removes the business core from the CPU_ONLINE set, which will be represented in the CPU bitmap representing the set The BIT of the business core is set from 1 to 0.
  • Step 3 The control core sends a service online notification. Before executing the wake-up action, add one or more service cores to the CPU_ONLINE_EXCLUSIVE set, that is, set the BIT of the service core in the CPU bitmap representing the set from 0 to 1.
  • Step 4 When the service core is awakened, it checks the CPU bitmap representing the CPU_ONLINE_EXCLUSIVE collection, and finds that its BIT is 1, then it no longer joins the CPU_ONLINE collection.
  • Step 5 After the service core is awakened, the clock interrupt triggers task scheduling. Each time the scheduler runs, the CPU bitmap representing the set of CPU_ONLINE_EXCLUSIVE is checked, and after finding that its BIT is 1, enter a different scheduling process.
  • Step 6 When the control core starts the business processing task and binds it to the business core, the judging legal condition is no longer just CPU_ONLINE, but the union of CPU_ONLINE and CPU_ONLINE_EXCLUSIVE.
  • Step 7 After the service core is scheduled to run the service processing program, turn off the clock interrupt.
  • Step 1 Pre-allocate shared memory that can be accessed by two control cores and business cores: as shown in Figure 6, one of them is used to represent the set of system call descriptors, and each descriptor contains status, system call number, parameters, and results For fields, each descriptor has the same length, is continuous in the address space, and is organized in a ring. The other block is used as a parameter memory pool to store parameters larger than 8 bytes in system calls (such as file buf).
  • Step 2 As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query status changes to requesting Further, first modify the status as executing, and then take out the system call number and parameters to execute the system call. After the parsing and execution, if the parameter needs a large memory to save the result, apply from the parameter memory pool and copy the result to the parameter In the memory, further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
  • Step 3 When the service core makes a system call, it first obtains the position of the write pointer in the descriptor ring. After the legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and set the system call number and parameters or parameters The memory address is filled in the descriptor, and further, the descriptor status is changed to requesting, the loop waits for the descriptor status to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
  • Step 1 As shown in Figure 8, the system is powered on. After the CPU completes normal initialization, the status is CPU_ONLINE. All CPU cores complete the system version loading together, and the process and service are initialized and powered on. Different from the isolation of the CPU core at startup, the parallel execution of the CPU core greatly improves the power-on speed.
  • Step 2 Choose to divide the control core used for management and the service core used for data message forwarding, further, shut down the operating system to interrupt the load balancing management task, and further, send the CPU ready offline notification to the operating system kernel.
  • Step 3 On the basis of step 2, the operating system will run on the management process of the business core after receiving the above notification, the normal business process, the kernel timer and work queue, interrupt and interrupt the lower half of the program, migrate to the control core, After completing the migration operation, modify the CPU logic state of the service core to the CPU_OFFLINE state.
  • Step 4 On the basis of step 3, turn on the service core clock interrupt and modify the CPU logic state to CPU_ONLINE_EXCLUSIVE.
  • Step 5 On the basis of Step 4, start the packet sending and receiving task and bind it to the corresponding business core.
  • Step 6 Optionally, on the basis of step 5, turn off the clock interruption on the service core to reduce the time consumption caused by unnecessary system scheduling. At this time, the data forwarding task completely takes up the processing time of the service core and makes full use of the CPU core performance.
  • Step 7 Optionally, on the basis of Step 5, run the system call agent task on the control core.
  • Step 1 Type in the relevant kernel patch of the present invention on the server operating system.
  • Step 2 According to the number of server CPU cores and whether it is sufficient for business use, if the number of CPU cores is sufficient, the business CPU cores will be isolated during the system startup phase. Preferably, the startup parameter activates the patch. It can also be used before the business software runs. Make full use of each CPU core.
  • Step 3 The server is powered on, the operating system is loaded and the related application services are started.
  • the CPU core and memory resources are specified to start the corresponding virtual machine.
  • Step 4 Optionally, on the basis of step 2, select the CPU core in the host or virtual machine as the computing or soft forwarding interactive service.
  • the service core is dynamically Isolate and bind to the business core for execution.
  • Step 5 Optionally, repeat the above steps to realize the recovery of business cores and the reuse of control cores.
  • the electronic device includes: a memory 901, a processor 902, and a computer program stored in the memory 901 and running on the processor 902, and the computer program is executed by the processor 902 When implementing the steps of the above-mentioned method.
  • the electronic device of the embodiment of the present invention by executing the task processing method based on the multi-core system proposed by the present invention, in a symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that business processing Tasks completely exclusively run the business core, and will not cause bottlenecks due to system jitter, which will affect business performance and indicators.
  • a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the steps of the task processing method based on the multi-core system as described above are realized.
  • the computer storage medium of the embodiment of the present invention by executing the task processing method based on the multi-core system proposed by the present invention, in a symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that the business
  • the processing tasks are completely exclusive to the operation of the business core, thus making full use of the single-core CPU processing capacity, and will not cause bottlenecks due to system jitter, affecting business performance and indicators.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Hardware Redundancy (AREA)
  • Multi Processors (AREA)

Abstract

Provided are a task processing method, device, and computer-readable storage medium based on a multi-core system, said method comprising: dividing a CPU core into a service core set domain and a control core set domain; binding a service processing task to the service core in the service core set domain, said service core processing task being processed by said service core.

Description

一种基于多核系统的任务处理方法、装置及计算机可读存储介质Task processing method, device and computer readable storage medium based on multi-core system
相关申请的交叉引用Cross references to related applications
本申请基于申请号为201910714824.8、申请日为2019年8月2日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with an application number of 201910714824.8 and an application date of August 2, 2019, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby incorporated into this application by reference.
技术领域Technical field
本发明涉及计算机技术领域,尤其涉及一种基于多核系统的任务处理方法、装置及计算机可读存储介质。The present invention relates to the field of computer technology, and in particular to a task processing method, device and computer-readable storage medium based on a multi-core system.
背景技术Background technique
随着多核CPU系统的发展,尤其是在嵌入式领域中,系统在完成系统管理和控制等基本功能外,对要求同时完成实时性高、数据量大的业务处理任务的需求越来越高。对于这种处理任务不相同的复杂系统,多核CPU如何相互协调,防止系统抖动和干扰以提升业务处理性能就尤为重要。With the development of multi-core CPU systems, especially in the embedded field, in addition to basic functions such as system management and control, the system has an increasing demand for simultaneous completion of high real-time, large data volume business processing tasks. For such complex systems with different processing tasks, it is particularly important how multi-core CPUs coordinate with each other to prevent system jitter and interference to improve business processing performance.
发明内容Summary of the invention
本发明旨在至少在一定程度上解决相关技术中的技术问题之一,为此,本发明提供一种基于多核系统的任务处理方法、装置及计算机可读存储介质。The present invention aims to solve one of the technical problems in the related art at least to a certain extent. To this end, the present invention provides a task processing method, device and computer-readable storage medium based on a multi-core system.
根据本发明实施例的基于多核系统的任务处理方法,包括:将CPU核划分为业务核集合域和控制核集合域;将业务处理任务绑定到所述业务核集合域中的业务核上,由所述业务核处理所述业务处理任务。The task processing method based on the multi-core system according to the embodiment of the present invention includes: dividing a CPU core into a service core collection domain and a control core collection domain; binding service processing tasks to the service cores in the service core collection domain, The business processing task is processed by the business core.
根据本发明实施例的基于多核系统的任务处理装置,包括:划分模块,用于将CPU核划分为业务核集合域和控制核集合域;任务处理模块,用于将业务处理任务绑定到所述业务核集合域中的业务核上,由所述业务核处理所述业务处理任务。The task processing device based on the multi-core system according to the embodiment of the present invention includes: a dividing module for dividing a CPU core into a service core collection domain and a control core collection domain; a task processing module for binding service processing tasks to all On the business core in the business core collection domain, the business core processes the business processing tasks.
根据本发明实施例的电子装置,所述电子装置包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上述所述的基于多核系统的任务处理方法的步骤。According to the electronic device of the embodiment of the present invention, the electronic device includes: a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor Implement the steps of the task processing method based on the multi-core system as described above.
根据本发明实施例的计算机存储介质,所述计算机存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述所述的基于多核系统的任务处理方法的步骤。According to the computer storage medium of the embodiment of the present invention, a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the steps of the task processing method based on the multi-core system as described above are realized.
附图说明Description of the drawings
图1是现有对称对处理系统和非对称多处理系统对比示意图;Figure 1 is a schematic diagram of the comparison between the existing symmetric pair processing system and the asymmetric multiprocessing system;
图2是根据本发明实施例的基于多核系统的任务处理装置的结构示意图;2 is a schematic structural diagram of a task processing device based on a multi-core system according to an embodiment of the present invention;
图3是根据本发明实施例的基于多核系统的任务处理方法流程图;3 is a flowchart of a task processing method based on a multi-core system according to an embodiment of the present invention;
图4是根据本发明实施例的划分为业务核集合域和控制核集合域的方法流程图;4 is a flowchart of a method for dividing a service core set domain and a control core set domain according to an embodiment of the present invention;
图5是根据本发明实施例的CPU核逻辑状态转换示意图;Fig. 5 is a schematic diagram of a logic state transition of a CPU core according to an embodiment of the present invention;
图6是本发明实施例的系统调用代理使用共享内存布局示意图;FIG. 6 is a schematic diagram of a system call proxy using a shared memory layout according to an embodiment of the present invention;
图7是根据本发明实施例的业务核和控制核进行系统调用代理流程示意图;FIG. 7 is a schematic diagram of a system call agent flow diagram of a service core and a control core according to an embodiment of the present invention;
图8是根据本发明实施例的通讯设备管理和转发一体化系统流程示意图;8 is a schematic diagram of the flow of an integrated system for management and forwarding of communication equipment according to an embodiment of the present invention;
图9是根据本发明实施例的基于多核系统的任务处理装置的结构示意图。Fig. 9 is a schematic structural diagram of a task processing device based on a multi-core system according to an embodiment of the present invention.
具体实施方式Detailed ways
为更进一步阐述本发明为达成预定目的所采取的技术手段及功效,以下结合附图及较佳实施例,对本发明进行详细说明如后。In order to further explain the technical means and effects of the present invention to achieve the predetermined purpose, the present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments.
传统的方法中,对于处理不同任务,具有非对称多处理架构(AMP,Asymmetric MultiProcessing)和基于对称多处理架构(SMP,Symmetrical Multi-Processing)两种解决方案,它们的特点如图1所示。In traditional methods, for processing different tasks, there are two solutions: Asymmetric Multi-Processing (AMP) and Symmetrical Multi-Processing (SMP). Their characteristics are shown in Figure 1.
其中,AMP解决方案中,每个CPU核处理不同任务,甚至单独运行一个系统,CPU核间不会相互影响,但这种系统复杂性高,业务程序开发和移植困难,在处理任务复杂的系统中很少应用。Among them, in the AMP solution, each CPU core handles different tasks, or even runs a system separately, and the CPU cores will not affect each other. However, this kind of system has high complexity and difficult business program development and transplantation. Rarely applied in.
采用SMP的方法则被广泛的使用,其特点是每个CPU核共享处理,运行操作系统的单一副本。任务在多个CPU核间公平调度,负载均衡。The SMP method is widely used, and its characteristic is that each CPU core shares processing and runs a single copy of the operating system. Tasks are fairly scheduled and load balanced among multiple CPU cores.
在对称多处理系统中,为了完成实时性高、数据量大的业务处理任务,相关技术中采用的做法是通过系统优化来减少系统抖动以满足处理性能,其基本工作方法和原理如下文描述:In a symmetric multi-processing system, in order to complete business processing tasks with high real-time performance and large data volume, the method adopted in related technologies is to reduce system jitter through system optimization to meet processing performance. The basic working methods and principles are described below:
首先,关闭不必要的系统服务进程,进一步的,把在业务核中运行的普通任务迁移到其它CPU核,进一步的,将所有中断迁移到其它非业务核上,进一步的,把业务处理任务绑定到业务CPU核执行。通过这些操作流程,让在业务CPU核上执行业务处理程序的时间尽可能的不受影响。First, shut down unnecessary system service processes, further, migrate ordinary tasks running in the business core to other CPU cores, and further, migrate all interrupts to other non-business cores, and further, bind business processing tasks Scheduled to the business CPU core for execution. Through these operating procedures, the time to execute the business processing program on the business CPU core is as unaffected as possible.
上述方式的缺点主要有:因为SMP方案其本质上的对称处理特性,并不能完全解决系统抖动问题,尤其是对于CPU业务核在启动后再动态隔离CPU核进行业务绑定的应用场景中,这些优化方法还无法做到完全隔离,业务处理任务不仅容易受到其所在CPU核之前已经绑定CPU核的任务进程、定时器、中断下半部程序等的影响,而且还会受到不必要的系统时钟中断调度带来的额外开销(传统的动态时钟TICKLESS只能减少),以及系统调用因竞争引起阻塞,业务处理任务无法百分百占用运行业务处理的CPU核,导致业务处理任务无法满足业务处理性能,而且甚至容易因为调度策略和调度优先级的问题,反向阻塞和影响管理和控制功能的正常运行。The main disadvantages of the above methods are: because of the inherent symmetrical processing characteristics of the SMP solution, it cannot completely solve the system jitter problem, especially in the application scenario where the CPU service core is dynamically isolated after the CPU core is started for service binding. The optimization method cannot be completely isolated. The business processing tasks are not only vulnerable to the task processes, timers, and interrupt lower-half programs that have been bound to the CPU core before the CPU core where they are located, but also unnecessary system clocks. The extra overhead caused by interrupt scheduling (traditional dynamic clock TICKLESS can only be reduced), and system calls are blocked due to competition, business processing tasks cannot occupy 100% of the CPU cores running business processing, resulting in business processing tasks that cannot meet business processing performance , And even easily due to scheduling strategy and scheduling priority issues, reverse blocking and affecting the normal operation of management and control functions.
如图3所示,根据本发明实施例的基于多核系统的任务处理方法,包括:As shown in FIG. 3, a task processing method based on a multi-core system according to an embodiment of the present invention includes:
S101:将CPU核划分为业务核集合域和控制核集合域;S101: Divide the CPU core into a service core collection domain and a control core collection domain;
由此,可以在不同的集合域的CPU核进行不同的任务处理,提高业务处理效率。例如, 如图2所示,在对称对处理系统中,控制核集合域中的控制核可以是用于管理控制的CPU核;业务核可以是用于业务处理的CPU核。通过使控制核和业务核处于不同的调度集合中,可以使控制核和业务核相互隔离,互不影响,实现在业务逻辑上的非对称多处理系统。As a result, different task processing can be performed on the CPU cores of different collection domains, thereby improving service processing efficiency. For example, as shown in FIG. 2, in a symmetric pair processing system, the control core in the control core set domain may be a CPU core used for management control; the service core may be a CPU core used for service processing. By placing the control core and the business core in different scheduling sets, the control core and the business core can be isolated from each other without affecting each other, and an asymmetric multiprocessing system in business logic can be realized.
S102:将业务处理任务绑定到业务核集合域中的业务核上,由业务核处理业务处理任务。S102: Bind the business processing task to the business core in the business core collection domain, and the business core processes the business processing task.
根据本发明实施例的基于多核系统的任务处理方法,通过将CPU和划分为业务核集合域和控制核集合域,将业务处理任务绑定到业务核上,由业务核处理业务处理任务,在对称多处理的系统中,能动态平滑的切换为业务逻辑上的非对称多处理状态,使得业务处理任务完全独占业务核运行,不会因为系统抖动而造成瓶颈,而影响业务性能和指标,从而可以充分利用业务核单核CPU处理能力,提升了业务处理性能。According to the task processing method based on the multi-core system of the embodiment of the present invention, by dividing the CPU and the service core collection domain and the control core collection domain, the service processing tasks are bound to the service cores, and the service cores process the service processing tasks. In a symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that business processing tasks completely monopolize the operation of the business core, and will not cause bottlenecks due to system jitter, which will affect business performance and indicators. It can make full use of the single-core CPU processing capacity of the business core to improve business processing performance.
根据本发明的一些实施例,如图4所示,将CPU核划分为业务核集合域和控制核集合域,包括:According to some embodiments of the present invention, as shown in FIG. 4, dividing the CPU core into a service core collection domain and a control core collection domain includes:
S201:使所有CPU核均处于在线状态;S201: Make all CPU cores online;
S202:从所有CPU核中选出部分CPU核作为控制核,以形成控制核集合域;S202: Select some CPU cores from all CPU cores as control cores to form a control core set domain;
S203:将其余CPU核作为业务核,并将业务核进行离线后再上线的处理以形成业务核集合域。S203: Use the remaining CPU cores as service cores, and process the service cores to go offline and then go online to form a service core set domain.
需要说明的是,传统上CPU核逻辑状态有CPU_ONLINE和CPU_OFFLINE两种。如图5所示,本发明提出了一种新的CPU核逻辑状态CPU_ONLINE_EXCLUSIVE,利用CPU热插拔技术,业务核可以通过离线再上线的方式从传统状态切换进入第三种逻辑状态CPU_ONLINE_EXCLUSIVE,如图5所示,在引入此新状态后,操作系统把业务核划分为和控制核完全不同的调度集合域,独立调度,避免相互影响,达到业务逻辑上的非对称处理效果。It should be noted that traditionally, the logic state of the CPU core has two types: CPU_ONLINE and CPU_OFFLINE. As shown in Figure 5, the present invention proposes a new CPU core logic state CPU_ONLINE_EXCLUSIVE. Using CPU hot plug technology, the service core can switch from the traditional state to the third logical state CPU_ONLINE_EXCLUSIVE by going offline and then online, as shown in the figure As shown in 5, after the introduction of this new state, the operating system divides the business core into a completely different scheduling set domain from the control core, independently scheduling, avoiding mutual influence, and achieving asymmetric processing effects in business logic.
在进行业务核集合域和控制核集合域划分时,首先可以使所有CPU核均处于在线状态,然后,通过选出部分CPU核作为业务核,通过对其采用先离线后再上线的处理方式形成业务核集合域。When dividing the service core collection domain and the control core collection domain, firstly, all CPU cores can be online, and then, by selecting some CPU cores as service cores, it is formed by the processing method of offline and then online. Business core collection domain.
在本发明的一些实施例中,方法还可以包括:In some embodiments of the present invention, the method may further include:
当所有CPU核均处于在线状态时,将任务分配至所有CPU核进行处理。When all CPU cores are online, tasks are distributed to all CPU cores for processing.
当业务核离线后,将业务核中的任务迁移至控制核。When the business core is offline, the tasks in the business core are migrated to the control core.
根据本发明的一些实施例,方法还包括:在业务核再上线之前,打开业务核的时钟中断,并发送上线通知给操作系统。According to some embodiments of the present invention, the method further includes: before the service core goes online again, turning on the clock interrupt of the service core, and sending an online notification to the operating system.
需要说明的是,当将运行在业务核的所有程序或服务迁移到控制核后,业务核的运行环境已经清理干净,在业务核再上线之前,可以打开相应业务核的时钟中断,并发送CPU准备业务上线通知给操作系统内核。It should be noted that when all programs or services running on the business core are migrated to the control core, the operating environment of the business core has been cleaned up. Before the business core goes online again, the clock interrupt of the corresponding business core can be turned on and the CPU is sent Prepare to notify the operating system kernel of the business launch.
在本发明的一些实施例中,方法还包括:在将业务处理任务绑定到业务核集合域中的 业务核上之后,关闭业务核的时钟中断。由此,通过关闭业务核上用于调度的时钟中断,可以避免其打断业务处理任务,从而进一步提高业务处理性能。In some embodiments of the present invention, the method further includes: after binding the service processing task to the service core in the service core set domain, turning off the clock interruption of the service core. Therefore, by turning off the clock interrupt for scheduling on the service core, it can avoid interrupting the service processing task, thereby further improving the service processing performance.
根据本发明的一些实施例,方法还可以包括:According to some embodiments of the present invention, the method may further include:
在控制核上运行系统调用代理任务;Run the system call agent task on the control core;
通过共享内存的方式,使业务核根据在控制核上运行系统调用代理任务的运行结果进行系统调用。By sharing memory, the business core makes system calls based on the running results of the system call agent task running on the control core.
需要说明的是,当关闭业务核上的时钟中断后,业务处理任务直接进入系统调用会受到信号量、自旋锁等资源竞争而引起阻塞。因此,业务处理任务应尽量避免使用系统调用,但某些场景仍无法避免,若获取时间,读写文件等。为了解决此问题,如图6和图7所示,本发明提出了一种系统调用代理的方法,预先在控制核上运行系统调用代理任务,在业务核上不直接调用系统调用,而是通过共享内存的方式,通知代理任务间接完成,避免业务核受到系统阻塞以及上下文切换带来的系统性能损耗。It should be noted that when the clock interruption on the service core is turned off, the service processing task directly enters the system call, which will be blocked by resource competition such as semaphores and spin locks. Therefore, system calls should be avoided as much as possible for business processing tasks, but certain scenarios are still unavoidable, such as obtaining time, reading and writing files, etc. In order to solve this problem, as shown in Figure 6 and Figure 7, the present invention proposes a method of system call proxy. The system call proxy task is run on the control core in advance, and the system call is not directly called on the business core, but through The shared memory method informs the agent that the task is completed indirectly, avoiding the system performance loss caused by system blockage and context switching of the business core.
其中,通过共享内存队列的方式,使业务核根据系统调用代理任务进行系统调用,包括:Among them, by sharing the memory queue, the business core makes system calls according to the system call agent tasks, including:
分配共享内存,共享内存包括系统调用描述符。如图6所示,可以预先分配两块控制核和业务核都能访问的共享内存,其中一块用于表示系统调用描述符集合,每个描述符包含状态、系统调用号、参数、结果等字段,各个描述字符长度相等,在地址空间上连续,以环的方式组织。Allocate shared memory, which includes system call descriptors. As shown in Figure 6, you can pre-allocate two shared memory that can be accessed by the control core and the business core. One of them is used to represent the set of system call descriptors. Each descriptor contains fields such as status, system call number, parameters, and results. , Each description character is equal in length, continuous in the address space, organized in a ring.
将业务核进行系统调用时的系统调用参数信息写到描述符中,并将描述符状态修改为请求中。业务核进行系统调用时,首先获取描述环中写指针位置,合法判断后,如果参数需要大块内存,则先从参数内存池中申请一块内存,将系统调用号和参数或者参数内存地址填写到描述符中,进一步的,将描述符状态修改为请求中,循环等待描述符状态变更为执行完成,取出结果,释放参数内存池。Write the system call parameter information when the business core makes a system call to the descriptor, and modify the status of the descriptor to request. When the service core makes a system call, it first obtains the position of the write pointer in the description ring. After legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and fill in the system call number and the parameter or parameter memory address. In the descriptor, further, the status of the descriptor is changed to requesting, the loop waits for the status of the descriptor to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
通过控制核查找状态为请求中的描述符,并基于描述符中的系统调用参数信息执行系统调用。如图7所示,控制核启动系统调用代理任务,并设置为较高优先级,此任务不断轮询描述符环中读指针位置的描述符状态,直到查询到状态变更为请求中,进一步的,首先修改状态为执行中,然后取出系统调用号和参数执行系统调用,解析执行完后,如果参数需要大块内存保存结果,则从参数内存池中申请后并把结果复制到参数内存中,进一步的,修改状态为执行完成。读指针加1,继续取下一个描述符。The control core searches for the descriptor whose status is in the request, and executes the system call based on the system call parameter information in the descriptor. As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query finds that the status is changed to the request. , First modify the status to executing, and then take out the system call number and parameters to execute the system call. After the analysis and execution, if the parameter needs a large block of memory to save the result, apply from the parameter memory pool and copy the result to the parameter memory. Further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
结合图4和图5所示,将CPU核划分为控制核和业务核的具体步骤包括:As shown in Figure 4 and Figure 5, the specific steps of dividing the CPU core into a control core and a service core include:
步骤1:CPU完成初始化后,CPU正常进入CPU_ONLINE逻辑状态,在此状态下,CPU核对所有任务并行对称处理,公平调度,负载均衡;Step 1: After the CPU is initialized, the CPU normally enters the CPU_ONLINE logic state. In this state, the CPU checks all tasks in parallel and symmetric processing, fair scheduling, and load balancing;
步骤2:在上述步骤的基础上,发送业务核准备离线通知给操作系统内核,将运行在业务核的所有程序或服务迁移到控制核,具体包括管理控制任务、定时器、工作队列、中 断以及中断下半部程序,当完成迁移操作后,业务核的CPU逻辑状态即变迁为CPU_OFFLINE状态。此状态下,业务核处于下电、离线状态。Step 2: On the basis of the above steps, send the service core ready offline notification to the operating system core, and migrate all programs or services running in the service core to the control core, including management control tasks, timers, work queues, interrupts, and Interrupt the lower half of the program. When the migration operation is completed, the CPU logic state of the service core changes to the CPU_OFFLINE state. In this state, the service core is powered off and offline.
步骤3:在上述步骤的基础上,业务核的运行环境已经清理干净,进一步的,打开相应业务核的时钟中断,发送CPU准备业务上线通知给操作系统内核,唤醒业务核并将业务核的CPU逻辑状态状态变迁CPU_ONLINE_EXCLUSIVE,在此状态下,业务核处于独立的调度集合域中,进程调度器以和控制核完全不同的方式开始执行,运行队列为空,不执行任何任务,也不执行任何工作队列,定时器等中断下半部程序。Step 3: On the basis of the above steps, the operating environment of the business core has been cleaned up. Further, turn on the clock interrupt of the corresponding business core, send the CPU ready to go online notification to the operating system kernel, wake up the business core and send the CPU of the business core The logical state state transition CPU_ONLINE_EXCLUSIVE, in this state, the business core is in an independent scheduling set domain, the process scheduler starts execution in a completely different way from the control core, the run queue is empty, no task is performed, and no work is performed Queues, timers, etc. interrupt the lower half of the program.
步骤4:在上述步骤的基础上,业务核的时钟中断已打开,其调度器开始运行,此时启动业务处理任务,并把其绑定到相应的业务核中运行。Step 4: On the basis of the above steps, the clock interrupt of the service core has been turned on, and its scheduler starts to run. At this time, the service processing task is started and bound to the corresponding service core to run.
通过以上步骤,业务核处于CPU_ONLINE_EXCLUSIVE逻辑状态集合中,控制核处于CPU_ONLINE逻辑状态集合中,两者进入不同的调度集合域,控制核中运行普通管理控制、工作队列,定时器、中断以及中断下半部等任务,业务核则单独运行业务处理任务,不同任务在控制核和业务核之间不会进行负载均衡:业务核不会主动拉起控制核任务队列的任务,控制核调度器也不能把任务放入业务核的任务调度队列。Through the above steps, the service core is in the CPU_ONLINE_EXCLUSIVE logic state set, and the control core is in the CPU_ONLINE logic state set. The two enter different scheduling set domains. The control core runs ordinary management control, work queues, timers, interrupts, and the second half of interrupts. Department and other tasks, the business core runs business processing tasks separately, and different tasks will not be load balanced between the control core and the business core: the business core will not actively pull up the tasks of the control core task queue, and the control core scheduler cannot The task is put into the task scheduling queue of the business core.
步骤5,可选的,在步骤4的基础上,业务处理任务已经运行,为进一步提高业务处理性能,选择关闭业务核上用于调度的时钟中断,避免其打断业务处理任务。Step 5. Optionally, on the basis of step 4, the business processing task is already running. In order to further improve the business processing performance, choose to turn off the clock interrupt for scheduling on the business core to avoid interrupting the business processing task.
步骤6:可选的,在步骤4的基础上,预先在控制核上运行系统调用代理任务,在业务核上运行的业务处理任务不直接调用系统调用,而是通过共享内存队列的方式,通知代理任务间接完成,避免业务核受到系统阻塞以及上下文切换带来的系统性能损耗。Step 6: Optionally, on the basis of step 4, run the system call proxy task on the control core in advance. The business processing task running on the business core does not directly call the system call, but informs through the shared memory queue The agent task is completed indirectly to avoid system performance loss caused by system blockage and context switching.
根据本发明实施例的基于多核系统的任务处理装置,包括:划分模块和任务处理模块。The task processing device based on the multi-core system according to the embodiment of the present invention includes: a division module and a task processing module.
具体而言,划分模块可以用于将CPU核划分为业务核集合域和控制核集合域。Specifically, the dividing module may be used to divide the CPU core into a service core set domain and a control core set domain.
由此,可以在不同的集合域的CPU核进行不同的任务处理,提高业务处理效率。例如,如图2所示,在对称对处理系统中,控制核集合域中的控制核可以是用于管理控制的CPU核;业务核可以是用于业务处理的CPU核。通过使控制核和业务核处于不同的调度集合中,可以使控制核和业务核相互隔离,互不影响,实现在业务逻辑上的非对称多处理系统。As a result, different task processing can be performed on the CPU cores of different collection domains, thereby improving service processing efficiency. For example, as shown in FIG. 2, in a symmetric pair processing system, the control core in the control core set domain may be a CPU core used for management control; the service core may be a CPU core used for service processing. By placing the control core and the business core in different scheduling sets, the control core and the business core can be isolated from each other without affecting each other, and an asymmetric multiprocessing system in business logic can be realized.
任务处理模块用于将业务处理任务绑定到业务核集合域中的业务核上,由业务核处理业务处理任务。The task processing module is used to bind the business processing tasks to the business cores in the business core collection domain, and the business cores process the business processing tasks.
根据本发明实施例的基于多核系统的任务处理装置,在对称多处理的系统中,能动态平滑的切换为业务逻辑上的非对称多处理状态,使得业务处理任务完全独占业务核运行,不会因为系统抖动而造成瓶颈,影响业务性能和指标。According to the task processing device based on the multi-core system of the embodiment of the present invention, in the symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that the business processing task completely monopolizes the operation of the business core. The bottleneck caused by system jitter affects business performance and indicators.
根据本发明的一些实施例,划分模块具体用于:According to some embodiments of the present invention, the division module is specifically used for:
使所有CPU核均处于在线状态;Make all CPU cores online;
从所有CPU核中选出部分CPU核作为控制核,以形成控制核集合域;Select some CPU cores from all CPU cores as control cores to form a control core set domain;
将其余CPU核作为业务核,并将业务核进行离线后再上线的处理以形成业务核集合域。The remaining CPU cores are used as business cores, and the business cores are processed offline and then online to form a business core set domain.
需要说明的是,利用CPU热插拔技术,业务核可以通过离线再上线的方式从传统状态切换进入第三种逻辑状态CPU_ONLINE_EXCLUSIVE,如图5所示,在引入此新状态后,操作系统把业务核划分为和控制核完全不同的调度集合域,独立调度,避免相互影响,达到业务逻辑上的非对称处理效果。It should be noted that using CPU hot-plug technology, the service core can switch from the traditional state to the third logical state CPU_ONLINE_EXCLUSIVE by offline and then online, as shown in Figure 5. After introducing this new state, the operating system will The core is divided into a completely different scheduling set domain from the control core, independent scheduling, avoiding mutual influence, and achieving asymmetric processing effects in business logic.
在进行业务核集合域和控制核集合域划分时,首先可以使所有CPU核均处于在线状态,然后,通过选出部分CPU核作为业务核,通过对其采用先离线后再上线的处理方式形成业务核集合域。When dividing the service core collection domain and the control core collection domain, firstly, all CPU cores can be online, and then, by selecting some CPU cores as service cores, it is formed by the processing method of offline and then online. Business core collection domain.
在本发明的一些实施例中,任务处理模块还用于:In some embodiments of the present invention, the task processing module is also used to:
当所有CPU核均处于在线状态时,将任务分配至所有CPU核进行处理;When all CPU cores are online, assign tasks to all CPU cores for processing;
业务核离线后,将业务核中的任务迁移至控制核。After the business core is offline, the tasks in the business core are migrated to the control core.
根据本发明的一些实施例,装置还包括:控制模块。控制模块用于在业务核再上线之前,打开业务核的时钟中断,并发送上线通知给操作系统。According to some embodiments of the present invention, the device further includes: a control module. The control module is used to turn on the clock interrupt of the service core before the service core goes online again, and send an online notification to the operating system.
需要说明的是,当将运行在业务核的所有程序或服务迁移到控制核后,业务核的运行环境已经清理干净,在业务核再上线之前,可以打开相应业务核的时钟中断,并发送CPU准备业务上线通知给操作系统内核。It should be noted that when all programs or services running on the business core are migrated to the control core, the operating environment of the business core has been cleaned up. Before the business core goes online again, the clock interrupt of the corresponding business core can be turned on and the CPU is sent Prepare to notify the operating system kernel of the business launch.
在本发明的一些实施例中,控制模块还用于:在将业务处理任务绑定到业务核集合域中的业务核上之后,关闭业务核的时钟中断。由此,通过关闭业务核上用于调度的时钟中断,可以避免其打断业务处理任务,从而进一步提高业务处理性能。In some embodiments of the present invention, the control module is further configured to: after binding the service processing task to the service core in the service core set domain, turn off the clock interruption of the service core. Therefore, by turning off the clock interrupt for scheduling on the service core, it can avoid interrupting the service processing task, thereby further improving the service processing performance.
根据本发明的一些实施例,装置还可以包括:系统调用代理模块,系统调用代理模块用于在控制核上运行系统调用代理任务;According to some embodiments of the present invention, the device may further include: a system call proxy module, which is used to run a system call proxy task on the control core;
通过共享内存的方式,使业务核根据在控制核上运行系统调用代理任务的运行结果进行系统调用。By sharing memory, the business core makes system calls based on the running results of the system call agent task running on the control core.
需要说明的是,当关闭业务核上的时钟中断后,业务处理任务直接进入系统调用会受到信号量、自旋锁等资源竞争而引起阻塞。因此,业务处理任务应尽量避免使用系统调用,但某些场景仍无法避免,若获取时间,读写文件等。为了解决此问题,如图6和图7所示,本发明提出了一种系统调用代理的方法,预先在控制核上运行系统调用代理任务,在业务核上不直接调用系统调用,而是通过共享内存的方式,通知代理任务间接完成,避免业务核受到系统阻塞以及上下文切换带来的系统性能损耗。It should be noted that when the clock interruption on the service core is turned off, the service processing task directly enters the system call, which will be blocked by resource competition such as semaphores and spin locks. Therefore, system calls should be avoided as much as possible for business processing tasks, but certain scenarios are still unavoidable, such as obtaining time, reading and writing files, etc. In order to solve this problem, as shown in Figure 6 and Figure 7, the present invention proposes a method of system call proxy. The system call proxy task is run on the control core in advance, and the system call is not directly called on the business core, but through The shared memory method informs the agent that the task is completed indirectly, avoiding the system performance loss caused by system blockage and context switching of the business core.
其中,系统调用代理模块可以具体用于:Among them, the system call proxy module can be specifically used for:
分配共享内存,共享内存包括系统调用描述符。如图6所示,可以预先分配两块控制核和业务核都能访问的共享内存,其中一块用于表示系统调用描述符集合,每个描述符包含状态、系统调用号、参数、结果等字段,各个描述字符长度相等,在地址空间上连续,以环的方式组织。Allocate shared memory, which includes system call descriptors. As shown in Figure 6, you can pre-allocate two shared memory that can be accessed by the control core and the business core. One of them is used to represent the set of system call descriptors. Each descriptor contains fields such as status, system call number, parameters, and results. , Each description character is equal in length, continuous in the address space, organized in a ring.
将业务核进行系统调用时的系统调用参数信息写到描述符中,并将描述符状态修改为 请求中。业务核进行系统调用时,首先获取描述环中写指针位置,合法判断后,如果参数需要大块内存,则先从参数内存池中申请一块内存,将系统调用号和参数或者参数内存地址填写到描述符中,进一步的,将描述符状态修改为请求中,循环等待描述符状态变更为执行完成,取出结果,释放参数内存池。Write the system call parameter information when the business core makes a system call to the descriptor, and modify the descriptor status to request. When the service core makes a system call, it first obtains the position of the write pointer in the description ring. After legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and fill in the system call number and the parameter or parameter memory address. In the descriptor, further, the status of the descriptor is changed to requesting, the loop waits for the status of the descriptor to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
通过控制核查找状态为请求中的描述符,并基于描述符中的系统调用参数信息执行系统调用。如图7所示,控制核启动系统调用代理任务,并设置为较高优先级,此任务不断轮询描述符环中读指针位置的描述符状态,直到查询到状态变更为请求中,进一步的,首先修改状态为执行中,然后取出系统调用号和参数执行系统调用,解析执行完后,如果参数需要大块内存保存结果,则从参数内存池中申请后并把结果复制到参数内存中,进一步的,修改状态为执行完成。读指针加1,继续取下一个描述符。The control core searches for the descriptor whose status is in the request, and executes the system call based on the system call parameter information in the descriptor. As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query finds that the status is changed to the request. , First modify the status to executing, and then take out the system call number and parameters to execute the system call. After the analysis and execution, if the parameter needs a large block of memory to save the result, apply from the parameter memory pool and copy the result to the parameter memory. Further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
结合图4和图5所示,将CPU核划分为控制核和业务核的具体步骤包括:As shown in Figure 4 and Figure 5, the specific steps of dividing the CPU core into a control core and a service core include:
步骤1:CPU完成初始化后,CPU正常进入CPU_ONLINE逻辑状态,在此状态下,CPU核对所有任务并行对称处理,公平调度,负载均衡;Step 1: After the CPU is initialized, the CPU normally enters the CPU_ONLINE logic state. In this state, the CPU checks all tasks in parallel and symmetric processing, fair scheduling, and load balancing;
步骤2:在上述步骤的基础上,发送业务核准备离线通知给操作系统内核,将运行在业务核的所有程序或服务迁移到控制核,具体包括管理控制任务、定时器、工作队列、中断以及中断下半部程序,当完成迁移操作后,业务核的CPU逻辑状态即变迁为CPU_OFFLINE状态。此状态下,业务核处于下电、离线状态。Step 2: On the basis of the above steps, send the service core ready offline notification to the operating system core, and migrate all programs or services running in the service core to the control core, including management control tasks, timers, work queues, interrupts, and Interrupt the lower half of the program. When the migration operation is completed, the CPU logic state of the service core changes to the CPU_OFFLINE state. In this state, the service core is powered off and offline.
步骤3:在上述步骤的基础上,业务核的运行环境已经清理干净,进一步的,打开相应业务核的时钟中断,发送CPU准备业务上线通知给操作系统内核,唤醒业务核并将业务核的CPU逻辑状态变迁为CPU_ONLINE_EXCLUSIVE,在此状态下,业务核处于独立的调度集合域中,进程调度器以和控制核完全不同的方式开始执行,运行队列为空,不执行任何任务,也不执行任何工作队列,定时器等中断下半部程序。Step 3: On the basis of the above steps, the operating environment of the business core has been cleaned up. Further, turn on the clock interrupt of the corresponding business core, send the CPU ready to go online notification to the operating system kernel, wake up the business core and send the CPU of the business core The logical state transitions to CPU_ONLINE_EXCLUSIVE. In this state, the business core is in an independent scheduling set domain, and the process scheduler starts execution in a completely different way from the control core. The run queue is empty, and no task or work is performed. Queues, timers, etc. interrupt the lower half of the program.
步骤4:在上述步骤的基础上,业务核的时钟中断已打开,其调度器开始运行,此时启动业务处理任务,并把其绑定到相应的业务核中运行。Step 4: On the basis of the above steps, the clock interrupt of the service core has been turned on, and its scheduler starts to run. At this time, the service processing task is started and bound to the corresponding service core to run.
通过以上步骤,业务核处于CPU_ONLINE_EXCLUSIVE逻辑状态集合中,控制核处于CPU_ONLINE逻辑状态集合中,两者进入不同的调度集合域,控制核中运行普通管理控制、工作队列,定时器、中断以及中断下半部等任务,业务核则单独运行业务处理任务,不同任务在控制核和业务核之间不会进行负载均衡:业务核不会主动拉起控制核任务队列的任务,控制核调度器也不能把任务放入业务核的任务调度队列。Through the above steps, the service core is in the CPU_ONLINE_EXCLUSIVE logic state set, and the control core is in the CPU_ONLINE logic state set. The two enter different scheduling set domains. The control core runs ordinary management control, work queues, timers, interrupts, and the second half of interrupts. Department and other tasks, the business core runs business processing tasks separately, and different tasks will not be load balanced between the control core and the business core: the business core will not actively pull up the tasks of the control core task queue, and the control core scheduler cannot The task is put into the task scheduling queue of the business core.
步骤5,可选的,在步骤4的基础上,业务处理任务已经运行,为进一步提高业务处理性能,选择关闭业务核上用于调度的时钟中断,避免其打断业务处理任务。Step 5. Optionally, on the basis of step 4, the business processing task is already running. In order to further improve the business processing performance, choose to turn off the clock interrupt for scheduling on the business core to avoid interrupting the business processing task.
步骤6:可选的,在步骤4的基础上,预先在控制核上运行系统调用代理任务,在业务核上运行的业务处理任务不直接调用系统调用,而是通过共享内存队列的方式,通知代理任务间接完成,避免业务核受到系统阻塞以及上下文切换带来的系统性能损耗。Step 6: Optionally, on the basis of step 4, run the system call proxy task on the control core in advance. The business processing task running on the business core does not directly call the system call, but informs through the shared memory queue The agent task is completed indirectly to avoid system performance loss caused by system blockage and context switching.
下面以一个具体的实施例详细描述根据本发明实施例引入新CPU核逻辑状态进行业务逻辑上非对称多处理调度的实施方式:In the following, a specific embodiment is used to describe in detail the implementation of introducing a new CPU core logic state to perform asymmetric multi-processing scheduling in business logic according to an embodiment of the present invention:
步骤1:新增CPU_ONLINE_EXCLUSIVE集合,该集合使用CPU位图的方式表示处于此逻辑状态下的CPU核,BIT位置代表CPU核索引,为1表示该CPU核处于持逻辑状态下,为0表示不在此逻辑状态。该集合初始状态为空。Step 1: Add a new set of CPU_ONLINE_EXCLUSIVE. This set uses a CPU bitmap to indicate the CPU core in this logical state. The BIT position represents the index of the CPU core. 1 means that the CPU core is in the logical state, and 0 means not here. Logical state. The initial state of the collection is empty.
步骤2:控制核发送下线通知,对一个或多个业务核进行离线处理,业务核进入CPU_OFFLINE逻辑状态后,操作系统将业务核从CPU_ONLINE集合中剔除,即将表示该集合的CPU位图中表示业务核的BIT从1置为0。Step 2: The control core sends a offline notification to perform offline processing on one or more business cores. After the business core enters the CPU_OFFLINE logic state, the operating system removes the business core from the CPU_ONLINE set, which will be represented in the CPU bitmap representing the set The BIT of the business core is set from 1 to 0.
步骤3:控制核发送业务上线通知,在执行唤醒动作前,将一个或多个业务核加入到CPU_ONLINE_EXCLUSIVE集合中,即将表示该集合的CPU位图中表示业务核的BIT从0置为1。Step 3: The control core sends a service online notification. Before executing the wake-up action, add one or more service cores to the CPU_ONLINE_EXCLUSIVE set, that is, set the BIT of the service core in the CPU bitmap representing the set from 0 to 1.
步骤4:业务核被唤醒时,检测代表CPU_ONLINE_EXCLUSIVE集合的CPU位图,发现其BIT为1后,便不再加入CPU_ONLINE集合中。Step 4: When the service core is awakened, it checks the CPU bitmap representing the CPU_ONLINE_EXCLUSIVE collection, and finds that its BIT is 1, then it no longer joins the CPU_ONLINE collection.
步骤5:业务核被唤醒后,时钟中断触发任务调度,每次调度程序运行时,检测代表CPU_ONLINE_EXCLUSIVE集合的CPU位图,发现其BIT为1后,进入不同的调度流程。Step 5: After the service core is awakened, the clock interrupt triggers task scheduling. Each time the scheduler runs, the CPU bitmap representing the set of CPU_ONLINE_EXCLUSIVE is checked, and after finding that its BIT is 1, enter a different scheduling process.
步骤6:控制核启动业务处理任务并绑定到业务核中时,判断合法条件不再仅仅是CPU_ONLINE,而是CPU_ONLINE和CPU_ONLINE_EXCLUSIVE的并集。Step 6: When the control core starts the business processing task and binds it to the business core, the judging legal condition is no longer just CPU_ONLINE, but the union of CPU_ONLINE and CPU_ONLINE_EXCLUSIVE.
步骤7:业务核调度运行业务处理程序后,关闭时钟中断。Step 7: After the service core is scheduled to run the service processing program, turn off the clock interrupt.
下面以一个具体的实施例详细描述根据本发明实施例的系统调用代理的实施方式:The following describes in detail the implementation of the system call proxy according to the embodiment of the present invention with a specific embodiment:
步骤1:预先分配两块控制核和业务核都能访问的共享内存:如图6所示,其中一块用于表示系统调用描述符集合,每个描述符包含状态、系统调用号、参数、结果等字段,各个描述符长度相等,在地址空间上连续,以环的方式组织。另一块作为参数内存池,用于保存系统调用中大于8个字节的参数(如文件buf)。Step 1: Pre-allocate shared memory that can be accessed by two control cores and business cores: as shown in Figure 6, one of them is used to represent the set of system call descriptors, and each descriptor contains status, system call number, parameters, and results For fields, each descriptor has the same length, is continuous in the address space, and is organized in a ring. The other block is used as a parameter memory pool to store parameters larger than 8 bytes in system calls (such as file buf).
步骤2:如图7所示,控制核启动系统调用代理任务,并设置为较高优先级,此任务不断轮询描述符环中读指针位置的描述符状态,直到查询到状态变更为请求中,进一步的,首先修改状态为执行中,然后取出系统调用号和参数执行系统调用,解析执行完后,如果参数需要大块内存保存结果,则从参数内存池中申请后并把结果复制到参数内存中,进一步的,修改状态为执行完成。读指针加1,继续取下一个描述符。Step 2: As shown in Figure 7, the control core starts the system call proxy task and sets it to a higher priority. This task continuously polls the status of the descriptor at the position of the read pointer in the descriptor ring until the query status changes to requesting Further, first modify the status as executing, and then take out the system call number and parameters to execute the system call. After the parsing and execution, if the parameter needs a large memory to save the result, apply from the parameter memory pool and copy the result to the parameter In the memory, further, the modification status is execution complete. The read pointer is incremented by 1, and the next descriptor is continued.
步骤3:业务核进行系统调用时,首先获取描述符环中写指针位置,合法判断后,如果参数需要大块内存,则先从参数内存池中申请一块内存,将系统调用号和参数或者参数内存地址填写到描述符中,进一步的,将描述符状态修改为请求中,循环等待描述符状态变更为执行完成,取出结果,释放参数内存池。Step 3: When the service core makes a system call, it first obtains the position of the write pointer in the descriptor ring. After the legal judgment, if the parameter requires a large block of memory, first apply for a block of memory from the parameter memory pool, and set the system call number and parameters or parameters The memory address is filled in the descriptor, and further, the descriptor status is changed to requesting, the loop waits for the descriptor status to be changed to the completion of execution, the result is retrieved, and the parameter memory pool is released.
下面以一个具体的实施例详细描述根据本发明实施例的基于多核系统的任务处理方法在通讯设备管理和转发板卡一体化系统中的实施方式:In the following, a specific embodiment is used to describe in detail the implementation of the multi-core system-based task processing method in the integrated system of communication equipment management and forwarding board according to the embodiment of the present invention:
步骤1:如图8所示,系统上电,CPU完成正常初始化后状态为CPU_ONLINE,所有CPU核共同完成系统版本加载,进程和服务初始化上电。区别于启动时CPU核隔离,CPU核并行执行大幅度提供上电速度。Step 1: As shown in Figure 8, the system is powered on. After the CPU completes normal initialization, the status is CPU_ONLINE. All CPU cores complete the system version loading together, and the process and service are initialized and powered on. Different from the isolation of the CPU core at startup, the parallel execution of the CPU core greatly improves the power-on speed.
步骤2:选择划分用于管理的控制核和用于数据报文转发的业务核,进一步的,关闭操作系统中断负载均衡管理任务,进一步的,发送CPU准备离线通知给操作系统内核。Step 2: Choose to divide the control core used for management and the service core used for data message forwarding, further, shut down the operating system to interrupt the load balancing management task, and further, send the CPU ready offline notification to the operating system kernel.
步骤3:在步骤2的基础上,操作系统收到上述通知后将运行在业务核的管理进程,普通业务进程、内核定时器和工作队列、中断以及中断下半部程序,迁移到控制核,当完成迁移操作后,修改业务核的CPU逻辑状态为CPU_OFFLINE状态。Step 3: On the basis of step 2, the operating system will run on the management process of the business core after receiving the above notification, the normal business process, the kernel timer and work queue, interrupt and interrupt the lower half of the program, migrate to the control core, After completing the migration operation, modify the CPU logic state of the service core to the CPU_OFFLINE state.
步骤4:在步骤3的基础上,打开业务核时钟中断,修改CPU逻辑状态为CPU_ONLINE_EXCLUSIVE。Step 4: On the basis of step 3, turn on the service core clock interrupt and modify the CPU logic state to CPU_ONLINE_EXCLUSIVE.
步骤5:在步骤4的基础上,启动收发包任务,并绑定到相应的业务核。Step 5: On the basis of Step 4, start the packet sending and receiving task and bind it to the corresponding business core.
步骤6:可选的,在步骤5的基础上,关闭业务核上的时钟中断,减少不必要的系统调度带来的时间消耗,此时数据转发任务完全占用业务核处理时间,充分利用CPU核性能。Step 6: Optionally, on the basis of step 5, turn off the clock interruption on the service core to reduce the time consumption caused by unnecessary system scheduling. At this time, the data forwarding task completely takes up the processing time of the service core and makes full use of the CPU core performance.
步骤7:可选的,在步骤5的基础上,在控制核上运行系统调用代理任务。Step 7: Optionally, on the basis of Step 5, run the system call agent task on the control core.
下面以一个具体的实施例详细描述根据本发明实施例的在多功能服务器系统的实施方式:The following describes in detail the implementation of the multifunctional server system according to the embodiment of the present invention with a specific embodiment:
随着SDN和虚拟化的发展,使用服务器架构软件自定义网络控制和计算节点,部署OVS,OpenStack等应用越来越广泛,本发明在该应用系统的实施方式为:With the development of SDN and virtualization, the use of server architecture software to customize network control and computing nodes, deployment of OVS, OpenStack and other applications are becoming more and more extensive. The implementation of the present invention in the application system is as follows:
步骤1:在服务器操作系统上打入本发明相关内核补丁。Step 1: Type in the relevant kernel patch of the present invention on the server operating system.
步骤2:根据服务器CPU核数目的多少以及是否足够业务使用的情况,如果CPU核数目足够,在系统启动阶段即将业务CPU核进行隔离,优选的,启动参数激活补丁,在业务软件运行前也可以充分利用每个CPU核。Step 2: According to the number of server CPU cores and whether it is sufficient for business use, if the number of CPU cores is sufficient, the business CPU cores will be isolated during the system startup phase. Preferably, the startup parameter activates the patch. It can also be used before the business software runs. Make full use of each CPU core.
步骤3:服务器上电,完成操作系统加载和相关应用服务的启动,可选的,指定CPU核和内存资源启动相应的虚机。Step 3: The server is powered on, the operating system is loaded and the related application services are started. Optionally, the CPU core and memory resources are specified to start the corresponding virtual machine.
步骤4:可选的,在步骤2的基础上,选择在宿主机或虚机中作为计算或者软转发交互业务的CPU核,同上述实施例相同的步骤3-步骤7,把业务核进行动态隔离,并绑定到业务核中执行。Step 4: Optionally, on the basis of step 2, select the CPU core in the host or virtual machine as the computing or soft forwarding interactive service. The same steps 3 to 7 as in the above embodiment, the service core is dynamically Isolate and bind to the business core for execution.
步骤5:可选的,重复上述步骤,实现业务核的回收和控制核的再利用。Step 5: Optionally, repeat the above steps to realize the recovery of business cores and the reuse of control cores.
根据本发明实施例的电子装置,如图9所示,电子装置包括:存储器901、处理器902及存储在存储器901上并可在处理器902上运行的计算机程序,计算机程序被处理器902执行时实现如上述的方法的步骤。According to the electronic device of the embodiment of the present invention, as shown in FIG. 9, the electronic device includes: a memory 901, a processor 902, and a computer program stored in the memory 901 and running on the processor 902, and the computer program is executed by the processor 902 When implementing the steps of the above-mentioned method.
根据本发明实施例的电子装置,通过执行本发明提出的基于多核系统的任务处理方法,在对称多处理的系统中,能动态平滑的切换为业务逻辑上的非对称多处理状态,使得业务处理任务完全独占业务核运行,不会因为系统抖动而造成瓶颈,影响业务性能和指标。According to the electronic device of the embodiment of the present invention, by executing the task processing method based on the multi-core system proposed by the present invention, in a symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that business processing Tasks completely exclusively run the business core, and will not cause bottlenecks due to system jitter, which will affect business performance and indicators.
根据本发明实施例的计算机存储介质,计算机存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上述的基于多核系统的任务处理方法的步骤。According to the computer storage medium of the embodiment of the present invention, a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the steps of the task processing method based on the multi-core system as described above are realized.
根据本发明实施例的计算机存储介质,通过执行本发明提出的基于多核系统的任务处理方法,在对称多处理的系统中,能动态平滑的切换为业务逻辑上的非对称多处理状态,使得业务处理任务完全独占业务核运行,从而充分利用了单核CPU处理能力,不会因为系统抖动而造成瓶颈,影响业务性能和指标。According to the computer storage medium of the embodiment of the present invention, by executing the task processing method based on the multi-core system proposed by the present invention, in a symmetric multi-processing system, it can dynamically and smoothly switch to the asymmetric multi-processing state in business logic, so that the business The processing tasks are completely exclusive to the operation of the business core, thus making full use of the single-core CPU processing capacity, and will not cause bottlenecks due to system jitter, affecting business performance and indicators.
通过具体实施方式的说明,应当可对本发明为达成预定目的所采取的技术手段及功效得以更加深入且具体的了解,然而所附图示仅是提供参考与说明之用,并非用来对本发明加以限制。Through the description of the specific embodiments, it should be possible to have a more in-depth and specific understanding of the technical means and effects adopted by the present invention to achieve the intended purpose. However, the attached drawings are only for reference and explanation, and are not used to describe the present invention. limit.

Claims (10)

  1. 一种基于多核系统的任务处理方法,包括:A task processing method based on a multi-core system, including:
    将CPU核划分为业务核集合域和控制核集合域;Divide the CPU core into a service core collection domain and a control core collection domain;
    将业务处理任务绑定到所述业务核集合域中的业务核上,由所述业务核处理所述业务处理任务。The service processing task is bound to the service core in the service core collection domain, and the service core processes the service processing task.
  2. 根据权利要求1所述的基于多核系统的任务处理方法,其中,所述将CPU核划分为业务核集合域和控制核集合域,包括:The task processing method based on a multi-core system according to claim 1, wherein the dividing the CPU cores into a service core set domain and a control core set domain comprises:
    使所有CPU核均处于在线状态;Make all CPU cores online;
    从所有CPU核中选出部分CPU核作为控制核,以形成所述控制核集合域;Select some CPU cores from all CPU cores as control cores to form the control core set domain;
    将其余CPU核作为业务核,并将所述业务核进行离线后再上线的处理以形成所述业务核集合域。The remaining CPU cores are used as service cores, and the service cores are processed offline and then online to form the service core set domain.
  3. 根据权利要求2所述的基于多核系统的任务处理方法,还包括:The task processing method based on a multi-core system according to claim 2, further comprising:
    当所有CPU核均处于在线状态时,将任务分配至所有CPU核进行处理;When all CPU cores are online, assign tasks to all CPU cores for processing;
    所述业务核离线后,将所述业务核中的任务迁移至所述控制核。After the business core is offline, the tasks in the business core are migrated to the control core.
  4. 根据权利要求2所述的基于多核系统的任务处理方法,还包括:The task processing method based on a multi-core system according to claim 2, further comprising:
    在所述业务核再上线之前,打开所述业务核的时钟中断,并发送上线通知给操作系统。Before the service core goes online again, the clock interrupt of the service core is turned on, and an online notification is sent to the operating system.
  5. 根据权利要求4所述的基于多核系统的任务处理方法,还包括:The task processing method based on the multi-core system according to claim 4, further comprising:
    在将业务处理任务绑定到所述业务核集合域中的业务核上之后,关闭所述业务核的时钟中断。After the service processing task is bound to the service core in the service core set domain, the clock interruption of the service core is turned off.
  6. 根据权利要求1所述的基于多核系统的任务处理方法,还包括:The task processing method based on a multi-core system according to claim 1, further comprising:
    在所述控制核上运行系统调用代理任务;Run a system call agent task on the control core;
    通过共享内存的方式,使所述业务核根据在所述控制核上运行所述系统调用代理任务的运行结果进行系统调用。By means of shared memory, the service core is made to perform system calls according to the running results of the system call agent task running on the control core.
  7. 根据权利要求6所述的基于多核系统的任务处理方法,其中,所述通过共享内存队列的方式,使所述业务核根据所述系统调用代理任务进行系统调用,包括:7. The task processing method based on a multi-core system according to claim 6, wherein the method of sharing a memory queue to enable the service core to make a system call according to the system call agent task comprises:
    分配所述共享内存,所述共享内存包括系统调用描述符;Allocating the shared memory, where the shared memory includes a system call descriptor;
    将所述业务核进行系统调用时的系统调用参数信息写到所述描述符中,并将所述描述符状态修改为请求中;Write system call parameter information when the service core makes a system call into the descriptor, and modify the descriptor status to request;
    通过所述控制核查找状态为请求中的所述描述符,并基于所述描述符中的系统调用参数信息执行系统调用。The control core searches for the descriptor whose status is in the request, and executes the system call based on the system call parameter information in the descriptor.
  8. 一种基于多核系统的任务处理装置,包括:A task processing device based on a multi-core system, including:
    划分模块,用于将CPU核划分为业务核集合域和控制核集合域;The division module is used to divide the CPU core into a service core collection domain and a control core collection domain;
    任务处理模块,用于将业务处理任务绑定到所述业务核集合域中的业务核上,由所述业务核处理所述业务处理任务。The task processing module is used to bind business processing tasks to the business cores in the business core set domain, and the business cores process the business processing tasks.
  9. 一种电子装置,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述计算机程序被所述处理器执行时实现如权利要求1至7中任一项所述的方法的步骤。An electronic device, comprising: a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the computer program is executed by the processor to implement 7. The steps of any one of the methods.
  10. 一种计算机存储介质,存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至7中任一项所述的基于多核系统的任务处理方法的步骤。A computer storage medium storing a computer program, wherein when the computer program is executed by a processor, the steps of the task processing method based on a multi-core system according to any one of claims 1 to 7 are realized.
PCT/CN2020/100834 2019-08-02 2020-07-08 Task processing method, device, and computer-readable storage medium based on multi-core system WO2021022964A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910714824.8 2019-08-02
CN201910714824.8A CN112306669A (en) 2019-08-02 2019-08-02 Task processing method and device based on multi-core system

Publications (1)

Publication Number Publication Date
WO2021022964A1 true WO2021022964A1 (en) 2021-02-11

Family

ID=74486593

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/100834 WO2021022964A1 (en) 2019-08-02 2020-07-08 Task processing method, device, and computer-readable storage medium based on multi-core system

Country Status (2)

Country Link
CN (1) CN112306669A (en)
WO (1) WO2021022964A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113391821A (en) * 2021-05-11 2021-09-14 中国电力科学研究院有限公司 Asymmetric multiprocessor embedded operating system
CN113778936A (en) * 2021-08-17 2021-12-10 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Performance optimization method of domestic embedded DSP operating system
CN113821174A (en) * 2021-09-26 2021-12-21 迈普通信技术股份有限公司 Storage processing method, device, network card equipment and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115098430B (en) * 2022-06-27 2024-03-19 西安电子科技大学 Inter-core communication priority scheduling method based on AMP architecture

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662740A (en) * 2012-03-29 2012-09-12 迈普通信技术股份有限公司 Asymmetric multi-core system and realization method thereof
US20140351828A1 (en) * 2013-05-27 2014-11-27 Electronics And Telecommunications Research Institute Apparatus and method for controlling multi-core system on chip
CN104899089A (en) * 2015-05-25 2015-09-09 常州北大众志网络计算机有限公司 Task scheduling method in heterogeneous multi-core architecture
CN108958944A (en) * 2018-07-26 2018-12-07 郑州云海信息技术有限公司 A kind of multiple core processing system and its method for allocating tasks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662740A (en) * 2012-03-29 2012-09-12 迈普通信技术股份有限公司 Asymmetric multi-core system and realization method thereof
US20140351828A1 (en) * 2013-05-27 2014-11-27 Electronics And Telecommunications Research Institute Apparatus and method for controlling multi-core system on chip
CN104899089A (en) * 2015-05-25 2015-09-09 常州北大众志网络计算机有限公司 Task scheduling method in heterogeneous multi-core architecture
CN108958944A (en) * 2018-07-26 2018-12-07 郑州云海信息技术有限公司 A kind of multiple core processing system and its method for allocating tasks

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113391821A (en) * 2021-05-11 2021-09-14 中国电力科学研究院有限公司 Asymmetric multiprocessor embedded operating system
CN113778936A (en) * 2021-08-17 2021-12-10 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Performance optimization method of domestic embedded DSP operating system
CN113821174A (en) * 2021-09-26 2021-12-21 迈普通信技术股份有限公司 Storage processing method, device, network card equipment and storage medium
CN113821174B (en) * 2021-09-26 2024-03-22 迈普通信技术股份有限公司 Storage processing method, storage processing device, network card equipment and storage medium

Also Published As

Publication number Publication date
CN112306669A (en) 2021-02-02

Similar Documents

Publication Publication Date Title
WO2021022964A1 (en) Task processing method, device, and computer-readable storage medium based on multi-core system
US10891158B2 (en) Task scheduling method and apparatus
EP3358463B1 (en) Method, device and system for implementing hardware acceleration processing
US9996401B2 (en) Task processing method and virtual machine
US20190317802A1 (en) Architecture for offload of linked work assignments
CN105579961B (en) Data processing system, operating method and hardware unit for data processing system
US9135060B2 (en) Method and apparatus for migrating task in multicore platform
WO2016078178A1 (en) Virtual cpu scheduling method
WO2019223596A1 (en) Method, device, and apparatus for event processing, and storage medium
JP2000330806A (en) Computer system
US20150254113A1 (en) Lock Spin Wait Operation for Multi-Threaded Applications in a Multi-Core Computing Environment
US20110265093A1 (en) Computer System and Program Product
WO2023103296A1 (en) Write data cache method and system, device, and storage medium
EP3598310B1 (en) Network interface device and host processing device
US20140068165A1 (en) Splitting a real-time thread between the user and kernel space
US20070239890A1 (en) Method, system and program storage device for preventing a real-time application from running out of free threads when the real-time application receives a device interface request
CN113946445A (en) Multithreading module based on ASIC and multithreading control method
US11429438B2 (en) Network interface device and host processing device
JP7346649B2 (en) Synchronous control system and method
US20030014558A1 (en) Batch interrupts handling device, virtual shared memory and multiple concurrent processing device
US20130247065A1 (en) Apparatus and method for executing multi-operating systems
US9619277B2 (en) Computer with plurality of processors sharing process queue, and process dispatch processing method
WO2022174442A1 (en) Multi-core processor, multi-core processor processing method, and related device
US11954534B2 (en) Scheduling in a container orchestration system utilizing hardware topology hints
CN110333899B (en) Data processing method, device and 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: 20851187

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20851187

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20851187

Country of ref document: EP

Kind code of ref document: A1