WO2012016472A1 - 多核CPU加载Linux操作系统的方法及系统 - Google Patents

多核CPU加载Linux操作系统的方法及系统 Download PDF

Info

Publication number
WO2012016472A1
WO2012016472A1 PCT/CN2011/074713 CN2011074713W WO2012016472A1 WO 2012016472 A1 WO2012016472 A1 WO 2012016472A1 CN 2011074713 W CN2011074713 W CN 2011074713W WO 2012016472 A1 WO2012016472 A1 WO 2012016472A1
Authority
WO
WIPO (PCT)
Prior art keywords
core
cpu
data
operating system
control
Prior art date
Application number
PCT/CN2011/074713
Other languages
English (en)
French (fr)
Inventor
李弘博
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012016472A1 publication Critical patent/WO2012016472A1/zh

Links

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/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system

Definitions

  • the present invention relates to the field of multi-core CPUs using the Linux operating system, and more particularly to a method and system for a multi-core CPU-powered Linux operating system.
  • BACKGROUND Currently, multi-core CPUs are more and more widely used. Compared with traditional single-core CPUs, multi-core CPUs have more parallel processing capabilities, higher computational density, and lower power consumption. In this architecture, multicore
  • the CPU runs a single copy of the operating system, sharing resources such as cache, memory, and I/O bus.
  • AMP asymmetric multiprocessing
  • SMP Symmetric multiprocessing
  • BMP Bound multiprocessing
  • each CPU core runs a separate operating system or a copy of the same operating system.
  • all CPU cores are managed by one operating system, and the process is not bound to a specific kernel.
  • the hybrid multiprocessing approach is based on symmetric multiprocessing, where all CPU cores are managed uniformly by an operating system, but processes can be bound to a specific kernel.
  • Asymmetric multiprocessing is mainly used in the traditional single-core CPU operating environment. A process always runs in the same kernel. On a multi-core CPU, it is easy to cause a kernel to be either underutilized or overutilized. Symmetric multi-processing is used by the operating system to monitor the running status of the system in real time. The resources are allocated reasonably among the multiple cores, so that the load can be evenly distributed to all the cores, but some system resources may be wasted on frequent process switching. Hybrid multiprocessing takes advantage of the first two approaches. In Linux operating systems running in symmetric multiprocessing, process bindings allow processes to run only in the same kernel.
  • control CPU is a CPU that processes more complex services and controls, maintains, and manages the entire operating system when multiple CPUs run the Linux operating system in SMP or BMP mode.
  • Control the CPU to run the system management process support the full Linux operating system, can handle all complex services, but the performance is poor.
  • Data CPU only focuses on data processing, focusing on the performance of processing, requiring processing of as many services as possible within a certain period of time. Run only one task. Therefore, for some performance-oriented data processing, it needs to be put on the data core to execute. This puts two requirements on the loading of the Linux operating system on the multi-core CPU:
  • Control CPU, data CPU can not interfere with each other.
  • the above requirements 1) can be achieved by SMP.
  • the above requirements 2) can be realized by the BMP method in theory, that is, the way in which the process is bound to the CPU, but the implementation of the BMP requires all processes to be bound to the CPU, which is very cumbersome to operate. Complex, difficult to maintain, and reduces system maintainability, portability, and availability.
  • SUMMARY OF THE INVENTION It is an object of the present invention to provide an improved multi-core CPU loading method for a Linux operating system that does not affect the control core and data cores and does not require all processes to be bound to the CPU.
  • the present invention provides a method for loading a Linux operating system by a multi-core CPU, where the multi-core CPU includes: at least one control core and at least one data core, wherein the following steps are included: Step 4: Translating one of the at least one control core as a main core to load the Linux operating system, and during the initialization process, waking up all the slave cores, causing all the slave cores to enter a predetermined infinite loop state; Step B, the master core sets the CPU bitmap, The CPU bitmap includes only the control core; Step C, the main core performs symmetric multiprocessing initialization of the Linux operating system, and when the CPU bitmap includes other control cores other than the main core, according to The symmetric multi-processing manner performs a second wake-up on the other control cores except the primary core; Step D, the primary core causes each of the at least one data core to enter a respective entry function.
  • the step D further includes: the primary core allocates a memory space, where the memory space is used as a stack and a global data area of the at least one data core;
  • the main core configures a stack pointer, a global data pointer, and an entry function for each data core in the at least one data core.
  • step 4 collecting E, each data core in the at least one data core loading a predetermined service processing process.
  • each data core in the at least one data core separately entering a respective entry function, and after entering the respective entry function, Configure interrupts, fast remap buffers, and/or exception handling functions for this data core.
  • a multi-core CPU system including: at least one control core and at least one data core, wherein the control core as the primary core includes: a first processing module configured to load a Linux operating system and initialized During the process, all slave cores are woken up, and all slave cores enter a predetermined infinite loop state; a bitmap setting module is set to set a CPU bitmap, so that only the control core is included in the CPU bitmap; the second processing module is set to Performing symmetric multiprocessing initialization of the Linux operating system, and when the CPU bitmap includes other control cores other than the primary core, performing other control cores other than the primary core in a symmetric multiprocessing manner.
  • the second wake-up module is configured to cause each of the at least one data core to enter a respective entry function.
  • the multi-core CPU system wherein the third processing module further includes: an allocating module configured to allocate a memory space, where the memory space is used as a stack and a global data area of the at least one data core CPU; a configuration module, configured to configure a stack pointer, a global data pointer, and an entry function for each data core in the at least one data core.
  • each of the at least one data core comprises: a fourth processing module configured to load a predetermined service processing process.
  • each of the at least one data core further comprises: a second configuration module, configured to: after entering the respective entry function, configuring the data core before loading a predetermined service processing process Interrupts, fast re-addressable buffers, and/or exception handling functions.
  • a second configuration module configured to: after entering the respective entry function, configuring the data core before loading a predetermined service processing process Interrupts, fast re-addressable buffers, and/or exception handling functions.
  • the main core realizes the second wake-up by making each data core perform its own entry function. In this way, after all the CPUs are booted, all CPUs only need to load a Linux operating system kernel, and the control core and the data core do not affect each other.
  • the data core is not managed by the Linux operating system, but only runs itself. Data processing flow. Compared with the existing BMP technology, the method and system of the present invention do not need to bind all the processes - and the CPU, which improves the flexibility, ease of use and maintainability of the Linux system, and makes the relationship between the multiple cores The division is also more clear.
  • 1 is a schematic flowchart of a method for loading a Linux operating system by a multi-core CPU according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of partitioning a multi-core CPU in a method for loading a Linux operating system by a multi-core CPU according to another embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a method for loading a Linux operating system by a multi-core CPU according to another embodiment of the present invention.
  • DETAILED DESCRIPTION OF THE INVENTION The present invention will be described in detail below with reference to the drawings and specific embodiments.
  • FIG. 1 is a schematic flowchart diagram of a method for loading a Linux operating system by a multi-core CPU according to an embodiment of the present invention.
  • the multi-core CPU includes: at least one control core and at least one data core; the data core may include multiple CPUs, and each CPU may be configured to run only one task for quickly processing a predetermined service.
  • the main core the main CPU
  • the main CPU is the first CPU to load the Linux operating system. It completes the main system configuration and initial ⁇ actions, and is responsible for waking up other CPUs. From the core, that is, from the CPU, including the CPU other than the main core.
  • the method for loading a Linux operating system by the multi-core CPU of the embodiment includes the following steps: Step 101: One of the at least one control core loads the Linux operating system as a main core, and wakes up all the slave cores during the initialization process.
  • Step 102 the master core sets the CPU bitmap, and the CPU bitmap only includes the control core;
  • the CPU bitmap is a bit representation of the multi-core CPU in place by a variable, one bit of the variable ( Bit) corresponds to one CPU;
  • Step 103 the main core performs symmetric multiprocessing initialization of the Linux operating system, and when the CPU bitmap includes other control cores other than the main core, the symmetric multiprocessing is performed in addition to the main core
  • the other control core performs the second wake-up; in this step, the main core will load the Linux operating system into the CPU included in the CPU bitmap according to the SMP method. Since the CPU bitmap only contains the control core, the main core only controls the core according to the control core.
  • the SMP method records the Linux operating system, and the data core remains in the original infinite loop state;
  • the master core causes each of the at least one data core to enter a respective entry function.
  • the CPU bitmap only includes the control core and does not include the data core, so that the main core is
  • the CPU in the CPU bitmap is loaded with Linux in the SMP mode, since the CPU bitmap only contains the control core, the CPU only loads the Linux operating system on the control core, and the Linux operating system only It is possible to manage all control cores in a unified manner and cannot manage data cores.
  • the second waking is performed by entering the corresponding entry function, and after the data core enters the corresponding entry function, the predetermined service process can be started. In this way, it is guaranteed that the data core can realize that the data core only runs one task and quickly processes a certain service.
  • the data core of the method of the present invention is not uniformly managed by Linux, so that it is not necessary to bind all processes - and the CPU, thereby improving the flexibility, ease of use and maintainability of the Linux system. Sex, and make the division between multiple cores more clear.
  • the method further includes: the primary core allocates a memory space, where the memory space is used as a stack and a global data area of the at least one data core; A stack pointer, a global data pointer, and an entry function for each data core in the at least one data core are separately configured.
  • the method further includes: Step 105: Each data core in the at least one data core loads a predetermined service processing process.
  • the method further includes: each data core in the at least one data core respectively enters a respective entry function, and configures the data after entering the respective entry function.
  • Kernel interrupts, fast remap buffers, and/or exception handlers The method of the embodiment of the present invention will be described below with a specific example.
  • the 4-core CPU shown in FIG. 2 is taken as an example.
  • CPU0 and CPU1 are control cores;
  • CPU2 and CPU3 are data cores.
  • the method of the present invention is not limited to the 4-core CPU shown in this example.
  • the principles and methods described in the present invention can also be implemented on other core multi-core CPUs, and are also applicable to multi-core CPUs allocated by other methods. . As shown in FIG.
  • the method for loading the Linux operating system by the multi-core CPU of the embodiment includes the following steps: Step 301: The control core CPU as the main core loads the Linux operating system, and wakes up the slave core for the first time.
  • the control core CPU0 is used as the main core, that is, the main CPU, and the Linux operating system is loaded.
  • the CPU 0 loads the Linux operating system according to the existing normal process, and the first call is made during the initialization process.
  • Wake up other states as slave CPUs to bring the core into a predetermined infinite loop these slave cores wait for the master core to wake up twice during subsequent boot.
  • the main core sets the CPU bitmap so that the bitmap contains only the control core, that is, the control CPU.
  • the primary core sets the CPU bitmap through the loaded Linux operating system.
  • the CPU bitmap may not include all the control cores. Specifically, which control cores are specifically included in the CPU bitmap are set by the Linux operating system.
  • the CPU bitmap is used to represent the in-position condition of a multi-core CPU by a variable. One bit (bit) of this variable corresponds to one CPU.
  • the bits of the CPU bitmap are used to identify the properties of the CPU.
  • the CPU bitmap is a binary variable, each bit of the variable corresponding to a CPU, and the value of the bit identifies an attribute of the corresponding CPU.
  • each bit in the CPU bitmap cpu_possible_map is used to identify whether the corresponding CPU supports hot swap.
  • the CPU bitmap cpu_possible_map shows the in-position of the CPU that supports hot swapping in the system; each bit in the CPU bitmap cpu_present map is used to identify whether the corresponding CPU is currently inserted, such as a CPU has Insert, the corresponding bit of the CPU in the cpu_present map takes a value of 1, otherwise, the value is 0.
  • the CPU bitmap cpu_present map shows the in-position of the currently inserted CPU, and the inserted CPU can The online status can also be offline; each bit in the CPU bitmap cpu_oneline_map is used to identify whether the corresponding inserted CPU is online.
  • cpu_oneline_map is a subset of cpu_present map, showing the presence of the CPU in the currently inserted CPU.
  • none of the above three CPU bitmaps contain data cores. Which control cores are specifically included in the CPU bitmap are set by the Linux operating system. For normal SMP processes, hot swapping does not occur. After the boot is completed, the CPU bitmaps identified by the three bitmap variables are equal.
  • the above three CPU bitmaps are only exemplary and are not intended to limit the invention. In other embodiments of the invention, when there are other CPU bitmaps, the CPU bitmap set by the master core includes all CPU bitmaps present.
  • Step 302 start SMP Linux on the primary core.
  • the control core CPU0 performs the SMP initialization
  • the main core can only see other control cores except the main core.
  • CPU0 can only see CPU1.
  • CPU0 will wake up CPU1 according to the standard SMP mode, that is, break the waiting cycle of CPU 1 in the first step, and complete the initialization of SMP. So after the CPU 1 starts up, Will run Linux with SMP in the same way as CPUO.
  • the data core CPU2 and CPU3 are still in an infinite loop waiting state.
  • Step 303 The primary core wakes up the data core twice.
  • the main core CPU0 allocates a memory space for use as a stack and global data area of the data cores CPU2 and CPU3.
  • the stack pointer, global data pointer, and entry function of each data core CPU2 and CPU3 are separately configured. The purpose of this is to separate the data core from the control core stack and no longer be managed by Linux.
  • the main core breaks the infinite loop of the data core CPU2 and CPU3, causing them to enter their respective entry functions, achieving a second wake-up of the data core.
  • Step 304 the data core starts a single process; specifically, the data core CPU2 and the CPU3 respectively enter respective entry functions, configure the interrupt of the data core, the fast re-addressable buffer TLB, the exception handling function, etc.;
  • the predetermined business process is loaded, and exemplarily, a single process is initiated by entering a predetermined data processing function, which is often an infinite loop process.
  • all CPUs are booted, fully meeting the following objectives: multi-core CPU loads the same Linux operating system kernel; control CPU: CPUO and CPU1 run Linux in SMP mode; data CPU: CPU2 and CPU3 respectively run a business process; Ability to share resources such as APIs, data structures, memory, etc.; Control processes on the CPU are not dispatched to the data CPU.
  • the embodiment of the present invention further provides a multi-core CPU system, including: at least one control core and at least one data core, wherein the control core as the primary core includes: a first processing module, configured to load a Linux operating system, and initialized During the process, all the slave cores are woken up, and all the slave cores enter a predetermined infinite loop state; the bitmap setting module is set to set the CPU bitmap so that only the control core is included in the CPU bitmap; the second processing module is set to Perform symmetric multiprocessing initialization of the Linux operating system, and When the CPU bitmap includes other control cores other than the main core, the other control cores other than the main core are secondarily woken up in a symmetric multi-processing manner; the third processing module is configured to enable the Each of the at least one data core enters its respective entry function.
  • the control core as the primary core includes: a first processing module, configured to load a Linux operating system, and initialized During the process, all the slave cores are woken up, and
  • the multi-core CPU system wherein the third processing module further comprises: an allocation module, configured to allocate a memory space, where the memory space is used as a stack and a global data area of the at least one data core CPU And a first configuration module, configured to configure a stack pointer, a global data pointer, and an entry function of each data core in the at least one data core.
  • the multi-core CPU system wherein each of the at least one data core comprises: a fourth processing module, configured to load a predetermined service processing process.
  • each of the at least one data core further comprises: a second configuration module, configured to: before entering a respective entry function, before loading a predetermined service processing process, configuring the local Data core interrupts, fast re-address buffers, and/or exception handling functions.
  • a second configuration module configured to: before entering a respective entry function, before loading a predetermined service processing process, configuring the local Data core interrupts, fast re-address buffers, and/or exception handling functions.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Hardware Redundancy (AREA)
  • Microcomputers (AREA)

Description

多核 CPU加载 Linux操作系统的方法及系统 技术领域 本发明涉及釆用 Linux操作系统的多核 CPU领域,特别涉及一种多核 CPU 力口载 Linux操作系统的方法及系统。 背景技术 目前多核 CPU的应用越来越广泛, 与传统的单核 CPU相比, 多核 CPU具 有更强的并行处理能力、 更高的计算密度和更低的功耗。 在这种架构中, 多核
CPU运行操作系统的单一副本, 共享高速緩存、 内存、 I/O总线等资源。 目前 Linux 操作系统的运转方式主要有三种: 非对称多处理 ( AMP , Asymmetric multiprocessing )、 对称多处理 ( SMP, Symmetric multiprocessing )、 混合多处理 (BMP, Bound multiprocessing)。 非对称多处理的方式中, 每个 CPU 内核运行一个独立的操作系统或同一操作系统的拷贝。 对称多处理的方式中, 由一个操作系统统一管理所有的 CPU 内核, 进程并不与某一个特定内核相绑 定。 混合多处理的方式基于对称多处理, 由一个操作系统统一管理所有的 CPU 内核, 但是进程可以与某一个特定内核相绑定。 这三种方式各有优缺点。 非对称多处理主要用于传统的单核 CPU运行环 境, 一个进程总是运行在同一个内核中, 在多核 CPU 上, 容易导致一个内核 要么没有被充分利用, 要么被利用过度。 对称多处理由操作系统实时监控系统 的运行状态, 在多核之间合理分配资源, 使负载能够均匀地分配到所有内核之 上, 但可能导致一部分系统资源浪费在频繁的进程切换之上。 混合多处理吸取 了前两种方式的优点, 在以对称多处理方式运行的 Linux操作系统上, 通过进 程绑定可以使进程只能运行在同一个内核中。 本发明的发明人在实现本发明的过程中发现: 在釆用多核 CPU 的领域, 通常将多核划分为控制 CPU和数据 CPU。 控制 CPU是在多个 CPU以 SMP或 BMP方式运行 Linux操作系统时, 用于处理较复杂的业务, 并控制、 维护、 管 理整个操作系统的 CPU。 控制 CPU运行有关系统管理方面的进程, 支持完整 的 Linux操作系统, 能够处理所有复杂的业务, 但性能较差。 数据 CPU只专注 于数据处理, 注重的是处理的性能, 要求一定时间内处理尽可能多的业务, 往 往只运行一个任务。 故而对于某些注重性能的数据处理, 需要放到数据核上去 执行。 这就对 Linux操作系统在多核 CPU上的加载提出了两点要求:
1 ) 所有内核之间共享内存、 全局数据结构、 API等资源;
2 ) 控制 CPU、 数据 CPU之间不能相互千扰。 上述要求 1 ) 可通过 SMP方式实现。 上述要求 2 ) 理论上可通过 BMP方 式实现, 即釆用进程与 CPU绑定的方式, 但利用这种 BMP的方式实现时需要 将所有的进程——和 CPU 进行绑定, 这样操作起来十分繁瑣、 复杂, 维护起 来也十分困难, 且降低了系统的可维护性、 可移植性、 和可用性。 发明内容 本发明的目的是提供一种改进的多核 CPU加载 Linux操作系统的方法,该 方法使得控制核和数据核之间不会相互影响,且无需将所有的进程——与 CPU 进行绑定。 为了实现上述目的,本发明提供了一种多核 CPU加载 Linux操作系统的方 法, 所述多核 CPU 包括: 至少一个控制核和至少一个数据核, 其中, 包括如 下步 4聚: 步 4聚 A, 所述至少一个控制核中的一个作为主核加载 Linux操作系统, 并在初始化过程中, 唤醒所有从核, 使所有从核进入预定的死循环状态; 步骤 B, 所述主核设置 CPU位图, 所述 CPU位图中只包括控制核; 步骤 C, 所述 主核执行 Linux操作系统的对称多处理初始化,并当所述 CPU位图中包括除所 述主核外的其它控制核时, 按照对称多处理的方式对所述除主核外的其它控制 核进行二次唤醒; 步骤 D, 所述主核使所述至少一个数据核中的每个进入各自 的入口函数。 所述的方法, 其中, 所述步骤 C之后, 所述步骤 D之前还包括: 所述主核 分配内存空间, 所述内存空间用于作为所述至少一个数据核的堆栈和全局数据 区; 所述主核分别配置所述至少一个数据核中每个数据核的堆栈指针、 全局数 据指针和入口函数。 所述的方法, 其中, 所述步 4聚 D之后, 还包括: 步 4聚 E, 所述至少一个数 据核中的每个数据核加载预定的业务处理进程。 所述的方法, 其中, 所述步骤 D之后, 所述步骤 E之前, 还包括: 所述至 少一个数据核中的每个数据核分别进入各自的入口函数, 并在进入各自的入口 函数后, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理函数。 另一方面, 提供一种多核 CPU 系统, 其中, 包括: 至少一个控制核和至 少一个数据核,其中,作为主核的控制核包括:第一处理模块,设置为加载 Linux 操作系统, 并在初始化过程中, 唤醒所有从核, 使所有从核进入预定的死循环 状态; 位图设置模块, 设置为设置 CPU位图, 使所述 CPU位图中只包括控制 核; 第二处理模块, 设置为执行 Linux操作系统的对称多处理初始化, 并当所 述 CPU位图中包括除所述主核外的其它控制核时, 按照对称多处理的方式对 所述除主核外的其它控制核进行二次唤醒; 第三处理模块, 设置为使所述至少 一个数据核中的每个进入各自的入口函数。 所述的多核 CPU 系统, 其中, 所述第三处理模块还包括: 分配模块, 设 置为分配内存空间, 所述内存空间用于作为所述至少一个数据核 CPU 的堆栈 和全局数据区; 第一配置模块, 设置为配置所述至少一个数据核中每个数据核 的堆栈指针、 全局数据指针和入口函数。 所述的多核 CPU 系统, 其中, 所述至少一个数据核中的每个包括: 第四 处理模块, 设置为加载预定的业务处理进程。 所述的多核 CPU 系统, 其中, 所述至少一个数据核中的每个还包括: 第 二配置模块, 设置为在进入各自的入口函数后, 加载预定的业务处理进程前, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理函数。 本发明的技术效果在于: 通过在主核加载 Linux操作系统、 并首次唤醒所 有从核进入死循环状态后, 设置 CPU位图, 使得 CPU位图中只包括控制核, 这样在主核执行 SMP初始化时, 只会以 SMP的方式二次唤醒其它控制核, 而 不会影响到数据核; 对于数据核, 主核通过使每个数据核进行各自的入口函数 实现二次唤醒。这样,所有的 CPU启动完毕后,所有的 CPU只需加载一个 Linux 操作系统内核, 且控制核和数据核之间不会相互影响, 数据核能不受 Linux操 作系统的统一管理, 而是只运行自身的数据处理流程。 与现有的 BMP技术相 比,本发明的方法及系统无需将所有的进程——和 CPU进行绑定,提高了 Linux 系统的灵活性、 易用性和可维护性, 且使得多核之间的划分也更加清晰明了。 附图说明 图 1为本发明一实施例的多核 CPU加载 Linux操作系统的方法的流程示意 图; 图 2为本发明另一实施例的多核 CPU加载 Linux操作系统的方法中,多核 CPU的划分示意图; 图 3为本发明另一实施例的多核 CPU加载 Linux操作系统的方法的流程示 意图。 具体实施方式 为使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图及具体实 施例对本发明进行详细描述。 图 1为本发明实施例的多核 CPU加载 Linux操作系统的方法的流程示意 图。 其中, 多核 CPU 包括: 至少一个控制核和至少一个数据核; 数据核, 可 以包括多个 CPU, 每个 CPU可设定只运行一个任务, 用于快速的处理预定的 某项业务。加载 Linux操作系统的过程中,主核即主 CPU,是第一个加载 Linux 操作系统的 CPU, 完成主要的系统配置、 初始^ ^动作, 负责唤醒其他 CPU。 从核即从 CPU, 包括除主核之外的 CPU。 如图 1 , 该实施例的多核 CPU加载 Linux操作系统的方法包括如下步骤: 步骤 101 , 至少一个控制核中的一个作为主核加载 Linux操作系统, 并在 初始化过程中, 唤醒所有从核、 使所有从核进入预定的死循环状态; 步骤 102 , 主核设置 CPU位图, CPU位图中只包括控制核; CPU位图为 通过一个变量表示多核 CPU 的在位情况, 此变量的一个比特 (bit )对应一个 CPU; 步骤 103 , 主核执行 Linux操作系统的对称多处理初始化, 并当 CPU位图 中包括除主核外的其它控制核时, 按照对称多处理的方式对除主核外的其它控 制核进行二次唤醒; 该步骤中, 主核将按照 SMP的方式对 CPU位图中包含的 CPU加载 Linux 操作系统, 由于 CPU位图中只包含控制核, 则主核只对控制核按照 SMP的方 式记载 Linux操作系统, 而数据核仍保持原来的死循环状态; 步骤 104, 主核使至少一个数据核中的每个进入各自的入口函数。 本发明实施例的方法, 在主核加载 Linux操作系统、 并唤醒从核进入死循 环状态后,通过设置 CPU位图,使 CPU位图中只包含控制核而不包含数据核, 这样主核在执行 Linux系统的 SMP初始化后, 并对 CPU位图中的 CPU按照 SMP的方式加载 Linux时, 由于 CPU位图中只包含控制核, 所以 CPU只会对 控制核加载 Linux操作系统, Linux操作系统只能统一管理所有的控制核, 而 无法对数据核进行管理。 而对于数据核, 则通过使其进入对应的入口函数, 进 而进行二次唤醒,数据核进入对应的入口函数后, 即可启动预定的业务进程了。 这样, 保证了数据核能够实现数据核只运行一个任务, 快速处理某项业务。 与 现有的 BMP技术相比, 本发明的方法数据核不受 Linux的统一管理, 从而无 需将所有的进程——和 CPU进行绑定, 提高了 Linux系统的灵活性、 易用性和 可维护性, 且使得多核之间的划分也更加清晰明了。 本发明实施例的方法中, 步骤 103之后, 步骤 104之前还包括: 所述主核 分配内存空间, 所述内存空间用于作为所述至少一个数据核的堆栈和全局数据 区; 所述主核分别配置所述至少一个数据核中每个数据核的堆栈指针、 全局数 据指针和入口函数。 本发明实施例的方法中, 步骤 104之后, 还包括: 步骤 105 , 所述至少一 个数据核中的每个数据核加载预定的业务处理进程。 本发明实施例的方法中, 步骤 104之后, 步骤 105之前, 还包括: 所述至 少一个数据核中的每个数据核分别进入各自的入口函数, 并在进入各自的入口 函数后, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理函数。 下面以一具体例子来对本发明实施例的方法进行说明。 该例中, 以图 2所 示的 4核 CPU为例。如图 2,该例中, CPU0和 CPU1为控制核; CPU2和 CPU3 为数据核。 需要说明是, 本发明的方法不仅限于该例所示的 4核 CPU, 本发明 中描述的原理和方法同样可以实现在其他核数的多核 CPU 上, 同样适用于以 其他方法分配的多核 CPU上。 如图 3 , 该实施例的多核 CPU加载 Linux操作 系统的方法包括如下步骤: 步骤 301 , 作为主核的控制核 CPU加载 Linux操作系统, 首次唤醒从核。 具体地, 控制核 CPU0作为主核即主 CPU, 加载 Linux操作系统, 示例性 地, CPU0按照现有正常流程加载 Linux操作系统, 在初始化过程中, 首次唤 醒其他作为从核的 CPU 以使从核进入预定的死循环的状态, 这些从核等待主 核在后续的启动过程中对它们进行二次唤醒。 然后, 主核设置 CPU位图, 使 位图中只包含控制核即控制 CPU, 该本例中为只包含 CPU0和 CPU1。 示例性 地, 主核通过加载的 Linux操作系统设置 CPU位图。 CPU位图可不包含全部 的控制核, 具体地 CPU位图中具体包含哪些控制核由 Linux操作系统设置。 CPU位图用于通过一个变量表示多核 CPU的在位情况,此变量的一个比特( bit ) 对应一个 CPU。 CPU位图的比特位用于标识出 CPU的属性。 示例性地, CPU 位图为二进制变量, 变量的每一比特与一 CPU对应, 该比特的取值标识出对 应 CPU的一个属性。本发明实施例通过以该方式设置 CPU位图,确保了 Linux 进程调度时, 不会将控制 CPU的进程调度到数据 CPU上。 示例性地, CPU位图 cpu_possible_map中的每一比特用于标识对应的 CPU 是否支持热插拔, 如某一 CPU支持热插拔, 则该 CPU对应的比特位取值为 1 , 否则, 取值为 0, CPU位图 cpu_possible_map示出了系统中支持热插拔的 CPU 的在位情况; CPU位图 cpu_ present map 中的每一比特用于标识对应的 CPU 当前是否已插入, 如某一 CPU已插入, 则 cpu_ present map中该 CPU对应的 比特位取值为 1 , 否则, 取值为 0, 该 CPU位图 cpu_ present map示出了当前 已插入的 CPU的在位情况, 已插入的 CPU可以处于在线状态也可以处于离线 状态; CPU位图 cpu_oneline_map中的每一比特用于标识对应的已插入的 CPU 是否处于在线状态, 如某一已插入的 CPU处于在线状态, 则 cpu_oneline_map 中该 CPU 对应的比特位取值为 1 , 否则, 为 0 , cpu_oneline_map 为 cpu_ present map的子集, 示出了当前已插入的 CPU中、 在线的 CPU的在位情况。 该例中, 上述三个 CPU位图中均不包含数据核。 CPU位图中具体包含哪些控 制核由 Linux操作系统设置。 对于正常的 SMP流程, 不发生热插拔, 启动完 成后, 这三个位图变量标识的 CPU位图相等。 上述三个 CPU位图只是示例性 地, 并不用于限制本发明。 本发明的其它实施例中, 当存在其它 CPU位图时, 主核设置的 CPU位图包括存在的所有 CPU位图。 步骤 302, 在主核上启动 SMP Linux。 具体地, 控制核 CPU0执行到 SMP初始化时, 因为步骤 301 中已经改变 了 CPU位图, 所以主核只能看到除主核外的其它控制核, 该例中, CPU0只能 看到 CPU1 , 这样 CPU0将按照标准的 SMP方式唤醒 CPU1 , 即打破第一步中 CPU 1的死循环等待状态, 使之完成 SMP的初始化。 这样 CPU 1启动完成后, 将和 CPUO—起以 SMP方式运行 Linux。 而此时, 数据核 CPU2和 CPU3仍处 于死循环等待的状态。 步骤 303 , 主核二次唤醒数据核。 具体地, 主核 CPU0分配内存空间, 该内存空间用于作为数据核 CPU2和 CPU3的堆栈和全局数据区。 分别配置各数据核 CPU2和 CPU3的堆栈指针、 全局数据指针和入口函数。 这样做的目的是使数据核和控制核的堆栈分离, 不 再受 Linux的统一管理。 从而, 主核打破了数据核 CPU2和 CPU3的死循环, 使它们进入各自的入口函数, 实现了对数据核的二次唤醒。 步骤 304, 数据核启动单进程; 具体地, 数据核 CPU2和 CPU3分别进入各自的入口函数, 配置本数据核 的中断、 快速重编址緩冲器 TLB、 异常处理函数等; 最后启动单进程即加载预 定的业务处理进程, 示例性地, 通过进入预定的数据处理函数来启动单进程, 该数据处理函数往往是一个死循环流程。 至此,所有 CPU启动完毕,完全满足如下目标:多核 CPU加载同一个 Linux 操作系统内核;控制 CPU: CPUO和 CPUl以 SMP方式运行 Linux;数据 CPU: CPU2和 CPU3分别运行一个业务进程; 多核 CPU之间能够共享 API、 数据结 构、 内存等资源; 控制 CPU上的进程不会调度到数据 CPU上。 综上所述, 多核 CPU利用本发明实施例的方法加载 Linux操作系统后, 所 有的 CPU只需加载一个 Linux操作系统内核, CPU0和 CPU1作为控制核以 SMP 方式运行 Linux, CPU2和 CPU3作为数据核只运行各自对应的一个数据处理进 程。 由于数据核只运行一个简单的任务, 不会发生进程上下文切换, 从而能够 显著的增加数据 CPU 的处理能量; 控制核、 数据核之间不会相互影响, 分别 有自己独立的中断和异常处理流程; 同时, 由于软件层面控制核、 数据核的代 码链接在一起, 从而能够共享全局数据、 内存、 API等资源, 极大地提高了代 码开发的效率。 本发明实施例还提供了一种多核 CPU 系统, 包括: 至少一个控制核和至 少一个数据核,其中,作为主核的控制核包括:第一处理模块,设置为加载 Linux 操作系统, 并在初始化过程中, 唤醒所有从核、 使所有从核进入预定的死循环 状态; 位图设置模块, 设置为设置 CPU位图, 使所述 CPU位图中只包括控制 核; 第二处理模块, 设置为执行 Linux操作系统的对称多处理初始化, 并当所 述 CPU位图中包括除所述主核外的其它控制核时, 按照对称多处理的方式对 所述除主核外的其它控制核进行二次唤醒; 第三处理模块, 设置为使所述至少 一个数据核中的每个进入各自的入口函数。 优选地, 所述的多核 CPU 系统, 其中, 所述第三处理模块还包括: 分配 模块, 设置为分配内存空间, 所述内存空间用于作为所述至少一个数据核 CPU 的堆栈和全局数据区; 第一配置模块, 设置为配置所述至少一个数据核中每个 数据核的堆栈指针、 全局数据指针和入口函数。 优选地, 所述的多核 CPU 系统, 其中, 所述至少一个数据核中的每个包 括: 第四处理模块, 设置为加载预定的业务处理进程。 优选地, 所述的多核 CPU 系统, 其中, 所述至少一个数据核中的每个还 包括: 第二配置模块, 设置为在进入各自的入口函数后, 加载预定的业务处理 进程前, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理函数。 以上所述仅是本发明的优选实施方式, 应当指出, 对于本技术领域的普通 技术人员来说, 在不脱离本发明原理的前提下, 还可以作出若千改进和润饰, 这些改进和润饰也应视为本发明的保护范围。

Claims

权 利 要 求 书
1. 一种多核 CPU加载 Linux操作系统的方法, 所述多核 CPU包括: 至少 一个控制核和至少一个数据核, 包括如下步骤:
步骤 A, 所述至少一个控制核中的一个作为主核加载 Linux操作系 统, 并在初始^ ^过程中, 唤醒所有从核, 使所有从核进入预定的死循环 状态;
步骤 B , 所述主核设置 CPU位图, 所述 CPU位图中只包括控制核; 步骤 C, 所述主核执行 Linux操作系统的对称多处理初始化, 并当 所述 CPU位图中包括除所述主核外的其它控制核时,按照对称多处理的 方式对所述其它控制核进行二次唤醒;
步骤 D, 所述主核使所述至少一个数据核中的每个进入各自的入口 函数。
2. 根据权利要求 1所述的方法, 其中, 所述步骤 C之后, 所述步骤 D之前 还包括:
所述主核分配内存空间, 所述内存空间用于作为所述至少一个数据 核的堆栈和全局数据区;
所述主核分别配置所述至少一个数据核中每个数据核的堆栈指针、 全局数据指针和入口函数。
3. 根据权利要求 1或 2所述的方法, 其中, 所述步骤 D之后, 还包括: 步骤 E, 所述至少一个数据核中的每个数据核加载预定的业务处理 进程。
4. 根据权利要求 3所述的方法, 其中, 所述步骤 D之后, 所述步骤 E之前, 还包括:
所述至少一个数据核中的每个数据核分别进入各自的入口函数, 并 在进入各自的入口函数后, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理函数。
5. —种多核 CPU系统, 包括: 至少一个控制核和至少一个数据核, 其中, 作为主核的控制核包括:
第一处理模块, 设置为加载 Linux操作系统, 并在初始化过程中, 唤醒所有从核, 使所有从核进入预定的死循环 态;
位图设置模块, 设置为设置 CPU位图, 使所述 CPU位图中只包括 控制核;
第二处理模块, 设置为执行 Linux操作系统的对称多处理初始化, 并当所述 CPU位图中包括除所述主核外的其它控制核时,按照对称多处 理的方式对所述除主核外的其它控制核进行二次唤醒;
第三处理模块, 设置为使所述至少一个数据核中的每个进入各自的 入口函数。
6. 根据权利要求 5所述的多核 CPU系统,其中,所述第三处理模块还包括: 分配模块, 设置为分配内存空间, 所述内存空间用于作为所述至少 一个数据核 CPU的堆栈和全局数据区;
第一配置模块, 设置为配置所述至少一个数据核中每个数据核的堆 栈指针、 全局数据指针和入口函数。
7. 根据权利要求 5或 6所述的多核 CPU系统, 其中, 所述至少一个数据核 中的每个包括:
第四处理模块, 设置为加载预定的业务处理进程。
8. 根据权利要求 7所述的多核 CPU系统, 其中, 所述至少一个数据核中的 每个还包括:
第二配置模块, 设置为在进入各自的入口函数后, 加载预定的业务 处理进程前, 配置本数据核的中断、 快速重编址緩冲器、 和 /或异常处理 函数。
PCT/CN2011/074713 2010-08-03 2011-05-26 多核CPU加载Linux操作系统的方法及系统 WO2012016472A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010244460.0 2010-08-03
CN201010244460.0A CN101901159B (zh) 2010-08-03 2010-08-03 一种多核CPU加载Linux操作系统的方法及系统

Publications (1)

Publication Number Publication Date
WO2012016472A1 true WO2012016472A1 (zh) 2012-02-09

Family

ID=43226711

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/074713 WO2012016472A1 (zh) 2010-08-03 2011-05-26 多核CPU加载Linux操作系统的方法及系统

Country Status (2)

Country Link
CN (1) CN101901159B (zh)
WO (1) WO2012016472A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901159B (zh) * 2010-08-03 2014-04-30 中兴通讯股份有限公司 一种多核CPU加载Linux操作系统的方法及系统
CN106155730A (zh) * 2015-04-21 2016-11-23 北京信威通信技术股份有限公司 操作系统加载方法及装置
CN104793996A (zh) * 2015-04-29 2015-07-22 中芯睿智(北京)微电子科技有限公司 一种并行计算设备的任务调度方法及任务调度装置
CN106484632A (zh) * 2015-09-01 2017-03-08 华耀(中国)科技有限公司 在Linux系统用户空间分配连续物理内存的方法
CN106126241A (zh) * 2016-06-29 2016-11-16 上海友衷科技有限公司 一种Linux系统启动方法及系统
CN106254134A (zh) * 2016-08-29 2016-12-21 上海斐讯数据通信技术有限公司 一种网络设备及其对数据流进行管控的方法
CN109101283A (zh) * 2018-07-17 2018-12-28 北京元心科技有限公司 Gpu设备的控制方法、装置及电子设备
CN114489826A (zh) * 2020-11-09 2022-05-13 哲库科技(上海)有限公司 芯片运行方法、装置、存储介质及电子设备
CN113391821B (zh) * 2021-05-11 2023-03-10 中国电力科学研究院有限公司 一种非对称多处理器嵌入式操作系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246431A (zh) * 2008-03-10 2008-08-20 中兴通讯股份有限公司 加载多核不同操作系统映像的管理方法
CN101256512A (zh) * 2008-03-20 2008-09-03 中兴通讯股份有限公司 异构多核体系中主引导核的自动选举方法
CN101770401A (zh) * 2008-12-30 2010-07-07 北京天融信网络安全技术有限公司 一种建立多核运行环境的方法
CN101901159A (zh) * 2010-08-03 2010-12-01 中兴通讯股份有限公司 一种多核CPU加载Linux操作系统的方法及系统

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100361118C (zh) * 2005-03-01 2008-01-09 华为技术有限公司 一种多cpu系统及其控制方法
US20080077774A1 (en) * 2006-09-26 2008-03-27 Cool Lyle E Hierarchical parallelism for system initialization

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246431A (zh) * 2008-03-10 2008-08-20 中兴通讯股份有限公司 加载多核不同操作系统映像的管理方法
CN101256512A (zh) * 2008-03-20 2008-09-03 中兴通讯股份有限公司 异构多核体系中主引导核的自动选举方法
CN101770401A (zh) * 2008-12-30 2010-07-07 北京天融信网络安全技术有限公司 一种建立多核运行环境的方法
CN101901159A (zh) * 2010-08-03 2010-12-01 中兴通讯股份有限公司 一种多核CPU加载Linux操作系统的方法及系统

Also Published As

Publication number Publication date
CN101901159B (zh) 2014-04-30
CN101901159A (zh) 2010-12-01

Similar Documents

Publication Publication Date Title
WO2012016472A1 (zh) 多核CPU加载Linux操作系统的方法及系统
JP6359069B2 (ja) オペレーティングシステムと切り離される異種計算
US8321693B2 (en) Parallel processing method and system, for instance for supporting embedded cluster platforms, computer program product therefor
US9779042B2 (en) Resource management in a multicore architecture
TWI233545B (en) Mechanism for processor power state aware distribution of lowest priority interrupts
KR101239082B1 (ko) 멀티코어 아키텍처 내의 리소스 관리
US7433985B2 (en) Conditional and vectored system management interrupts
US6363453B1 (en) Parallel processor with redundancy of processor pairs
WO2013131340A1 (zh) 片上系统soc的多处理器的调度方法及装置
WO2016159765A1 (en) Many-core processor architecture and many-core operating system
CN104598426A (zh) 用于异构多核处理器系统的任务调度方法
WO2014139379A1 (zh) 一种异构操作系统中内核运行的方法及装置
US10459771B2 (en) Lightweight thread synchronization using shared memory state
CN108885559A (zh) 在多个处理器之间快速转移工作负载
CN111459622B (zh) 调度虚拟cpu的方法、装置、计算机设备和存储介质
CN116868167A (zh) 操作系统的运行控制方法和装置,以及嵌入式系统和芯片
US11243800B2 (en) Efficient virtual machine memory monitoring with hyper-threading
WO2022022185A1 (zh) 内核重启方法
US20180341482A1 (en) Method and arrangement for utilization of a processing arrangement
US20230161600A1 (en) Kernel reboot method
US20230063893A1 (en) Simultaneous-multi-threading (smt) aware processor allocation for cloud real-time workloads
US20230118846A1 (en) Systems and methods to reserve resources for workloads
Liu et al. Inter-Core Communication Mechanisms for Microkernel Operating System based on Signal Transmission and Shared Memory
JP2018049406A (ja) 複数プロセッサ間のタスク連携装置

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: 11814055

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: 11814055

Country of ref document: EP

Kind code of ref document: A1