WO2023169289A1 - Method and apparatus for switching execution status of process - Google Patents

Method and apparatus for switching execution status of process Download PDF

Info

Publication number
WO2023169289A1
WO2023169289A1 PCT/CN2023/079222 CN2023079222W WO2023169289A1 WO 2023169289 A1 WO2023169289 A1 WO 2023169289A1 CN 2023079222 W CN2023079222 W CN 2023079222W WO 2023169289 A1 WO2023169289 A1 WO 2023169289A1
Authority
WO
WIPO (PCT)
Prior art keywords
logical core
core
slave
state
exception
Prior art date
Application number
PCT/CN2023/079222
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 WO2023169289A1 publication Critical patent/WO2023169289A1/en

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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • 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/54Interprogram communication

Definitions

  • the present application relates to the field of processors, and in particular, to a method and device for switching execution states of a process.
  • heterogeneous computing refers to the combination of CPU, digital signal processing (DSP), graphics processing unit (GPU), application specific integrated circuit (ASIC), field programmable logic gate array (field Computing units with different process architectures, different instruction sets, and different functions such as programmable gate array (FPGA) are combined to form a hybrid computing system.
  • DSP digital signal processing
  • GPU graphics processing unit
  • ASIC application specific integrated circuit
  • FPGA field programmable logic gate array
  • the CPU physical core includes the ARM64 logical core and the ARM32 logical core.
  • the ARM64 logical core can execute one of the privilege levels EL0 to EL4, and the ARM32 logical core can execute the privilege level EL0, among which the privileges of EL0 The lowest level.
  • the ARM32 process specifically runs in the ARM32 logical core.
  • the ARM64 logic core and the ARM32 logic core need to be tightly coupled.
  • the ARM64 logic core needs to add new registers and vector table entries to support the ARM32 logic core.
  • the two logic cores cannot evolve independently.
  • This application provides a process execution state switching method and device, which are used to decouple two logical cores on the premise of flexibly switching the corresponding execution states of two logical cores, so that one of the logical cores can be independently evolved.
  • this application provides a method for switching the execution state of a process, which is applied to a CPU.
  • the CPU includes a physical core, and the physical core includes a master logical core and a slave logical core.
  • the method includes: if running on the slave When the process of the logical core meets the first condition, the running process is suspended from the logical core, and the pause position of the process is recorded.
  • the pause position can be used to determine the execution position when the process is run from the logical core next time, where the first condition is Instructs the process to perform the target operation, and the target operation can be executed when the execution state of the process is in the privileged state of the main logical core; switches the execution state of the process from the user mode of the slave logical core to the privileged state of the main logical core; in Processes run in the main logical core for the process to perform target operations.
  • the process when a process is run from a logical core and the process needs to perform a target operation, the process is run from the logical core Record the pause position of the process, which can be used to determine the execution position the next time the process is run in the slave logical core.
  • the master logical core and the slave logical core do not need to share registers, and can flexibly switch the corresponding execution states of the two logical cores.
  • one of the logic cores can be evolved independently.
  • recording the pause position of the process includes writing the pause position information into the configuration space through the slave logical core, and the configuration space is used for information interaction between the master logical core and the slave logical core.
  • the configuration space is used for information interaction between the slave logic core and the slave logical core.
  • the method also includes: switching the execution state of the process from the privileged state of the main logical core to the user state of the slave logical core; reading the pause position information from the configuration space through the slave logical core; In the logical core, the process continues from the paused position. In this way, after the main logical core completes the target operation, the slave logical core can continue to be started to continue running the process. Since the slave logical core has previously recorded the pause position, the slave logical core can continue to run from the pause position, thereby realizing that the process can Switch between two logical cores and the process can run without interruption.
  • the first condition includes the process triggering a first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions;
  • the method before switching the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, the method further includes: obtaining the virtual memory address corresponding to the target privilege level; determining the virtual memory address of the target privilege level; The memory address is not mapped to the physical memory address.
  • the main logical core accesses the virtual memory address corresponding to the target privilege level. If it is determined that the virtual memory address does not establish a mapping relationship with the physical memory address, a page fault is triggered.
  • the main logical core can process the process based on the triggered page fault.
  • the execution state falls from the user state of the main logical core to the target privilege level of the privileged state of the main logical core. In this way, by constructing a special exception (ie, page fault), the execution state of the process is dropped from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, thereby reducing the complexity of the execution of the process falling into the privileged state.
  • a special exception ie, page fault
  • the first condition includes the process receiving an interrupt, or the process triggering a RAS exception. Since interrupts or RAS exceptions are asynchronous events and need to be processed quickly, when the process running on the slave logical core receives an interrupt or triggers a RAS exception, the process can be processed through the hardware unit (or hardware part) in the CPU physical core. The execution state falls from the user state of the slave logical core to the target privilege level of the privileged state of the main logical core.
  • the method also includes: starting the process in the main logical core; if the instruction set of the process belongs to the instruction set running from the slave logical core, recording the starting position of the process and triggering the slave logical core to enter the running state. ;In the slave logical core, run the process from the starting position.
  • some processes such as mySql process, graph calculation process or encryption and decryption operators
  • start these processes in the main logical core it can be determined that these processes need to run in the slave logical core.
  • the starting position of the process is recorded through the main logical core, and the slave logical core is triggered to enter the running state, so that the slave logical core reads the starting position and runs the process at the starting position.
  • the method further includes: releasing the hardware resources of the physical core occupied by the main logical core when running the process; where the hardware resources include memory resources and/or input and output resources. In this way, the released hardware resources can be reused to run other processes, which helps to fully utilize the hardware resources.
  • the method also includes: recording one or more of the following information from the logical core: the reason why the running process is suspended on the logical core, the execution parameters corresponding to the target operation, and when the running process is suspended. Environment information, or privilege level information; where the privilege level information is used to indicate the privilege level of the privileged state of the main logical core when the process performs the target operation. In this way, the main logic core can correctly handle the target operation based on these parameters.
  • the slave logical core can run acceleration engines and algorithms, such as one or more of the mySql process, graph calculation process, or encryption and decryption operators. Compared with running these processes on the main logical core, it can Improve computing speed.
  • this application provides a device for switching the execution state of a process, and the device may be a CPU.
  • the device includes a processor and a memory; the memory is used to store a computer program; the processor is used to call the computer program stored in the memory to perform the following steps: if the process running in the slave logical core meets the first condition, the process in the slave logical core is suspended. process, and record the pause position of the process. The pause position is used to determine the execution position the next time the process is run from the logical core.
  • the first condition is used to indicate that the process is to perform the target operation, and the target operation is in the execution state of the process.
  • the processor when the processor records the pause position of the process, it is specifically used to: write the pause position information into the configuration space through the slave logical core, and the configuration space is used for information exchange between the master logical core and the slave logical core. Interaction.
  • the processor is also used to: switch the execution state of the process from the privileged state of the main logical core to the user state of the slave logical core; read the pause position information from the configuration space through the slave logical core; In the secondary logical core, the process continues from the pause position.
  • the first condition includes the process triggering a first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions;
  • the execution state is switched from the user state of the slave logical core to the privileged state of the master logical core, it is specifically used to: trigger the master logical core to run the process, so as to switch the execution state of the process from the user state of the slave logical core to the user state of the master logical core. state; determine the target privilege level corresponding to the first type of exception from the multiple privilege levels of the privileged state of the main logical core; switch the execution state of the process from the user mode of the main logical core to the target privilege level of the privileged state of the main logical core .
  • the processor before switching the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, the processor is also used to: obtain the virtual memory corresponding to the target privilege level. Address; determine that the virtual memory address is not mapped to the physical memory address.
  • the first condition includes the process receiving an interrupt or triggering a RAS exception.
  • the processor is also used to: start a process in the main logical core; if the instruction set of the process belongs to the instruction set running from the slave logical core, record the starting position of the process, and trigger entry from the slave logical core Running status; in the slave logical core, start running the process from the starting position.
  • the processor is also used to: release hardware resources of the physical core occupied by the main logical core when running the process; where the hardware resources include memory resources and/or input and output resources.
  • the processor is also used to record one or more of the following information from the logical core: the reason for suspending the running process on the slave logical core, the execution parameters corresponding to the target operation, and the suspension of operation.
  • this application provides a device for switching the execution state of a process, and the device may be a CPU.
  • the device includes a main logic core module and a slave logic core module.
  • the slave logic core module is used to determine that when the process running in the slave logic core module meets the first condition, it pauses the running process and records the pause position of the process. The pause position is used for next time.
  • the execution position is determined when the process is running in the slave logical core module, where the first condition is used to indicate that the process is to perform a target operation, and the target operation can be executed when the execution state of the process is in the privileged state of the main logical core module; the slave logical core module
  • the core module is also used to switch the execution state of the process from the user state of the slave logical core module to the privileged state of the main logical core module; the main logical core module is used to run the process so that the process can perform target operations.
  • the slave logical core module when the slave logical core module records the pause position of the process, it is specifically used to write the pause position information into the configuration space.
  • the configuration space is used for information interaction between the master logical core module and the slave logical core module. .
  • the main logical core module is also used to switch the execution state of the process from the privileged state of the main logical core module to the user mode of the slave logical core module; the slave logical core module is also used to read from the configuration space. Get the information of the pause position and continue running the process from the pause position.
  • the first condition includes the process triggering the first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions; from the specific use of the logical core module It is used to trigger the main logical core module to run the process, so as to switch the execution state of the process from the user mode of the slave logical core module to the user mode of the main logical core module; the main logical core module is specifically used for multiple privileged states of the slave main logical core module.
  • the target privilege level corresponding to the first type of exception is determined among the privilege levels, and the target privilege level is used to switch the execution state of the process from the user state of the main logical core module to the privileged state of the main logical core module.
  • the main logical core module is also used to obtain the corresponding target privilege level before switching the execution state of the process from the user mode of the main logical core module to the target privilege level of the privileged state of the main logical core module.
  • the virtual memory address determine that the virtual memory address does not have a mapping relationship with the physical memory address.
  • the first condition includes the process receiving an interrupt or triggering a RAS exception.
  • the main logical core module is also used to start the process. If the instruction set of the process belongs to the instruction set running from the slave logical core, the starting position of the process is recorded and the slave logical core module is triggered to enter the running state. ; The slave logic core module is also used to run the process from the starting position.
  • the main logical core module releases the hardware resources of the physical core occupied when running the process; where the hardware resources include memory resources and/or input and output resources.
  • the slave logical core module is also used to record one or more of the following information: the reason for suspending the running process on the slave logical core, the execution parameters corresponding to the target operation, and the reasons for suspending the running process. Environment information, or privilege level information; where the privilege level information is used to indicate the privilege level of the privileged state of the main logical core when the process performs the target operation.
  • embodiments of the present application provide a chip system, including: a processor and a memory.
  • the processor is coupled to the memory.
  • the memory is used to store programs or instructions. When the program or instructions are processed by the processor When executed, the chip system is caused to implement the method in the above first aspect or any possible implementation manner of the first aspect.
  • the present application provides a computer program product.
  • the computer program product includes a computer program or instructions.
  • the computer program or instructions are executed by a device, the first aspect or any possible implementation manner of the first aspect is implemented. Methods.
  • the present application provides a computer-readable storage medium.
  • Computer programs or instructions are stored in the computer-readable storage medium.
  • the above-mentioned first aspect or any of the first aspects is implemented. method in one possible implementation.
  • the present application provides a computing device, including a processor, the processor is connected to a memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that The computing device executes the method in the above first aspect or any possible implementation of the first aspect.
  • Figure 1 is a schematic diagram of an ARMv8-A architecture
  • Figure 2 is a schematic diagram of the process of switching between AArch64 and AArch32 execution states
  • FIG. 3 is an architectural schematic diagram of a chip system provided by this application.
  • Figure 4 is a schematic diagram of the running processes in a Master logical core and a Slave logical core provided by this application;
  • FIG. 5 is a schematic flow chart of an execution state switching method provided by this application.
  • FIG. 6 is a schematic diagram of a startup process provided by this application.
  • Figure 7 is a schematic diagram of a method for switching the execution state of a process provided by this application.
  • Figure 8 is a schematic diagram of a Master logical core provided by this application trapping a process into a target privilege level
  • Figure 9 is a schematic diagram of yet another method for switching the execution status of a process provided by this application.
  • Figure 10 is a schematic diagram of another method for switching the execution status of a process provided by this application.
  • FIG 11 is a schematic flowchart of yet another execution state switching method provided by this application.
  • a program is an ordered collection of instructions, it is just a static entity.
  • a process is the execution of a program on some data set.
  • a process is a dynamic entity with its own life cycle. Processes are created due to creation, run due to scheduling, placed in a waiting state due to waiting for resources or events, and canceled due to completion of tasks.
  • a process reflects the entire dynamic process of a program running on a certain data set.
  • a process When a process is executing user code, it is in the user running state (also called user mode). When a process is trapped in kernel code for execution due to a system call, the process is in the kernel running state (also called kernel state). The executed kernel code will use the kernel stack of the current process, and each process has its own kernel stack.
  • the user runs a program, and the process created by the program starts by running its own code in user mode.
  • the kernel code is called through system calls such as write and send.
  • the process enters the kernel address space to execute kernel code to complete the corresponding operation. After the kernel mode process is executed, it will return to the user mode.
  • User-mode processes cannot manipulate the kernel address space at will.
  • CPU is not equal to physical core, nor is it equal to logical core.
  • the physical core (physical core/processor) is a visible, real CPU core.
  • the physical core has independent circuit components and L1 and L2 caches, and can execute instructions independently.
  • Logical core/processor A core at the logical level within the same physical core.
  • a CPU can have multiple physical cores.
  • a physical core can be divided into multiple logical cores.
  • Real-time operating system refers to the core part of most operating systems. It consists of the parts of the operating system that manage memory, files, peripherals, and system resources.
  • Executable and Linkable Format (ELF) files refer to target files on Unix and X86-64 Linux.
  • the target file refers to the computer file used to store the target code.
  • the target file can contain machine code, data used by the code when running, debugging information, etc. It is the process of generating program files from source code files. mid product.
  • Synchronous operation means that when the caller calls, it needs to wait for the call to return the result before continuing to execute.
  • Asynchronous operations are the opposite of synchronous operations. After the caller issues a call, it does not need to wait for the call result, but continues to perform subsequent operations. The callee notifies the caller through the status, or handles the call by calling back the function.
  • Reliability means that the system must be as reliable as possible without unexpected crashes, restarts or even physical damage to the system.
  • Availability refers to the fact that the system must be able to work as long as possible without going offline. Even if some minor problems occur in the system, it will not affect the normal operation of the entire system.
  • Serviceability refers to the ability of the system to provide convenient diagnostic functions, such as system logs, dynamic detection and other means to facilitate system diagnosis and maintenance operations by managers, so as to detect and repair errors as early as possible. As a whole, the role of RAS is to ensure that the entire system runs reliably for as long as possible without going offline, and has a sufficiently powerful fault-tolerant mechanism.
  • Firmware is generally stored in the electrically erasable programmable ROM (EEPROM) or FLASH chip in the device.
  • Firmware is, for example, the basic input/output system BIOS (basic input/output system) on the computer motherboard.
  • Register is an integral part of the central processing unit. Registers are high-speed storage components with limited storage capacity. Registers can be used to temporarily store instructions, data and addresses.
  • the program status saving register (saved program status register, SPSR) is used to save the status of the program status register (current program status register, CPSR) so that the working status when the exception occurs can be restored after an exception returns. When a specific exception interrupt occurs, this register is used to store the contents of the current program status register. When exiting from an abnormal interrupt, SPSR can be used to restore CPSR.
  • the CPU physical core can include a master logical core and a slave logical core.
  • the CPU physical core can run multiple processes, and the multiple processes can run on the Master logical core or the Slave logical core.
  • the Master logical core is an ARM64 logical core and the Slave logical core is an ARM32 logical core
  • the ARM64 process can run in the ARM64 logical core
  • the ARM32 process can run in the ARM32 logical core.
  • no matter what kind of logical core a process is running in it can be started by the Master logical core.
  • the Master logical core determines that the process needs to run on the Slave logical core, it can call the Slave logical core so that the process Runs in the Slave logical core.
  • AArch32 (or ARM32) and AArch64 (or ARM64) can be supported at the same time.
  • the AArch64 execution state supports the A64 instruction set and can run ARM64 processes.
  • AArch32 execution state supports T32 and A32 instruction sets and can run ARM32 processes.
  • exception level A logical division of privilege levels at which a program runs. Exception levels are divided into the following four types:
  • EL1 operating system kernel
  • EL3 Low-level firmware, including Secure Monitor.
  • a piece of software such as an application, operating system kernel, or virtual machine monitor, occupies only one exception level.
  • the ARMv8-A architecture can be seen in Figure 1.
  • the execution state of the ARM32 logical core is AArch32
  • the execution state of the ARM64 logical core is AArch64.
  • AArch32 can correspond to the EL0 privilege level
  • AArch64 can correspond to the EL0 and EL1 privilege levels.
  • user-mode processes can be run in AARCH64 and AARCH32 execution states
  • kernel-mode processes can be run in the AArch64 execution state.
  • the ARMv8-A architecture can have the following characteristics:
  • A32 and T32 instruction sets supported by AArch32, and the A64 instruction set supported by AArch64 can be encapsulated through execution state.
  • the CPU must be in the execution state of AArch32 or AArch64 at any time. When switching between the two execution states of AArch32 and AArch64, the CPU needs to fall into a high privilege level through an exception.
  • AArch32 and AArch64 are tightly coupled, and they can share registers.
  • AArch32 and AArch64 cannot call each other (for example, functions in the A64 instruction set cannot call functions in the A32 instruction set or T32 instruction set), and AArch32 and AArch64 cannot be used as extensions of each other.
  • the exception vector table includes the correspondence between exceptions and exception handlers.
  • AArch32 needs to trap the low privilege level to the high privilege level when an exception occurs.
  • AArch64 accesses the exception vector table when the high privilege level determines the exception handler that needs to be scheduled.
  • Figure 2 illustrates a process of switching between AArch64 and AArch32 execution states provided by this application. Specifically, the process is to run an ARM32 executable program (which can be referred to as a program) in the AArch64 execution state.
  • an ARM32 executable program which can be referred to as a program
  • Step 201 In the AArch64 execution state, the EL0 user state loads the ARM32 process and will fall into the EL1 kernel state.
  • the ELF file format is parsed in the EL1 kernel and it is found that the EL0 user state needs to run the program of the A32 instruction set. Then, return to the EL0 user state. When in the state, it will switch to the AArch32 execution state by setting the SPSR, that is, the execution state switches from AArch64 to AArch32.
  • Step 202 When the ARM32 process running in the AArch32 execution state needs to handle an exception, it needs to do so by falling into the EL1 kernel state, that is, the execution state is switched from AArch32 to AArch64 again. After handling the exception, the EL1 kernel state returns to the AArch32 execution state of EL0 as required. Or, after the ARM32 process running in the AArch32 execution state finishes running, it needs to be completed by falling into the EL1 kernel state.
  • the logical core run by the ARM32 process needs to frequently switch between the ARM64 logical core and the ARM32 logical core.
  • This abnormal switching requires the hardware to complete a lot of work.
  • Switching between the ARM64 logic core and the ARM32 logic core needs to be based on the exception recorded in the exception vector table and the handler corresponding to the exception.
  • the exception vector table is stored in a register, and the exception vector table needs to occupy a large number of registers.
  • the ARM64 logic core and the ARM32 logic core share registers, and they are tightly coupled and cannot evolve independently.
  • This application provides a method and device for switching the execution state of a process, which is used to flexibly switch the execution state of two logical cores. Under the premise of running status, the two logical cores are decoupled, so that one of the logical cores can be independently evolved.
  • FIG. 3 is a schematic diagram of the architecture of a chip system.
  • the chip system includes multiple CPU physical cores.
  • Each CPU physical core can include two logical cores, which can be represented as Master logical core and Slave logical core respectively.
  • the Master logical core can be used to perform privileged state operations, and the Slave logical core can be used to perform user state operations. Among them, multiple privilege levels in the privileged state are higher than those in the user state.
  • the Master logical core is ARM64.
  • the privileged state implemented by the Master logical core corresponds to the three privilege levels of EL1, EL2 and EL3.
  • the Slave logical core implements the privileged level of the user state. Among them, the three privileged levels of EL1, EL2 and EL3 are higher than User mode privilege level.
  • the Master logical core can also be used to perform user-mode operations, which can achieve user-mode privilege levels. Still taking the Master logical core as ARM64 as an example, the user mode implemented by the Master logical core includes the EL0 privilege level. The user-mode privilege level implemented by the Master logical core can be the same privilege level as the user-mode privilege level implemented by the Slave logical core.
  • the user mode program can run in the Master logical core according to its instruction set, or it can also run in the Slave logical core.
  • System software (such as Kernel/Hypervisor/Firmware) can only run in the Master logical core.
  • the Master logic core and the Slave logic core use different instruction sets.
  • the instruction set of the Master logic core can be the current mainstream instruction set such as X86 or ARM.
  • the instruction set of the slave logic core can be a self-developed instruction set.
  • the computing power of the Slave logical core can be higher than the computing power of the Master logical core.
  • the process running on the Slave logical core includes an executable code segment.
  • the executable code segment may include two parts: a springboard code segment (which can be expressed as trampoline code in English) and a main body code segment.
  • the springboard code segment runs in the Master logical core and is used to call the Slave logical core to run the process. It can be understood that since the loading of the process occurs in the Master logical core and the running of the process occurs in the Slave logical core, a springboard code segment in the Master logical core is needed to switch the process from running on the Master logical core to running on the Slave logic. nuclear.
  • the main code segment runs in the Slave logical core, where the main code segment is the main code of the running process.
  • This configuration space can be understood as the interactive interface between the two logical cores.
  • the configuration space can be a register group or a special memory space.
  • This configuration space can be used for information exchange between the Master logical core and the Slave logical core. For example, when the Master logical core starts a process, it can determine that the process needs to run in the Slave logical core, and then execute the Slave logical core. The relevant parameters of the process are written into the configuration space. The Slave logic core reads the relevant parameters from the configuration space and starts executing the process based on the read parameters.
  • Each CPU physical core corresponds to an extra-core resource, such as a cache or a memory management unit (MMU).
  • MMU memory management unit
  • Multiple CPU physical cores and corresponding extra-core resources of the multiple CPU physical cores can be packaged together in a chip system, and the chip system can be connected to memory and peripherals.
  • the Master logical core as an ARM64 logical core as an example, explain the processes running in the Master logical core and Slave logical core.
  • the Master instruction set in the ARM64 logical core can also be called the A64 instruction set
  • the process running on the ARM64 logical core can also be called the A64 process.
  • the chip system corresponds to the user state, privileged state and hardware part.
  • the user-mode processes and system software (such as Kernel/Hypervisor/Firmware) of the A64 instruction set run on the ARM64 logical core
  • the user-mode processes ie processes) of the Slave instruction set run on the Slave logical core.
  • Step 501 Start the process on the Master logical core and determine that the process needs to run on the Slave logical core. Start the Slave logical core so that the Slave logical core runs the process. Among them, when running a process on the Slave logical core, the process can only perform user-mode operations.
  • Step 502 When it is determined that the process needs to perform operations in the privileged state, the execution state of the process is switched from the user state to the privileged state. Correspondingly, the process needs to be switched to run in the Master logical core.
  • Step 503 After the process in the Master logical core processes the privileged state operation, the execution state of the process can be switched from the privileged state back to the user state. Correspondingly, the process is switched back to the Slave logical core to run.
  • the Master logical core and the Slave logical core can exchange information with each other through the configuration space.
  • FIG. 6 is a schematic diagram of a Master logical core startup process provided by this application.
  • the above-mentioned step 501 is explained with reference to Figure 6, in which the text in the dotted box may represent the actions performed by the Master logical core or the Slave logical core.
  • the Master logical core starts the running process in the user state and traps the process from the user state to the privileged state.
  • the Master logical core loads the process data from memory.
  • the data of the process such as the code segment/text segment, data segment, executable file, etc. of the process.
  • a code segment is usually an area of memory used to store program execution code.
  • the data segment usually refers to the memory area used to store initialized global variables in the program.
  • An executable file is, for example, an ELF file.
  • the executable file of the process records the identification of whether the process needs to run on the slave logical core.
  • the Master logical core determines whether the process needs to run on the Slave logical core based on the identification.
  • the Master logical core determines, based on the code segment, that the instruction set executed by the process belongs to the instruction set run by the Slave logical core, and then determines that the process needs to run on the Slave logical core.
  • the Master logical core determines that the process needs to run in the Slave logical core, it can return the process from the privileged state to the user mode of the Slave logical core, so that the Slave logical core executes the process in the user mode. Specifically, when the Master logical core returns the process from the privileged state to the user state of the Slave logical core, it can return the process to the entry of the springboard code segment in the Master logical core, and write the entry of the process through the springboard code segment. Enter the configuration space, thereby triggering the Slave logical core to start executing the process from this entry.
  • the Master logical core can write the starting position (or starting position information) of the process into the configuration space through the springboard code segment, and then the Master logical core operates the configuration space through the springboard code segment to trigger the startup command (available in English). This is called the slave call instruction), thereby starting the Slave logical core through the slave call instruction.
  • the slave logic core reads the starting position from the configuration space and starts the process based on the read starting position.
  • the Master logical core can release the hardware resources of the physical core occupied by the Master logical core when running the process.
  • the hardware resources can include memory resources, input/output (I/O) One or more resources. In this way, this part of the released hardware resources can be reused to execute other processes, which helps to make full use of the hardware resources.
  • the Master logic core writes the position of the next instruction of the slave call instruction (this position can be recorded as master.pc) into the configuration space.
  • This master.pc can be used by the Master logical core to know from which position to start executing the process when it needs to execute the process again.
  • the next instruction of the slave call instruction can be called the master.pc instruction.
  • the first condition can be used to indicate that the process needs to perform an operation in a privileged state.
  • the operation in the privileged state can be called a target operation. That is, the first condition can be used to indicate that the process needs to perform the target operation.
  • the Slave logic core needs to suspend the current running The process in the Slave logical core is then switched to be run by the Master logical core, so that the process running in the Master logical core can perform the target operation.
  • the pauses triggered by the target operations can be divided into exceptions (Exception) and interruptions (Interruption).
  • Exceptions refer to events from within the CPU executing instructions. Abnormalities can be divided into first-type exceptions and second-type exceptions.
  • the first-type exceptions can be ordinary exceptions
  • the second-type exceptions can be RAS exceptions.
  • RAS exceptions include physical damage to memory pages.
  • Common exceptions are exceptions other than RAS exceptions. Common exceptions include system calls (or syscalls for short), page faults, instruction faults, etc.
  • Interrupts refer to events that occur other than when the CPU executes instructions, such as clock interrupts, serial port interrupts, network interrupts, I/O interrupt stops, etc. Take the clock interrupt as an example.
  • the clock interrupt indicates that a fixed time slice has arrived, allowing the CPU to process timing, start scheduled tasks, etc.
  • step 502 is explained as follows based on three situations: ordinary exception, interruption, and RAS exception.
  • Figure 7 shows a schematic diagram of a method for switching the execution state of a process when a process triggers a common exception.
  • the text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
  • the process triggers a common exception because it needs to perform the target operation.
  • the slave logical core needs to write the running context (or common exception information) of the process into the configuration space.
  • Ordinary exception information may include one or more of the following: privilege level information, instruction location that triggered the exception, exception cause, exception occurrence address, exception parameters, register information, etc.
  • the privilege level information is used to indicate the privilege level corresponding to the target operation (which can be called the target privilege level), that is, which privilege level the Master logical core needs to use to handle this exception. For example, if the target operation is a system call, the target privilege level is EL1.
  • the instruction location that triggers the exception can be considered as the location where the process was interrupted, and can be recorded as slave.pc.
  • the Slave logical core resumes execution, the Slave logical core can continue execution from this location slave.pc.
  • the instruction corresponding to the location slave.pc can be called the slave.pc instruction.
  • Exception cause indicates the reason for suspending the running process on the secondary logical core, or indicates the reason for the exception, such as system call, page fault, instruction failure, etc.
  • the address where the exception occurred such as the location in memory being accessed.
  • Exception parameters such as parameters that need to be passed in system calls.
  • Register information is used to indicate the running environment information in the Slave logical core when the running process is suspended in the Slave logical core. This running environment information can be used by the Slave logical core to continue executing the process. Register information is, for example, SPSR information.
  • the hardware resources corresponding to the Slave logical core can be released (Retired) at the instruction location that triggers the target operation.
  • the Slave hardware unit switches the process from running on the Slave logical core to running on the Master logical core.
  • the Master logical core reads the location master.pc in the configuration space, and then continues execution from the next instruction of the slave call instruction in the springboard code segment (ie, the master.pc instruction) based on the location master.pc.
  • the execution state of the process is switched from the user state of the Slave logical core to the user state of the Master logical core.
  • the Master logical core needs to further switch the process from the user state of the Master logical core to the privileged state of the Master logical core.
  • the Master logical core can also read the common exception information of the process in the configuration space, and according to the common exception information of the process, the execution state of the process is dropped from the user state of the Master logical core to the privileged state of the Master logical core.
  • the Master logical core can determine whether to trap the process based on the privilege level information in the ordinary exception information. Enter the target privilege level of the privileged state.
  • the Master logic core After the process falls into the target privilege level, the Master logic core further performs the target operation based on the exception cause, exception occurrence address, exception parameters and other information in the ordinary exception information, that is, handles the ordinary exception.
  • exception parameters may include system call identification (syscall id) and system call input parameters.
  • the Master logical core can read the system call identifier and system call input parameters from the common exception information in the configuration space, construct a system call based on these two parameters, and then issue the system call, that is, the Master logical core privileged state sees is the converted system call. After the system call is executed, the Master logical core can write the return value of the system call into the configuration space. In this way, the Slave logical core can read the return value of the system call from the configuration space.
  • the Master logical core can construct the system call according to the application binary interface (ABI) rules of the corresponding architecture of the Master logical core, so that it is applicable to different CPUs.
  • the Master logical core still writes the return value of the system call to the configuration space according to the ABI rules.
  • ABSI application binary interface
  • exception parameters may include the virtual page address corresponding to the page fault.
  • the Master logical core can read the virtual page address from the common exception information in the configuration space, apply for a physical page address for the virtual page address, and then establish a mapping relationship between the virtual page address and the physical page address, and update the page table.
  • the virtual page address can also be called a virtual memory address
  • the physical page address can also be called a physical memory address.
  • this application can determine the privilege levels corresponding to these common exceptions for different common exceptions. It can be understood that one privilege level can correspond to a variety of common exceptions.
  • the EL1 privilege level corresponds to system calls, page faults, instruction failures, etc. When such exceptions occur, the Master logical core can trap the process into the EL1 privilege level for processing. .
  • the Master logical core changes the execution state of the process from the user state of the Master logical core to the target privilege level of the Master logical core's privileged state. This can be achieved by constructing a special exception. For details, please refer to the trapping method shown in Figure 8 .
  • two virtual page addresses can be added in the real-time operating system, and the two virtual page addresses respectively correspond to two privilege levels of the privileged state (specifically, the kernel state).
  • the two privilege levels in the kernel state are EL1 privilege level and EL2 privilege level.
  • virtual page address 1 corresponds to the EL1 privilege level
  • virtual page address 2 corresponds to the EL2 privilege level.
  • the two virtual page addresses do not establish a mapping relationship with the physical page addresses.
  • the Master logical core can select the target privilege level corresponding to the ordinary exception from multiple privilege levels corresponding to the privileged state based on the type of ordinary exception triggered by the Slave logical core; and then determine the target privilege level from multiple virtual page addresses.
  • the Master logical core accesses the virtual page address corresponding to the target privilege level by executing the page access instruction and determines that the virtual page address does not establish a mapping relationship with the physical page address, so an exception (i.e., page fault) is triggered. Subsequently, the Master logical core falls from the user state to the target privilege level in the privileged state.
  • the Master logical core determines that the exception triggered by the process is a system call, and the Master logical core determines that the process needs to be trapped into the EL1 privilege level based on the system call.
  • the master logical core accesses virtual page address 1 and determines that the current virtual page address 1 does not correspond to the physical page address, that is, the virtual page address 1 access error.
  • the Master logical core triggers a page fault exception and traps the process into the EL1 privilege level. In this way, the process runs at the EL1 privilege level of the Master logical core, and the Master logical core can perform the target operation, that is, process the system call.
  • the Master logical core can repeatedly trigger page fault exceptions, thereby trapping the execution state of the process from the user state of the Master logical core to the target privilege level of the Master logical core's privileged state.
  • the page fault here is used to change the execution state of the process from the user state of the Master logical core to the target privilege level of the privileged state of the Master logical core. This page fault is different from the one triggered when the Slave logical core runs the process. Page fault, the latter is an exception that really needs to be handled during the running of the process.
  • the Master logic core After the Master logic core completes the target operation in the privileged state (or is understood to have handled ordinary exceptions), it can return to the springboard code segment. Specifically, the Master logic core can return to the page access instruction in the springboard code segment. After the page access instruction, the Master logical core continues to execute the slave call instruction, thereby triggering the operation of the Slave logical core. The Slave logical core continues execution from the interrupted position slave.pc. Furthermore, the Slave logical core can read the register information from the ordinary exception information in the configuration space, and based on the read register information, restore the running environment information of the process before the Slave logical core triggered the exception.
  • Figure 9 shows a schematic diagram of a method for switching the execution state of a process when the process receives an interrupt.
  • the text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
  • the process receives an interrupt during the running of the Slave logical core.
  • the Slave logical core needs to write the running context (or interrupt information) of the process into the configuration space.
  • the interrupt information may include one or more of the following: privilege level information, instruction location where the interrupt was received, interrupt cause, interrupt occurrence address, interrupt parameters, register information, etc.
  • the privilege level information, interrupt parameters, register information, and interrupt occurrence address can be found in the description of the running context in the above common exception.
  • the instruction location that received the interrupt can also be recorded as slave.pc.
  • the Slave logical core resumes execution the Slave logical core can continue execution from this location slave.pc.
  • Interruption reason indicates the cause of the interruption, such as clock interruption, serial port interruption, network interruption, etc.
  • the hardware unit of the Slave logical core can trap the execution state of the process into a privileged state.
  • the hardware unit of the Slave logical core can also determine which privilege level the process will fall into in the privileged state based on the type of interrupt, such as falling into the EL1 privilege level or the EL2 privilege level.
  • the Slave logical core undergoes many operations during the execution of the salve.call instruction, such as the Master logical core sleeping, the Slave logical core triggering a running instruction, etc.
  • the time when an interrupt occurs is during the execution of salve.call.
  • the time point when the Master logic core responds to the interrupt is after the salve.call instruction is executed and the next instruction (ie, the master.pc instruction) is executed. before execution.
  • the Master logical core After the Master logical core completes the target operation in the privileged state (or is understood to have processed the interrupt), the Master logical core returns to master.pc in the springboard code segment. Subsequently, the Master logical core continues to execute the slave call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
  • Figure 10 shows a schematic diagram of a method for switching the execution state of a process when a process triggers a RAS exception.
  • the text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
  • RAS exceptions can be further divided into synchronous abort (SErrors for short) and asynchronous abort (SEI for short).
  • SErrors are related to the execution of instructions.
  • the return address maintained by SErrors when entering the exception state accurately reflects the instruction in which the exception occurred, and may occur at any step during the execution of the instruction. For example, failure in the instruction fetch phase, failure in the decoding phase, failure in the instruction execution phase, etc.
  • SErrors are similar to ordinary exceptions and are a synchronous event.
  • SEI has nothing to do with the executed instructions. SEI comes from an external memory system or an error on the bus, such as an unrecoverable error correcting code error (ECC error). SEI is similar to an interrupt and is an asynchronous event.
  • ECC error unrecoverable error correcting code error
  • RAS exception information may include one or more of the following: privilege level information, instruction location that triggers RAS exception, RAS exception cause, RAS exception occurrence address, RAS exception parameters, register information, etc.
  • the privilege level information, RAS exception parameters, register information, and RAS exception occurrence address can be found in the description of the running context in the above common exceptions.
  • the instruction location that triggers the RAS exception can also be recorded as slave.pc.
  • the Slave logical core resumes execution the Slave logical core can continue execution from the slave.pc.
  • RAS abnormality reason indicating the cause of RAS abnormality, such as error correction code error, etc.
  • the hardware unit of the Slave logical core can drop the execution state of the process from the original user state to the privileged state.
  • the privileged state can specifically be a firmware state.
  • the firmware state corresponds to the EL3 privilege level.
  • the hardware unit of the Slave logical core can trap the execution state of the process to the EL3 privilege level.
  • the user state can also be called the EL0 privilege level in the privileged state.
  • the EL0 privilege level is lower than other privilege levels in the privileged state.
  • the RAS exception occurs in master.pc.
  • the explanation is that the salve logical core undergoes many operations during the execution of the salve.call instruction, such as the Master logical core sleeping, the Slave logical core triggering a running instruction, etc.
  • the time when a RAS exception occurs is during the execution of salve.call.
  • the time point when the Master logical core responds to the RAS exception is after the salve.call instruction is executed, and the next instruction (i.e. the master.pc instruction ) before execution.
  • the Master logical core handles RAS exceptions in the EL3 privilege level and obtains the RAS exception processing results.
  • the RAS exception processing result can be used to indicate whether the RAS exception is recoverable.
  • the Master logical core returns from the EL3 privilege level to the EL1 privilege level, or in other words, returns from the firmware state to the kernel state.
  • the Master logical core obtains the RAS exception processing result at the EL1 privilege level.
  • the Master logical core performs the target operation at the EL1 privilege level and returns to the master recorded in the configuration space.
  • the instruction corresponding to the .pc position that is, the master.pc instruction.
  • the Master logical core performs panic kernel processing at the EL1 privilege level.
  • the firmware of the Master logical core may perform the following steps (a) to (c):
  • the Master logical core After the privileged state of the Master logical core processes the target operation, the Master logical core returns to the master.pc instruction in the springboard code segment. Subsequently, the Master logical core continues to execute the slave call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
  • the above-mentioned general exception information, interrupt information, and RAS exception information can be collectively referred to as the running context of the process.
  • the exception cause, interrupt cause, and RAS exception cause can be collectively referred to as the suspension of the running process on the Slave logical core.
  • Reason that is, the reason for the suspension of the process; exception parameters, interrupt parameters, and RAS exception parameters can be collectively referred to as the execution parameters corresponding to the target operation of the process; the instruction location that triggers the exception, the instruction location that receives the interrupt, and the instruction location that triggers the RAS exception.
  • the location where the process was interrupted can be collectively referred to as the location where the process was interrupted, or the pause location of the process (slave.pc), or the information of the pause location of the process.
  • the running context of a process may include one or more of the following: the pause position of the process on the Slave logical core, the reason for the suspension of the process on the Slave logical core, execution parameters corresponding to the target operation, and register information. (ie, environment information when the running process is suspended) or privilege level information.
  • the Slave logical core runs the process and determines that the process triggers a common exception.
  • the Slave logical core switches the execution state of the process from the user mode of the Slave logical core to the user mode of the Master logical core.
  • the Master logical core starts executing from the instruction at the master.pc location (i.e., the master.pc instruction), and determines that it needs to go to the EL1 privilege level for processing based on the common exception, so it accesses the virtual page address 1 corresponding to the EL1 privilege level (shown as in Figure 11 page1), and then, after the Master logical core triggers the page fault exception corresponding to page1, the execution state of the process falls into the EL1 privilege level to perform the target operation.
  • the Master logic core After completing the target operation, the Master logic core returns to the instruction that accesses page1 (that is, the page access instruction), and then returns to instruction 1. Further, the Master logical core calls the slave.call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
  • the Slave logical core runs the process and determines that the process has received an interrupt.
  • the hardware unit of the Slave logical core changes the execution state of the process from the user state of the Slave logical core directly to the privileged state of the Master logical core (such as EL1 privilege level).
  • the Master logical core runs the process so that the process performs the target operation. After the process completes the target operation, it returns to the instruction at the master.pc location (that is, the master.pc instruction), and then returns to instruction 1. Further, the Master logical core calls the slave.call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
  • the Slave logical core runs the process and determines that the process triggers a RAS exception.
  • the hardware unit of the Slave logical core changes the execution state of the process from the user state of the Slave logical core directly to the privileged state of the Master logical core (such as EL3 privilege level).
  • the Master logical core runs the process so that the process performs the target operation. After the process completes the target operation, it returns to the instruction at the master.pc location (that is, the master.pc instruction), and then returns to instruction 1.
  • the Master logical core calls the slave.call instruction to trigger the Slave logical core to run.
  • the Slave logical core continues execution from the interrupted location slave.pc.
  • the Master logic core and the Slave logic core exchange information through the configuration space to realize the decoupling of the Master logic core and the Slave logic core, so that the Master logic core and the Slave logic core can develop independently, that is, Without destroying the architectural semantics/instruction space corresponding to the Master logical core, the independent evolution of the instruction set corresponding to the Slave logical core can be achieved.
  • the Slave logical core can run acceleration engines and algorithms, such as mySql One or more of the processes, graph calculation processes, or encryption and decryption operators can increase the computing speed compared to the Master logical core.
  • the Slave logical core can write the running context of the process into the configuration space.
  • the running context includes the pause location corresponding to the paused process of the Slave logical core.
  • the Slave logical core can read the pause position from the configuration space and continue to execute the process at the pause position. process. In this way, the process can switch the running state between the Master logical core and the Slave logical core.
  • the relationship between the logical core, the process and the target operation can be understood as the process runs in the logical core (Slave logical core or Master logical core), and the process executes the target operation, that is, its runtime
  • the logical core where it is located (such as the Master logical core) performs the target operation.
  • the computer program product includes a computer program or instructions.
  • the method in the above method embodiment is implemented.
  • this application provides a computer-readable storage medium.
  • Computer programs or instructions are stored in the computer-readable storage medium.
  • the computer program or instructions are executed by a computing device, the method in the above method embodiment is implemented. .
  • this application provides a computing device, including a processor.
  • the processor is connected to a memory.
  • the memory is used to store computer programs.
  • the processor is used to execute the computer program stored in the memory, so that the computing device implements the above method. Methods in Examples.

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)
  • Storage Device Security (AREA)

Abstract

A method and apparatus for switching the execution status of a process, for use in switching, when a master logic core and a slave logic core are decoupled, a process running in the slave logic core to the master logic core for running. In the present application, the method comprises: if a process running in a slave logical core satisfies a first condition, suspending running of the process in the slave logical core, and recording the suspension position of the process, wherein the suspension position is used for determining an execution position when running the process in the slave logic core next time, the first condition is used for indicating a target operation to be executed of the process, and the target operation can be executed when the execution status of the process is in a privileged mode of a master logic core; switching the execution status of the process from a user mode of the slave logic core to the privileged mode of the master logic core; and running the process in the master logic core for the process to execute the target operation.

Description

一种进程的执行状态切换方法及装置A method and device for switching execution state of a process
相关申请的交叉引用Cross-references to related applications
本申请要求在2022年03月11日提交中国专利局、申请号为202210238502.2、申请名称为“一种进程的执行状态切换方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application submitted to the China Patent Office on March 11, 2022, with application number 202210238502.2 and the application title "A method and device for switching execution state of a process", the entire content of which is incorporated by reference in in this application.
技术领域Technical field
本申请涉及处理器领域,尤其涉及一种进程的执行状态切换方法及装置。The present application relates to the field of processors, and in particular, to a method and device for switching execution states of a process.
背景技术Background technique
现代计算机面对越来越复杂的计算需求,一种架构的中央处理器(central processing unit,CPU)已经无法满足业务的需要,很多方案会选择异构计算。所谓异构,就是将CPU、数字信号处理(digital signal processing,DSP)、图形处理器(graphics processing unit,GPU)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程逻辑门阵列(field programmable gate array,FPGA)等不同制程架构、不同指令集、不同功能的计算单元,组合起来形成一个混合的计算系统。Modern computers are facing increasingly complex computing requirements. The central processing unit (CPU) of one architecture can no longer meet business needs. Many solutions will choose heterogeneous computing. The so-called heterogeneous refers to the combination of CPU, digital signal processing (DSP), graphics processing unit (GPU), application specific integrated circuit (ASIC), field programmable logic gate array (field Computing units with different process architectures, different instruction sets, and different functions such as programmable gate array (FPGA) are combined to form a hybrid computing system.
以ARMv8-A体系架构为例,CPU物理核包括ARM64逻辑核和ARM32逻辑核,其中,ARM64逻辑核可执行特权级EL0至EL4中的一个,ARM32逻辑核可执行特权级EL0,其中EL0的特权级最低。在ARMv8-A体系架构中运行一个ARM32进程时,该ARM32进程具体是运行在ARM32逻辑核中,但是当ARM32进程需要执行高特权级操作(比如系统调用)时,需要触发异常,以使得ARM32进程的执行状态由特权级EL0陷入至特权级EL1中,从而在ARM64逻辑核中执行该高特权级操作。随后,ARM32进程的执行状态再次由特权级EL1返回至特权级EL0,在ARM32逻辑核中继续执行。Taking the ARMv8-A architecture as an example, the CPU physical core includes the ARM64 logical core and the ARM32 logical core. The ARM64 logical core can execute one of the privilege levels EL0 to EL4, and the ARM32 logical core can execute the privilege level EL0, among which the privileges of EL0 The lowest level. When running an ARM32 process in the ARMv8-A architecture, the ARM32 process specifically runs in the ARM32 logical core. However, when the ARM32 process needs to perform high-privilege level operations (such as system calls), an exception needs to be triggered so that the ARM32 process The execution state is trapped from privilege level EL0 to privilege level EL1, thereby executing the high-privilege level operation in the ARM64 logic core. Subsequently, the execution status of the ARM32 process returns from privilege level EL1 to privilege level EL0 again, and execution continues in the ARM32 logical core.
在该方式中,ARM64逻辑核和ARM32逻辑核二者需要紧密耦合,比如ARM64逻辑核需要新增寄存器和向量表表项来支持ARM32逻辑核,该两个逻辑核不能独立演进。In this method, the ARM64 logic core and the ARM32 logic core need to be tightly coupled. For example, the ARM64 logic core needs to add new registers and vector table entries to support the ARM32 logic core. The two logic cores cannot evolve independently.
发明内容Contents of the invention
本申请提供一种进程的执行状态切换方法及装置,用于在灵活切换两个逻辑核对应执行状态的前提下,将两个逻辑核解耦合,从而可独立演进其中的一个逻辑核。This application provides a process execution state switching method and device, which are used to decouple two logical cores on the premise of flexibly switching the corresponding execution states of two logical cores, so that one of the logical cores can be independently evolved.
第一方面,本申请提供一种进程的执行状态切换方法,应用于CPU中,CPU包括物理核,物理核包括主(Master)逻辑核和从(Slave)逻辑核,方法包括:如果运行在从逻辑核的进程满足第一条件,在从逻辑核中暂停运行进程,并记录进程的暂停位置,该暂停位置可用于下次在从逻辑核中运行进程时确定执行位置,其中,第一条件用于指示进程待执行目标操作,且目标操作在进程的执行状态处于主逻辑核的特权态时能够被执行;将进程的执行状态由从逻辑核的用户态切换为主逻辑核的特权态;在主逻辑核中运行进程,以供进程执行目标操作。In the first aspect, this application provides a method for switching the execution state of a process, which is applied to a CPU. The CPU includes a physical core, and the physical core includes a master logical core and a slave logical core. The method includes: if running on the slave When the process of the logical core meets the first condition, the running process is suspended from the logical core, and the pause position of the process is recorded. The pause position can be used to determine the execution position when the process is run from the logical core next time, where the first condition is Instructs the process to perform the target operation, and the target operation can be executed when the execution state of the process is in the privileged state of the main logical core; switches the execution state of the process from the user mode of the slave logical core to the privileged state of the main logical core; in Processes run in the main logical core for the process to perform target operations.
上述技术方案中,在从逻辑核中运行进程且进程需要执行目标操作时,通过从逻辑核 记录进程的暂停位置,该暂停位置可用于下次在从逻辑核中运行进程时确定执行位置,如此,主逻辑核和从逻辑核无需共享寄存器,可实现在灵活切换两个逻辑核对应执行状态的前提下,将两个逻辑核解耦合,从而可独立演进其中的一个逻辑核。In the above technical solution, when a process is run from a logical core and the process needs to perform a target operation, the process is run from the logical core Record the pause position of the process, which can be used to determine the execution position the next time the process is run in the slave logical core. In this way, the master logical core and the slave logical core do not need to share registers, and can flexibly switch the corresponding execution states of the two logical cores. Under the premise of decoupling the two logic cores, one of the logic cores can be evolved independently.
在一种可能的实现方式中,记录进程的暂停位置,包括:通过从逻辑核将暂停位置的信息写入配置空间,配置空间用于主逻辑核与从逻辑核进行信息交互。通过在物理核中配置用于从逻辑核和主逻辑核进行信息交互的配置空间,实现主逻辑核和从逻辑核的解耦合,从而主逻辑核和从逻辑核二者可以独立发展,在不破坏主逻辑核对应的架构语义/指令空间的前提下,可实现从逻辑核对应指令集的独立演进。In one possible implementation, recording the pause position of the process includes writing the pause position information into the configuration space through the slave logical core, and the configuration space is used for information interaction between the master logical core and the slave logical core. By configuring the configuration space for information interaction between the slave logic core and the master logic core in the physical core, the master logic core and the slave logic core are decoupled, so that the master logic core and the slave logic core can develop independently. Under the premise of destroying the architectural semantics/instruction space corresponding to the main logical core, the independent evolution of the instruction set corresponding to the slave logical core can be achieved.
在一种可能的实现方式中,方法还包括:将进程的执行状态由主逻辑核的特权态切换为从逻辑核的用户态;通过从逻辑核从配置空间读取暂停位置的信息;在从逻辑核中,从暂停位置开始继续运行进程。如此,在主逻辑核执行完成目标操作之后,可继续启动从逻辑核来继续运行进程,由于从逻辑核之前记录了暂停位置,则从逻辑核可从该暂停位置处继续运行,从而实现进程可在两个逻辑核之间切换,且进程可不间断地运行。In a possible implementation, the method also includes: switching the execution state of the process from the privileged state of the main logical core to the user state of the slave logical core; reading the pause position information from the configuration space through the slave logical core; In the logical core, the process continues from the paused position. In this way, after the main logical core completes the target operation, the slave logical core can continue to be started to continue running the process. Since the slave logical core has previously recorded the pause position, the slave logical core can continue to run from the pause position, thereby realizing that the process can Switch between two logical cores and the process can run without interruption.
在一种可能的实现方式中,第一条件包括进程触发第一类异常,第一类异常包括除可靠性异常、可用性异常、以及可服务性RAS异常以外的其它异常;将进程的执行状态由从逻辑核的用户态切换为主逻辑核的特权态,包括:触发主逻辑核运行进程,以将进程的执行状态由从逻辑核的用户态切换为主逻辑核的用户态;从主逻辑核的特权态的多个特权级中确定第一类异常对应的目标特权级;将进程的执行状态由主逻辑核的用户态切换为主逻辑核的特权态的目标特权级。In a possible implementation, the first condition includes the process triggering a first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions; the execution status of the process is Switching from the user mode of the slave logical core to the privileged state of the main logical core includes: triggering the main logical core to run a process to switch the execution state of the process from the user mode of the slave logical core to the user mode of the main logical core; Determine the target privilege level corresponding to the first type of exception among multiple privilege levels of the privileged state; switch the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core.
在一种可能的实现方式中,将进程的执行状态由主逻辑核的用户态切换为主逻辑核的特权态的目标特权级之前,还包括:获取目标特权级对应的虚拟内存地址;确定虚拟内存地址未与物理内存地址建立映射关系。In one possible implementation, before switching the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, the method further includes: obtaining the virtual memory address corresponding to the target privilege level; determining the virtual memory address of the target privilege level; The memory address is not mapped to the physical memory address.
上述技术方案中,通过主逻辑核访问目标特权级对应的虚拟内存地址,确定虚拟内存地址未与物理内存地址建立映射关系,则触发页面错误,主逻辑核可根据该触发的页面错误,将进程的执行状态由主逻辑核的用户态陷入至主逻辑核的特权态的目标特权级。如此,通过构造特殊异常(即页面错误)实现将进程的执行状态由主逻辑核的用户态陷入主逻辑核的特权态的目标特权级,减少进程陷入特权态的执行的复杂程度。In the above technical solution, the main logical core accesses the virtual memory address corresponding to the target privilege level. If it is determined that the virtual memory address does not establish a mapping relationship with the physical memory address, a page fault is triggered. The main logical core can process the process based on the triggered page fault. The execution state falls from the user state of the main logical core to the target privilege level of the privileged state of the main logical core. In this way, by constructing a special exception (ie, page fault), the execution state of the process is dropped from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, thereby reducing the complexity of the execution of the process falling into the privileged state.
在一种可能的实现方式中,第一条件包括进程收到中断,或者进程触发RAS异常。由于中断或者RAS异常属于异步事件且需要快速被处理,则当运行在从逻辑核的进程收到中断或者触发RAS异常时,可通过CPU物理核中的硬件单元(或硬件部分),将进程的执行状态由从逻辑核的用户态陷入至主逻辑核的特权态的目标特权级。In a possible implementation, the first condition includes the process receiving an interrupt, or the process triggering a RAS exception. Since interrupts or RAS exceptions are asynchronous events and need to be processed quickly, when the process running on the slave logical core receives an interrupt or triggers a RAS exception, the process can be processed through the hardware unit (or hardware part) in the CPU physical core. The execution state falls from the user state of the slave logical core to the target privilege level of the privileged state of the main logical core.
在一种可能的实现方式中,方法还包括:在主逻辑核中启动进程;如果进程的指令集属于从逻辑核运行的指令集,记录进程的起始位置,并触发从逻辑核进入运行状态;在从逻辑核中,从起始位置开始运行进程。上述技术方案中,某些进程(比如mySql进程、图计算进程或加解密算子)是需要运行在从逻辑核中的,当在主逻辑核中启动这些进程时,可确定这些进程需要运行在从逻辑核中,于是通过主逻辑核记录进程的起始位置,并触发从逻辑核进入运行状态,以使得从逻辑核读取该起始位置,并在该起始位置处运行该进程。In a possible implementation, the method also includes: starting the process in the main logical core; if the instruction set of the process belongs to the instruction set running from the slave logical core, recording the starting position of the process and triggering the slave logical core to enter the running state. ;In the slave logical core, run the process from the starting position. In the above technical solution, some processes (such as mySql process, graph calculation process or encryption and decryption operators) need to run in the slave logical core. When starting these processes in the main logical core, it can be determined that these processes need to run in the slave logical core. In the slave logical core, the starting position of the process is recorded through the main logical core, and the slave logical core is triggered to enter the running state, so that the slave logical core reads the starting position and runs the process at the starting position.
在一种可能的实现方式中,方法还包括:释放主逻辑核在运行进程时所占用的物理核的硬件资源;其中,硬件资源包括内存资源和/或输入输出资源。如此,该被释放的硬件资源,可被重新用于运行其他进程,有助于充分利用硬件资源。 In a possible implementation, the method further includes: releasing the hardware resources of the physical core occupied by the main logical core when running the process; where the hardware resources include memory resources and/or input and output resources. In this way, the released hardware resources can be reused to run other processes, which helps to fully utilize the hardware resources.
在一种可能的实现方式中,方法还包括:通过从逻辑核记录如下信息中的一项或多项:在从逻辑核上暂停运行进程的原因,目标操作对应的执行参数,暂停运行进程时的环境信息,或,特权级信息;其中,特权级信息用于指示进程在执行目标操作时主逻辑核的特权态的特权级。如此,主逻辑核可根据这些参数正确处理目标操作。In a possible implementation, the method also includes: recording one or more of the following information from the logical core: the reason why the running process is suspended on the logical core, the execution parameters corresponding to the target operation, and when the running process is suspended. Environment information, or privilege level information; where the privilege level information is used to indicate the privilege level of the privileged state of the main logical core when the process performs the target operation. In this way, the main logic core can correctly handle the target operation based on these parameters.
在一种可能的实现方式中,从逻辑核可运行加速引擎及算法,比如mySql进程、图计算进程或加解密算子中的一项或多项,相比于主逻辑核运行这些进程,可提高运算速率。In a possible implementation, the slave logical core can run acceleration engines and algorithms, such as one or more of the mySql process, graph calculation process, or encryption and decryption operators. Compared with running these processes on the main logical core, it can Improve computing speed.
第二方面,本申请提供一种进程的执行状态切换装置,装置可以是CPU。In the second aspect, this application provides a device for switching the execution state of a process, and the device may be a CPU.
装置包括处理器和存储器;存储器用于存储计算机程序;处理器用于调用存储器所存储的计算机程序,以执行如下步骤:如果运行在从逻辑核的进程满足第一条件,在从逻辑核中暂停运行进程,并记录进程的暂停位置,暂停位置用于下次在从逻辑核中运行进程时确定执行位置,其中,第一条件用于指示进程待执行目标操作,且目标操作在进程的执行状态处于主逻辑核的特权态时能够被执行;将进程的执行状态由从逻辑核的用户态切换为主逻辑核的特权态;在主逻辑核中运行进程,以供进程执行目标操作。The device includes a processor and a memory; the memory is used to store a computer program; the processor is used to call the computer program stored in the memory to perform the following steps: if the process running in the slave logical core meets the first condition, the process in the slave logical core is suspended. process, and record the pause position of the process. The pause position is used to determine the execution position the next time the process is run from the logical core. The first condition is used to indicate that the process is to perform the target operation, and the target operation is in the execution state of the process. It can be executed when the main logical core is in the privileged state; the execution state of the process is switched from the user mode of the slave logical core to the privileged state of the main logical core; the process is run in the main logical core so that the process can perform the target operation.
在一种可能的实现方式中,处理器在记录进程的暂停位置时,具体用于:通过从逻辑核将暂停位置的信息写入配置空间,配置空间用于主逻辑核与从逻辑核进行信息交互。In a possible implementation, when the processor records the pause position of the process, it is specifically used to: write the pause position information into the configuration space through the slave logical core, and the configuration space is used for information exchange between the master logical core and the slave logical core. Interaction.
在一种可能的实现方式中,处理器还用于:将进程的执行状态由主逻辑核的特权态切换为从逻辑核的用户态;通过从逻辑核从配置空间读取暂停位置的信息;在从逻辑核中,从暂停位置开始继续运行进程。In a possible implementation, the processor is also used to: switch the execution state of the process from the privileged state of the main logical core to the user state of the slave logical core; read the pause position information from the configuration space through the slave logical core; In the secondary logical core, the process continues from the pause position.
在一种可能的实现方式中,第一条件包括进程触发第一类异常,第一类异常包括除可靠性异常、可用性异常、以及可服务性RAS异常以外的其它异常;处理器在将进程的执行状态由从逻辑核的用户态切换为主逻辑核的特权态时,具体用于:触发主逻辑核运行进程,以将进程的执行状态由从逻辑核的用户态切换为主逻辑核的用户态;从主逻辑核的特权态的多个特权级中确定第一类异常对应的目标特权级;将进程的执行状态由主逻辑核的用户态切换为主逻辑核的特权态的目标特权级。In a possible implementation, the first condition includes the process triggering a first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions; When the execution state is switched from the user state of the slave logical core to the privileged state of the master logical core, it is specifically used to: trigger the master logical core to run the process, so as to switch the execution state of the process from the user state of the slave logical core to the user state of the master logical core. state; determine the target privilege level corresponding to the first type of exception from the multiple privilege levels of the privileged state of the main logical core; switch the execution state of the process from the user mode of the main logical core to the target privilege level of the privileged state of the main logical core .
在一种可能的实现方式中,处理器在将进程的执行状态由主逻辑核的用户态切换为主逻辑核的特权态的目标特权级之前,还用于:获取目标特权级对应的虚拟内存地址;确定虚拟内存地址未与物理内存地址建立映射关系。In one possible implementation, before switching the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, the processor is also used to: obtain the virtual memory corresponding to the target privilege level. Address; determine that the virtual memory address is not mapped to the physical memory address.
在一种可能的实现方式中,第一条件包括进程收到中断或者触发RAS异常。In a possible implementation, the first condition includes the process receiving an interrupt or triggering a RAS exception.
在一种可能的实现方式中,处理器还用于:在主逻辑核中启动进程;如果进程的指令集属于从逻辑核运行的指令集,记录进程的起始位置,并触发从逻辑核进入运行状态;在从逻辑核中,从起始位置开始运行进程。In a possible implementation, the processor is also used to: start a process in the main logical core; if the instruction set of the process belongs to the instruction set running from the slave logical core, record the starting position of the process, and trigger entry from the slave logical core Running status; in the slave logical core, start running the process from the starting position.
在一种可能的实现方式中,处理器还用于:释放主逻辑核在运行进程时所占用的物理核的硬件资源;其中,硬件资源包括内存资源和/或输入输出资源。In a possible implementation, the processor is also used to: release hardware resources of the physical core occupied by the main logical core when running the process; where the hardware resources include memory resources and/or input and output resources.
在一种可能的实现方式中,处理器还用于:通过从逻辑核记录如下信息中的一项或多项:在从逻辑核上暂停运行进程的原因,目标操作对应的执行参数,暂停运行进程时的环境信息,或,特权级信息;其中,特权级信息用于指示进程在执行目标操作时主逻辑核的特权态的特权级。In a possible implementation, the processor is also used to record one or more of the following information from the logical core: the reason for suspending the running process on the slave logical core, the execution parameters corresponding to the target operation, and the suspension of operation. The environment information of the process, or the privilege level information; where the privilege level information is used to indicate the privilege level of the privileged state of the main logical core when the process performs the target operation.
第三方面,本申请提供一种进程的执行状态切换装置,装置可以是CPU。 In a third aspect, this application provides a device for switching the execution state of a process, and the device may be a CPU.
装置包括主逻辑核模块和从逻辑核模块,从逻辑核模块用于确定运行在从逻辑核模块的进程满足第一条件时,暂停运行进程,并记录进程的暂停位置,暂停位置用于下次在从逻辑核模块中运行进程时确定执行位置,其中,第一条件用于指示进程待执行目标操作,且目标操作在进程的执行状态处于主逻辑核模块的特权态时能够被执行;从逻辑核模块还用于将进程的执行状态由从逻辑核模块的用户态切换为主逻辑核模块的特权态;主逻辑核模块用于运行进程,以供进程执行目标操作。The device includes a main logic core module and a slave logic core module. The slave logic core module is used to determine that when the process running in the slave logic core module meets the first condition, it pauses the running process and records the pause position of the process. The pause position is used for next time. The execution position is determined when the process is running in the slave logical core module, where the first condition is used to indicate that the process is to perform a target operation, and the target operation can be executed when the execution state of the process is in the privileged state of the main logical core module; the slave logical core module The core module is also used to switch the execution state of the process from the user state of the slave logical core module to the privileged state of the main logical core module; the main logical core module is used to run the process so that the process can perform target operations.
在一种可能的实现方式中,从逻辑核模块在记录进程的暂停位置时,具体用于将暂停位置的信息写入配置空间,配置空间用于主逻辑核模块与从逻辑核模块进行信息交互。In one possible implementation, when the slave logical core module records the pause position of the process, it is specifically used to write the pause position information into the configuration space. The configuration space is used for information interaction between the master logical core module and the slave logical core module. .
在一种可能的实现方式中,主逻辑核模块还用于将进程的执行状态由主逻辑核模块的特权态切换为从逻辑核模块的用户态;从逻辑核模块还用于从配置空间读取暂停位置的信息,从暂停位置开始继续运行进程。In a possible implementation, the main logical core module is also used to switch the execution state of the process from the privileged state of the main logical core module to the user mode of the slave logical core module; the slave logical core module is also used to read from the configuration space. Get the information of the pause position and continue running the process from the pause position.
在一种可能的实现方式中,第一条件包括进程触发第一类异常,第一类异常包括除可靠性异常、可用性异常、以及可服务性RAS异常以外的其它异常;从逻辑核模块具体用于触发主逻辑核模块运行进程,以将进程的执行状态由从逻辑核模块的用户态切换为主逻辑核模块的用户态;主逻辑核模块具体用于从主逻辑核模块的特权态的多个特权级中确定第一类异常对应的目标特权级,以及将进程的执行状态由主逻辑核模块的用户态切换为主逻辑核模块的特权态的目标特权级。In a possible implementation, the first condition includes the process triggering the first type of exception, and the first type of exception includes other exceptions except reliability exceptions, availability exceptions, and serviceability RAS exceptions; from the specific use of the logical core module It is used to trigger the main logical core module to run the process, so as to switch the execution state of the process from the user mode of the slave logical core module to the user mode of the main logical core module; the main logical core module is specifically used for multiple privileged states of the slave main logical core module. The target privilege level corresponding to the first type of exception is determined among the privilege levels, and the target privilege level is used to switch the execution state of the process from the user state of the main logical core module to the privileged state of the main logical core module.
在一种可能的实现方式中,主逻辑核模块在将进程的执行状态由主逻辑核模块的用户态切换为主逻辑核模块的特权态的目标特权级之前,还用于获取目标特权级对应的虚拟内存地址;确定虚拟内存地址未与物理内存地址建立映射关系。In a possible implementation, the main logical core module is also used to obtain the corresponding target privilege level before switching the execution state of the process from the user mode of the main logical core module to the target privilege level of the privileged state of the main logical core module. The virtual memory address; determine that the virtual memory address does not have a mapping relationship with the physical memory address.
在一种可能的实现方式中,第一条件包括进程收到中断或者触发RAS异常。In a possible implementation, the first condition includes the process receiving an interrupt or triggering a RAS exception.
在一种可能的实现方式中,主逻辑核模块还用于启动进程,如果进程的指令集属于从逻辑核运行的指令集,则记录进程的起始位置,并触发从逻辑核模块进入运行状态;从逻辑核模块还用于从起始位置开始运行进程。In a possible implementation, the main logical core module is also used to start the process. If the instruction set of the process belongs to the instruction set running from the slave logical core, the starting position of the process is recorded and the slave logical core module is triggered to enter the running state. ;The slave logic core module is also used to run the process from the starting position.
在一种可能的实现方式中,主逻辑核模块释放在运行进程时所占用的物理核的硬件资源;其中,硬件资源包括内存资源和/或输入输出资源。In a possible implementation manner, the main logical core module releases the hardware resources of the physical core occupied when running the process; where the hardware resources include memory resources and/or input and output resources.
在一种可能的实现方式中,从逻辑核模块还用于记录如下信息中的一项或多项:在从逻辑核上暂停运行进程的原因,目标操作对应的执行参数,暂停运行进程时的环境信息,或,特权级信息;其中,特权级信息用于指示进程在执行目标操作时主逻辑核的特权态的特权级。In a possible implementation, the slave logical core module is also used to record one or more of the following information: the reason for suspending the running process on the slave logical core, the execution parameters corresponding to the target operation, and the reasons for suspending the running process. Environment information, or privilege level information; where the privilege level information is used to indicate the privilege level of the privileged state of the main logical core when the process performs the target operation.
第四方面,本申请实施例提供一种芯片系统,包括:处理器和存储器,所述处理器与存储器耦合,所述存储器用于存储程序或指令,当所述程序或指令被所述处理器执行时,使得该芯片系统实现上述第一方面或第一方面的任一种可能的实现方式中的方法。In a fourth aspect, embodiments of the present application provide a chip system, including: a processor and a memory. The processor is coupled to the memory. The memory is used to store programs or instructions. When the program or instructions are processed by the processor When executed, the chip system is caused to implement the method in the above first aspect or any possible implementation manner of the first aspect.
第五方面,本申请提供一种计算机程序产品,计算机程序产品包括计算机程序或指令,当计算机程序或指令被装置执行时,实现上述第一方面或第一方面的任一种可能的实现方式中的方法。In a fifth aspect, the present application provides a computer program product. The computer program product includes a computer program or instructions. When the computer program or instructions are executed by a device, the first aspect or any possible implementation manner of the first aspect is implemented. Methods.
第六方面,本申请提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序或指令,当计算机程序或指令被计算设备执行时,实现上述第一方面或第一方面的任一种可能的实现方式中的方法。 In a sixth aspect, the present application provides a computer-readable storage medium. Computer programs or instructions are stored in the computer-readable storage medium. When the computer program or instructions are executed by a computing device, the above-mentioned first aspect or any of the first aspects is implemented. method in one possible implementation.
第七方面,本申请提供一种计算设备,包括处理器,所述处理器与存储器相连,所述存储器用于存储计算机程序,所述处理器用于执行所述存储器中存储的计算机程序,以使得所述计算设备执行上述第一方面或第一方面的任一种可能的实现方式中的方法。In a seventh aspect, the present application provides a computing device, including a processor, the processor is connected to a memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that The computing device executes the method in the above first aspect or any possible implementation of the first aspect.
上述第二方面至第七方面中任一方面可以达到的技术效果可以参照上述第一方面中有益效果的描述,此处不再重复赘述。The technical effects that can be achieved by any one of the above-mentioned second to seventh aspects can be referred to the description of the beneficial effects in the above-mentioned first aspect, and will not be repeated here.
附图说明Description of the drawings
图1为一种ARMv8-A体系架构的示意图;Figure 1 is a schematic diagram of an ARMv8-A architecture;
图2为一种AArch64和AArch32两种执行状态切换的过程的示意图;Figure 2 is a schematic diagram of the process of switching between AArch64 and AArch32 execution states;
图3为本申请提供的一种芯片系统的架构示意图;Figure 3 is an architectural schematic diagram of a chip system provided by this application;
图4为本申请提供的一种Master逻辑核和Slave逻辑核中运行进程的示意图;Figure 4 is a schematic diagram of the running processes in a Master logical core and a Slave logical core provided by this application;
图5为本申请提供的一种执行状态的切换方法流程示意图;Figure 5 is a schematic flow chart of an execution state switching method provided by this application;
图6为本申请提供的一种启动进程的示意图;Figure 6 is a schematic diagram of a startup process provided by this application;
图7为本申请提供的一种切换进程的执行状态的方法示意图;Figure 7 is a schematic diagram of a method for switching the execution state of a process provided by this application;
图8为本申请提供的一种Master逻辑核将进程陷入至目标特权级的示意图;Figure 8 is a schematic diagram of a Master logical core provided by this application trapping a process into a target privilege level;
图9为本申请提供的再一种切换进程的执行状态的方法示意图;Figure 9 is a schematic diagram of yet another method for switching the execution status of a process provided by this application;
图10为本申请提供的又一种切换进程的执行状态的方法示意图;Figure 10 is a schematic diagram of another method for switching the execution status of a process provided by this application;
图11为本申请提供的再一种执行状态的切换方法流程示意图。Figure 11 is a schematic flowchart of yet another execution state switching method provided by this application.
具体实施方式Detailed ways
为了更好的解释本申请实施例,先对本申请中的相关术语或技术解释:In order to better explain the embodiments of this application, the relevant terms or technologies in this application will first be explained:
(1)程序和进程(1)Procedures and processes
程序是一组指令的有序集合,它只是一个静态的实体。A program is an ordered collection of instructions, it is just a static entity.
进程是程序在某个数据集上的执行。进程是一个动态的实体,它有自己的生命周期。进程因创建而产生,因调度而运行,因等待资源或事件而被处于等待状态,因完成任务而被撤消。进程反映了一个程序在一定数据集上运行的全部动态过程。A process is the execution of a program on some data set. A process is a dynamic entity with its own life cycle. Processes are created due to creation, run due to scheduling, placed in a waiting state due to waiting for resources or events, and canceled due to completion of tasks. A process reflects the entire dynamic process of a program running on a certain data set.
(2)用户态(user mode)和内核态(kernel mode)(2) User mode and kernel mode
当一个进程在执行用户代码时处于用户运行状态(又可称为是用户态)。当一个进程因为系统调用陷入内核代码中执行时,该进程处于内核运行状态(又可称为是内核态)。执行的内核代码会使用当前进程的内核栈,每个进程都有自己的内核栈。When a process is executing user code, it is in the user running state (also called user mode). When a process is trapped in kernel code for execution due to a system call, the process is in the kernel running state (also called kernel state). The executed kernel code will use the kernel stack of the current process, and each process has its own kernel stack.
用户运行一个程序,该程序创建的进程开始时运行自己的代码,处于用户态。在进程需要执行文件操作、网络数据发送等操作时,则通过write(写)、send(发送)等系统调用来调用内核的代码。进程进入内核地址空间去执行内核代码来完成相应的操作。内核态的进程执行完后又会回到用户态。用户态的进程不能随意操作内核地址空间。The user runs a program, and the process created by the program starts by running its own code in user mode. When the process needs to perform operations such as file operations and network data transmission, the kernel code is called through system calls such as write and send. The process enters the kernel address space to execute kernel code to complete the corresponding operation. After the kernel mode process is executed, it will return to the user mode. User-mode processes cannot manipulate the kernel address space at will.
(3)CPU、物理核、逻辑核(3)CPU, physical core, logical core
CPU不等于物理核,更不等于逻辑核。CPU is not equal to physical core, nor is it equal to logical core.
物理核(physical core/processor)是可看到的、真实的CPU核,物理核有独立的电路元件以及L1、L2缓存,可以独立地执行指令。The physical core (physical core/processor) is a visible, real CPU core. The physical core has independent circuit components and L1 and L2 caches, and can execute instructions independently.
逻辑核(logical core/processor,LCPU):在同一个物理核内,逻辑层面的核。 Logical core/processor (LCPU): A core at the logical level within the same physical core.
其中,一个CPU可以有多个物理核。一个物理核可分成多个逻辑核。Among them, a CPU can have multiple physical cores. A physical core can be divided into multiple logical cores.
(4)实时操作系统(kernel),是指大多数操作系统的核心部分。它由操作系统中用于管理存储器、文件、外设和系统资源的部分组成。(4) Real-time operating system (kernel) refers to the core part of most operating systems. It consists of the parts of the operating system that manage memory, files, peripherals, and system resources.
(5)可执行和可连接格式(Executable and Linkable Format,ELF)文件,是指在Unix和X86-64 Linux上的目标文件。其中目标文件指的是,用于存放目标代码的计算机文件,目标文件中可包含着机器代码、代码在运行时使用的数据、调试信息等,是从源代码文件产生程序文件这一过程中的中间产物。(5) Executable and Linkable Format (ELF) files refer to target files on Unix and X86-64 Linux. The target file refers to the computer file used to store the target code. The target file can contain machine code, data used by the code when running, debugging information, etc. It is the process of generating program files from source code files. mid product.
(6)同步操作和异步操作(6) Synchronous operations and asynchronous operations
同步操作,指的是调用方调用时,需要等待这个调用返回结果才能继续往后执行。Synchronous operation means that when the caller calls, it needs to wait for the call to return the result before continuing to execute.
异步操作,与同步操作相反,调用方发出调用之后,无需等待调用结果,而是继续执行后续操作,被调用者通过状态来通知调用者,或者通过回掉函数来处理这个调用。Asynchronous operations are the opposite of synchronous operations. After the caller issues a call, it does not need to wait for the call result, but continues to perform subsequent operations. The callee notifies the caller through the status, or handles the call by calling back the function.
(7)可靠性、可用性、耐用性(reliability、availability、serviceability,RAS)(7) Reliability, availability, durability (RAS)
reliability,指的是系统必须尽可能的可靠,不会意外的崩溃,重启甚至导致系统物理损坏。availability,指的是系统必须能够确保尽可能长时间工作而不下线,即使系统出现一些小的问题也不会影响整个系统的正常运行。serviceability,指的是系统能够提供便利的诊断功能,如系统日志,动态检测等手段方便管理人员进行系统诊断和维护操作,从而及早的发现错误并且修复错误。RAS作为一个整体,其作用在于确保整个系统尽可能长期可靠的运行而不下线,并且具备足够强大的容错机制。Reliability means that the system must be as reliable as possible without unexpected crashes, restarts or even physical damage to the system. Availability refers to the fact that the system must be able to work as long as possible without going offline. Even if some minor problems occur in the system, it will not affect the normal operation of the entire system. Serviceability refers to the ability of the system to provide convenient diagnostic functions, such as system logs, dynamic detection and other means to facilitate system diagnosis and maintenance operations by managers, so as to detect and repair errors as early as possible. As a whole, the role of RAS is to ensure that the entire system runs reliably for as long as possible without going offline, and has a sufficiently powerful fault-tolerant mechanism.
(8)固件(firmware),一般存储于设备中的电可擦除只读存储器(electrically erasable programmable ROM,EEPROM)或FLASH芯片中。firmware比如是计算机主板上的基本输入/输出系统BIOS(basic input/output system)。(8) Firmware is generally stored in the electrically erasable programmable ROM (EEPROM) or FLASH chip in the device. Firmware is, for example, the basic input/output system BIOS (basic input/output system) on the computer motherboard.
(9)寄存器,是中央处理器内的组成部分。寄存器是有限存贮容量的高速存贮部件,寄存器可用于暂存指令、数据和地址。程序状态保存寄存器(saved program status register,SPSR),用于保存程序状态寄存器(current program status register,CPSR)的状态,以便异常返回后恢复异常发生时的工作状态。当特定的异常中断发生时,这个寄存器用于存放当前程序状态寄存器的内容。在异常中断退出时,可以用SPSR来恢复CPSR。(9) Register is an integral part of the central processing unit. Registers are high-speed storage components with limited storage capacity. Registers can be used to temporarily store instructions, data and addresses. The program status saving register (saved program status register, SPSR) is used to save the status of the program status register (current program status register, CPSR) so that the working status when the exception occurs can be restored after an exception returns. When a specific exception interrupt occurs, this register is used to store the contents of the current program status register. When exiting from an abnormal interrupt, SPSR can be used to restore CPSR.
基于上述相关术语或技术解释,如下解释说明本申请所适用的场景。Based on the above related terms or technical explanations, the scenarios applicable to this application are explained as follows.
在CPU物理核中,可包括主(Master)逻辑核和从(Slave)逻辑核。CPU物理核可运行多个进程,该多个进程可运行于Master逻辑核或Slave逻辑核。比如Master逻辑核是ARM64逻辑核,Slave逻辑核是ARM32逻辑核,则ARM64的进程可运行于ARM64逻辑核中,ARM32的进程可运行于ARM32逻辑核中。而通常情况下,不管是运行于哪种逻辑核中的进程,均可由Master逻辑核来启动,Master逻辑核若确定该进程需要运行于Slave逻辑核,则可调用Slave逻辑核,以使得该进程在Slave逻辑核中运行。The CPU physical core can include a master logical core and a slave logical core. The CPU physical core can run multiple processes, and the multiple processes can run on the Master logical core or the Slave logical core. For example, if the Master logical core is an ARM64 logical core and the Slave logical core is an ARM32 logical core, the ARM64 process can run in the ARM64 logical core, and the ARM32 process can run in the ARM32 logical core. Under normal circumstances, no matter what kind of logical core a process is running in, it can be started by the Master logical core. If the Master logical core determines that the process needs to run on the Slave logical core, it can call the Slave logical core so that the process Runs in the Slave logical core.
如下,以Master逻辑核是ARM64逻辑核,Slave逻辑核是ARM32逻辑核为例说明ARM64逻辑核如何启动ARM32进程,并将ARM32进程运行于ARM32逻辑核中。As follows, taking the Master logical core as an ARM64 logical core and the Slave logical core as an ARM32 logical core as an example to illustrate how the ARM64 logical core starts the ARM32 process and runs the ARM32 process in the ARM32 logical core.
示例性的,在ARMv8体系架构中,可同时支持AArch32(或称为ARM32)和AArch64(或称为ARM64)两种执行状态。其中,AArch64执行状态支持A64指令集,可运行ARM64进程。AArch32执行状态支持T32和A32指令集,可运行ARM32进程。For example, in the ARMv8 architecture, two execution states of AArch32 (or ARM32) and AArch64 (or ARM64) can be supported at the same time. Among them, the AArch64 execution state supports the A64 instruction set and can run ARM64 processes. AArch32 execution state supports T32 and A32 instruction sets and can run ARM32 processes.
ARMv8-A中特权级(privilege level)的概念被称为异常级别(EL,exception level),它是 程序运行所处特权级别的逻辑划分。异常级别被划分为以下四种:The concept of privilege level in ARMv8-A is called exception level (EL, exception level), which is A logical division of privilege levels at which a program runs. Exception levels are divided into the following four types:
EL0:通常用户程序;EL0: Normal user program;
EL1:操作系统内核;EL1: operating system kernel;
EL2:虚拟机监视器;EL2: virtual machine monitor;
EL3:低级固件,包括安全监控(Secure Monitor)。EL3: Low-level firmware, including Secure Monitor.
其中,特权级的数字越大,其特权越高。通常情况下,一个软件,例如应用程序,操作系统内核或是虚拟机监视器仅占据一个异常级别。Among them, the larger the privilege level number, the higher the privilege. Typically, a piece of software, such as an application, operating system kernel, or virtual machine monitor, occupies only one exception level.
ARMv8-A体系架构可参见图1所示,ARM32逻辑核的执行状态为AArch32,ARM64逻辑核的执行状态为AArch64。其中AArch32可对应于EL0特权级,AArch64可对应于EL0和EL1特权级。或者也可以理解,在EL0特权级,可在AARCH64和AARCH32两种执行状态运行用户态进程;在EL1特权级,可在AArch64执行状态运行内核态进程。The ARMv8-A architecture can be seen in Figure 1. The execution state of the ARM32 logical core is AArch32, and the execution state of the ARM64 logical core is AArch64. Among them, AArch32 can correspond to the EL0 privilege level, and AArch64 can correspond to the EL0 and EL1 privilege levels. Or it can be understood that at the EL0 privilege level, user-mode processes can be run in AARCH64 and AARCH32 execution states; at EL1 privilege level, kernel-mode processes can be run in the AArch64 execution state.
进一步的,ARMv8-A体系架构可具有如下特点:Furthermore, the ARMv8-A architecture can have the following characteristics:
(1)AArch32支持的A32和T32指令集,以及AArch64支持的A64指令集可通过执行状态(execution state)进行封装。(1) The A32 and T32 instruction sets supported by AArch32, and the A64 instruction set supported by AArch64 can be encapsulated through execution state.
(2)CPU在任意时刻必须处于AArch32或AArch64的执行状态,AArch32、AArch64两个执行状态在切换时,CPU需要通过异常陷入高特权级。(2) The CPU must be in the execution state of AArch32 or AArch64 at any time. When switching between the two execution states of AArch32 and AArch64, the CPU needs to fall into a high privilege level through an exception.
(3)AArch32和AArch64是紧耦合的,二者可共用寄存器。(3) AArch32 and AArch64 are tightly coupled, and they can share registers.
(4)AArch32和AArch64不能互相调用(如A64指令集的函数不能调用A32指令集或T32指令集的函数),AArch32和AArch64二者不能用作对方的扩展。(4) AArch32 and AArch64 cannot call each other (for example, functions in the A64 instruction set cannot call functions in the A32 instruction set or T32 instruction set), and AArch32 and AArch64 cannot be used as extensions of each other.
(5)为了实现AArch64支持AArch32的异常处理,在异常向量表上,增加一组ARM32EL0异常的处理入口。示例性的,异常向量表中包括有异常与异常处理程序之间的对应关系。AArch32在异常时,需要将低特权级陷入至高特权级,AArch64在高特权级时访问异常向量表,从中确定需要调度的异常处理程序。(5) In order to implement AArch64 to support AArch32 exception handling, add a set of ARM32EL0 exception processing entries to the exception vector table. For example, the exception vector table includes the correspondence between exceptions and exception handlers. AArch32 needs to trap the low privilege level to the high privilege level when an exception occurs. AArch64 accesses the exception vector table when the high privilege level determines the exception handler that needs to be scheduled.
如图2为本申请示例性提供的一种AArch64和AArch32两种执行状态切换的过程,其中,该过程具体是在AArch64执行状态下,运行ARM32可执行程序(可简称为程序)。Figure 2 illustrates a process of switching between AArch64 and AArch32 execution states provided by this application. Specifically, the process is to run an ARM32 executable program (which can be referred to as a program) in the AArch64 execution state.
步骤201,在AArch64执行状态下,EL0用户态加载ARM32进程会陷入到EL1内核态,在EL1内核中解析ELF文件格式,发现EL0用户态需要运行的是A32指令集的程序,那么在返回EL0用户态时会通过设置SPSR切换到AArch32执行状态,即执行状态由AArch64切换为AArch32。Step 201. In the AArch64 execution state, the EL0 user state loads the ARM32 process and will fall into the EL1 kernel state. The ELF file format is parsed in the EL1 kernel and it is found that the EL0 user state needs to run the program of the A32 instruction set. Then, return to the EL0 user state. When in the state, it will switch to the AArch32 execution state by setting the SPSR, that is, the execution state switches from AArch64 to AArch32.
步骤202,在AArch32执行状态运行的ARM32进程在需要处理异常时,需要通过陷入至EL1内核态来完成,即执行状态再次由AArch32切换为AArch64。EL1内核态在处理完异常之后根据需求再返回到EL0的AArch32执行状态。或者,在AArch32执行状态运行的ARM32进程运行完毕后,需要通过陷入至EL1内核态来完成。Step 202: When the ARM32 process running in the AArch32 execution state needs to handle an exception, it needs to do so by falling into the EL1 kernel state, that is, the execution state is switched from AArch32 to AArch64 again. After handling the exception, the EL1 kernel state returns to the AArch32 execution state of EL0 as required. Or, after the ARM32 process running in the AArch32 execution state finishes running, it needs to be completed by falling into the EL1 kernel state.
如此,ARM32进程所运行的逻辑核需要经常地在ARM64逻辑核和ARM32逻辑核之间切换,该异常切换需要硬件完成大量工作。ARM64逻辑核和ARM32逻辑核之间的切换,需要基于异常向量表中记录的异常和该异常对应的处理程序,其中,该异常向量表存储于寄存器中,且该异常向量表需要占用大量寄存器。ARM64逻辑核和ARM32逻辑核共享寄存器,二者处于紧密耦合状态,无法独立演进。In this way, the logical core run by the ARM32 process needs to frequently switch between the ARM64 logical core and the ARM32 logical core. This abnormal switching requires the hardware to complete a lot of work. Switching between the ARM64 logic core and the ARM32 logic core needs to be based on the exception recorded in the exception vector table and the handler corresponding to the exception. The exception vector table is stored in a register, and the exception vector table needs to occupy a large number of registers. The ARM64 logic core and the ARM32 logic core share registers, and they are tightly coupled and cannot evolve independently.
本申请提供一种进程的执行状态切换方法及装置,用于在灵活切换两个逻辑核对应执 行状态的前提下,将两个逻辑核解耦合,从而可独立演进其中的一个逻辑核。This application provides a method and device for switching the execution state of a process, which is used to flexibly switch the execution state of two logical cores. Under the premise of running status, the two logical cores are decoupled, so that one of the logical cores can be independently evolved.
为方便描述本申请中的切换方法,先对本申请适用的系统架构解释说明。如图3为一种芯片系统的架构示意图,该芯片系统中包括有多个CPU物理核,每个CPU物理核中可包括两个逻辑核,可分别表示为Master逻辑核和Slave逻辑核。In order to facilitate the description of the switching method in this application, the system architecture applicable to this application is first explained. Figure 3 is a schematic diagram of the architecture of a chip system. The chip system includes multiple CPU physical cores. Each CPU physical core can include two logical cores, which can be represented as Master logical core and Slave logical core respectively.
Master逻辑核可用于执行特权态的操作,Slave逻辑核用于执行用户态的操作。其中,特权态的多个特权级均高于用户态的特权级。比如,Master逻辑核是ARM64,Master逻辑核实现的特权态对应于EL1、EL2和EL3三个特权级,Slave逻辑核实现用户态的特权级,其中EL1、EL2和EL3三个特权级均高于用户态的特权级。The Master logical core can be used to perform privileged state operations, and the Slave logical core can be used to perform user state operations. Among them, multiple privilege levels in the privileged state are higher than those in the user state. For example, the Master logical core is ARM64. The privileged state implemented by the Master logical core corresponds to the three privilege levels of EL1, EL2 and EL3. The Slave logical core implements the privileged level of the user state. Among them, the three privileged levels of EL1, EL2 and EL3 are higher than User mode privilege level.
此外,Master逻辑核还可用于执行用户态的操作,即可实现用户态的特权级。仍然以Master逻辑核是ARM64为例,Master逻辑核实现的用户态包括EL0特权级。Master逻辑核实现的用户态特权级,与Slave逻辑核实现的用户态特权级可为相同特权级。In addition, the Master logical core can also be used to perform user-mode operations, which can achieve user-mode privilege levels. Still taking the Master logical core as ARM64 as an example, the user mode implemented by the Master logical core includes the EL0 privilege level. The user-mode privilege level implemented by the Master logical core can be the same privilege level as the user-mode privilege level implemented by the Slave logical core.
示例性的,用户态程序可根据其指令集在Master逻辑核中运行,也可以在Slave逻辑核中运行。系统软件(如Kernel/Hypervisor/Firmware)只能在Master逻辑核中运行。For example, the user mode program can run in the Master logical core according to its instruction set, or it can also run in the Slave logical core. System software (such as Kernel/Hypervisor/Firmware) can only run in the Master logical core.
进一步的,Master逻辑核与Slave逻辑核采用不同的指令集,其中,Master逻辑核的指令集可以是X86或ARM等当前主流指令集。Slave逻辑核的指令集可以是自研指令集。Slave逻辑核的算力可高于Master逻辑核的算力。Furthermore, the Master logic core and the Slave logic core use different instruction sets. Among them, the instruction set of the Master logic core can be the current mainstream instruction set such as X86 or ARM. The instruction set of the slave logic core can be a self-developed instruction set. The computing power of the Slave logical core can be higher than the computing power of the Master logical core.
其中,运行在Slave逻辑核的进程(如下可简称为进程)中包括可执行代码段,该可执行代码段可包括跳板代码段(英文可表示为trampoline code)和主体代码段两大部分。Among them, the process running on the Slave logical core (hereinafter referred to as the process) includes an executable code segment. The executable code segment may include two parts: a springboard code segment (which can be expressed as trampoline code in English) and a main body code segment.
其中,跳板代码段运行在Master逻辑核,用于调用Slave逻辑核运行进程。可以理解,由于进程的加载发生在Master逻辑核,而进程的运行是发生在Slave逻辑核,则需要Master逻辑核中跳板代码段来将进程由原来的运行在Master逻辑核切换至运行在Slave逻辑核。Among them, the springboard code segment runs in the Master logical core and is used to call the Slave logical core to run the process. It can be understood that since the loading of the process occurs in the Master logical core and the running of the process occurs in the Slave logical core, a springboard code segment in the Master logical core is needed to switch the process from running on the Master logical core to running on the Slave logic. nuclear.
主体代码段运行在Slave逻辑核,其中主体代码段即运行进程的主要代码。The main code segment runs in the Slave logical core, where the main code segment is the main code of the running process.
在Master逻辑核和Slave逻辑核之间包括有配置空间,该配置空间可以理解为两个逻辑核之间的交互界面,该配置空间可以是寄存器组,也可以是一片特殊的内存空间。该配置空间可用于Master逻辑核和Slave逻辑核之间进行信息交互,示例性的,Master逻辑核在启动某个进程时,可确定该进程需要运行在Slave逻辑核中,于是将Slave逻辑核执行该进程的相关参数写入至配置空间中,Slave逻辑核从该配置空间中读取该相关参数,并根据读取到的参数开始执行该进程。There is a configuration space between the Master logical core and the Slave logical core. This configuration space can be understood as the interactive interface between the two logical cores. The configuration space can be a register group or a special memory space. This configuration space can be used for information exchange between the Master logical core and the Slave logical core. For example, when the Master logical core starts a process, it can determine that the process needs to run in the Slave logical core, and then execute the Slave logical core. The relevant parameters of the process are written into the configuration space. The Slave logic core reads the relevant parameters from the configuration space and starts executing the process based on the read parameters.
每个CPU物理核对应于一个核外资源,该核外资源比如是cache(缓存)或存储器管理单元(memory management unit,MMU)。Each CPU physical core corresponds to an extra-core resource, such as a cache or a memory management unit (MMU).
可将多个CPU物理核以及该多个CPU物理核分别对应的核外资源,一起封装于一个芯片系统中,该芯片系统可以连接有内存和外设。Multiple CPU physical cores and corresponding extra-core resources of the multiple CPU physical cores can be packaged together in a chip system, and the chip system can be connected to memory and peripherals.
以Master逻辑核是ARM64逻辑核为例,解释说明Master逻辑核和Slave逻辑核中运行的进程。其中,ARM64逻辑核中的Master指令集又可称为是A64指令集,运行在ARM64逻辑核上的进程又可称为是A64进程。如图4中,该芯片系统对应于用户态、特权态和硬件部分。A64指令集的用户态进程和系统软件(如Kernel/Hypervisor/Firmware)在ARM64逻辑核上运行,Slave指令集的用户态进程(即进程)在Slave逻辑核上运行。Taking the Master logical core as an ARM64 logical core as an example, explain the processes running in the Master logical core and Slave logical core. Among them, the Master instruction set in the ARM64 logical core can also be called the A64 instruction set, and the process running on the ARM64 logical core can also be called the A64 process. As shown in Figure 4, the chip system corresponds to the user state, privileged state and hardware part. The user-mode processes and system software (such as Kernel/Hypervisor/Firmware) of the A64 instruction set run on the ARM64 logical core, and the user-mode processes (ie processes) of the Slave instruction set run on the Slave logical core.
如下解释说明本申请中进程的执行状态的切换方法,该方法可参见图5所示的流程图。The method for switching the execution state of the process in this application is explained as follows. For this method, please refer to the flow chart shown in Figure 5.
步骤501,在Master逻辑核上启动进程,并确定该进程需要运行在Slave逻辑核上。 启动Slave逻辑核,以使得Slave逻辑核运行该进程。其中,在Slave逻辑核上运行进程时,进程仅可执行用户态的操作。Step 501: Start the process on the Master logical core and determine that the process needs to run on the Slave logical core. Start the Slave logical core so that the Slave logical core runs the process. Among them, when running a process on the Slave logical core, the process can only perform user-mode operations.
步骤502,在确定进程需要执行特权态的操作时,将进程的执行状态由用户态切换至特权态,相应的,需要将该进程切换到Master逻辑核中运行。Step 502: When it is determined that the process needs to perform operations in the privileged state, the execution state of the process is switched from the user state to the privileged state. Correspondingly, the process needs to be switched to run in the Master logical core.
步骤503,在Master逻辑核中的进程处理完该特权态的操作之后,进程的执行状态可由特权态再次切换回用户态,相应的,将该进程再次切换回Slave逻辑核中运行。Step 503: After the process in the Master logical core processes the privileged state operation, the execution state of the process can be switched from the privileged state back to the user state. Correspondingly, the process is switched back to the Slave logical core to run.
在上述进程的执行状态由特权态切换至用户态,或者由用户态切换至特权态时,Master逻辑核和Slave逻辑核二者可通过配置空间来相互交换信息。When the execution state of the above process switches from the privileged state to the user state, or from the user state to the privileged state, the Master logical core and the Slave logical core can exchange information with each other through the configuration space.
图6为本申请示例性提供的一种Master逻辑核启动进程的示意图。参照图6解释说明上述步骤501,其中虚线方框中文字可表示Master逻辑核或者Slave逻辑核执行的动作。Figure 6 is a schematic diagram of a Master logical core startup process provided by this application. The above-mentioned step 501 is explained with reference to Figure 6, in which the text in the dotted box may represent the actions performed by the Master logical core or the Slave logical core.
Master逻辑核在用户态上启动运行进程,并将该进程由用户态陷入到特权态。Master逻辑核从内存中加载进程的数据。The Master logical core starts the running process in the user state and traps the process from the user state to the privileged state. The Master logical core loads the process data from memory.
其中,进程的数据比如进程的代码段(code segment/text segment)、数据段(data segment)、可执行文件等。代码段通常是用来存放程序执行代码的内存区域。数据段通常是指用来存放程序中已初始化的全局变量的内存区域。可执行文件比如是ELF文件。Among them, the data of the process such as the code segment/text segment, data segment, executable file, etc. of the process. A code segment is usually an area of memory used to store program execution code. The data segment usually refers to the memory area used to store initialized global variables in the program. An executable file is, for example, an ELF file.
示例性的,进程的可执行文件中记载有该进程是否需要运行于Slave逻辑核的标识。相应的,Master逻辑核根据该标识,确定该进程是否需要运行于Slave逻辑核。For example, the executable file of the process records the identification of whether the process needs to run on the slave logical core. Correspondingly, the Master logical core determines whether the process needs to run on the Slave logical core based on the identification.
又示例性的,Master逻辑核根据代码段,确定进程所执行的指令集属于Slave逻辑核运行的指令集,进而确定该进程需要运行于Slave逻辑核。For another example, the Master logical core determines, based on the code segment, that the instruction set executed by the process belongs to the instruction set run by the Slave logical core, and then determines that the process needs to run on the Slave logical core.
Master逻辑核若确定该进程需要运行于Slave逻辑核,则可将该进程从特权态返回至Slave逻辑核的用户态,以使得Slave逻辑核在用户态执行该进程。具体的,Master逻辑核在将该进程从特权态返回至Slave逻辑核的用户态时,具体可将该进程返回至Master逻辑核中跳板代码段的入口,并通过跳板代码段将进程的入口写入至配置空间,从而触发Slave逻辑核从该入口处开始执行进程。If the Master logical core determines that the process needs to run in the Slave logical core, it can return the process from the privileged state to the user mode of the Slave logical core, so that the Slave logical core executes the process in the user mode. Specifically, when the Master logical core returns the process from the privileged state to the user state of the Slave logical core, it can return the process to the entry of the springboard code segment in the Master logical core, and write the entry of the process through the springboard code segment. Enter the configuration space, thereby triggering the Slave logical core to start executing the process from this entry.
具体的,Master逻辑核可通过跳板代码段将进程的起始位置(或者起始位置的信息)写入配置空间中,然后Master逻辑核通过跳板代码段操作配置空间,以触发启动指令(英文可称为是slave call指令),从而通过slave call指令启动Slave逻辑核。相应的,Slave逻辑核从配置空间中读取该起始位置,根据该读取到的起始位置启动进程。Specifically, the Master logical core can write the starting position (or starting position information) of the process into the configuration space through the springboard code segment, and then the Master logical core operates the configuration space through the springboard code segment to trigger the startup command (available in English). This is called the slave call instruction), thereby starting the Slave logical core through the slave call instruction. Correspondingly, the slave logic core reads the starting position from the configuration space and starts the process based on the read starting position.
此外,Master逻辑核在调用slave call指令之后,可释放Master逻辑核在运行进程时所占用的物理核的硬件资源,其中硬件资源可以包括内存资源、输入/输出(input/output,I/O)资源中一项或多项。如此,该部分被释放的硬件资源,可被重新用于执行其他进程,有助于充分利用硬件资源。In addition, after calling the slave call instruction, the Master logical core can release the hardware resources of the physical core occupied by the Master logical core when running the process. The hardware resources can include memory resources, input/output (I/O) One or more resources. In this way, this part of the released hardware resources can be reused to execute other processes, which helps to make full use of the hardware resources.
进一步的,Master逻辑核将slave call指令的下一条指令的位置(这个位置可记为master.pc)写入至配置空间中。该master.pc可用于Master逻辑核再次需要执行该进程时,知道从哪个位置上开始执行,该实现方式可参见下述实施例中关于步骤502的描述。如下,为方便描述,可将该slave call指令的下一条指令称为是master.pc指令。Further, the Master logic core writes the position of the next instruction of the slave call instruction (this position can be recorded as master.pc) into the configuration space. This master.pc can be used by the Master logical core to know from which position to start executing the process when it needs to execute the process again. For this implementation, please refer to the description of step 502 in the following embodiment. As shown below, for the convenience of description, the next instruction of the slave call instruction can be called the master.pc instruction.
在Slave逻辑核执行进程时,可能存在进程满足第一条件的情况,其中,第一条件可用于指示进程需要执行特权态的操作,此处,可将该特权态的操作称为是目标操作,也即第一条件可用于指示进程需要执行目标操作。进一步的,Slave逻辑核需要暂停当前运行在 Slave逻辑核中的进程,然后将该进程切换至由Master逻辑核运行,如此,运行在Master逻辑核中的该进程可执行该目标操作。When the Slave logical core executes a process, there may be situations where the process satisfies the first condition. The first condition can be used to indicate that the process needs to perform an operation in a privileged state. Here, the operation in the privileged state can be called a target operation. That is, the first condition can be used to indicate that the process needs to perform the target operation. Further, the Slave logic core needs to suspend the current running The process in the Slave logical core is then switched to be run by the Master logical core, so that the process running in the Master logical core can perform the target operation.
进一步的,基于目标操作的不同类型,可将目标操作触发的暂停划分为异常(Exception)和中断(Interruption)。Furthermore, based on different types of target operations, the pauses triggered by the target operations can be divided into exceptions (Exception) and interruptions (Interruption).
异常,指来自CPU执行指令内部的事件。异常又可分为第一类异常和第二类异常,其中第一类异常可以是普通异常,第二类异常可以是RAS异常。RAS异常比如内存页面物理损坏,普通异常是除RAS异常以外的其他异常,普通异常比如系统调用(system call,或简称为syscall)、页面错误(page fault),指令故障(instruction fault)等。Exceptions refer to events from within the CPU executing instructions. Abnormalities can be divided into first-type exceptions and second-type exceptions. The first-type exceptions can be ordinary exceptions, and the second-type exceptions can be RAS exceptions. RAS exceptions include physical damage to memory pages. Common exceptions are exceptions other than RAS exceptions. Common exceptions include system calls (or syscalls for short), page faults, instruction faults, etc.
中断,指来自CPU执行指令以外的事件发生,比如时钟中断、串口中断、网络中断、I/O中断停止等。以时钟中断为例,时钟中断表示一个固定的时间片已到,让CPU处理计时、启动定时运行的任务等。Interrupts refer to events that occur other than when the CPU executes instructions, such as clock interrupts, serial port interrupts, network interrupts, I/O interrupt stops, etc. Take the clock interrupt as an example. The clock interrupt indicates that a fixed time slice has arrived, allowing the CPU to process timing, start scheduled tasks, etc.
如下基于普通异常、中断、RAS异常三种情况解释上述步骤502。The above step 502 is explained as follows based on three situations: ordinary exception, interruption, and RAS exception.
一、普通异常1. Common exceptions
图7示出一种进程触发普通异常时切换进程的执行状态的方法示意图。其中虚线方框中文字可表示Master逻辑核或者Slave逻辑核执行的动作。Figure 7 shows a schematic diagram of a method for switching the execution state of a process when a process triggers a common exception. The text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
进程在Slave逻辑核的运行过程中,由于需要执行目标操作,则触发了普通异常。Slave逻辑核需要将该进程的运行上下文(或称为普通异常信息)写入至配置空间中。During the running of the Slave logical core, the process triggers a common exception because it needs to perform the target operation. The slave logical core needs to write the running context (or common exception information) of the process into the configuration space.
普通异常信息中可包括如下中一项或多项:特权级信息、触发异常的指令位置、异常原因、异常发生地址、异常参数、寄存器信息等。Ordinary exception information may include one or more of the following: privilege level information, instruction location that triggered the exception, exception cause, exception occurrence address, exception parameters, register information, etc.
其中特权级信息用于指示目标操作对应的特权级(可称为目标特权级),即Master逻辑核需要通过哪个特权级来处理这个异常。比如目标操作是系统调用,则目标特权级为EL1。The privilege level information is used to indicate the privilege level corresponding to the target operation (which can be called the target privilege level), that is, which privilege level the Master logical core needs to use to handle this exception. For example, if the target operation is a system call, the target privilege level is EL1.
触发异常的指令位置,可认为是进程被打断的位置,可记为slave.pc。当Slave逻辑核恢复执行时,Slave逻辑核可从该位置slave.pc继续执行。其中,可将位置slave.pc对应的指令称为是slave.pc指令。The instruction location that triggers the exception can be considered as the location where the process was interrupted, and can be recorded as slave.pc. When the Slave logical core resumes execution, the Slave logical core can continue execution from this location slave.pc. Among them, the instruction corresponding to the location slave.pc can be called the slave.pc instruction.
异常原因,指示在从逻辑核上暂停运行进程的原因,或者指示导致异常发生的原因,比如系统调用、页面错误、指令故障等。Exception cause indicates the reason for suspending the running process on the secondary logical core, or indicates the reason for the exception, such as system call, page fault, instruction failure, etc.
异常发生地址,比如访问的内存中的位置。The address where the exception occurred, such as the location in memory being accessed.
异常参数,比如系统调用需要传递的参数。Exception parameters, such as parameters that need to be passed in system calls.
寄存器信息,用于指示在Slave逻辑核中暂停运行进程时Slave逻辑核中的运行环境信息,该运行环境信息可用于Slave逻辑核继续执行进程。寄存器信息比如是SPSR信息。Register information is used to indicate the running environment information in the Slave logical core when the running process is suspended in the Slave logical core. This running environment information can be used by the Slave logical core to continue executing the process. Register information is, for example, SPSR information.
相应的,Slave逻辑核对应的硬件资源可在触发目标操作的指令位置处释放(Retired),Slave硬件单元将该进程由原来的在Slave逻辑核上运行,切换至在Master逻辑核上运行。相应的,Master逻辑核读取配置空间中的位置master.pc,然后根据该位置master.pc,从跳板代码段中slave call指令的下一条指令(即master.pc指令)处继续执行。Correspondingly, the hardware resources corresponding to the Slave logical core can be released (Retired) at the instruction location that triggers the target operation. The Slave hardware unit switches the process from running on the Slave logical core to running on the Master logical core. Correspondingly, the Master logical core reads the location master.pc in the configuration space, and then continues execution from the next instruction of the slave call instruction in the springboard code segment (ie, the master.pc instruction) based on the location master.pc.
可以理解,该进程的执行状态是由Slave逻辑核的用户态,切换至了Master逻辑核的用户态,Master逻辑核需要进一步将该进程由Master逻辑核的用户态切换至Master逻辑核的特权态。具体的,Master逻辑核还可读取配置空间中该进程的普通异常信息,根据该进程的普通异常信息,将进程的执行状态由Master逻辑核的用户态,陷入至Master逻辑核的特权态。其中,Master逻辑核可根据普通异常信息中的特权级信息,确定将该进程陷 入至特权态的目标特权级。It can be understood that the execution state of the process is switched from the user state of the Slave logical core to the user state of the Master logical core. The Master logical core needs to further switch the process from the user state of the Master logical core to the privileged state of the Master logical core. . Specifically, the Master logical core can also read the common exception information of the process in the configuration space, and according to the common exception information of the process, the execution state of the process is dropped from the user state of the Master logical core to the privileged state of the Master logical core. Among them, the Master logical core can determine whether to trap the process based on the privilege level information in the ordinary exception information. Enter the target privilege level of the privileged state.
在该进程陷入至目标特权级之后,Master逻辑核进一步根据普通异常信息中异常原因、异常发生地址、异常参数等信息,执行目标操作,也即处理该普通异常。After the process falls into the target privilege level, the Master logic core further performs the target operation based on the exception cause, exception occurrence address, exception parameters and other information in the ordinary exception information, that is, handles the ordinary exception.
如下,以普通异常分别为系统调用和页面错误为例说明。As follows, the common exceptions are system calls and page faults as examples.
1、系统调用1. System call
进一步的,异常参数中可包括系统调用标识(syscall id)和系统调用入参。Further, the exception parameters may include system call identification (syscall id) and system call input parameters.
Master逻辑核可从配置空间的普通异常信息中读取系统调用标识和系统调用入参,根据这两个参数构造一个系统调用,接着下发这个系统调用,也即,Master逻辑核特权态看到的是这个转换后的系统调用。在系统调用执行完毕后,Master逻辑核可将该系统调用的返回值写入到配置空间,如此,Slave逻辑核可从配置空间中读取到该系统调用的返回值。The Master logical core can read the system call identifier and system call input parameters from the common exception information in the configuration space, construct a system call based on these two parameters, and then issue the system call, that is, the Master logical core privileged state sees is the converted system call. After the system call is executed, the Master logical core can write the return value of the system call into the configuration space. In this way, the Slave logical core can read the return value of the system call from the configuration space.
示例性的,Master逻辑核可按照Master逻辑核对应架构的二进制接口交互(application binary interface,ABI)规则构造该系统调用,从而适用于不同CPU。相应的,Master逻辑核仍然按照该ABI规则将系统调用的返回值写入到配置空间。For example, the Master logical core can construct the system call according to the application binary interface (ABI) rules of the corresponding architecture of the Master logical core, so that it is applicable to different CPUs. Correspondingly, the Master logical core still writes the return value of the system call to the configuration space according to the ABI rules.
2、页面错误2. Page error
进一步的,异常参数中可包括页面错误对应的虚拟页面地址。Further, the exception parameters may include the virtual page address corresponding to the page fault.
Master逻辑核可从配置空间的普通异常信息中读取虚拟页面地址,并为该虚拟页面地址申请物理页面地址,随后将该虚拟页面地址和物理页面地址建立映射关系,并更新页表。其中虚拟页面地址又可称为是虚拟内存地址,物理页面地址又可称为是物理内存地址。The Master logical core can read the virtual page address from the common exception information in the configuration space, apply for a physical page address for the virtual page address, and then establish a mapping relationship between the virtual page address and the physical page address, and update the page table. The virtual page address can also be called a virtual memory address, and the physical page address can also be called a physical memory address.
需要指出的是,由于进程导致的普通异常数量较多,本申请可针对不同的普通异常,确定这些普通异常所对应的特权级。可以理解,一个特权级可对应于多种普通异常,比如EL1特权级对应于系统调用、页面错误、指令故障等,在发生这类异常时,Master逻辑核可将进程陷入至EL1特权级进行处理。It should be pointed out that since the number of common exceptions caused by the process is relatively large, this application can determine the privilege levels corresponding to these common exceptions for different common exceptions. It can be understood that one privilege level can correspond to a variety of common exceptions. For example, the EL1 privilege level corresponds to system calls, page faults, instruction failures, etc. When such exceptions occur, the Master logical core can trap the process into the EL1 privilege level for processing. .
在一种可能实现方式中,Master逻辑核将进程的执行状态由Master逻辑核的用户态,陷入至Master逻辑核的特权态的目标特权级,可以是通过构造特殊异常的方式实现。具体可参见图8示出的陷入方式。In one possible implementation, the Master logical core changes the execution state of the process from the user state of the Master logical core to the target privilege level of the Master logical core's privileged state. This can be achieved by constructing a special exception. For details, please refer to the trapping method shown in Figure 8 .
预先说明的是,可在实时操作系统中新增两个虚拟页面地址,该两个虚拟页面地址分别对应于特权态(具体可以是内核态)的两个特权级。比如内核态中的两个特权级分别是EL1特权级和EL2特权级,其中,虚拟页面地址1对应于EL1特权级,虚拟页面地址2对应于EL2特权级。进一步的,该两个虚拟页面地址未与物理页面地址建立映射关系。It should be noted in advance that two virtual page addresses can be added in the real-time operating system, and the two virtual page addresses respectively correspond to two privilege levels of the privileged state (specifically, the kernel state). For example, the two privilege levels in the kernel state are EL1 privilege level and EL2 privilege level. Among them, virtual page address 1 corresponds to the EL1 privilege level, and virtual page address 2 corresponds to the EL2 privilege level. Further, the two virtual page addresses do not establish a mapping relationship with the physical page addresses.
相应的,Master逻辑核可以根据Slave逻辑核触发的普通异常的类型,从特权态对应的多个特权级中选择该普通异常对应的目标特权级;然后从多个虚拟页面地址中确定出目标特权级对应的虚拟页面地址。Master逻辑核通过执行页面访问指令,来访问该目标特权级对应的虚拟页面地址,确定该虚拟页面地址未与物理页面地址建立映射关系,于是会触发异常(即页面错误)。随后,Master逻辑核由用户态陷入至特权态中的目标特权级。Correspondingly, the Master logical core can select the target privilege level corresponding to the ordinary exception from multiple privilege levels corresponding to the privileged state based on the type of ordinary exception triggered by the Slave logical core; and then determine the target privilege level from multiple virtual page addresses. The virtual page address corresponding to the level. The Master logical core accesses the virtual page address corresponding to the target privilege level by executing the page access instruction and determines that the virtual page address does not establish a mapping relationship with the physical page address, so an exception (i.e., page fault) is triggered. Subsequently, the Master logical core falls from the user state to the target privilege level in the privileged state.
示例性的,Master逻辑核确定进程触发的异常为系统调用,Master逻辑核根据系统调用确定需要将进程陷入至EL1特权级。Master逻辑核访问虚拟页面地址1,并确定当前虚拟页面地址1未对应于物理页面地址,也即虚拟页面地址1访问错误。随后,Master逻辑核触发页面错误异常,并将进程陷入至EL1特权级。如此,进程在Master逻辑核的EL1特权级运行,Master逻辑核可执行目标操作,也即处理该系统调用。For example, the Master logical core determines that the exception triggered by the process is a system call, and the Master logical core determines that the process needs to be trapped into the EL1 privilege level based on the system call. The master logical core accesses virtual page address 1 and determines that the current virtual page address 1 does not correspond to the physical page address, that is, the virtual page address 1 access error. Subsequently, the Master logical core triggers a page fault exception and traps the process into the EL1 privilege level. In this way, the process runs at the EL1 privilege level of the Master logical core, and the Master logical core can perform the target operation, that is, process the system call.
此处,无需对Master逻辑核访问该虚拟页面地址触发的页面错误,执行缺页处理,如 此,Master逻辑核可以重复触发页面错误异常,从而将进程的执行状态由Master逻辑核的用户态,陷入至Master逻辑核的特权态的目标特权级。Here, there is no need to perform page fault processing for page faults triggered by the Master logical core accessing the virtual page address, such as Therefore, the Master logical core can repeatedly trigger page fault exceptions, thereby trapping the execution state of the process from the user state of the Master logical core to the target privilege level of the Master logical core's privileged state.
进一步的,此处的页面错误,用于将进程的执行状态由Master逻辑核的用户态,陷入至Master逻辑核的特权态的目标特权级,该页面错误区分于Slave逻辑核运行进程时触发的页面错误,后者是进程运行中的真正需要处理的异常。Furthermore, the page fault here is used to change the execution state of the process from the user state of the Master logical core to the target privilege level of the privileged state of the Master logical core. This page fault is different from the one triggered when the Slave logical core runs the process. Page fault, the latter is an exception that really needs to be handled during the running of the process.
Master逻辑核在特权态执行完目标操作(或理解为处理完普通异常)之后,可以返回至跳板代码段中。具体的,Master逻辑核可返回至跳板代码段中的页面访问指令。Master逻辑核在页面访问指令之后,继续执行slave call指令,从而触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc位置继续执行。进一步的,Slave逻辑核可从配置空间的普通异常信息中读取寄存器信息,根据读取到的寄存器信息,恢复Slave逻辑核触发异常之前的、该进程的运行环境信息。After the Master logic core completes the target operation in the privileged state (or is understood to have handled ordinary exceptions), it can return to the springboard code segment. Specifically, the Master logic core can return to the page access instruction in the springboard code segment. After the page access instruction, the Master logical core continues to execute the slave call instruction, thereby triggering the operation of the Slave logical core. The Slave logical core continues execution from the interrupted position slave.pc. Furthermore, the Slave logical core can read the register information from the ordinary exception information in the configuration space, and based on the read register information, restore the running environment information of the process before the Slave logical core triggered the exception.
二、中断2. Interruption
图9示出一种进程收到中断时切换进程的执行状态的方法示意图。其中虚线方框中文字可表示Master逻辑核或者Slave逻辑核执行的动作。Figure 9 shows a schematic diagram of a method for switching the execution state of a process when the process receives an interrupt. The text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
进程在Slave逻辑核的运行过程中收到了中断,Slave逻辑核需要将该进程的运行上下文(或称为中断信息)写入至配置空间中。The process receives an interrupt during the running of the Slave logical core. The Slave logical core needs to write the running context (or interrupt information) of the process into the configuration space.
中断信息中可包括如下中一项或多项:特权级信息、收到中断的指令位置、中断原因、中断发生地址、中断参数、寄存器信息等。其中,特权级信息、中断参数、寄存器信息、中断发生地址均可参见上述普通异常中关于运行上下文的描述。The interrupt information may include one or more of the following: privilege level information, instruction location where the interrupt was received, interrupt cause, interrupt occurrence address, interrupt parameters, register information, etc. Among them, the privilege level information, interrupt parameters, register information, and interrupt occurrence address can be found in the description of the running context in the above common exception.
收到中断的指令位置同样可记为slave.pc。当Slave逻辑核恢复执行时,Slave逻辑核可从该位置slave.pc继续执行。The instruction location that received the interrupt can also be recorded as slave.pc. When the Slave logical core resumes execution, the Slave logical core can continue execution from this location slave.pc.
中断原因,指示导致中断发生的原因,比如时钟中断、串口中断、网络中断等。Interruption reason indicates the cause of the interruption, such as clock interruption, serial port interruption, network interruption, etc.
由于中断属于异步事件且需要快速被处理,则Slave逻辑核的硬件单元可将进程的执行状态陷入至特权态。此处,Slave逻辑核的硬件单元也可根据中断的类型,确定将进程陷入至特权态的哪个特权级,比如陷入至EL1特权级或EL2特权级。Since interrupts are asynchronous events and need to be processed quickly, the hardware unit of the Slave logical core can trap the execution state of the process into a privileged state. Here, the hardware unit of the Slave logical core can also determine which privilege level the process will fall into in the privileged state based on the type of interrupt, such as falling into the EL1 privilege level or the EL2 privilege level.
从Master逻辑核的角度来看,中断发生的位置是在master.pc。解释为,Slave逻辑核在执行salve.call指令的过程中发生了很多操作,比如Master逻辑核休眠、Slave逻辑核触发运行指令等。而对于Master逻辑核来说,发生中断的时机是在salve.call的执行过程中,Master逻辑核响应中断的时间点是在salve.call指令执行完,下一条指令(即master.pc指令)的执行前。From the perspective of the Master logical core, the location where the interrupt occurs is master.pc. The explanation is that the Slave logical core undergoes many operations during the execution of the salve.call instruction, such as the Master logical core sleeping, the Slave logical core triggering a running instruction, etc. For the Master logic core, the time when an interrupt occurs is during the execution of salve.call. The time point when the Master logic core responds to the interrupt is after the salve.call instruction is executed and the next instruction (ie, the master.pc instruction) is executed. before execution.
Master逻辑核在特权态执行完目标操作(或理解为处理完中断)之后,Master逻辑核返回到跳板代码段中的master.pc。随后,Master逻辑核继续执行slave call指令触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc处继续执行。After the Master logical core completes the target operation in the privileged state (or is understood to have processed the interrupt), the Master logical core returns to master.pc in the springboard code segment. Subsequently, the Master logical core continues to execute the slave call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
三、RAS异常3. RAS abnormality
图10示出一种进程触发RAS异常时切换进程的执行状态的方法示意图。其中虚线方框中文字可表示Master逻辑核或者Slave逻辑核执行的动作。Figure 10 shows a schematic diagram of a method for switching the execution state of a process when a process triggers a RAS exception. The text in the dotted box can represent the actions performed by the Master logical core or the Slave logical core.
RAS异常可进一步划分为同步中止(Synchronous abort,简称SErrors)和异步中止(Asynchronous abort,简称SEI)。 RAS exceptions can be further divided into synchronous abort (SErrors for short) and asynchronous abort (SEI for short).
其中,SErrors与指令的执行有关。SErrors在进入异常状态时候保持的返回地址精准的反应了发生异常的指令,有可能在执行指令过程中的任何一步发生。例如,在取指阶段失败,在译码阶段失败,在指令执行阶段等。SErrors与普通异常类似,是一个同步事件。Among them, SErrors are related to the execution of instructions. The return address maintained by SErrors when entering the exception state accurately reflects the instruction in which the exception occurred, and may occur at any step during the execution of the instruction. For example, failure in the instruction fetch phase, failure in the decoding phase, failure in the instruction execution phase, etc. SErrors are similar to ordinary exceptions and are a synchronous event.
SEI与执行的指令无关。SEI是来自于外部的存储系统(memory system),或者来自于总线(bus)上的错误,例如不可恢复的误差校正码错误(error correcting code error,ECC error)。SEI与中断类似,是一个异步事件。SEI has nothing to do with the executed instructions. SEI comes from an external memory system or an error on the bus, such as an unrecoverable error correcting code error (ECC error). SEI is similar to an interrupt and is an asynchronous event.
进程在Slave逻辑核的运行过程中,由于需要执行目标操作,则触发了RAS异常。Slave逻辑核需要将该进程的运行上下文(或称为RAS异常信息)写入至配置空间中。When the process is running on the Slave logical core, a RAS exception is triggered because it needs to perform the target operation. The slave logical core needs to write the running context of the process (or RAS exception information) into the configuration space.
RAS异常信息中可包括如下中一项或多项:特权级信息、触发RAS异常的指令位置、RAS异常原因、RAS异常发生地址、RAS异常参数、寄存器信息等。RAS exception information may include one or more of the following: privilege level information, instruction location that triggers RAS exception, RAS exception cause, RAS exception occurrence address, RAS exception parameters, register information, etc.
其中,特权级信息、RAS异常参数、寄存器信息、RAS异常发生地址均可参见上述普通异常中关于运行上下文的描述。Among them, the privilege level information, RAS exception parameters, register information, and RAS exception occurrence address can be found in the description of the running context in the above common exceptions.
触发RAS异常的指令位置同样可记为slave.pc。当Slave逻辑核恢复执行时,Slave逻辑核可从该slave.pc继续执行。The instruction location that triggers the RAS exception can also be recorded as slave.pc. When the Slave logical core resumes execution, the Slave logical core can continue execution from the slave.pc.
RAS异常原因,指示导致RAS异常发生的原因,比如误差校正码错误等。RAS abnormality reason, indicating the cause of RAS abnormality, such as error correction code error, etc.
Slave逻辑核的硬件单元可将进程的执行状态,由原来的用户态陷入至特权态。其中,特权态具体可以固件(firmware)态,比如该firmware态对应于EL3特权级。相应的,Slave逻辑核的硬件单元可将进程的执行状态陷入至EL3特权级。在RAS异常中,还可将用户态称为是特权态中的EL0特权级,该EL0特权级低于特权态中的其他特权级。The hardware unit of the Slave logical core can drop the execution state of the process from the original user state to the privileged state. Among them, the privileged state can specifically be a firmware state. For example, the firmware state corresponds to the EL3 privilege level. Correspondingly, the hardware unit of the Slave logical core can trap the execution state of the process to the EL3 privilege level. In RAS exceptions, the user state can also be called the EL0 privilege level in the privileged state. The EL0 privilege level is lower than other privilege levels in the privileged state.
从Master逻辑核的特权态角度来看,RAS异常发生的位置是在master.pc。解释为,salve逻辑核在执行salve.call指令的过程中发生了很多操作,比如Master逻辑核休眠、Slave逻辑核触发运行指令等。而对于Master逻辑核来说,发生RAS异常的时机是在salve.call的执行过程中,Master逻辑核响应RAS异常的时间点是在salve.call指令执行完,下一条指令(即master.pc指令)的执行前。From the perspective of the privileged state of the Master logical core, the RAS exception occurs in master.pc. The explanation is that the salve logical core undergoes many operations during the execution of the salve.call instruction, such as the Master logical core sleeping, the Slave logical core triggering a running instruction, etc. For the Master logical core, the time when a RAS exception occurs is during the execution of salve.call. The time point when the Master logical core responds to the RAS exception is after the salve.call instruction is executed, and the next instruction (i.e. the master.pc instruction ) before execution.
Master逻辑核在EL3特权级中处理RAS异常,得到RAS异常的处理结果。其中RAS异常的处理结果可用于指示RAS异常是否可恢复。Master逻辑核从EL3特权级返回至EL1特权级,或者说,从firmware态返回至内核态。The Master logical core handles RAS exceptions in the EL3 privilege level and obtains the RAS exception processing results. The RAS exception processing result can be used to indicate whether the RAS exception is recoverable. The Master logical core returns from the EL3 privilege level to the EL1 privilege level, or in other words, returns from the firmware state to the kernel state.
相应的,Master逻辑核在EL1特权级获取RAS异常的处理结果,根据RAS异常的处理结果确定RAS异常可恢复时,Master逻辑核在EL1特权级执行目标操作,并返回至配置空间中记录的master.pc位置对应的指令(即master.pc指令)。根据RAS异常的处理结果确定RAS异常不可恢复时,Master逻辑核在EL1特权级执行panic内核处理。Correspondingly, the Master logical core obtains the RAS exception processing result at the EL1 privilege level. When it is determined that the RAS exception is recoverable based on the RAS exception processing result, the Master logical core performs the target operation at the EL1 privilege level and returns to the master recorded in the configuration space. The instruction corresponding to the .pc position (that is, the master.pc instruction). When it is determined that the RAS exception is unrecoverable based on the RAS exception processing result, the Master logical core performs panic kernel processing at the EL1 privilege level.
在一种可能方式中,Master逻辑核在EL3特权级中处理RAS异常时,具体可以是Master逻辑核的firmware执行如下步骤(a)至(c):In one possible way, when the Master logical core handles RAS exceptions in the EL3 privilege level, the firmware of the Master logical core may perform the following steps (a) to (c):
(a)保存用户态上下文,恢复EL3特权级上下文。(a) Save the user mode context and restore the EL3 privilege level context.
(b)读取配置空间中RAS异常信息,根据RAS异常信息对RAS异常做处理,比如尝试对内存页面进行修复。(b) Read the RAS exception information in the configuration space, and handle the RAS exception based on the RAS exception information, such as trying to repair the memory page.
(c)保存EL3特权级上下文,恢复用户态上下文,设置ESR_EL1、FAR_EL1、SPSR_EL1等寄存器,由于EL1特权级是通过ESR_EL1、FAR_EL1、SPSR_EL1这些寄存器来获取异常的一些状态,设置这些寄存器的目的是使EL1特权级认为异常的来源为用户态,在EL1特权级处理异常后,通过ERET指令返回用户态,而非返回至EL3特权级对应的Fireware。 (c) Save the EL3 privilege level context, restore the user mode context, and set the ESR_EL1, FAR_EL1, SPSR_EL1 and other registers. Since the EL1 privilege level obtains some exception status through the ESR_EL1, FAR_EL1, SPSR_EL1 registers, the purpose of setting these registers is to enable The EL1 privilege level believes that the source of the exception is the user mode. After the EL1 privilege level handles the exception, it returns to the user mode through the ERET instruction instead of returning to the Fireware corresponding to the EL3 privilege level.
Master逻辑核的特权态处理完目标操作之后,Master逻辑核返回到跳板代码段中的master.pc指令。随后,Master逻辑核继续执行slave call指令触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc处继续执行。After the privileged state of the Master logical core processes the target operation, the Master logical core returns to the master.pc instruction in the springboard code segment. Subsequently, the Master logical core continues to execute the slave call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
需要说明的是,上述普通异常信息、中断信息、RAS异常信息均可统称为是进程的运行上下文,其中,异常原因、中断原因、RAS异常原因可统称为是在Slave逻辑核上暂停运行进程的原因,也即进程的暂停原因;异常参数、中断参数、RAS异常参数可统称为是进程的目标操作对应的执行参数;触发异常的指令位置、收到中断的指令位置、触发RAS异常的指令位置可统称为是进程被打断的位置,或者进程的暂停位置(slave.pc),或者进程的暂停位置的信息。也可以理解,进程的运行上下文可包括如下中一项或多项:Slave逻辑核上暂停运行进程的暂停位置、在Slave逻辑核上暂停运行进程的暂停原因、目标操作对应的执行参数、寄存器信息(即暂停运行进程时的环境信息)或特权级信息。It should be noted that the above-mentioned general exception information, interrupt information, and RAS exception information can be collectively referred to as the running context of the process. Among them, the exception cause, interrupt cause, and RAS exception cause can be collectively referred to as the suspension of the running process on the Slave logical core. Reason, that is, the reason for the suspension of the process; exception parameters, interrupt parameters, and RAS exception parameters can be collectively referred to as the execution parameters corresponding to the target operation of the process; the instruction location that triggers the exception, the instruction location that receives the interrupt, and the instruction location that triggers the RAS exception. It can be collectively referred to as the location where the process was interrupted, or the pause location of the process (slave.pc), or the information of the pause location of the process. It can also be understood that the running context of a process may include one or more of the following: the pause position of the process on the Slave logical core, the reason for the suspension of the process on the Slave logical core, execution parameters corresponding to the target operation, and register information. (ie, environment information when the running process is suspended) or privilege level information.
此外,还需要补充的是,上述图6至图10中仅标注出相关实施例中的主要步骤,且各图中的步骤序号,仅在其所在图中表示各动作的前后顺序。In addition, it should be added that only the main steps in the relevant embodiments are marked in the above-mentioned Figures 6 to 10, and the step numbers in each figure only indicate the sequence of each action in the figure in which they are located.
为了更好的说明本申请实施例中普通异常、中断或RAS异常情况下,Master逻辑核和Slave逻辑核的执行位置,参照图11中例子继续说明,其中图11中左边代码段可认为是Master逻辑核中包含的跳板代码段。In order to better explain the execution positions of the Master logical core and the Slave logical core in the case of ordinary exceptions, interruptions or RAS exceptions in the embodiments of this application, continue the explanation with reference to the example in Figure 11, where the code segment on the left in Figure 11 can be considered as the Master The springboard code segment contained in the logic core.
Slave逻辑核运行进程并确定进程触发普通异常,Slave逻辑核将进程的执行状态由Slave逻辑核的用户态,切换至Master逻辑核的用户态。Master逻辑核从master.pc位置的指令(即master.pc指令)开始执行,并根据该普通异常确定需要去EL1特权级处理,于是访问EL1特权级对应的虚拟页面地址1(图11中表示为page1),随后,Master逻辑核触发该page1对应的页面错误异常之后,将进程的执行状态陷入至EL1特权级执行目标操作。Master逻辑核在执行完成该目标操作之后,返回至该访问page1的指令(即页面访问指令)处,进而返回至指令1。进一步的,Master逻辑核调用slave.call指令,触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc处继续执行。The Slave logical core runs the process and determines that the process triggers a common exception. The Slave logical core switches the execution state of the process from the user mode of the Slave logical core to the user mode of the Master logical core. The Master logical core starts executing from the instruction at the master.pc location (i.e., the master.pc instruction), and determines that it needs to go to the EL1 privilege level for processing based on the common exception, so it accesses the virtual page address 1 corresponding to the EL1 privilege level (shown as in Figure 11 page1), and then, after the Master logical core triggers the page fault exception corresponding to page1, the execution state of the process falls into the EL1 privilege level to perform the target operation. After completing the target operation, the Master logic core returns to the instruction that accesses page1 (that is, the page access instruction), and then returns to instruction 1. Further, the Master logical core calls the slave.call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
Slave逻辑核运行进程并确定进程收到中断,Slave逻辑核的硬件单元将进程的执行状态由Slave逻辑核的用户态,直接陷入至Master逻辑核的特权态(比如EL1特权级)。Master逻辑核运行该进程,以使得进程执行目标操作。在进程执行完成该目标操作之后,返回至master.pc位置的指令(即master.pc指令),进而返回至指令1。进一步的,Master逻辑核调用slave.call指令,触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc处继续执行。The Slave logical core runs the process and determines that the process has received an interrupt. The hardware unit of the Slave logical core changes the execution state of the process from the user state of the Slave logical core directly to the privileged state of the Master logical core (such as EL1 privilege level). The Master logical core runs the process so that the process performs the target operation. After the process completes the target operation, it returns to the instruction at the master.pc location (that is, the master.pc instruction), and then returns to instruction 1. Further, the Master logical core calls the slave.call instruction to trigger the Slave logical core to run, and the Slave logical core continues execution from the interrupted location slave.pc.
Slave逻辑核运行进程并确定进程触发RAS异常,Slave逻辑核的硬件单元将进程的执行状态由Slave逻辑核的用户态,直接陷入至Master逻辑核的特权态(比如EL3特权级)。Master逻辑核运行该进程,以使得进程执行目标操作。在进程执行完成该目标操作之后,返回至master.pc位置的指令(即master.pc指令),进而返回至指令1。Master逻辑核调用slave.call指令,触发Slave逻辑核运行,Slave逻辑核从被打断位置slave.pc处继续执行。The Slave logical core runs the process and determines that the process triggers a RAS exception. The hardware unit of the Slave logical core changes the execution state of the process from the user state of the Slave logical core directly to the privileged state of the Master logical core (such as EL3 privilege level). The Master logical core runs the process so that the process performs the target operation. After the process completes the target operation, it returns to the instruction at the master.pc location (that is, the master.pc instruction), and then returns to instruction 1. The Master logical core calls the slave.call instruction to trigger the Slave logical core to run. The Slave logical core continues execution from the interrupted location slave.pc.
上述技术方案中,Master逻辑核和Slave逻辑核二者通过配置空间进行信息交互,实现Master逻辑核和Slave逻辑核的解耦合,从而Master逻辑核和Slave逻辑核二者可以独立发展,也即,在不破坏Master逻辑核对应的架构语义/指令空间的前提下,可实现Slave逻辑核对应指令集的独立演进。如此,Slave逻辑核可运行加速引擎及算法,比如mySql 进程、图计算进程或加解密算子中的一项或多项,相比于Master逻辑核可提高运算速率。In the above technical solution, the Master logic core and the Slave logic core exchange information through the configuration space to realize the decoupling of the Master logic core and the Slave logic core, so that the Master logic core and the Slave logic core can develop independently, that is, Without destroying the architectural semantics/instruction space corresponding to the Master logical core, the independent evolution of the instruction set corresponding to the Slave logical core can be achieved. In this way, the Slave logical core can run acceleration engines and algorithms, such as mySql One or more of the processes, graph calculation processes, or encryption and decryption operators can increase the computing speed compared to the Master logical core.
进一步的,当运行在Slave逻辑核的进程需要执行目标操作时,Slave逻辑核可将进程的运行上下文写入至配置空间,该运行上下文中包括Slave逻辑核暂停运行进程对应的暂停位置。相应的,Master逻辑核执行完成该进程的目标操作之后,可继续启动Slave逻辑核运行该进程,随后,Slave逻辑核可从配置空间中读取该暂停位置,继续在该暂停位置处继续执行该进程。如此,可实现进程在Master逻辑核和Slave逻辑核之间切换运行状态。Further, when a process running on the Slave logical core needs to perform a target operation, the Slave logical core can write the running context of the process into the configuration space. The running context includes the pause location corresponding to the paused process of the Slave logical core. Correspondingly, after the Master logical core completes the target operation of the process, it can continue to start the Slave logical core to run the process. Subsequently, the Slave logical core can read the pause position from the configuration space and continue to execute the process at the pause position. process. In this way, the process can switch the running state between the Master logical core and the Slave logical core.
需要补充的是,在本申请中,逻辑核、进程和目标操作之间的关系可以理解为,进程运行于逻辑核(Slave逻辑核或Master逻辑核)中,进程执行目标操作也即其运行时所在的逻辑核(比如Master逻辑核)执行目标操作。It should be added that in this application, the relationship between the logical core, the process and the target operation can be understood as the process runs in the logical core (Slave logical core or Master logical core), and the process executes the target operation, that is, its runtime The logical core where it is located (such as the Master logical core) performs the target operation.
基于上述内容和相同构思,本申请提供一种计算机程序产品,计算机程序产品包括计算机程序或指令,当计算机程序或指令被装置执行时,实现上述方法实施例中的方法。Based on the above content and the same concept, this application provides a computer program product. The computer program product includes a computer program or instructions. When the computer program or instructions are executed by a device, the method in the above method embodiment is implemented.
基于上述内容和相同构思,本申请提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序或指令,当计算机程序或指令被计算设备执行时,实现上述方法实施例中的方法。Based on the above content and the same concept, this application provides a computer-readable storage medium. Computer programs or instructions are stored in the computer-readable storage medium. When the computer program or instructions are executed by a computing device, the method in the above method embodiment is implemented. .
基于上述内容和相同构思,本申请提供一种计算设备,包括处理器,处理器与存储器相连,存储器用于存储计算机程序,处理器用于执行存储器中存储的计算机程序,以使得计算设备实现上述方法实施例中的方法。Based on the above content and the same concept, this application provides a computing device, including a processor. The processor is connected to a memory. The memory is used to store computer programs. The processor is used to execute the computer program stored in the memory, so that the computing device implements the above method. Methods in Examples.
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定。It can be understood that the various numerical numbers involved in the embodiments of the present application are only for convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the serial numbers of the above processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的保护范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。 Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the protection scope of the present application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and equivalent technologies, the present application is also intended to include these modifications and variations.

Claims (21)

  1. 一种进程的执行状态切换方法,其特征在于,应用于中央处理器CPU,所述CPU包括物理核,所述物理核包括主逻辑核和从逻辑核,所述方法包括:A method for switching execution states of a process, which is characterized in that it is applied to a central processing unit (CPU). The CPU includes a physical core, and the physical core includes a master logical core and a slave logical core. The method includes:
    如果运行在所述从逻辑核的进程满足第一条件,在所述从逻辑核中暂停运行所述进程,并记录所述进程的暂停位置,所述暂停位置用于下次在所述从逻辑核中运行所述进程时确定执行位置,其中,所述第一条件用于指示所述进程待执行目标操作,且所述目标操作在所述进程的执行状态处于所述主逻辑核的特权态时能够被执行;If the process running on the slave logical core meets the first condition, the process is suspended in the slave logical core, and the pause position of the process is recorded. The pause position is used for the next time the slave logical core is used. The execution position is determined when the process is running in the core, wherein the first condition is used to indicate that the process is to perform a target operation, and the target operation is in the privileged state of the main logical core when the execution state of the process is can be executed;
    将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的特权态;Switch the execution state of the process from the user state of the slave logical core to the privileged state of the main logical core;
    在所述主逻辑核中运行所述进程,以供所述进程执行所述目标操作。The process is run in the main logical core, so that the process performs the target operation.
  2. 如权利要求1所述的方法,其特征在于,所述记录所述进程的暂停位置,包括:The method of claim 1, wherein recording the pause position of the process includes:
    通过所述从逻辑核将所述暂停位置的信息写入配置空间,所述配置空间用于所述主逻辑核与所述从逻辑核进行信息交互。The information about the pause position is written into a configuration space through the slave logic core, and the configuration space is used for information interaction between the master logic core and the slave logic core.
  3. 如权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, further comprising:
    将所述进程的执行状态由所述主逻辑核的特权态切换为所述从逻辑核的用户态;Switch the execution state of the process from the privileged state of the master logical core to the user state of the slave logical core;
    通过所述从逻辑核从所述配置空间读取所述暂停位置的信息;Read the information of the pause position from the configuration space through the slave logic core;
    在所述从逻辑核中,从所述暂停位置开始继续运行所述进程。In the slave logical core, the process continues to run from the pause position.
  4. 如权利要求1至3任一项所述的方法,其特征在于,所述第一条件包括所述进程触发第一类异常,所述第一类异常包括除可靠性异常、可用性异常、以及可服务性RAS异常以外的其它异常;The method according to any one of claims 1 to 3, characterized in that the first condition includes the process triggering a first type of exception, and the first type of exception includes reliability exception, availability exception, and availability exception. Exceptions other than service RAS exceptions;
    所述将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的特权态,包括:Switching the execution state of the process from the user state of the slave logical core to the privileged state of the main logical core includes:
    触发所述主逻辑核运行所述进程,以将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的用户态;Triggering the main logical core to run the process to switch the execution state of the process from the user mode of the slave logical core to the user mode of the main logical core;
    从所述主逻辑核的特权态的多个特权级中确定所述第一类异常对应的目标特权级;Determine the target privilege level corresponding to the first type of exception from multiple privilege levels of the privileged state of the main logical core;
    将所述进程的执行状态由所述主逻辑核的用户态切换为所述主逻辑核的特权态的所述目标特权级。Switch the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core.
  5. 如权利要求4所述的方法,其特征在于,所述将所述进程的执行状态由所述主逻辑核的用户态切换为所述主逻辑核的特权态的所述目标特权级之前,还包括:The method of claim 4, wherein before switching the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core, include:
    获取所述目标特权级对应的虚拟内存地址;Obtain the virtual memory address corresponding to the target privilege level;
    确定所述虚拟内存地址未与物理内存地址建立映射关系。It is determined that the virtual memory address does not establish a mapping relationship with the physical memory address.
  6. 如权利要求1至3任一项所述的方法,其特征在于,所述第一条件包括所述进程收到中断,或者所述进程触发RAS异常。The method according to any one of claims 1 to 3, wherein the first condition includes the process receiving an interrupt, or the process triggering a RAS exception.
  7. 如权利要求1至6任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 6, characterized in that the method further includes:
    在所述主逻辑核中启动所述进程;Start the process in the main logical core;
    如果所述进程的指令集属于所述从逻辑核运行的指令集,记录所述进程的起始位置,并触发所述从逻辑核进入运行状态;If the instruction set of the process belongs to the instruction set running from the slave logical core, record the starting position of the process and trigger the slave logical core to enter the running state;
    在所述从逻辑核中,从所述起始位置开始运行所述进程。In the slave logical core, the process is run starting from the starting position.
  8. 如权利要求1至7任一项所述的方法,其特征在于,所述方法还包括: The method according to any one of claims 1 to 7, characterized in that the method further includes:
    释放所述主逻辑核在运行所述进程时所占用的所述物理核的硬件资源;Release the hardware resources of the physical core occupied by the main logical core when running the process;
    其中,所述硬件资源包括内存资源和/或输入输出资源。Wherein, the hardware resources include memory resources and/or input and output resources.
  9. 如权利要求1至8中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 8, characterized in that the method further includes:
    通过所述从逻辑核记录如下信息中的一项或多项:One or more of the following information is recorded through the slave logic core:
    在所述从逻辑核上暂停运行所述进程的原因,所述目标操作对应的执行参数,暂停运行所述进程时的环境信息,或,特权级信息;其中,所述特权级信息用于指示所述进程在执行所述目标操作时所述主逻辑核的特权态的特权级。The reason why the process is suspended on the slave logical core, the execution parameters corresponding to the target operation, the environment information when the process is suspended, or privilege level information; wherein the privilege level information is used to indicate The privilege level of the privileged state of the main logical core when the process performs the target operation.
  10. 一种执行状态的切换装置,其特征在于,包括处理器和存储器;An execution state switching device, characterized in that it includes a processor and a memory;
    所述存储器用于存储计算机程序;The memory is used to store computer programs;
    所述处理器用于调用所述存储器所存储的计算机程序,以执行如下步骤:The processor is used to call the computer program stored in the memory to perform the following steps:
    如果运行在所述从逻辑核的进程满足第一条件,在所述从逻辑核中暂停运行所述进程,并记录所述进程的暂停位置,所述暂停位置用于下次在所述从逻辑核中运行所述进程时确定执行位置,其中,所述第一条件用于指示所述进程待执行目标操作,且所述目标操作在所述进程的执行状态处于所述主逻辑核的特权态时能够被执行;If the process running on the slave logical core meets the first condition, the process is suspended in the slave logical core, and the pause position of the process is recorded. The pause position is used for the next time the slave logical core is used. The execution position is determined when the process is running in the core, wherein the first condition is used to indicate that the process is to perform a target operation, and the target operation is in the privileged state of the main logical core when the execution state of the process is can be executed;
    将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的特权态;Switch the execution state of the process from the user state of the slave logical core to the privileged state of the main logical core;
    在所述主逻辑核中运行所述进程,以供所述进程执行所述目标操作。The process is run in the main logical core, so that the process performs the target operation.
  11. 如权利要求10所述的装置,其特征在于,所述处理器在记录所述进程的暂停位置时,具体用于:通过所述从逻辑核将所述暂停位置的信息写入配置空间,所述配置空间用于所述主逻辑核与所述从逻辑核进行信息交互。The device according to claim 10, wherein when the processor records the pause position of the process, it is specifically configured to: write the information of the pause position into the configuration space through the slave logical core, so The configuration space is used for information interaction between the master logic core and the slave logic core.
  12. 如权利要求11所述的装置,其特征在于,所述处理器还用于:The device of claim 11, wherein the processor is further configured to:
    将所述进程的执行状态由所述主逻辑核的特权态切换为所述从逻辑核的用户态;Switch the execution state of the process from the privileged state of the master logical core to the user state of the slave logical core;
    通过所述从逻辑核从所述配置空间读取所述暂停位置的信息;Read the information of the pause position from the configuration space through the slave logic core;
    在所述从逻辑核中,从所述暂停位置开始继续运行所述进程。In the slave logical core, the process continues to run from the pause position.
  13. 如权利要求10至12任一项所述的装置,其特征在于,所述第一条件包括所述进程触发第一类异常,所述第一类异常包括除可靠性异常、可用性异常、以及可服务性RAS异常以外的其它异常;The device according to any one of claims 10 to 12, wherein the first condition includes the process triggering a first type of exception, and the first type of exception includes reliability exception, availability exception, and availability exception. Exceptions other than service RAS exceptions;
    所述处理器在将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的特权态时,具体用于:When the processor switches the execution state of the process from the user state of the slave logical core to the privileged state of the main logical core, it is specifically used to:
    触发所述主逻辑核运行所述进程,以将所述进程的执行状态由所述从逻辑核的用户态切换为所述主逻辑核的用户态;Triggering the main logical core to run the process to switch the execution state of the process from the user mode of the slave logical core to the user mode of the main logical core;
    从所述主逻辑核的特权态的多个特权级中确定所述第一类异常对应的目标特权级;Determine the target privilege level corresponding to the first type of exception from multiple privilege levels of the privileged state of the main logical core;
    将所述进程的执行状态由所述主逻辑核的用户态切换为所述主逻辑核的特权态的所述目标特权级。Switch the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core.
  14. 如权利要求13所述的装置,其特征在于,所述处理器在将所述进程的执行状态由所述主逻辑核的用户态切换为所述主逻辑核的特权态的所述目标特权级之前,还用于:The apparatus of claim 13, wherein the processor switches the execution state of the process from the user state of the main logical core to the target privilege level of the privileged state of the main logical core. Previously, also used for:
    获取所述目标特权级对应的虚拟内存地址;Obtain the virtual memory address corresponding to the target privilege level;
    确定所述虚拟内存地址未与物理内存地址建立映射关系。It is determined that the virtual memory address does not establish a mapping relationship with the physical memory address.
  15. 如权利要求10至12任一项所述的装置,其特征在于,所述第一条件包括所述进程收到中断,或者所述进程触发RAS异常。 The apparatus according to any one of claims 10 to 12, wherein the first condition includes the process receiving an interrupt, or the process triggering a RAS exception.
  16. 如权利要求10至15任一项所述的装置,其特征在于,所述处理器还用于:The device according to any one of claims 10 to 15, wherein the processor is further configured to:
    在所述主逻辑核中启动所述进程;Start the process in the main logical core;
    如果所述进程的指令集属于所述从逻辑核运行的指令集,记录所述进程的起始位置,并触发所述从逻辑核进入运行状态;If the instruction set of the process belongs to the instruction set running from the slave logical core, record the starting position of the process and trigger the slave logical core to enter the running state;
    在所述从逻辑核中,从所述起始位置开始运行所述进程。In the slave logical core, the process is run starting from the starting position.
  17. 如权利要求10至16任一项所述的装置,其特征在于,所述处理器还用于:The device according to any one of claims 10 to 16, wherein the processor is further configured to:
    释放所述主逻辑核在运行所述进程时所占用的所述物理核的硬件资源;Release the hardware resources of the physical core occupied by the main logical core when running the process;
    其中,所述硬件资源包括内存资源和/或输入输出资源。Wherein, the hardware resources include memory resources and/or input and output resources.
  18. 如权利要求10至17中任一项所述的装置,其特征在于,所述处理器还用于:The device according to any one of claims 10 to 17, wherein the processor is further configured to:
    通过所述从逻辑核记录如下信息中的一项或多项:One or more of the following information is recorded through the slave logic core:
    在所述从逻辑核上暂停运行所述进程的原因,所述目标操作对应的执行参数,暂停运行所述进程时的环境信息,或,特权级信息;其中,所述特权级信息用于指示所述进程在执行所述目标操作时所述主逻辑核的特权态的特权级。The reason why the process is suspended on the slave logical core, the execution parameters corresponding to the target operation, the environment information when the process is suspended, or privilege level information; wherein the privilege level information is used to indicate The privilege level of the privileged state of the main logical core when the process performs the target operation.
  19. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序或指令,当所述计算机程序或指令被装置执行时,实现如权利要求1至9中任一项所述的方法。A computer program product, characterized in that the computer program product includes a computer program or instructions, and when the computer program or instructions are executed by a device, the method according to any one of claims 1 to 9 is implemented.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序或指令,当所述计算机程序或指令被计算设备执行时,实现如权利要求1至9中任一项所述的方法。A computer-readable storage medium, characterized in that a computer program or instructions are stored in the computer-readable storage medium. When the computer program or instructions are executed by a computing device, any one of claims 1 to 9 is implemented. method described in the item.
  21. 一种计算设备,其特征在于,包括处理器,所述处理器与存储器相连,所述存储器用于存储计算机程序,所述处理器用于执行所述存储器中存储的计算机程序,以使得所述计算设备执行如权利要求1至9中任一项所述的方法。 A computing device, characterized in that it includes a processor, the processor is connected to a memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the calculation The device performs the method according to any one of claims 1 to 9.
PCT/CN2023/079222 2022-03-11 2023-03-02 Method and apparatus for switching execution status of process WO2023169289A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210238502.2 2022-03-11
CN202210238502.2A CN116775234A (en) 2022-03-11 2022-03-11 Method and device for switching execution state of process

Publications (1)

Publication Number Publication Date
WO2023169289A1 true WO2023169289A1 (en) 2023-09-14

Family

ID=87937220

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/079222 WO2023169289A1 (en) 2022-03-11 2023-03-02 Method and apparatus for switching execution status of process

Country Status (2)

Country Link
CN (1) CN116775234A (en)
WO (1) WO2023169289A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070226740A1 (en) * 2006-02-28 2007-09-27 Xiao-Feng Li Method and apparatus for global breakpoint for parallel debugging on multiprocessor systems
US20110099550A1 (en) * 2009-10-26 2011-04-28 Microsoft Corporation Analysis and visualization of concurrent thread execution on processor cores.
CN111400002A (en) * 2020-03-09 2020-07-10 聚好看科技股份有限公司 Application process and processor core binding method and terminal
CN112667318A (en) * 2020-12-31 2021-04-16 京信网络系统股份有限公司 Binding method, device, equipment and storage medium of logic core
CN113867828A (en) * 2020-06-30 2021-12-31 华为技术有限公司 Method and device for running process

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070226740A1 (en) * 2006-02-28 2007-09-27 Xiao-Feng Li Method and apparatus for global breakpoint for parallel debugging on multiprocessor systems
US20110099550A1 (en) * 2009-10-26 2011-04-28 Microsoft Corporation Analysis and visualization of concurrent thread execution on processor cores.
CN111400002A (en) * 2020-03-09 2020-07-10 聚好看科技股份有限公司 Application process and processor core binding method and terminal
CN113867828A (en) * 2020-06-30 2021-12-31 华为技术有限公司 Method and device for running process
CN112667318A (en) * 2020-12-31 2021-04-16 京信网络系统股份有限公司 Binding method, device, equipment and storage medium of logic core

Also Published As

Publication number Publication date
CN116775234A (en) 2023-09-19

Similar Documents

Publication Publication Date Title
US7966615B2 (en) Transitioning of virtual machine from replay mode to live mode
US8429669B2 (en) Virtual machine switching control by prefetching information out of and updating a set of processor control information based on a bitmap having update status
US7793286B2 (en) Methods and systems to manage machine state in virtual machine operations
US6480952B2 (en) Emulation coprocessor
US7356735B2 (en) Providing support for single stepping a virtual machine in a virtual machine environment
US7768518B2 (en) Enabling multiple instruction stream/multiple data stream extensions on microprocessors
Fattori et al. Dynamic and transparent analysis of commodity production systems
JP7538950B2 (en) COMPUTER DEVICE, EXCEPTION PROCESSING METHOD, AND INTERRUPT PROCESSING METHOD - Patent application
US12014199B1 (en) Virtualization extension modules
JP6530723B2 (en) System and method for facilitating joint operation of multiple hypervisors in a computer system
US10049064B2 (en) Transmitting inter-processor interrupt messages by privileged virtual machine functions
CN111459623B (en) Method, device and computer for restoring running of application program
US9053022B2 (en) Synchronous software interface for an accelerated compute engine
WO2023169289A1 (en) Method and apparatus for switching execution status of process
CN111506395B (en) Method and device for realizing hybrid simulation full-digital virtual operating environment
US7890740B2 (en) Processor comprising a first and a second mode of operation and method of operating the same
US7673125B2 (en) Resetting multiple cells within a partition of a multiple partition computer system
US9959225B2 (en) Computer apparatus and control method of computer apparatus
US8732721B2 (en) Method for reducing trap overhead when executing a guest in a virtual machine
EP4187387A1 (en) Inter-process communication method and apparatus, and computer storage medium
JP2022107229A (en) Information processing apparatus, control method, and control program
Oikawa et al. Simultaneous virtual-machine logging and replay
JP2022055002A (en) Information processing device, information processing method, and information processing program
JP2020086872A (en) Debug system, bios, information processor, and debug method
Oikawa et al. Simultaneous logging and replay for recording evidences of system failures

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

Country of ref document: EP

Kind code of ref document: A1