WO2024037482A1 - 一种中断消息处理方法及装置 - Google Patents

一种中断消息处理方法及装置 Download PDF

Info

Publication number
WO2024037482A1
WO2024037482A1 PCT/CN2023/112829 CN2023112829W WO2024037482A1 WO 2024037482 A1 WO2024037482 A1 WO 2024037482A1 CN 2023112829 W CN2023112829 W CN 2023112829W WO 2024037482 A1 WO2024037482 A1 WO 2024037482A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
interrupt
cpu
event
identifier
Prior art date
Application number
PCT/CN2023/112829
Other languages
English (en)
French (fr)
Inventor
郭寒军
李硕
丁帅
缪勰
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024037482A1 publication Critical patent/WO2024037482A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application is designed in the field of chip technology, and in particular relates to an interrupt message processing method and device.
  • Kernel mode is the mode in which the operating system kernel runs. Processes running in this mode can have unlimited access to system memory and peripheral devices ( For example, hard disk, network card), etc. are accessed; user mode refers to a non-privileged state. Processes running in this state are restricted by hardware and cannot perform certain privileged operations.
  • the CPU needs to switch from user mode to kernel mode, save the CPU context, switch processes, and other operations. After that, the CPU switches to user mode to complete the data processing tasks.
  • the CPU In the process of processing interrupt messages, it can be seen that it is necessary to switch between user mode and kernel mode multiple times, which is a big challenge for delay-sensitive services.
  • This application provides an interrupt message processing method and device, which converts the interrupt message into an event message when waking up the CPU through an interrupt message, realizes point-to-point waking up of the CPU, and shortens the delay in processing the interrupt message.
  • this application provides an interrupt message processing device.
  • the device includes a first CPU and a first interrupt controller.
  • the first interrupt controller communicates with the first CPU through a bus, wherein the first interrupt controller is used to Receive the first interrupt message, convert the first interrupt message into the first event message, and send the first event message to the first CPU; the first CPU is used to respond to the first event message in the user mode, starting from low power consumption The mode is converted to a non-low power consumption mode and the first event is processed in user mode.
  • the first event message carries an identifier of the CPU; the first CPU is specifically configured to confirm the identifier carried in the first event message after receiving the first event message.
  • the identifier of the CPU is the identifier of the first CPU, and when the first CPU is in the low power consumption mode, the CPU is converted from the low power consumption mode to the non-low power consumption mode, and the first event is processed in the user mode. In this way, the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the first CPU is also configured to confirm that the identity of the CPU carried in the first event message is not the identity of the first CPU after receiving the first event message, and /Or when the first CPU is not in low power consumption mode, the first event message is discarded.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the first interrupt message further includes an identifier of the first interrupt message; the first interrupt controller is also configured to obtain the first mapping table. Including the identifier of one or more interrupt messages that need to be converted into event messages; the first interrupt controller is specifically configured to include the identifier of the first interrupt message in determining the identifier of one or more interrupt messages that need to be converted into event messages. In the case of , the first interrupt message is converted into a first event message, and the first event message is sent to the first CPU.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages. For interrupt messages that need to be converted into event messages, you can convert the interrupt message into an event message and respond to the event message directly in the user mode.
  • the first interrupt controller is also used to determine that one or more events need to be converted into events. If the identifier of the interrupt message of the message does not include the identifier of the first interrupt message, send the first interrupt message to the first CPU; the first CPU is also configured to respond to the first interrupt message in the kernel state after receiving the first interrupt message. Upon receiving an interrupt message, the system switches from the low-power mode to the non-low-power mode, then switches from the kernel mode to the user mode, and processes the first event in the user mode.
  • interrupt messages that do not need to be converted into event messages
  • the interrupt messages are still executed according to the original execution process, that is, first falling into the kernel state to respond to the interrupt message, then switching from the kernel state to the user state, and executing tasks in the user state.
  • the first interrupt controller is further configured to receive the first mapping table and convert one or more interrupt messages in the first mapping table that need to be converted into event messages.
  • the logo is saved to memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; wherein the first message type is used to indicate the first
  • the type of the interrupt message is an interrupt message, and the identifier of the first CPU is used to indicate the identifier of the CPU that processes the first interrupt message;
  • the first event message carries the second message type and the identifier of the first CPU, where the second message type Used to indicate that the type of the first event message is event message.
  • the first interrupt controller is specifically configured to obtain the identity of the first CPU from the first interrupt message after receiving the first interrupt message, based on the first CPU The identifier and the second message type are used to obtain the first event message.
  • the first interrupt controller obtains the field information from the first interrupt message, and then generates the first event message based on the obtained field information.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU;
  • the first event message carries the first message type or The second message type, the identifier of the first peripheral module, and the identifier of the first CPU.
  • the first interrupt message and the first event message further include an event identification field, wherein the value of the event identification field in the first interruption message is the first value, and the first The value of the event identification field in the event message is a second value, and the second value is different from the first value; the first interrupt controller is specifically used to change the event identification field in the first interruption message after receiving the first interruption message. The value of is modified to the second value, and the first event message is obtained.
  • the first interrupt controller can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the first interrupt controller when the message type carried in the first event message is the second message type, the first interrupt controller is also configured to convert the first event message into the first event message. The message type is changed to the second message type and the first event message is obtained. In this way, the first interrupt controller also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • the device further includes a first peripheral module, wherein the first peripheral module is configured to generate a first interrupt message when the first event is triggered; the first peripheral module The module is also configured to send a first interrupt message to the first interrupt controller; the first interrupt controller is specifically configured to receive the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: a network card, a hard disk, a graphics processor GPU, an acceleration processor APU, and an AI accelerator card NPU.
  • this application provides an interrupt message processing method.
  • the method includes: obtaining the first interrupt message; converting the first interrupt message into a first event message; and controlling the first CPU to switch from low to low in user mode through the first event message. power mode to a non-low power mode, and Handle the first event in user mode.
  • the first event message carries the identifier of the CPU; the first event message is used to control the first CPU to convert from the low power consumption mode to the non-low power consumption mode in the user mode, and processing the first event in the user mode, specifically including: when the identifier of the CPU carried in the first event message is the identifier of the first CPU, and the first CPU is in the low power consumption mode, controlling the first CPU to operate in the user mode Convert from low-power mode to non-low-power mode and process the first event in user mode.
  • the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the method further includes: the identity of the CPU carried in the first event message is not the identity of the first CPU, and/or the first CPU is in a non-low power consumption mode. Next, discard the first event message.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the first interrupt message further includes an identifier of the first interrupt message; before converting the first interrupt message into the first event message, the method further includes: obtaining the first interrupt message.
  • a mapping table the first mapping table includes the identification of one or more interrupt messages that need to be converted into event messages; converting the first interrupt message into the first event message specifically includes: determining that one or more interrupt messages need to be converted into event messages If the identifier of the interrupt message of the message includes the identifier of the first interrupt message, the first interrupt message is converted into the first event message.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the interrupt message can be converted into an event message and the event message can be directly responded to in user mode.
  • the method further includes: when it is determined that the identifier of one or more interrupt messages that need to be converted into an event message does not include the identifier of the first interrupt message, through the third interrupt message.
  • An interrupt message controls the first CPU to switch from the low power consumption mode to the non-low power consumption mode in the kernel mode, then switch from the kernel mode to the user mode, and process the first event in the user mode.
  • interrupt messages that do not need to be converted into event messages
  • the interrupt messages are still executed according to the original execution process, that is, first falling into the kernel state to respond to the interrupt message, then switching from the kernel state to the user state, and executing tasks in the user state.
  • the method before obtaining the first mapping table, further includes: receiving the first mapping table, and converting one or more requirements in the first mapping table into an event message.
  • the identifier of the interrupt message is saved to memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; wherein the first message type is used to indicate the first The type of the interrupt message is an interrupt message, and the identifier of the first CPU is used to indicate the identifier of the CPU that processes the first interrupt message; the first event message carries the second message type and the identifier of the first CPU, where the second message type Used to indicate that the type of the first event message is event message.
  • converting the first interrupt message into the first event message specifically includes: obtaining the identifier of the first CPU from the first interrupt message, based on the identifier of the first CPU and The second message type gets the first event message.
  • the first interrupt controller obtains the field information from the first interrupt message, and then generates the first event message based on the obtained field information.
  • the first interrupt message carries the first message type, the identification of the first peripheral module, and the identification of the first CPU;
  • the first event message carries the first message type or The second message type, the identifier of the first peripheral module, and the identifier of the first CPU.
  • the first interrupt message and the first event message further include an event identification field, wherein the value of the event identification field in the first interruption message is the first value, and the first The value of the event identification field in the event message is the second value, The second value is different from the first value; converting the first interrupt message into the first event message specifically includes: modifying the value of the event identification field in the first interrupt message to the second value to obtain the first event message.
  • the first interrupt controller can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the method when the message type carried by the first event message is a second message type, the method further includes: modifying the first message type in the first interrupt message to the second message type. Message type, get the first event message.
  • the first interrupt controller also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • obtaining the first interrupt message specifically includes: receiving and obtaining the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: network card, hard disk, graphics processor GPU, acceleration processor APU, and AI accelerator card NPU.
  • this application provides another interrupt message processing device, which includes an acquisition unit, an acquisition unit and a processing unit.
  • the acquisition unit is used to acquire the first interrupt message.
  • a conversion unit configured to convert the first interrupt message into the first event message.
  • the processing unit is configured to control the first CPU to convert from the low power consumption mode to the non-low power consumption mode in the user mode through the first event message, and process the first event in the user mode.
  • the interrupt message is converted into an event message to wake up the CPU point-to-point and shorten the delay in processing the interrupt message.
  • the first event message carries the identifier of the CPU.
  • the processing unit is specifically configured to control the first CPU to convert from the low-power mode in the user mode when the identifier of the CPU carried in the first event message is the identifier of the first CPU and the first CPU is in the low-power mode. It is not a low power consumption mode and handles the first event in user mode. In this way, the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the processing unit is also configured to carry an identifier of the CPU in the first event message that is not an identifier of the first CPU, and/or the first CPU is in a non-low power consumption mode. In this case, the first event message is discarded.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the first interrupt message further includes an identifier of the first interrupt message; a conversion unit is specifically configured to perform the method before converting the first interrupt message into the first event message. It also includes: obtaining a first mapping table, which includes identification of one or more interrupt messages that need to be converted into event messages; converting the first interrupt message into a first event message specifically includes: determining one or more interrupt messages; If the identifiers of the multiple interrupt messages that need to be converted into event messages include the identifier of the first interrupt message, the first interrupt message is converted into the first event message.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages. For interrupt messages that need to be converted into event messages, you can convert the interrupt message into an event message and respond to the event message directly in the user mode.
  • the conversion unit is also configured to, when it is determined that the identifier of one or more interrupt messages that need to be converted into event messages does not include the identifier of the first interrupt message, The first interrupt message is used to control the first CPU to switch from the low power consumption mode to the non-low power consumption mode in the kernel mode, then switch from the kernel mode to the user mode, and process the first event in the user mode.
  • interrupt messages that do not need to be converted into event messages
  • the interrupt messages are still executed according to the original execution process, that is, first falling into the kernel state to respond to the interrupt message, then switching from the kernel state to the user state, and executing tasks in the user state.
  • the acquisition unit is further configured to receive the first mapping table and convert one or more requirements in the first mapping table into events before acquiring the first mapping table.
  • the identifier of the interrupt message is saved to memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; wherein the first message type is used to indicate the first The type of the interrupt message is an interrupt message, and the identifier of the first CPU is used to indicate the identifier of the CPU that processes the first interrupt message; the first event message carries the second message type and the identifier of the first CPU, where the second message type Used to indicate that the type of the first event message is event message.
  • the conversion unit is specifically configured to obtain the identity of the first CPU from the first interrupt message, and obtain the first event message based on the identity of the first CPU and the second message type.
  • the conversion unit can obtain the field information from the first interrupt message, and then generate the first event message based on the obtained field information.
  • the first interrupt message carries the first message type, the identification of the first peripheral module, and the identification of the first CPU;
  • the first event message carries the first message type or The second message type, the identifier of the first peripheral module, and the identifier of the first CPU.
  • the first interrupt message and the first event message further include an event identification field, wherein the value of the event identification field in the first interruption message is the first value, and the first The value of the event identification field in the event message is the second value, and the second value is different from the first value; converting the first interrupt message into the first event message specifically includes: converting the value of the event identification field in the first interruption message Modify it to the second value and get the first event message.
  • the conversion unit can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the conversion unit when the message type carried by the first event message is the second message type, the conversion unit is also configured to modify the first message type in the first interrupt message to the second message type. Second message type, get the first event message.
  • the conversion unit also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • the obtaining unit is specifically configured to receive and obtain the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: network card, hard disk, graphics processor GPU, acceleration processor APU, and AI accelerator card NPU.
  • the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program When executed by a processor, it implements any of the above aspects provided in any possible implementation manner. Interrupt message processing method.
  • the present application provides a computer program product.
  • the computer program product When the computer program product is run on a device, it causes the device to execute an interrupt message processing method provided in any possible implementation of any of the above aspects.
  • inventions of the present application provide a chip.
  • the chip includes a processor and a communication interface.
  • the processor is configured to call and run instructions from the communication interface.
  • the chip Execute an interrupt message processing method provided in any possible implementation of any of the above aspects.
  • embodiments of the present application provide a chip system that includes the first CPU and the first interrupt controller described in any possible implementation of any of the above aspects.
  • the first CPU and the first interrupt controller are used to implement an interrupt message processing method provided in any possible implementation of any of the above aspects.
  • the chip system further includes a memory, and the memory is used to store necessary program instructions and data for an interrupt message processing method.
  • the chip system may be composed of chips, or may include chips and other discrete devices.
  • Figure 1 is a schematic diagram of a network card waking up the CPU through an interrupt message according to an embodiment of the present application
  • FIG. 2 is a system architecture diagram provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of a first CPU processing first interrupt information provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of generating and saving interrupt configuration information provided by an embodiment of the present application.
  • Figure 5A- Figure 5B exemplarily illustrate a schematic diagram of the message body of a first interrupt message and the message body of a first event message;
  • Figure 5C is a schematic diagram of the message body of a first interrupt message provided by an embodiment of the present application.
  • Figure 5D is a schematic diagram of the message body of a first event message provided by an embodiment of the present application.
  • Figure 5E is a schematic diagram of the message body of another first event message provided by an embodiment of the present application.
  • Figure 5F is a schematic diagram of the message body of yet another first event message provided by an embodiment of the present application.
  • Figures 5G to 5H exemplarily show yet another schematic diagram of the message body of the first interrupt message and the message body of the first event message;
  • Figure 6 is a flow chart of a first CPU executing a first interrupt message provided by an embodiment of the present application
  • Figure 7 is a schematic structural diagram of an interrupt message processing device provided by an embodiment of the present application.
  • FIG. 8 is a schematic flowchart of an interrupt message processing method provided by an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of another interrupt message processing device provided by an embodiment of the present application.
  • first and second are used for descriptive purposes only and shall not be understood as implying or implying relative importance or implicitly specifying the quantity of indicated technical features. Therefore, the features defined as “first” and “second” may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, “plurality” The meaning is two or more.
  • the working state of the CPU can be divided into low power consumption state and non-low power consumption state.
  • the CPU when the CPU is in a low power consumption state, the CPU stops running.
  • the CPU is running when it is in a non-low power state. In this way, when the CPU has no events to process, the CPU can be in a low power consumption state to reduce the power consumption of the CPU.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit, etc. in the CPU The functional unit starts running.
  • Method 1 When the CPU has no event processing, the CPU can run the WFE (wait for interrupt) instruction to put the CPU into a low-power state. After the CPU enters the low-power state, you can send messages to the CPU in the low-power state through other CPUs that are not in low-power mode. Send an event message to wake up the CPU and make the CPU enter a non-low power state.
  • WFE wait for interrupt
  • Method 2 When the CPU has no event processing, the CPU can run the WFI (wait for event) instruction. Causes the CPU to enter a low power consumption state. After the CPU enters the low-power state, when the peripheral module detects an event that needs to be processed, the peripheral module generates an interrupt message and sends an interrupt message to the CPU to wake up the CPU, causing the CPU to enter a non-low-power state.
  • WFI wait for event
  • the CPU can be put into a low-power mode when there is no task processing.
  • the CPU enters low power mode. If there are new tasks that require the CPU to execute, the CPU needs to be woken up to change the CPU from low-power mode to non-low-power mode.
  • Method 1 Wake up by interrupt message.
  • Method 2 Wake up by event message.
  • the interrupt message means that when the computer is running and some situation occurs that requires host intervention, the computer can automatically stop the running program and switch to processing a new program. After the processing is completed, it will return to the original suspended program to continue running.
  • Interrupt messages are used to wake up the CPU, that is, to change the CPU from low-power mode to non-low-power mode.
  • the peripheral module can send an interrupt message to the CPU. Since interrupt messages can only be processed in the operating system kernel, after the CPU receives the interrupt message, the CPU needs to switch from user mode to kernel mode. After the CPU switches to the kernel state, the CPU needs to determine which peripheral module sent the interrupt message based on the interrupt message, and save the CPU context in the memory. After that, the CPU switches to user mode to perform new tasks. After the new task event is executed, the CPU falls into the kernel again, reads the CPU context from the memory, loads the CPU context into the register, and then interrupts the task event before continuing to run.
  • Specific events are also a way to interrupt the current state of the CPU.
  • the CPU When the CPU is in low-power mode, other CPUs that are not in low-power mode can run event messages to wake up the CPU in low-power mode. After a CPU in low-power mode receives event messages sent by other CPUs that are not in low-power mode, the CPU can directly process the event message in user mode. The CPU does not need to fall into the kernel to respond to the event message. The CPU will start from low-power mode. The mode is switched to a non-low power mode. After the CPU switches to a non-low power mode, the CPU will run the program following the event message.
  • the CPU After the CPU receives the interrupt message and switches from user mode to kernel mode, the CPU needs to determine which peripheral module sent the interrupt message based on the interrupt message. The CPU also needs to suspend the previous task based on the interrupt message and execute the new task. And execute new tasks based on the switched process or thread. During the process of switching execution tasks, the CPU context needs to be saved so that the CPU can run the previously suspended process normally after switching processes.
  • Registers and program counters are the environment that the CPU must rely on before executing tasks. Among them, the register is a small-capacity but extremely fast memory built into the CPU.
  • the program counter is used to store the location of the instruction being executed by the CPU or the location of the next instruction to be executed.
  • Switching context refers to saving the register information and program counter information of the previous task before the CPU receives the interrupt message.
  • the register information and program counter information of the previous task will be saved in the kernel, and then the CPU will transfer the new task to the new task.
  • the register information and program counter information are loaded into the registers and program counter, and finally jump to the new location pointed by the program counter to start executing a new task.
  • the CPU loads the register information and program counter information of the previous task into the register and program counter again, and begins to continue executing the previous task.
  • high-performance IO Input/Output
  • DPDK data plane develop kit
  • SPDK storage perforance develop kit
  • interrupts can be used to reduce CPU power consumption. That is, when there are no network packets, the CPU enters a low power consumption (idle) state to save energy. When there is a network packet, the network card wakes up the CPU through an interrupt to complete the task of sending and receiving packets.
  • peripheral modules such as network cards
  • Figure 1 shows a schematic diagram of the network card waking up the CPU through an interrupt message.
  • the sleep condition may be that the network card does not receive network packets within a preset time.
  • the network card calls the eventfd function to send a first notification to the CPU.
  • the first notification is used to instruct the CPU to enter the low power consumption mode.
  • the low power consumption mode may be the WFI mode.
  • the CPU After the CPU enters WFI mode, if the CPU does not receive the interrupt message sent by the network card, the CPU will always be in low power consumption mode. Only after the CPU receives the interrupt message sent by the network card, the CPU switches from the low-power mode to the non-low-power mode and starts to perform the task of sending and receiving packets.
  • the network card sends an interrupt message to the CPU.
  • the network card can call the eventfd function to send an interrupt message to the CPU, and the interrupt message is used to wake up the CPU.
  • the CPU receives the interrupt message, switches from the low-power mode to the non-low-power mode, and starts processing network packets.
  • the CPU Since interrupt messages can only be processed in the kernel, to receive the interrupt message, the CPU first needs to switch from user mode to kernel mode. After the CPU switches to the kernel state, the CPU needs to determine which peripheral module sent the interrupt message based on the interrupt message. For example, the CPU determines that the interrupt message was sent by the network card. The CPU also needs to find the corresponding process or thread, and run the process or thread to perform new tasks. If there are other processes running on the CPU, the CPU needs to pause this process and save the running data of this process to the memory. During the switching process between user mode and kernel mode and process switching process, the CPU also needs to save the CPU context. After that, the CPU switches from kernel mode to user mode. After the CPU switches to user mode, the CPU begins to perform tasks of sending and receiving packets.
  • the embodiment of the present application provides an interrupt processing method. Specifically, the method includes the following steps:
  • Step 1 The chip receives the first interrupt message sent by the first peripheral module.
  • the first interrupt message is used to wake up the first CPU in the low power consumption mode and execute the first event.
  • the type of the first peripheral module is any one of the following: storage device (such as hard disk), network device (such as network card), graphics processing unit (GPU), accelerated processing unit (APU), AI Acceleration card network processor (neural processor unit, NPU), etc.
  • the hard disk can be any of the following: solid state drive (SSD), non-volatile memory host controller interface specification (non-volatile memory express, NVMe), etc.
  • the first interrupt message includes the following fields: message type, peripheral module identifier, interrupt information identifier, and interrupt information routing identifier.
  • the message type is a first message type, and the first message type is used to indicate that the message is an interrupt message.
  • the identification of the peripheral module is the first peripheral module, the first peripheral module is used to indicate which peripheral module sent the first interrupt message.
  • the identifier of the interrupt information is interrupt one, and interrupt one is used to indicate the interrupt identifier of the first interrupt message.
  • the routing identifier of the interrupt message is the first CPU, and the first CPU user indicates the CPU identifier for processing the first interrupt message.
  • Step 2 After receiving the first interrupt message, the chip converts the first interrupt message into a first event message based on preset rules.
  • the first event message includes the following fields: message type and routing identifier of the interrupt information.
  • the message type is a second message type, and the second message type is used to indicate that the message is an event message.
  • the routing identifier of the interrupt information is the first CPU, and the first CPU user indicates the CPU identifier for processing the first event message.
  • the routing identifier of the interrupt information in the first event message is obtained by the chip from the first interrupt message.
  • the chip After the chip receives the first interrupt message, and before the chip converts the first interrupt message into the first event message based on preset rules, the chip also needs to read the interrupt configuration information from the memory. After the interrupt configuration information Search to see if there is an interrupt identifier of the first interrupt message. If so, convert the first interrupt message into the first event message according to the preset rules. If not, the chip directly sends the first interrupt message to the first CPU.
  • Step 3 After the chip converts the first interrupt message into the first event message, the chip sends the first event message to the first CPU.
  • the first event message is used to instruct the first CPU to wake up in the low power consumption mode and execute the first step. an event.
  • the first CPU receives the first event message, the first CPU does not need to fall into the operating system kernel to respond to the first event message, but can directly read data from the first peripheral module and execute the first event.
  • the chip directly sends the first event message to the first CPU.
  • the first CPU needs to fall into the operating system
  • the kernel responds to the first interrupt message and executes the first event.
  • the interrupt message can be converted into an event message.
  • the first CPU does not need to fall into the operating system kernel, save the CPU context, or switch contexts.
  • the chip converts the first interrupt message into the first event message and wakes up the first CPU through the first event message.
  • the first CPU can directly execute the first event corresponding to the first event message without falling into the operating system kernel to respond.
  • the first event message shortens the delay in waking up the CPU.
  • the first event message carries the identification of the first CPU.
  • the chip can send the first event message to the first CPU through the bus to realize point-to-point wake-up of the CPU, which solves the problem of accidentally waking up other CPUs in the current situation due to the current event message wake-up. Low power CPU issue.
  • interrupt messages into event messages it is not limited to converting interrupt messages into event messages.
  • the embodiments of this application can also be applied to converting event messages into interrupt messages. The principles are similar.
  • the following embodiments of this application take how to convert interrupt messages into event messages as an example. illustrate.
  • Figure 2 exemplarily shows a system architecture diagram provided by an embodiment of the present application.
  • the operating state of the operating system is divided into user mode and kernel mode. Some operations with a high safety factor, such as setting the clock and clearing memory, need to be processed in the kernel mode and cannot be processed in the user mode. While the application is running, it will repeatedly switch between user mode and kernel mode. Among them, the CPU in kernel mode can access any data, including memory and other data. The CPU in user mode can only have limited access to memory, for example, it is not allowed to access memory and other data.
  • the application program when the CPU is running in user mode, the application program (such as DPDK or SPDK) can provide an interface to configure the interrupt of the peripheral module to be converted into an event.
  • the interrupt strategy configuration module can be used to receive the interrupt identifier, which is the interrupt identifier of the interrupt message that needs to be converted into an event in the peripheral module.
  • the kernel state When the CPU is running in the kernel state, the kernel state needs to provide a user state configuration interface to enable the user state to transfer the interrupt identifier in the peripheral module to the kernel state that needs to be converted into an event message.
  • the kernel state has the ability to operate and configure peripheral modules.
  • the interrupt configuration module is used to configure the interrupt messages in the peripheral module that need to be converted into event messages, that is, convert the interrupt messages of the peripheral module into event messages and generate interrupt configuration information.
  • the interrupt configuration information may also be called an interrupt mapping table (for example, the first mapping table).
  • the interrupt mapping table records one or more interrupt identifiers of final interrupt messages that need to be converted into event messages.
  • the interrupt configuration module is also used to send interrupt configuration information to the interrupt controller.
  • the hardware layer includes the interrupt controller, memory and the first CPU.
  • Interrupt controller used to save interrupt configuration information in memory.
  • the peripheral module When there is a first event on the peripheral module (such as a network card), for example, after receiving a network packet, the peripheral module sends a first interrupt message to the interrupt controller.
  • the interrupt controller is used to read the interrupt configuration information from the memory after receiving the first interrupt message sent, and search the interrupt configuration information to see whether there is an interrupt identifier of the first interrupt message. If so, then according to the predetermined Set a rule to convert the first interrupt message into the first event message interest.
  • the interrupt controller is used to read the interrupt configuration information from the memory after receiving the first interrupt message sent, and search the interrupt configuration information to see whether there is an interrupt identifier of the first interrupt message. If so, then according to the predetermined Set a rule to convert the first interrupt message into the first event message interest.
  • the interrupt controller is also used to send the first event message to the first CPU.
  • the first CPU is configured to, after receiving the first event message, determine whether to receive the first event message based on the status of the first CPU and the CPU identifier carried in the first event message. If the state of the first CPU is a low-power state and the CPU identifier carried in the first event message is the identifier of the first CPU, the first CPU receives the first event message and switches from the low-power state to a non-low-power state. state without trapping the operating system kernel to execute the first event.
  • the interrupt controller directly sends the first interrupt message to the first CPU.
  • the first CPU switches from a low-power state to a non-low-power state, and needs to fall into the operating system kernel, perform operations such as saving context and switching processes to execute the first event.
  • FIG. 3 exemplarily shows a schematic diagram of the first CPU processing the first interrupt information.
  • the interrupt controller includes an interrupt receiving module and an interrupt conversion module.
  • the first CPU includes an event message receiving module, an interrupt message receiving module, an event message filtering module, an interrupt message filtering module and a CPU processing core.
  • the peripheral module when the peripheral module has a first event that needs to be processed, the first CPU in the low power consumption mode needs to be called. At this time, the peripheral module sends a first interrupt message to the first CPU.
  • the interrupt receiving module is configured to receive the first interrupt message sent by the peripheral module. Afterwards, the interrupt receiving module sends the first interrupt message to the interrupt conversion module.
  • the interrupt conversion module is used to determine whether to convert the first interrupt message into an event message after receiving the first interrupt message.
  • the interrupt conversion module needs to send a first request to the memory through the bus.
  • the first request is used to request acquisition.
  • Interrupt configuration information is used to send the interrupt configuration information to the interrupt conversion module after receiving the first request.
  • the interrupt conversion module is also configured to, after receiving the interrupt configuration information, if it is determined that the interrupt identifier recorded in the interrupt configuration information includes the interrupt identifier of the first interrupt message, determine that the first interrupt message needs to be converted into an event message. If it is determined that the interrupt identifier recorded in the interrupt configuration information does not include the interrupt identifier of the first interrupt message, it is determined that the first interrupt message does not need to be converted into an event message.
  • the interrupt conversion module is also configured to convert the first interrupt message into the first event message based on preset rules after the interrupt conversion module determines that the first interrupt message needs to be converted into an event message.
  • preset rules For an introduction to the preset rules, reference may be made to the embodiments shown in FIGS. 5A to 5H , and the embodiments of this application will not be described in detail here.
  • the interrupt conversion module is also used to send the first event message to the bus after converting the first interrupt message into the first event message.
  • the CPU can receive the first event message through the bus.
  • the event message receiving module in the first CPU can be used to receive the first event message through the bus.
  • the event message receiving module is also used to send the first event message to the event message filtering module after receiving the first event message.
  • the event message filtering module can be used to determine whether to send the first event message to the CPU processing core of the first CPU after receiving the first event message. Specifically, the event message filtering module determines whether to send the first event message to the CPU processing core of the first CPU based on the status of the first CPU and the CPU identifier carried in the first event message. If the state of the first CPU is a low power consumption state, and the CPU identifier carried in the first event message is the identifier of the first CPU, the event message filtering module sends the first event message to the CPU processing core of the first CPU. If the state of the first CPU is not a low-power consumption state, and/or the CPU identifier carried in the first event message is not the identifier of the first CPU, the event message filtering module discards the first event message.
  • the CPU processing core receives the first event message sent by the event message filtering module.
  • the CPU processing core is also used to switch the first CPU from a low-power state to a non-low-power state after receiving the first event message, without falling into the operating system kernel to respond to the first event message, and directly execute the second event message in the user mode. an event.
  • the interrupt conversion module is also configured to send the first interrupt message to the bus after the interrupt conversion module determines that it is not necessary to convert the first interrupt message into an event message.
  • the CPU can receive the first interrupt message through the bus.
  • the interrupt message receiving module in the first CPU may be used to receive the first interrupt message through the bus.
  • the interrupt message receiving module is also configured to send the first interrupt message to the interrupt message filtering module after receiving the first interrupt message.
  • the interrupt message filtering module can be used to determine whether to send the first interrupt message to the CPU processing core of the first CPU after receiving the first interrupt message. Specifically, the interrupt message filtering module determines whether to send the first interrupt message to the CPU processing core of the first CPU based on the status of the first CPU and the CPU identifier carried in the first interrupt message. If the state of the first CPU is a low power consumption state, and the CPU identifier carried in the first interrupt message is the identifier of the first CPU, the interrupt message filtering module sends the first interrupt message to the CPU processing core of the first CPU. If the state of the first CPU is not a low-power consumption state, and/or the CPU identifier carried in the first interrupt message is not the identifier of the first CPU, the interrupt message filtering module discards the first interrupt message.
  • the CPU processing core receives the first interrupt message sent by the interrupt message filtering module.
  • the CPU processing core is also used to switch the first CPU from a low-power state to a non-low-power state after receiving the first interrupt message, and needs to fall into the operating system kernel to identify which peripheral module the first interrupt message is. Send an interrupt, and perform operations such as saving context and switching processes to execute the first event.
  • An interrupt processing method provided by an embodiment of the present application can dynamically set whether the interrupt of the peripheral module needs to be converted into an event, and generate interrupt configuration information and save it in the memory.
  • the interrupt configuration information is used by the interrupt controller to determine whether the first interrupt message needs to be converted into a first event message.
  • Figure 4 exemplarily shows a schematic diagram of generating and saving interrupt configuration information.
  • the interrupt controller receives the interrupt identifier of the first interrupt information.
  • the peripheral module can send an interrupt message to the CPU. Developers or users can choose whether to convert the interrupt message of the peripheral module into an event message.
  • the first peripheral module when the first peripheral module has a first event to be processed, the first peripheral module can generate a first interrupt message and send the first interrupt message to the first CPU through the interrupt controller.
  • the first interrupt message is In order to wake up the first CPU in a low power consumption state and make the first CPU in a non-low power consumption state, the operating system kernel determines that the first interrupt message is an interrupt message sent by the first peripheral module, and starts executing the first CPU. event.
  • the interrupt controller receives the interrupt identifier of the first interrupt information.
  • the interrupt controller obtains the interrupt identifier of the peripheral module.
  • the interrupt controller After the interrupt controller obtains the interrupt identifier of the first interrupt information, in the kernel state, the interrupt controller obtains the interrupt identifier of the peripheral module.
  • the interrupt identifier of the peripheral module is used by the interrupt controller to determine the interrupt identifier of the first interrupt information. Whether the interrupt identifier is a valid interrupt identifier.
  • the interrupt controller determines whether the interrupt identifier of the first interrupt information is a valid interrupt identifier?
  • the interrupt controller After the interrupt controller obtains the interrupt identifier of the peripheral module, the interrupt controller needs to determine whether the interrupt identifier of the first interrupt information is a valid interrupt identifier. The interrupt controller needs to determine that the interrupt identifier of the first interrupt information is a valid interrupt identifier, that is, it determines which peripheral module sends the interrupt message of the interrupt identifier of the first interrupt information.
  • the interrupt identifier of the first interrupt information may also be called the interrupt number of the first interrupt information.
  • the interrupt controller can determine which peripheral module sent the interrupt information based on the interrupt number of the interrupt information.
  • the interrupt controller determines that the first interrupt information is interrupt information sent by the first peripheral module based on the interrupt identifier of the first interrupt information
  • the interrupt controller determines that the interrupt identifier of the first interrupt information is a valid interrupt identifier.
  • the interrupt controller can determine the identity of the peripheral module based on the identity of the interrupt information. After obtaining the identifiers of the interrupt information of all peripheral modules, the interrupt controller determines from the identifiers of the interrupt information of all peripheral modules whether the interrupt identifier of the first interrupt information is included. If it is included, it indicates the identifier of the first interrupt information. If the interrupt identifier is a valid interrupt identifier, S404 is executed, and the interrupt controller may determine the identifier of the first peripheral module based on the interrupt identifier of the first interrupt information. If it is not included, it means that the interrupt identifier of the first interrupt information is an invalid interrupt identifier, and S405 is executed, that is, the configuration fails.
  • an interrupt map is maintained in memory.
  • the interrupt mapping table records the mapping relationship between the identification of the peripheral module, the identification of the interrupt information and the interrupt routing identification. Among them, the identification of the peripheral module and the identification of the interrupt information are in a one-to-one correspondence, which represents the interrupt information generated by the peripheral module.
  • the interrupt routing identifier is used to indicate the identifier of the CPU that responds to the interrupt information, so the interrupt routing identifier may also be called the CPU identifier.
  • Table 1 illustrates an interrupt mapping table.
  • the network card when the peripheral module is a network card, the network card can generate the first interrupt information, the first interrupt information is identified as interrupt one, and the first interrupt information is used to wake up the first CPU.
  • the peripheral module when the peripheral module is a hard disk, the network card can generate second interrupt information, the second interrupt information is identified as interrupt two, and the second interrupt information is used to wake up the second CPU.
  • the peripheral module is a GPU
  • the network card can generate third interrupt information, the third interrupt information is identified as interrupt three, and the third interrupt information is used to wake up the third CPU.
  • the identification of the above-mentioned peripheral module, the identification of the peripheral module and the routing identification of the interrupt are in a one-to-one mapping relationship, that is, the interrupt controller can find the identification of the unique peripheral module based on the identification of the interrupt information, that is, determine to send the interrupt Information peripheral module.
  • first interrupt information, the second interrupt information and the third interrupt information can also wake up the same CPU, which is not limited in the embodiment of the present application.
  • the interrupt controller Before the interrupt controller determines whether the interrupt identifier of the first interrupt information is a valid interrupt identifier, the interrupt controller can obtain the interrupt mapping table from the memory, and whether the interrupt identifier of the first interrupt information can be found in the interrupt mapping table, If it can be found, it means that the interrupt identifier of the first interrupt information is a valid interrupt identifier. If it cannot be found, it means that the interrupt identifier of the first interrupt information is an invalid interrupt identifier.
  • the interrupt controller determines whether the interrupt identifier of the first interrupt information has been configured?
  • the interrupt controller determines whether the interrupt identifier of the first interrupt information has been configured to avoid repeated configuration.
  • the interrupt controller obtains the interrupt configuration information from the memory and checks whether the interrupt identifier of the first interrupt information can be found from the interrupt configuration information.
  • Table 2 exemplarily shows the identifier of the interrupt information that needs to be converted into an event message recorded in the interrupt configuration information. As shown in Table 2, the identifiers of the interrupt information that need to be converted into event messages include interrupt two and interrupt three.
  • the interrupt controller can obtain the interrupt configuration information and see whether it includes the interrupt identifier of the first interrupt information. If it can be found, it means that the interrupt identifier of the first interrupt information has been configured before, and there is no need to repeat the configuration. S405 is executed, that is, the configuration fails.
  • interrupt identifier of the first interrupt information is not found in the interrupt configuration information, it means that the interrupt identifier of the first interrupt information has not been configured before.
  • S406 is executed to add the interrupt identifier of the first interrupt information to the interrupt configuration information. Update interrupt configuration information.
  • interrupt controller may also execute S404 first and then execute S403.
  • the embodiment of the present application does not limit the execution order of S403 and S404.
  • the interrupt controller obtains the interrupt identifier of the first interrupt information after determining that the interrupt identifier of the first interrupt information is a valid interrupt identifier and that the interrupt identifier of the first interrupt information has not been configured.
  • the interrupt controller adds the interrupt identifier of the first interrupt information to the interrupt configuration information, and updates the interrupt configuration information.
  • the interrupt controller adds the interrupt identifier of the first interrupt information, such as interrupt one, to the interrupt configuration information, updates the interrupt configuration information, and obtains the updated interrupt configuration information shown in Table 3.
  • the interrupt identifier of the first interrupt information such as interrupt one
  • the interrupt controller sends the updated interrupt configuration information to the memory, so that the updated interrupt configuration information is stored in the memory.
  • the interrupt controller sends the updated interrupt configuration information to the memory, so that the updated interrupt configuration information is stored in the memory.
  • the interrupt controller can dynamically update the interrupt configuration information in the memory. It can not only add the interrupt identifier of the interrupt information in the interrupt configuration information, but also remove the interrupt identifier of the interrupt information, that is, remove the interrupt information. The interrupt identifier does not need to be converted into an event message.
  • the interrupt controller After the interrupt controller receives the first interrupt information sent by the first peripheral module, the interrupt controller obtains the interrupt configuration information from the memory and determines that the interrupt configuration information includes the interrupt identifier of the first interrupt information. An interrupt message is converted into the first event message.
  • Method 1 The interrupt controller obtains the routing identifier of the interrupt information from the message body of the first interrupt message, fills it in the message body of the first event message, and obtains the first event message.
  • FIG. 5A-FIG. 5B exemplarily show a schematic diagram of the message body of a first interrupt message and the message body of a first event message.
  • FIG. 5A is a schematic diagram of the message body of the first interrupt message.
  • the message body of the first interrupt message includes the following fields: message type, identifier of the peripheral module, identifier of the interrupt information, and routing identifier of the interrupt information.
  • the message type is a first message type, and the first message type is used to indicate that the message is an interrupt message.
  • the identifier of the peripheral module is the first peripheral module, and the first peripheral module is used to indicate which peripheral module sent the first interrupt message.
  • the identifier of the interrupt information is interrupt one, and interrupt one is used to indicate the interrupt identifier of the first interrupt message.
  • the routing identifier of the interrupt message is the first CPU, and the first CPU user indicates the CPU identifier for processing the first interrupt message.
  • the message body of the first interrupt message may also include other fields, such as the type of interrupt message and other fields.
  • the message body of the first interrupt message may not include the identification field of the peripheral module, because the interrupt controller can determine the peripheral device that sent the first interrupt message based on the identification of the interrupt information (ie, interrupt one). module (ie, the first peripheral module), which is not limited in the embodiments of this application.
  • the interrupt controller can obtain the routing identifier of the interrupt information from the message body of the first interrupt message and fill it into the message body of the first event message to obtain the first event message.
  • Figure 5B is a schematic diagram of the message body of the first event message.
  • the message body of the first event message includes the following fields: message type and routing identifier of the interrupt information.
  • the message type is a second message type, and the second message type is used to indicate that the message is an event message.
  • the routing identifier of the interrupt information is the first CPU, and the first CPU user indicates the CPU identifier for processing the first event message.
  • the routing identifier of the interrupt message is obtained from the message body of the first interrupt message.
  • the message body of the first event message may also include other fields, such as event message type and other fields.
  • the event message type may be used to indicate that the event message is converted from an interrupt message. The embodiments of the present application do not limit this.
  • Method 2 After receiving the message body of the first interrupt message, the interrupt controller adds an event identification field to the message body of the first interrupt message, and sets the value of the event identification field to the first value.
  • the first event message is obtained, where the first value is used to indicate that the message type is the first event message.
  • Figures 5C to 5F exemplarily illustrate another schematic diagram of the message body of the first interrupt message and the message body of the first event message.
  • FIG. 5C is a schematic diagram of the message body of the first interrupt message.
  • the message body of the first interrupt message includes the following fields: message type, peripheral module identifier, interrupt information identifier, interrupt information routing identifier, and event identifier.
  • the message type is a first message type, and the first message type is used to indicate that the message is an interrupt message.
  • the identifier of the peripheral module is the first peripheral module, and the first peripheral module is used to indicate which peripheral module sent the first interrupt message.
  • the identifier of the interrupt information is interrupt one, and interrupt one is used to indicate the interrupt identifier of the first interrupt message.
  • the routing identifier of the interrupt message is the first CPU, and the first CPU user indicates the CPU identifier for processing the first interrupt message.
  • the event identifier is element 0, which is used to identify the message type as an interrupt message.
  • the message body of the first interrupt message may also include other fields, such as the type of interrupt message and other information.
  • the message body of the first interrupt message may not include the identifier of the peripheral module, because the interrupt controller can determine the peripheral module that sent the first interrupt message based on the identifier of the interrupt information (ie, interrupt one). (i.e., the first peripheral module), the embodiment of the present application does not limit this.
  • Figure 5D is a schematic diagram of the message body of a first event message.
  • the message body of the first event message includes the following fields: message type, peripheral module identifier, interrupt information identifier, interrupt information routing identifier, and event identifier.
  • the message type is the first message type.
  • the identification of the peripheral module is the first peripheral module.
  • the interrupt information is identified as interrupt one.
  • the routing identifier of the interrupt information is the first CPU.
  • the event identifier is element 1, which is used to identify the message type as an event message. That is to say, after the interrupt controller receives the first interrupt message and determines that the first interrupt message needs to be converted into the first event message, the interrupt controller changes the event identifier from element 0 to element 1 to obtain the first event message. .
  • the message type in the message body of the first event message is the first message type, and the first message type is used to indicate that the message is an interrupt message
  • the value of the event identifier in the message body of the first event message is element 1, that is, the interrupt controller can confirm that the first event message is an event message obtained by converting the interrupt message based on the first message type and the value of the event identifier being element 1.
  • Figure 5E is a schematic diagram of another message body of the first event message.
  • the format of the message body of the first event message shown in Figure 5E is similar to the format of the message body of the first event message shown in Figure 5D.
  • the interrupt controller receives the first interrupt message and determines that the first interrupt message needs to be converted into the first event message, the interrupt controller changes the event identifier from element 0 to Element 1, it is also necessary to change the message type from the first message type to the second message type to obtain the first event message.
  • Figure 5F is a schematic diagram of another message body of the first event message.
  • the format of the message body of the first event message shown in Figure 5F is similar to the format of the message body of the first event message shown in Figure 5D.
  • the interrupt controller receives the first interrupt message and determines that the first interrupt message needs to be converted into the first event message, the interrupt controller changes the event identifier from element 0 to For element 1, you also need to delete the message type field to get the first event message.
  • Method 3 After receiving the message body of the first interrupt message, the interrupt controller modifies the message type field from the first message type to the second message type based on the message body of the first interrupt message to obtain the first event. information.
  • Figures 5G to 5H exemplarily illustrate yet another schematic diagram of the message body of the first interrupt message and the message body of the first event message.
  • FIG. 5G is a schematic diagram of the message body of the first interrupt message.
  • FIG. 5G is a schematic diagram of the message body of the first interrupt message.
  • Figure 5H is a schematic diagram of the message body of the first event message.
  • Figure 5H is similar to Figure 5G.
  • the difference between Figure 5H and Figure 5G is that the value of the message type field is different.
  • the value of the message type field in the first interrupt message is the first message type, and the first message type is used to indicate that the message is an interrupt message.
  • the interrupt controller After the interrupt controller receives the first interrupt message and determines that the first interrupt message needs to be converted into the first event message, the interrupt controller changes the value of the message type field in the first interrupt message from the first message type to the first event message. Two message types. The second message type is used to indicate that the message is an even message.
  • the first interruption information can also be converted into the first event message based on other methods. This is not done in the embodiment of this application. limited.
  • the interrupt controller After the interrupt controller converts the first interrupt message into the first event message, the first event message carries the routing identifier of the interrupt information, that is, the identifier of the CPU that responded to the first event message (ie, the first CPU). In this way, on the one hand, the interrupt controller can send the first event message to the first CPU through the bus to realize point-to-point wake-up of the CPU, which solves the current problem of waking up the CPU through the event message and accidentally waking up other low-power CPUs. On the other hand, the interrupt controller converts the first interrupt message into the first event message, and wakes up the first CPU through the first event message. The first CPU can directly execute the first event corresponding to the first event message without being trapped in the operating system. The kernel responds to the first event message, shortening the delay in waking up the CPU.
  • FIG. 6 exemplarily shows a flow chart of the first CPU executing the first interrupt message.
  • the interrupt controller receives the first interrupt information.
  • the peripheral module When there is a first event on the peripheral module (such as a network card), for example, after receiving a network packet, the peripheral module sends a first interrupt message to the interrupt controller.
  • the first interrupt message carries the first message type, the identifier of the first peripheral module, the interrupt identifier of the first interrupt message, and the identifier of the first CPU; where the first message type is used to indicate the type of the first interrupt message.
  • the identifier of the first peripheral module is used to indicate the identifier of the peripheral module that sent the first interrupt message
  • the identifier of the first CPU is used to indicate the identifier of the CPU that processes the first interrupt message.
  • the network card can send the first interrupt message to the first CPU.
  • the first interrupt message is used to wake up the first CPU so that the first CPU reads the network packet. network packet.
  • the interrupt controller obtains the interrupt configuration information.
  • the interrupt controller After the interrupt controller receives the first interrupt information, the interrupt controller needs to obtain the interrupt configuration information from the memory.
  • the interrupt configuration information can also be called an interrupt mapping table (for example, the first mapping table).
  • the interrupt configuration information records a Or multiple interrupt identifiers of final interrupt messages that need to be converted into event messages.
  • the interrupt controller determines whether the first interrupt information needs to be converted into an event message?
  • the interrupt controller may determine whether the first interrupt information needs to be converted into an event message based on the interrupt configuration information.
  • the interrupt controller can search from the interrupt configuration information whether there is an interrupt identifier of the first interrupt message. If there is, then according to the preset rules, convert the first interrupt message into the first event message, and the interrupt controller executes S604. If not, there is no need to convert the first interrupt message into an event message, and the interrupt controller executes S605.
  • the interrupt controller converts the first interrupt message into the first event message based on the preset rules.
  • the interrupt controller sends the first interrupt message to the first CPU.
  • the interrupt controller may send the first interrupt message to the first CPU through the bus.
  • the interrupt controller sends the first event message to the first CPU.
  • the interrupt controller After the interrupt controller converts the first interrupt message into the first event message, the interrupt controller sends the first event message to the first CPU.
  • the interrupt controller may send the first event message to the first CPU through the bus.
  • the first CPU receives the first event message.
  • the first CPU converts to a non-low power consumption mode and directly executes the first event without falling into the operating system kernel to respond to the first event message.
  • the first CPU determines whether to receive the first event message based on the status of the first CPU and the CPU identifier carried in the first event message. If the state of the first CPU is a low-power state and the CPU identifier carried in the first event message is the identifier of the first CPU, the first CPU receives the first event message and switches from the low-power state to a non-low-power state. state, and does not need to fall into the operating system kernel core to respond to the first event message and directly execute the first event.
  • the first CPU discards the first event message.
  • the state of the first CPU is converted to a non-low power consumption state, and the first CPU directly executes the next instruction of the first event message, that is, it determines whether a network packet arrives. Since the network card only sends the first interrupt command to the first CPU after confirming that a network packet has arrived, the first CPU can directly read the network packet from the network card after receiving the first event message and complete the packet collection. process.
  • the first CPU receives the first interrupt message.
  • the first CPU switches to a non-low power consumption mode, falls into the operating system kernel, responds to the first interrupt message, and executes the first event.
  • the first CPU determines whether to receive the first interrupt message based on the status of the first CPU and the CPU identifier carried in the first interrupt message. If the state of the first CPU is a low power consumption state and the CPU identifier carried in the first interrupt message is the identifier of the first CPU, the first CPU receives the first interrupt message and switches from the low power consumption state to a non-low power consumption state. state, the operating system kernel responds to the first interrupt message and executes the first event.
  • the first CPU discards the first interrupt message.
  • the state of the first CPU is converted to a non-low power consumption state. Since the first interrupt message can only be processed in the operating system kernel, the CPU receives the first interrupt message. First, the CPU needs to switch from user mode to kernel mode. After the CPU switches to the kernel state, the CPU needs to determine which peripheral module sent the interrupt message based on the first interrupt message. For example, the CPU determines that the first interrupt message is sent by the network card. The CPU also needs to find the corresponding process or thread, and run the process or thread to perform new tasks. If there are other processes saved on the CPU, the CPU needs to pause the running of this process, then run to the new process, and run the data Save to memory.
  • the CPU also needs to save the CPU context. After that, the CPU switches from kernel mode to user mode. After the CPU switches to user mode, the CPU calls the business process, reads the operating data from the memory, and completes the packet collection process.
  • Figure 7 is a schematic structural diagram of an interrupt message processing device provided by an embodiment of the present application.
  • the device 700 may include a first CPU and a first interrupt controller.
  • the first CPU and the first interrupt controller communicate through the bus.
  • the first interrupt controller is used to receive the first interrupt message, convert the first interrupt message into a first event message, and send the first event message to the first CPU.
  • the first CPU is configured to respond to the first event message in the user mode, convert from the low power consumption mode to the non-low power consumption mode, and process the first event in the user mode.
  • the first event message carries an identification of the CPU; the first CPU is specifically configured to confirm that the identification of the CPU carried in the first event message is the first after receiving the first event message.
  • An identifier of a CPU and when the first CPU is in a low power consumption mode, it converts from the low power consumption mode to a non-low power consumption mode, and processes the first event in the user mode. In this way, the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the first CPU is also configured to confirm that the identity of the CPU carried in the first event message is not the identity of the first CPU, and/or the first CPU after receiving the first event message. When in non-low power consumption mode, the first event message is discarded.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the first interrupt message also includes an identifier of the first interrupt message; the first interrupt controller is also configured to obtain the first mapping table, and the first mapping table includes one or more The identifier of the interrupt message that needs to be converted into an event message; the first interrupt controller is specifically used to determine that the identifier of one or more interrupt messages that need to be converted into an event message includes the identifier of the first interrupt message.
  • the first interrupt message is converted into a first event message, and the first event message is sent to the first CPU.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages. For interrupt messages that need to be converted into event messages, you can convert the interrupt message into an event message and respond to the event message directly in the user mode.
  • the first interrupt controller is further configured to send the first interrupt message when it is determined that the identifier of one or more interrupt messages that need to be converted into event messages does not include the identifier of the first interrupt message.
  • An interrupt message is sent to the first CPU; the first CPU is also configured to, after receiving the first interrupt message, respond to the first interrupt message in the kernel state, convert from the low power consumption mode to the non-low power consumption mode, and then switch from the kernel state to the first interrupt message. Switch to user mode and handle the first event in user mode.
  • interrupt messages that do not need to be converted into event messages
  • the interrupt messages are still executed according to the original execution process, that is, first falling into the kernel state to respond to the interrupt message, then switching from the kernel state to the user state, and executing tasks in the user state.
  • the first interrupt controller is also configured to receive the first mapping table and save the identifiers of one or more interrupt messages in the first mapping table that need to be converted into event messages into the memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; where the first message type is used to indicate that the type of the first interrupt message is In the interrupt message, the identity of the first CPU is used to indicate the identity of the CPU that processes the first interrupt message; the first event message carries the second message type and the identity of the first CPU, where the second message type is used to indicate the first The type of event message is event message.
  • the first interrupt controller is specifically configured to, after receiving the first interrupt message, obtain the identity of the first CPU from the first interrupt message, based on the identity of the first CPU and the second The message type gets the first event message.
  • the first interrupt controller obtains the field information from the first interrupt message, and then generates the first event message based on the obtained field information.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU;
  • the first event message carries the first message type or the second message type, The identification of the first peripheral module and the identification of the first CPU.
  • the first interrupt message and the first event message further include an event identification field, wherein the value of the event identification field in the first interruption message is the first value, and the first The value of the event identification field in the event message is a second value, and the second value is different from the first value; the first interrupt controller is specifically used to change the event identification field in the first interruption message after receiving the first interruption message. The value of is modified to the second value, and the first event message is obtained.
  • the first interrupt controller can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the first interrupt controller when the message type carried in the first event message is the second message type, the first interrupt controller is also configured to convert the first event message into the first event message. The message type is changed to the second message type and the first event message is obtained. In this way, the first interrupt controller also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • the device further includes a first peripheral module, where the first peripheral module is configured to generate a first interrupt message when the first event is triggered; the first peripheral module is also configured to Send the first interrupt message to the first interrupt controller; the first interrupt controller is specifically configured to receive the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: a network card, a hard disk, a graphics processor GPU, an acceleration processor APU, and an AI accelerator card NPU.
  • FIG. 8 is a schematic flowchart of an interrupt message processing method provided by an embodiment of the present application.
  • the first interrupt message also includes an identifier of the first interrupt message; before converting the first interrupt message into the first event message, the method further includes: obtaining the first mapping table, A mapping table includes the identification of one or more interrupt messages that need to be converted into event messages; converting the first interrupt message into the first event message specifically includes: determining one or more interrupt messages that need to be converted into event messages. If the identifier includes the identifier of the first interrupt message, the first interrupt message is converted into the first event message.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages. For interrupt messages that need to be converted into event messages, you can convert the interrupt message into an event message and respond to the event message directly in the user mode.
  • the method further includes: when it is determined that the identifier of one or more interrupt messages that need to be converted into event messages does not include the identifier of the first interrupt message, controlling the first interrupt message through the first interrupt message.
  • a CPU switches from the low power consumption mode to the non-low power consumption mode in the kernel mode, then switches from the kernel mode to the user mode, and processes the first event in the user mode.
  • the interrupt messages will still be executed according to the original execution flow, that is, they will first fall into
  • the kernel state responds to the interrupt message, switches from the kernel state to the user state, and performs tasks in the user state.
  • the method before obtaining the first mapping table, further includes: receiving the first mapping table, and identifying one or more interrupt messages in the first mapping table that need to be converted into event messages. Save to memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; where the first message type is used to indicate that the type of the first interrupt message is In the interrupt message, the identity of the first CPU is used to indicate the identity of the CPU that processes the first interrupt message; the first event message carries the second message type and the identity of the first CPU, where the second message type is used to indicate the first The type of event message is event message.
  • converting the first interrupt message into the first event message specifically includes: obtaining the identifier of the first CPU from the first interrupt message, based on the identifier of the first CPU and The second message type gets the first event message.
  • the first interrupt controller obtains the field information from the first interrupt message, and then generates the first event message based on the obtained field information.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU;
  • the first event message carries the first message type or the second message type, The identification of the first peripheral module and the identification of the first CPU.
  • the first interrupt message and the first event message further include an event identification field, wherein the value of the event identification field in the first interruption message is the first value, and the first The value of the event identification field in the event message is the second value, and the second value is different from the first value; converting the first interrupt message into the first event message specifically includes: converting the value of the event identification field in the first interruption message Modify it to the second value and get the first event message.
  • the first interrupt controller can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the method when the message type carried by the first event message is a second message type, the method further includes: modifying the first message type in the first interrupt message to the second message type to obtain the second message type. An event message.
  • the first interrupt controller also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the first event message carries the identification of the CPU; the first event message is used to control the first CPU to convert from the low-power mode to the non-low-power mode in the user mode, and process it in the user mode.
  • the first event specifically includes: when the identity of the CPU carried in the first event message is the identity of the first CPU, and the first CPU is in the low power consumption mode, controlling the first CPU to switch from the low power consumption mode to the user mode. Convert to non-low power mode and process the first event in user mode. In this way, the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the method further includes: when the identity of the CPU carried in the first event message is not the identity of the first CPU, and/or the first CPU is in a non-low power consumption mode, discarding the first event message.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • obtaining the first interrupt message specifically includes: receiving and obtaining the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: network card, hard disk, graphics processor GPU, acceleration processor APU, and AI accelerator card NPU.
  • FIG. 9 is a schematic flowchart of another interrupt message processing device provided by an embodiment of the present application.
  • the device 900 may include an acquisition unit 901, a conversion unit 902 and a processing unit 903.
  • the device 900 can be used to perform an interrupt message processing method shown in the embodiment of FIG. 8 .
  • the obtaining unit 901 is used to obtain the first interrupt message.
  • the conversion unit 902 is used to convert the first interrupt message into the first event message.
  • the processing unit 903 is configured to control the first CPU to convert from the low power consumption mode to the non-low power consumption mode in the user mode through the first event message, and process the first event in the user mode.
  • the interrupt message is converted into an event message to wake up the CPU point-to-point and shorten the delay in processing the interrupt message.
  • the first event message carries the identification of the CPU.
  • the processing unit 903 is specifically configured to control the first CPU to switch from the low-power mode in the user mode when the identifier of the CPU carried in the first event message is the identifier of the first CPU and the first CPU is in the low-power mode. Convert to non-low power mode and process the first event in user mode. In this way, the first event message carries the identification of the CPU, which can realize point-to-point wake-up of the CPU.
  • the processing unit 903 is also configured to: When the identity of the CPU carried in the first event message is not the identity of the first CPU, and/or the first CPU is in a non-low power consumption mode, Discard the first event message.
  • the first CPU will determine whether the first event message is sent to itself. If so, it will wake up and process the first event. If not, it will continue to be in the low power consumption mode.
  • the first interrupt message also includes an identifier of the first interrupt message;
  • the conversion unit 902 is specifically configured to, before converting the first interrupt message into the first event message, the method further includes: obtaining To the first mapping table, the first mapping table includes the identification of one or more interrupt messages that need to be converted into event messages; converting the first interrupt message into the first event message specifically includes: after determining that one or more interrupt messages need to be converted If the identifier of the interrupt message that becomes the event message includes the identifier of the first interrupt message, the first interrupt message is converted into the first event message.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages. For interrupt messages that need to be converted into event messages, you can convert the interrupt message into an event message and respond to the event message directly in the user mode.
  • the conversion unit 902 is also configured to, when it is determined that the identification of one or more interrupt messages that need to be converted into event messages does not include the identification of the first interruption message, through the first interruption message.
  • the message controls the first CPU to switch from the low power consumption mode to the non-low power consumption mode in the kernel mode, then switch from the kernel mode to the user mode, and process the first event in the user mode.
  • interrupt messages that do not need to be converted into event messages
  • the interrupt messages are still executed according to the original execution process, that is, first falling into the kernel state to respond to the interrupt message, then switching from the kernel state to the user state, and executing tasks in the user state.
  • the obtaining unit 901 is also configured to receive the first mapping table before obtaining the first mapping table, and convert one or more interrupt messages in the first mapping table that need to be converted into event messages.
  • the logo is saved to memory.
  • the implementation converts some interrupt messages into event messages as required, and some interrupt messages do not need to be converted into event messages.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU; where the first message type is used to indicate that the type of the first interrupt message is In the interrupt message, the identity of the first CPU is used to indicate the identity of the CPU that processes the first interrupt message; the first event message carries the second message type and the identity of the first CPU, where the second message type is used to indicate the first The type of event message is event message.
  • the conversion unit 902 is specifically configured to obtain the identity of the first CPU from the first interrupt message, and obtain the first event message based on the identity of the first CPU and the second message type.
  • the conversion unit 902 can obtain the field information from the first interrupt message, and then generate the first event message based on the obtained field information.
  • the first interrupt message carries a first message type, an identifier of the first peripheral module, and an identifier of the first CPU;
  • the first event message carries the first message type or the second message type, The identification of the first peripheral module and the identification of the first CPU.
  • the first interrupt message and the first event message also include an event identification field, where the value of the event identification field in the first interrupt message is the first value, and the event identification field in the first event message The value of the field is the second value, and the second value is different from the first value; converting the first interrupt message into the first event message specifically includes: modifying the value of the event identification field in the first interrupt message to the second value , get the first event message.
  • the conversion unit 902 can directly modify the value of the event identification field in the first interrupt message to obtain the first event message. That is, the value of the event identification field in the first interrupt message and the first event message is different.
  • the conversion unit 902 is also configured to modify the first message type in the first interrupt message to the second message type, Get the first event message.
  • the conversion unit 902 also needs to modify the first message type in the first interrupt message to the second message type to obtain the first event message.
  • the low power consumption mode is: the first CPU stops running; the non-low power consumption mode is: the first CPU runs.
  • the addressing unit, execution unit and other functional units in the CPU stop running.
  • the addressing unit, execution unit and other functions in the CPU stop running When the CPU is in a non-low power consumption state, the addressing unit, execution unit and other functions in the CPU stop running. The unit starts running.
  • the obtaining unit 901 is specifically configured to receive and obtain the first interrupt message sent by the first peripheral module.
  • the type of the first peripheral module includes any one of the following: network card, hard disk, graphics processor GPU, acceleration processor APU, and AI accelerator card NPU.
  • This application also provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program is executed by a processor, the interrupt message processing method provided in the embodiment of FIG. 8 is implemented.
  • This application also provides a computer program product.
  • the computer program product When the computer program product is run on a device, it causes the device to execute an interrupt message processing method provided in the embodiment of FIG. 8 .
  • the embodiment of the present application also provides a chip.
  • the chip includes a processor and a communication interface.
  • the processor is used to call and run instructions from the communication interface.
  • the processor executes the instructions, the chip executes the above-mentioned steps provided in the embodiment of Figure 8.
  • the embodiment of the present application provides a chip system.
  • the chip system includes the first CPU and the first interrupt controller described in the embodiment of FIG. 7 .
  • the first CPU and the first interrupt controller are used to implement an interrupt message processing method provided in the embodiment of FIG. 8 .
  • the chip system further includes a memory, and the memory is used to store necessary program instructions and data for an interrupt message processing method.
  • the chip system may be composed of chips, or may include chips and other discrete devices.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, e.g., the computer instructions may be transferred from a website, computer, server, or data center Transmission to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) means.
  • described Computer-readable storage media can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or other integrated media that contains one or more available media.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (SSD)), etc.

Abstract

本申请提供了一种中断消息处理方法及装置。第一中断控制器,用于接收第一中断消息,将第一中断消息转换为第一event消息,并将第一event消息发送至第一CPU;第一CPU,用于在用户态响应于第一event消息,从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。该方法实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。

Description

一种中断消息处理方法及装置
本申请要求于2022年08月19日提交中国专利局、申请号为202211003207.5、申请名称为“一种中断消息处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请设计芯片技术领域,尤其涉及一种中断消息处理方法及装置。
背景技术
中央处理器(central processing unit,CPU)的工作状态可以包括内核态和用户态,内核态是操作系统内核所运行的模式,运行在该模式的进程,可以无限制地对系统内存、外围设备(例如硬盘、网卡)等进行访问;用户态指非特权状态,运行在该状态下的进程被硬件限制,不能进行某些特权操作。
为了减少CPU的耗能问题,可以尝试使用中断来降低CPU的能耗。即在没有数据时,使得CPU处于低功耗状态。有数据时,通过中断消息来唤醒CPU,使得CPU开始处理数据。
但是,在处理中断消息时,CPU需要从用户态切换至内核态,保存CPU的上下文、切换进程等操作。之后,CPU再切换至用户态,完成数据处理的任务事项。在处理中断消息的过程中,可以看出需多次在用户态和内核态之间切换,这对时延敏感性业务,是一个很大的挑战。
发明内容
本申请提供了一种中断消息处理方法及装置,实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
第一方面,本申请提供了一种中断消息处理装置,装置包括第一CPU和第一中断控制器,第一中断控制器与第一CPU通过总线通信,其中,第一中断控制器,用于接收第一中断消息,将第一中断消息转换为第一event消息,并将第一event消息发送至第一CPU;第一CPU,用于在用户态响应于第一event消息,从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。
通过该方法,实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
结合第一方面,在一种可能的实现方式中,第一event消息中携带有CPU的标识;第一CPU,具体用于在接收到第一event消息后,确认出第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
结合第一方面,在一种可能的实现方式中,第一CPU,还用于在接收到第一event消息后,确认出第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
结合第一方面,在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;第一中断控制器,还用于获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断控制器,具体用于在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息,并将第一event消息发送至第一CPU。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
结合第一方面,在一种可能的实现方式中,第一中断控制器,还用于在确定出一个或多个需要转成event 消息的中断消息的标识中不包括第一中断消息的标识的情况下,发送第一中断消息给第一CPU;第一CPU,还用于在接收到第一中断消息后,在内核态响应第一中断消息,从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
结合第一方面,在一种可能的实现方式中,第一中断控制器,还用于接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
结合第一方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
结合第一方面,在一种可能的实现方式中,第一中断控制器,具体用于在接收到第一中断消息后,从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,第一中断控制器从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
结合第一方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
结合第一方面,在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值,第二值与第一值不同;第一中断控制器,具体用于在接收到第一中断消息后,将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,第一中断控制器可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
结合第一方面,在一种可能的实现方式中,在第一event消息中携带的消息类型为第二消息类型的情况下,第一中断控制器,还用于将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。这样,第一中断控制器还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
结合第一方面,在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
结合第一方面,在一种可能的实现方式中,装置还包括第一外设模块,其中,第一外设模块,用于在触发第一事件时,产生第一中断消息;第一外设模块,还用于向第一中断控制器发送第一中断消息;第一中断控制器,具体用于接收第一外设模块发送的第一中断消息。
结合第一方面,在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
第二方面,本申请提供了一种中断消息处理方法,方法包括:获取第一中断消息;将第一中断消息转换为第一event消息;通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并 在用户态处理第一事件。
通过该方法,实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
结合第二方面,在一种可能的实现方式中,第一event消息中携带有CPU的标识;通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件,具体包括:在第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
结合第二方面,在一种可能的实现方式中,方法还包括:在第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
结合第二方面,在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;在将第一中断消息转换为第一event消息之前,方法还包括:获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断消息转换为第一event消息,具体包括:在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
结合第二方面,在一种可能的实现方式中,方法还包括:在确定出一个或多个需要转成event消息的中断消息的标识中不包括第一中断消息的标识的情况下,通过第一中断消息控制第一CPU在内核态从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
结合第二方面,在一种可能的实现方式中,在获取到第一映射表之前,方法还包括:接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
结合第二方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
结合第二方面,在一种可能的实现方式中,将第一中断消息转换为第一event消息,具体包括:从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,第一中断控制器从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
结合第二方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
结合第二方面,在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值, 第二值与第一值不同;将第一中断消息转换为第一event消息,具体包括:将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,第一中断控制器可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
结合第二方面,在一种可能的实现方式中,在第一event消息携带的消息类型为第二消息类型的情况下,方法还包括:将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
这样,第一中断控制器还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
结合第二方面,在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
结合第二方面,在一种可能的实现方式中,获取第一中断消息,具体包括:接收并获取到第一外设模块发送的第一中断消息。
结合第二方面,在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
第三方面,本申请提供了另一种中断消息处理装置,装置包括获取单元、获取单元和处理单元。其中获取单元,用于获取第一中断消息。
转换单元,用于将第一中断消息转换为第一event消息。
处理单元,用于通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。
实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
结合第三方面,在一种可能的实现方式中,第一event消息中携带有CPU的标识。处理单元,具体用于在第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
结合第三方面,在一种可能的实现方式中,处理单元,还用于在第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
结合第三方面,在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;转换单元,具体用于在将第一中断消息转换为第一event消息之前,方法还包括:获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断消息转换为第一event消息,具体包括:在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
结合第三方面,在一种可能的实现方式中,转换单元,还用于在确定出一个或多个需要转成event消息的中断消息的标识中不包括第一中断消息的标识的情况下,通过第一中断消息控制第一CPU在内核态从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
结合第三方面,在一种可能的实现方式中,获取单元还用于在获取到第一映射表之前,接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
结合第三方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
结合第三方面,在一种可能的实现方式中,转换单元,具体用于从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,转换单元可以从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
结合第三方面,在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
结合第三方面,在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值,第二值与第一值不同;将第一中断消息转换为第一event消息,具体包括:将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,转换单元可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
结合第三方面,在一种可能的实现方式中,在第一event消息携带的消息类型为第二消息类型的情况下,转换单元还用于将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
这样,转换单元还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
结合第三方面,在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
结合第三方面,在一种可能的实现方式中,获取单元,具体用于接收并获取到第一外设模块发送的第一中断消息。
结合第三方面,在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
第四方面,本申请提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述任一方面任一可能的实现方式中提供的一种中断消息处理方法。
第五方面,本申请提供了一种计算机程序产品,当计算机程序产品在装置上运行时,使得装置执行上述任一方面任一可能的实现方式中提供的一种中断消息处理方法。
第六方面,本申请实施例提供了一种芯片,该芯片包括处理器和通信接口,所述处理器用于从该通信接口调用并运行指令,当该处理器执行所述指令时,使得该芯片执行上述任一方面任一可能的实现方式中提供的一种中断消息处理方法。
第七方面,本申请实施例提供了一种芯片系统,该芯片系统包括上述任一方面任一可能的实现方式中所述的第一CPU和第一中断控制器。所述第一CPU和第一中断控制器,用于实现上述任一方面任一可能的实现方式中提供的一种中断消息处理方法。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器,用于保存一种中断消息处理方法必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
对于第二方面至第七方面的有益效果,可以参考第一方面中有益效果的描述,本申请实施例在此不再赘述。
附图说明
图1为本申请实施例提供的一种网卡通过中断消息唤醒CPU的示意图;
图2为本申请实施例提供的一种系统架构图;
图3为本申请实施例提供的一种第一CPU处理第一中断信息的示意图;
图4为本申请实施例提供的一种生成并保存中断配置信息示意图;
图5A-图5B示例性示出了一种第一中断消息的消息体和第一event消息的消息体的示意图;
图5C为本申请实施例提供的一种第一中断消息的消息体的示意图;
图5D为本申请实施例提供的一种第一event消息的消息体的示意图;
图5E为本申请实施例提供的另一种第一event消息的消息体的示意图;
图5F为本申请实施例提供的又一种第一event消息的消息体的示意图;
图5G-图5H示例性示出了又一种第一中断消息的消息体和第一event消息的消息体的示意图;
图6为本申请实施例提供的一种第一CPU执行第一中断消息的流程图;
图7为本申请实施例提供的一种中断消息处理装置结构示意图;
图8为本申请实施例提供的一种中断消息处理方法的流程示意图;
图9为本申请实施例提供的另一种中断消息处理装置的流程示意图。
具体实施方式
下面将结合附图对本申请实施例中的技术方案进行清楚、详尽地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
在介绍本申请实施例之前,首先对本申请实施例涉及的技术术语进行解释。
1、CPU的工作状态
CPU的工作状态可以分为低功耗状态和非低功耗状态。
其中,CPU处于低功耗状态时,CPU停止运行。CPU处于非低功耗状态时,CPU正在运行。这样,在CPU没有事件需处理时,CPU可以处于低功耗状态,以减少CPU的功耗。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了,在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
有两种方式使得CPU进入低功耗状态。
方式一:在CPU没有事件处理时,CPU可以运行WFE(wait for interrupt)指令,使得CPU进入低功耗状态。在CPU进入低功耗状态之后,可以通过其他处于非低功耗模式的CPU向处于低功耗状态的CPU 发送event消息,唤醒CPU,使得CPU进入非低功耗状态。
方式二:在CPU没有事件处理时,CPU可以运行WFI(wait for event)指令。使得CPU进入低功耗状态。在CPU进入低功耗状态之后,在外设模块监测到有事件需处理时,外设模块产生中断消息并向CPU发送中断消息,唤醒CPU,使得CPU进入非低功耗状态。
2、CPU唤醒
为了减少CPU的功耗,在没有任务处理时,可以让CPU进入低功耗模式。CPU进入低功耗模式。若有新的任务事项需要CPU执行,此时需要唤醒CPU,让CPU从低功耗模式变为非低功耗模式。
目前有两种方式唤醒CPU。方式一:中断消息唤醒。方式二:event消息唤醒。
(1)、中断消息
中断消息是指计算机运行过程中,出现某些情况需主机干预时,计算机能自动停止正在运行的程序并转入处理新的程序,处理完毕后又返回原被暂停的程序继续运行。
中断可消息用于唤醒CPU,即使得CPU从低功耗模式变为非低功耗模式。具体的,在有新的任务事项来临时,外设模块可以向CPU发送中断消息。由于中断消息只能在操作系统内核中处理,因此CPU在接收到中断消息后,CPU需要从用户态切换至内核态。在CPU切换至内核态之后,CPU需基于中断消息确定出是哪个外设模块发送的中断消息,并将CPU上下文保存在内存中。之后,CPU再切换至用户态,执行新的任务事项。在新的任务事项执行完毕之后,CPU再陷入内核,从内存中读取CPU上下文,将CPU上下文加载在寄存器中,接着中断之前的任务事项继续运行。
(2)、event消息(特定的事件)
特定的事件也是打断CPU现有状态的一种方式。在CPU处于低功耗模式下,其他未处于低功耗模式的CPU可以运行event消息唤醒处于低功耗模式的CPU。处于低功耗模式的CPU在接收到其他未处于低功耗模式的CPU发送的event消息之后,CPU可以直接在用户态处理event消息,CPU不需陷入内核响应event消息,CPU将从低功耗模式切换为非低功耗模式。在CPU切换至非低功耗模式之后,CPU将运行event消息之后的程序。
但是其他未处于低功耗模式的CPU不知道什么时候需唤醒处于低功耗模式的CPU。因此其他未处于低功耗模式的CPU是随机向处于低功耗模式的CPU发送event消息的。当其他未处于低功耗模式的CPU向处于低功耗模式的CPU发送event消息之后,处于低功耗模式的CPU在接收到event消息后,将从低功耗模式切换为非低功耗模式。在处于低功耗模式的CPU切换为非低功耗模式后,回去查看是否有事件到来,若在一定时间内没有事件,则切换为非低功耗模式后的CPU又会再次切换至低功耗模式。
并且,其他未处于低功耗模式的CPU是通过总线发送event消息的,由于处于低功耗模式的CPU的数量可能有多个,那么多个处于低功耗模式的CPU在接收到event消息后,均会由非低功耗模式切换为低功耗模式,存在误唤醒的问题。
3、CPU上下文和切换上下文
在CPU接收到中断消息,CPU由用户态切换至内核态之后,CPU需要基于中断消息确定出该中断消息是哪个外设模块发送的。CPU还需基于中断消息暂停前一个任务,执行新的任务。并基于切换后的进程或者线程执行新的任务事项。在切换执行的任务事项的过程中,需要保存CPU上下文,从而使CPU在切换进程后能正常运行之前被暂停的进程。
CPU的上下文指的是寄存器信息和程序计数器信息,寄存器和程序计数器为CPU执行任务之前,必须依赖的环境。其中,寄存器是CPU内置的容量小、但速度极快的内存。程序计数器则是用来存储CPU正在执行的指令位置、或者即将执行的下一条指令位置。
切换上下文指的是,在CPU接收到中断消息之前,将前一个任务的寄存器信息和程序计数器信息保存起来,前一个任务的寄存器信息和程序计数器信息会被保存在内核中,然后CPU将新任务的寄存器信息和程序计数器信息加载到寄存器和程序计数器中,最后在跳转到程序计数器所指的新位置,开始执行新任务。在新任务执行完毕之后,CPU再次将前一个任务的寄存器信息和程序计数器信息加载到寄存器和程序计数器中,开始继续执行前一个任务。
快速处理数据包的开发平台和接口(data plane developent kit,DPDK)或者高性能存储开发包(storage perforance developent kit,SPDK)等高性能IO(Input/Output)软件,为了实现高性能,实现在用户态,一直占用CPU polling(轮询),CPU利用率100%。例如在外设模块(例如网卡)在没有接收到网络包时,CPU也在运行(即“空转”),这样会增加CPU的耗能。
为了实现高性能的同时降低CPU的功耗,可以使用中断的方式来降低CPU的功耗。即在没有网络包时,CPU进入低功耗(idle)状态,节省耗能。在有网络包时,网卡通过中断的方式来唤醒CPU,完成收发包的任务事项。
接下来对于外设模块(例如网卡)如何通过中断消息唤醒CPU的具体实现进行说明。
图1示出了网卡通过中断消息唤醒CPU的示意图。
S101、网卡判断是否有网络包?
若网卡判断出与网络包,则执行S105;否则,执行S102。
S102、网卡判断是否满足休眠条件?
若网卡判断出满足休眠条件,则执行S103;否则,执行S101。
示例性的,休眠条件可以是网卡在预设时间内没有接收到网络包。
S103、满足休眠条件时,网卡调用eventfd函数向CPU发送第一通知,第一通知用于指示CPU进入低功耗模式。
S104、CPU在接收到第一通知后,进入低功耗模式,低功耗模式可以是WFI模式。
在CPU进入WFI模式之后,若CPU没有接收到网卡发送的中断消息,则CPU一直处于低功耗模式。只有在CPU接收到网卡发送的中断消息之后,CPU由低功耗模式切换为非低功耗模式,并开始执行收发包任务事项。
S105、网卡向CPU发送中断消息。
网卡可以调用eventfd函数向CPU发送中断消息,中断消息用于唤醒CPU。
S106、CPU接收中断消息,从低功耗模式切换为非低功耗模式,开始处理网络包。
由于中断消息只能在内核中处理,CPU接收中断消息,首先CPU需要从用户态切换为内核态。在CPU切换至内核态之后,CPU需基于中断消息确定出是哪个外设模块发送的中断消息,例如CPU确定出是由网卡发送的中断消息。CPU还需查找到对应的进程或者线程,并运行该进程或者线程执行新的任务事项,若CPU上运行有其他的进程,CPU需要暂停运行此进程,并将此进程的运行数据保存至内存。在用户态和内核态切换过程中、进程切换过程中,CPU还需保存CPU上下文。之后,CPU再从内核态切换为用户态。在CPU切换至用户态之后,CPU开始执行收发包任务事项。
从上述分析过程可以发现,中断消息唤醒CPU的方式,由于中断仅能在操作系统内核中处理,因此CPU需要在用户态和内核态之间切换,保存CPU上下文、在内核态中进行进程切换等一些操组,导致基于中断的唤醒方案收发包时延大,有时会导致丢包,影响业务。
基于此,本申请实施例提供了一种中断处理方法,具体的,该方法包括以下步骤:
步骤一:芯片接收第一外设模块发送的第一中断消息,第一中断消息用于唤醒处于低功耗模式的第一CPU,执行第一事件。
第一外设模块的类型为以下任意一种:存储设备(例如硬盘)、网络设备(例如网卡)、图形处理器(graphic processing unit,GPU)、加速处理器(accelerated processing units,APU)、AI加速卡网络处理器(neural processor unit,NPU)等。其中,硬盘可以是以下任意一种:固态硬盘(solid state drive,SSD)、非易失性内存主机控制器接口规范(non-volatile memory express,NVMe)等。
第一中断消息中包括以下字段:消息类型、外设模块的标识、中断信息的标识、中断信息的路由标识。其中,消息类型为第一消息类型,第一消息类型用于指示该消息为中断消息。外设模块的标识为第一外设 模块,第一外设模块用于指示发送该第一中断消息的是哪一个外设模块。中断信息的标识为中断一,中断一用于指示第一中断消息的中断标识。中断信息的路由标识为第一CPU,第一CPU用户指示处理第一中断消息的CPU标识。
步骤二:在接收到第一中断消息之后,芯片基于预设的规则将第一中断消息转换为第一event消息。
第一event消息中包括以下字段:消息类型和中断信息的路由标识。其中,消息类型为第二消息类型,第二消息类型用于指示该消息为event消息。中断信息的路由标识为第一CPU,第一CPU用户指示处理第一event消息的CPU标识。第一event消息中的中断信息的路由标识是芯片从第一中断消息中获取到的。
对于预设规则的介绍,可以参考后续图5A-图5H所示的实施例,本申请实施例在此不做赘述。
可选的,在芯片接收到第一中断消息之后,在芯片基于预设的规则将第一中断消息转换为第一event消息之前,芯片还需从内存读取到中断配置信息,在中断配置信息中查找是否有第一中断消息的中断标识,若有的话,则按照预设规则,将第一中断消息转化为第一event消息。若没有的话,则芯片直接将第一中断消息发送至第一CPU。
步骤三:在芯片将第一中断消息转换为第一event消息之后,芯片将第一event消息发送至第一CPU,第一event消息用于指示唤醒处于低功耗模式的第一CPU,执行第一事件。第一CPU在接收到第一event消息之后,第一CPU不需要陷入操作系统内核响应第一event消息,可以直接从第一外设模块中读取数据,执行第一事件。
可选的,若芯片没有将第一中断消息转化为第一event消息,则芯片直接将第一event消息发送至第一CPU,在芯片接收到第一中断消息之后,第一CPU需陷入操作系统内核响应第一中断消息,执行第一事件。
通过该方法,可以使得通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,第一CPU不必陷入操作系统内核,不需要保存CPU上下文,也不需要切换上下文。一方面,芯片将第一中断消息转换为第一event消息,通过第一event消息唤醒第一CPU,第一CPU可以直接执行第一event消息对应的第一事件,不需要陷入操作系统内核去响应第一event消息,缩短了唤醒CPU的时延。另一方面,第一event消息中携带有第一CPU的标识,芯片可以通过总线将第一event消息发送至第一CPU,实现点对点唤醒CPU,解决了当前通过event消息唤醒CPU导致误唤醒其他处于低功耗的CPU的问题。
可选的,不仅限于将中断消息转换为event消息,本申请实施例也可以适用于将event消息转换为中断消息,原理类似,本申请以下实施例以如何将中断消息转换为event消息为例进行说明。
图2示例性示出了了本申请实施例提供的一种系统架构图。
为了区分访问能力,将操作系统的运行状态分为用户态和内核态,一些安全系数高的操作,例如设置时钟、清理内存等操作,需要在内核态下处理,而不能在用户态在处理。应用程序在运行过程中,会反复地在用户态和内核态之间切换。其中,处于内核态的CPU可以访问任意的数据,包括内存等数据。处于用户态的CPU只能受限的访问内存,例如不允许访问内存等数据。
其中,当CPU运行在用户态时,应用程序(例如DPDK或者SPDK)可以提供接口,配置外设模块的中断转为event。中断策略配置模块可以用于接收中断标识,该中断标识为外设模块中需转为event的中断消息的中断标识。
当CPU运行在内核态时,内核态需提供用户态配置接口,实现用户态向内核态传递外设模块中需转为event消息的中断标识。内核态具备操作和配置外设模块的能力。中断配置模块用于将外设模块中需转为event消息的中断消息进行配置,即将外设模块的中断消息转成event消息,生成中断配置信息。在一些实施例中,中断配置信息也可以被称为中断映射表(例如第一映射表),中断映射表中记载了一个或多个需转为event消息的终中断消息的中断标识。
中断配置模块,还用于将中断配置信息发送至中断控制器。
硬件层包括中断控制器、内存和第一CPU。
中断控制器,用于将中断配置信息保存在内存中。
外设模块(例如网卡)上有第一事件时,例如接收到网络包之后,外设模块向中断控制器发送第一中断消息。
中断控制器,用于在接收到发送的第一中断消息后,从内存读取到中断配置信息,在中断配置信息中查找是否有第一中断消息的中断标识,若有的话,则按照预设规则,将第一中断消息转化为第一event消 息。对于预设规则的介绍,可以参考后续图5A-图5H所示的实施例,本申请实施例在此不做赘述。
中断控制器,还用于将第一event消息发送至第一CPU。
第一CPU,用于在接收到第一event消息后,基于第一CPU的状态和第一event消息中携带的CPU标识,确定出是否接收第一event消息。若第一CPU的状态为低功耗状态、且第一event消息中携带的CPU标识为第一CPU的标识,则第一CPU接收第一event消息,从低功耗状态切换为非低功耗状态,并且无需陷入操作系统内核执行第一事件。
若在中断配置信息中查找没有第一中断消息的中断标识,则第一中断消息不可以转化为第一event消息,则中断控制器直接将第一中断消息发送至第一CPU。第一CPU从低功耗状态切换为非低功耗状态,且需陷入操作系统内核、执行保存上下文、切换进程等操作执行第一事件。
接下来结合中断控制器、内存和第一CPU,对第一CPU如何处理第一中断信息的进行详细的描述。
图3示例性示出了第一CPU处理第一中断信息的示意图。
如图3所示,中断控制器包含中断接收模块和中断转换模块。第一CPU包括event消息接收模块、中断消息接收模块、event消息过滤模块、中断消息过滤模块和CPU处理核。
其中,当外设模块有第一事件需要处理时,此时需唤处于低功耗模式的第一CPU,此时外设模块向第一CPU发送第一中断消息。
中断接收模块,用于接收外设模块发送的第一中断消息。之后,中断接收模块将第一中断消息发送至中断转换模块。
中断转换模块,用于在接收到第一中断消息后,为了确定出是否需将第一中断消息转换为event消息,中断转换模块需通过总线向内存发送第一请求,第一请求用于请求获取中断配置信息。内存,用于在接收到第一请求后,将中断配置信息发送至中断转换模块。
中断转换模块,还用于在接收到中断配置信息后,若确定出中断配置信息里记载的中断的标识包括第一中断消息的中断标识,则确定出需将第一中断消息转换为event消息。若确定出中断配置信息里记载的中断的标识不包括第一中断消息的中断标识,则确定出不用将第一中断消息转换为event消息。
中断转换模块,还用于在中断转换模块确定出需将第一中断消息转换为event消息后,基于预设的规则将第一中断消息转化为第一event消息。对于预设规则的介绍,可以参考后续图5A-图5H所示的实施例,本申请实施例在此不做赘述。
中断转换模块,还用于在将第一中断消息转化为第一event消息后,向总线发送第一event消息。
CPU可以通过总线接收第一event消息。
例如,第一CPU中的event消息接收模块,可用于通过总线接收到第一event消息。
event消息接收模块,还用于在接收到第一event消息后,将第一event消息发送至event消息过滤模块。
event消息过滤模块,可用于在接收到第一event消息后,确定出是否将第一event消息后,发送至第一CPU的CPU处理核。具体的,event消息过滤模块基于第一CPU的状态、第一event消息中携带的CPU标识,确定出是否将第一event消息发送至第一CPU的CPU处理核。若第一CPU的状态为低功耗状态,且第一event消息中携带的CPU标识为第一CPU的标识,则event消息过滤模块将第一event消息,发送至第一CPU的CPU处理核。若第一CPU的状态为非低功耗状态,和/或第一event消息中携带的CPU标识不是第一CPU的标识,则event消息过滤模块将第一event消息丢弃。
在第一CPU的状态为低功耗状态,且第一event消息中携带的CPU标识为第一CPU的标识的情况下,CPU处理核接收到event消息过滤模块发送的第一event消息。
CPU处理核,还用于在接收到第一event消息之后,第一CPU从低功耗状态切换为非低功耗状态,且无需陷入操作系统内核响应第一event消息,直接在用户态执行第一事件。
中断转换模块,还用于在中断转换模块确定出不需要将第一中断消息转换为event消息后,向总线发送第一中断消息。
CPU可以通过总线接收第一中断消息。
例如,第一CPU中的中断消息接收模块,可用于通过总线接收到第一中断消息。
中断消息接收模块,还用于在接收到第一中断消息后,将第一中断消息发送至中断消息过滤模块。
中断消息过滤模块,可用于在接收到第一中断消息后,确定出是否将第一中断消息后,发送至第一CPU的CPU处理核。具体的,中断消息过滤模块基于第一CPU的状态、第一中断消息中携带的CPU标识,确定出是否将第一中断消息发送至第一CPU的CPU处理核。若第一CPU的状态为低功耗状态,且第一中断消息中携带的CPU标识为第一CPU的标识,则中断消息过滤模块将第一中断消息,发送至第一CPU的CPU处理核。若第一CPU的状态为非低功耗状态,和/或第一中断消息中携带的CPU标识不是第一CPU的标识,则中断消息过滤模块奖第一中断消息丢弃。
在第一CPU的状态为低功耗状态,且第一中断消息中携带的CPU标识为第一CPU的标识的情况下,CPU处理核接收到中断消息过滤模块发送的第一中断消息。
CPU处理核,还用于在接收到第一中断消息之后,第一CPU从低功耗状态切换为非低功耗状态,且需陷入操作系统内核,识别到第一中断消息是哪个外设模块发送的中断,并执行保存上下文、切换进程等操作执行第一事件。
本申请实施例提供的一种中断处理方法,可以动态设置外设模块的中断是否需转换为event,并生成中断配置信息保存在内存中。其中,中断配置信息用于中断控制器判断是否需将第一中断消息转换为第一event消息。
图4示例性示出了生成并保存中断配置信息示意图。
S401、在用户态,中断控制器接收第一中断信息的中断标识。
基于业务需求,在外设模块有事件处理需唤醒CPU时,外设模块可以向CPU发送中断消息,开发人员或者用户可以选择是否将外设模块的中断消息转为event消息。
示例性的,第一外设模块有第一事件需处理时,第一外设模块可以产生第一中断消息,并将第一中断消息通过中断控制器发送至第一CPU,第一中断消息用于唤醒处于低功耗状态的第一CPU,并使得第一CPU处于非低功耗状态,陷入操作系统内核确定出第一中断消息为第一外设模块发送的中断消息,并开始执行第一事件。
为了避免得第一CPU在接收到第一中断消息,需要陷入操作系统内核处理第一中断消息,执行第一事件的时延比较久。因此开发人员或者用户可以选择将第一中断消息转为event消息。即中断控制器接收第一中断信息的中断标识。
S402、在内核态,中断控制器获取到外设模块的中断标识。
在中断控制器获取到第一中断信息的中断标识后,在内核态中,中断控制器获取到外设模块的中断标识,外设模块的中断标识用于中断控制器确定出第一中断信息的中断标识是否为有效的中断标识。
S403、中断控制器确定出第一中断信息的中断标识是否为有效的中断标识?
在中断控制器获取到外设模块的中断标识后,中断控制器需确定出第一中断信息的中断标识是否为有效的中断标识。中断控制器需确定出第一中断信息的中断标识为有效的中断标识,即确定出第一中断信息的中断标识是哪个外设模块发送的中断消息的中断标识。
在一些实施例中,第一中断信息的中断标识也可以被称为第一中断信息的中断号。中断控制器可以基于中断信息的中断号,确定出是哪个外设模块发送的中断信息。
例如,中断控制器基于第一中断信息的中断标识确定出第一中断信息为第一外设模块发送的中断信息后,中断控制器确定出第一中断信息的中断标识为有效的中断标识。
具体的,外设模块可以为多个,不同的外设模块产生中断信息的标识不同。中断控制器可以基于中断信息的标识确定出外设模块的标识。中断控制器在获取到所有外设模块的中断信息的标识后,从所有外设模块的中断信息的标识中确定出是否包含第一中断信息的中断标识,若包含,则说明第一中断信息的中断标识为有效的中断标识,执行S404,并且中断控制器可以基于第一中断信息的中断标识确定出第一外设模块的标识。若不包含,则说明第一中断信息的中断标识为无效的中断标识,执行S405,即配置失败。
在一些实施例中,内存中保存中断映射表。中断映射表中记载了外设模块的标识、中断信息的标识和中断的路由标识的映射关系。其中,外设模块的标识和中断信息的标识为一一对应的关系,即表征了外设模块产生的中断信息。中断的路由标识用于指示响应该中断信息的CPU的标识,因此中断的路由标识也可以被称为CPU的标识。
表1
表1示例性示出了一种中断映射表。如表1所示,外设模块为网卡时,网卡可以产生第一中断信息,第一中断信息的标识为中断一,第一中断信息用于唤醒第一CPU。外设模块为硬盘时,网卡可以产生第二中断信息,第二中断信息的标识为中断二,且第二中断信息用于唤醒第二CPU。外设模块为GPU时,网卡可以产生第三中断信息,第三中断信息的标识为中断三,且第三中断信息用于唤醒第三CPU。
上述外设模块的标识、外设模块的标识和中断的路由标识为一一映射关系,即中断控制器可以基于中断信息的标识,查找到唯一的外设模块的标识,即确定出发送该中断信息的外设模块。
需要说明的是,第一中断信息、第二中断信息和第三中断信息也可以唤醒同一个CPU,本申请实施例对此不做限定。
在中断控制器确定出第一中断信息的中断标识是否为有效的中断标识之前,中断控制器可以从内存获取到中断映射表,在中断映射表中是否可以查找到第一中断信息的中断标识,若可以查找到,则说明第一中断信息的中断标识为有效的中断标识,若没有查找到,则说明第一中断信息的中断标识为无效的中断标识。
S404、中断控制器确定出第一中断信息的中断标识是否已经配置?
在中断控制器确定出第一中断信息的中断标识是否已经配置,避免重复配置。
具体的,中断控制器从内存中获取到中断配置信息,看是否可以从中断配置信息中查找到第一中断信息的中断标识。
表2
表2示例性示出了中断配置信息中记载的需将中断消息转为event消息的中断信息的标识。如表2所示,需将中断消息转为event消息的中断信息的标识包括中断二和中断三。
那么中断控制器可以获取到中断配置信息,看其中是否包括第一中断信息的中断标识。若可以查找到,则说明之前第一中断信息的中断标识已经被配置了,无需再重复配置,执行S405,即配置失败。
若在中断配置信息中没有查找到第一中断信息的中断标识,则说明之前第一中断信息的中断标识没有被配置,执行S406,可以将第一中断信息的中断标识添加在中断配置信息中,更新中断配置信息。
需要说明的是,中断控制器也可以先执行S404,在执行S403,本申请实施例对于S403和S404的执行顺序不做限定。
S405、配置失败。
S406、中断控制器在确定出第一中断信息的中断标识为有效的中断标识,且第一中断信息的中断标识没有被配置,获取到第一中断信息的中断标识。
S407、中断控制器将第一中断信息的中断标识添加在中断配置信息中,更新中断配置信息。
表3
如表3所示,中断控制器将第一中断信息的中断标识,例如中断一添加在中断配置信息中,更新中断配置信息,得到表3所示的更新后的中断配置信息。
S408、中断控制器将更新后的中断配置信息发送至内存,使得更新后的中断配置信息保存在内存中。
中断控制器将更新后的中断配置信息发送至内存,使得更新后的中断配置信息保存在内存中。
需要说明的是,中断控制器可以动态的更新内存中的中断配置信息,不仅可以在中断配置信息中新增中断信息的中断标识,也可以去除掉中断信息的中断标识,即去除掉的中断信息的中断标识,该中断信息无需转为event消息。
在中断控制器接收到第一外设模块发送的第一中断信息后,中断控制器从内存获取到中断配置信息,并确定出中断配置信息中包括第一中断信息的中断标识,则需将第一中断信息转换为第一event消息。
接下来对中断控制器如何将第一中断信息转换为第一event消息的,进行详细的描述。
方式一:中断控制器从第一中断消息的消息体中获取到中断信息的路由标识,填充在第一event消息的消息体中,得到第一event消息。
图5A-图5B示例性示出了一种第一中断消息的消息体和第一event消息的消息体的示意图。
其中,图5A为第一中断消息的消息体的示意图。
第一中断消息的消息体中包括以下字段:消息类型、外设模块的标识、中断信息的标识和中断信息的路由标识。其中,消息类型为第一消息类型,第一消息类型用于指示该消息为中断消息。外设模块的标识为第一外设模块,第一外设模块用于指示发送该第一中断消息的是哪一个外设模块。中断信息的标识为中断一,中断一用于指示第一中断消息的中断标识。中断信息的路由标识为第一CPU,第一CPU用户指示处理第一中断消息的CPU标识。
在一些实施例中,第一中断消息的消息体中还可以包括其他的字段,例如中断消息的类型等字段。在其他实施例中,第一中断消息的消息体中也可以不包括外设模块的标识字段,因为中断控制器可以基于中断信息的标识(即中断一)确定出发送第一中断消息的外设模块(即第一外设模块),本申请实施例对此不做限定。
在中断控制器得到第一中断消息的消息体后,中断控制器可以从第一中断消息的消息体中获取到中断信息的路由标识,并填充到第一event消息的消息体中,得到第一event消息。
图5B为第一event消息的消息体的示意图。
第一event消息的消息体包括以下字段:消息类型和中断信息的路由标识。其中,消息类型为第二消息类型,第二消息类型用于指示该消息为event消息。中断信息的路由标识为第一CPU,第一CPU用户指示处理第一event消息的CPU标识。中断信息的路由标识是从第一中断消息的消息体中得到的。
在一些实施例中,第一event消息的消息体中还可以包括其他的字段,例如event消息的类型等字段,event消息的类型可以用于指示该event消息是由中断消息转换得到的。本申请实施例对此不做限定。
方式二:中断控制器在接收到第一中断消息的消息体后,在第一中断消息的消息体的基础上增加一个event标识字段,并将该event标识字段的取值置为第一值,得到第一event消息,其中,第一值用于指示该消息类型为第一event消息。
图5C-图5F示例性示出了另一种第一中断消息的消息体和第一event消息的消息体的示意图。
其中,图5C为第一中断消息的消息体的示意图。
第一中断消息的消息体中包括以下字段:消息类型、外设模块的标识、中断信息的标识、中断信息的路由标识和event标识。其中,消息类型为第一消息类型,第一消息类型用于指示该消息为中断消息。外设模块的标识为第一外设模块,第一外设模块用于指示发送该第一中断消息的是哪一个外设模块。中断信息的标识为中断一,中断一用于指示第一中断消息的中断标识。中断信息的路由标识为第一CPU,第一CPU用户指示处理第一中断消息的CPU标识。event标识为元素0,元素0用于标识该消息类型为中断消息。
在一些实施例中,第一中断消息的消息体中还可以包括其他的字段,例如中断消息的类型等信息。在其他实施例中,第一中断消息的消息体中也可以不包括外设模块的标识,因为中断控制器可以基于中断信息的标识(即中断一)确定出发送第一中断消息的外设模块(即第一外设模块),本申请实施例对此不做限定。
图5D为一种第一event消息的消息体的示意图。
第一event消息的消息体包括以下字段:消息类型、外设模块的标识、中断信息的标识、中断信息的路由标识和event标识。其中,消息类型为第一消息类型。外设模块的标识为第一外设模块。中断信息的标识为中断一。中断信息的路由标识为第一CPU。event标识为元素1,元素1用于标识该消息类型为event消息。也就是说,中断控制器在接收到第一中断消息,确定出需将第一中断消息转换为第一event消息,则中断控制器将event标识由元素0修改为元素1,得到第一event消息。需要说明的是,虽然第一event消息的消息体中消息类型为第一消息类型,第一消息类型用于指示消息为中断消息,但是第一event消息的消息体中event标识的取值为元素1,即中断控制器可以基于第一消息类型和event标识的取值为元素1,确认出第一event消息为中断消息转换得到的event消息。
图5E为另一种第一event消息的消息体的示意图。
图5E所示的第一event消息的消息体的格式与图5D所示的第一event消息的消息体的格式类似,对于图5E所示的第一event消息的消息体的介绍,可以参考图5D所示的描述,本申请实施例在此不再赘述。图5E与图5D的不同之处在于,在中断控制器在接收到第一中断消息,确定出需将第一中断消息转换为第一event消息,中断控制器除了将event标识由元素0修改为元素1,还需将消息类型由第一消息类型修改为第二消息类型,得到第一event消息。
图5F为又一种第一event消息的消息体的示意图。
图5F所示的第一event消息的消息体的格式与图5D所示的第一event消息的消息体的格式类似,对于图5E所示的第一event消息的消息体的介绍,可以参考图5D所示的描述,本申请实施例在此不再赘述。图5E与图5D的不同之处在于,在中断控制器在接收到第一中断消息,确定出需将第一中断消息转换为第一event消息,中断控制器除了将event标识由元素0修改为元素1,还需将消息类型字段删除掉,得到第一event消息。
方式三:中断控制器在接收到第一中断消息的消息体后,在第一中断消息的消息体的基础上,将消息类型字段由第一消息类型修改为第二消息类型,得到第一event消息。
图5G-图5H示例性示出了又一种第一中断消息的消息体和第一event消息的消息体的示意图。
其中,图5G为第一中断消息的消息体的示意图。对图5G的介绍,可以参考图5A中实施例的描述,本申请实施例在此不再赘述。
图5H为第一event消息的消息体的示意图。图5H与图5G类似,图5H与图5G的不同之处在于,消息类型字段的取值不一样。图5G中,第一中断消息中消息类型字段的取值为第一消息类型,第一消息类型用于指示消息为中断消息。在中断控制器在接收到第一中断消息,确定出需将第一中断消息转换为第一event消息,中断控制器将第一中断消息中消息类型字段的取值由第一消息类型修改为第二消息类型,第二消息类型用于指示消息为even消息。
不仅限于方式一至方式三中示出的第一中断信息转换为第一event消息的具体实现,还可以基于其他的方式将第一中断信息转换为第一event消息,本申请实施例对此不做限定。
在中断控制器将第一中断消息转换为第一event消息之后,第一event消息中携带有中断信息的路由标识,即响应第一event消息的CPU的标识(即第一CPU)。这样,一方面,中断控制器可以通过总线将第一event消息发送至第一CPU,实现点对点唤醒CPU,解决了当前通过event消息唤醒CPU导致误唤醒其他处于低功耗的CPU的问题。另一方面,中断控制器将第一中断消息转换为第一event消息,通过第一event消息唤醒第一CPU,第一CPU可以直接执行第一event消息对应的第一事件,不需要陷入操作系统内核去响应第一event消息,缩短了唤醒CPU的时延。
图6示例性示出了第一CPU执行第一中断消息的流程图。
S601、中断控制器接收第一中断信息。
外设模块(例如网卡)上有第一事件时,例如接收到网络包之后,外设模块向中断控制器发送第一中断消息。
第一中断消息中携带有第一消息类型、第一外设模块的标识、第一中断消息的中断标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一外设模块的标识用于指示发送第一中断消息的外设模块的标识,第一CPU的标识用于指示处理第一中断消息的CPU的标识。
示例性的,若网卡接收到网络包之后,需要CPU读取网络包,此时网卡可以向第一CPU发送第一中断信息,第一中断消息用于唤醒第一CPU,使得第一CPU读取网络包。
S602、中断控制器获取到中断配置信息。
在中断控制器接收第一中断信息后,中断控制器需从内存中获取到中断配置信息,中断配置信息也可以被称为中断映射表(例如第一映射表),中断配置信息中记载了一个或多个需转为event消息的终中断消息的中断标识。
S603、中断控制器确定出是否需将第一中断信息转换为event消息?
中断控制器可以基于中断配置信息,确定出是否需要将第一中断信息转为event消息。
具体的,中断控制器可以从中断配置信息中,查找是否有第一中断消息的中断标识若有的话,则按照预设规则,将第一中断消息转化为第一event消息,中断控制器执行S604。若没有的话,则无需将第一中断消息转化为event消息,中断控制器执行S605。
S604、中断控制器基于预设的规则,将第一中断消息转换为第一event消息。
对于中断控制器如何将第一中断消息转化为第一event消息的,可以参考图5A-图5H所示的实施例,本申请实施例在此不再赘述。
S605、中断控制器将第一中断消息发送至第一CPU。
在确定出第一中断消息无需转为event消息的情况下,中断控制器可以通过总线将第一中断消息发送至第一CPU。
S606、中断控制器将第一event消息发送至第一CPU。
在中断控制器将第一中断消息转化为第一event消息后,中断控制器将第一event消息发送至第一CPU。
中断控制器可以通过总线将第一event消息发送至第一CPU。
S607、若第一CPU状态为低功耗状态,且第一event消息中携带的CPU标识为第一CPU,第一CPU接收第一event消息。
S608、第一CPU转换为非低功耗模式,无需陷入操作系统内核响应第一event消息,直接执行第一事件。
第一CPU在接收到第一event消息后,基于第一CPU的状态和第一event消息中携带的CPU标识,确定出是否接收第一event消息。若第一CPU的状态为低功耗状态、且第一event消息中携带的CPU标识为第一CPU的标识,则第一CPU接收第一event消息,从低功耗状态切换为非低功耗状态,并且无需陷入操作系统内核核响应第一event消息,直接执行第一事件。
若第一CPU的状态为非低功耗状态,和/或第一event消息中携带的CPU标识不是第一CPU的标识,则第一CPU将第一event消息丢弃。
示例性的,第一CPU的状态转换为非低功耗状态,第一CPU直接执行第一event消息的下一条指令,即判断是否有网络包到达。由于网卡是在确定出有网络包到达之后,才向第一CPU发送第一中断指令的,因此第一CPU在接收到第一event消息后,可以直接从网卡上读取网络包,完成收包流程。
S609、若第一CPU状态为低功耗状态,且第一中断消息中携带的CPU标识为第一CPU,第一CPU接收第一中断消息。
S610、第一CPU转换为非低功耗模式,陷入操作系统内核响应第一中断消息,执行第一事件。
第一CPU在接收到第一中断消息后,基于第一CPU的状态和第一中断消息中携带的CPU标识,确定出是否接收第一中断消息。若第一CPU的状态为低功耗状态、且第一中断消息中携带的CPU标识为第一CPU的标识,则第一CPU接收第一中断消息,从低功耗状态切换为非低功耗状态,陷入操作系统内核响应第一中断消息,执行第一事件。
若第一CPU的状态为非低功耗状态,和/或第一中断消息中携带的CPU标识不是第一CPU的标识,则第一CPU将第一中断消息丢弃。
示例性的,第一CPU的状态转换为非低功耗状态,由于第一中断消息只能在操作系统内核中处理,CPU接收到第一中断消息,首先CPU需要从用户态切换为内核态。在CPU切换至内核态之后,CPU需基于第一中断消息确定出是哪个外设模块发送的中断消息,例如CPU确定出是由网卡发送的第一中断消息。CPU还需查找到对应的进程或者线程,并运行该进程或者线程执行新的任务事项,若CPU上保存的有其他进程,CPU需要暂停运行此进程,在运行至新的进程,并将运行数据保存至内存。在用户态和内核态切换过程中、进程切换过程中,CPU还需保存CPU上下文。之后,CPU再从内核态切换为用户态。在CPU切换至用户态之后,CPU调用业务进程,从内存中读取运行数据,完成收包流程。
图7为本申请实施例提供的一种中断消息处理装置结构示意图。
一种可能的实施方式中,该装置700可以包括第一CPU和第一中断控制器。第一CPU和第一中断控制器通过总线通信。
其中,第一中断控制器用于接收第一中断消息,将第一中断消息转换为第一event消息,并将第一event消息发送至第一CPU。
第一CPU用于在用户态响应于第一event消息,从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。
通过该方法,实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
在一种可能的实现方式中,第一event消息中携带有CPU的标识;第一CPU,具体用于在接收到第一event消息后,确认出第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
在一种可能的实现方式中,第一CPU,还用于在接收到第一event消息后,确认出第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;第一中断控制器,还用于获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断控制器,具体用于在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息,并将第一event消息发送至第一CPU。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
在一种可能的实现方式中,第一中断控制器,还用于在确定出一个或多个需要转成event消息的中断消息的标识中不包括第一中断消息的标识的情况下,发送第一中断消息给第一CPU;第一CPU,还用于在接收到第一中断消息后,在内核态响应第一中断消息,从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
第一中断控制器,还用于接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
在一种可能的实现方式中,第一中断控制器,具体用于在接收到第一中断消息后,从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,第一中断控制器从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
结合第一方面,在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值,第二值与第一值不同;第一中断控制器,具体用于在接收到第一中断消息后,将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,第一中断控制器可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
结合第一方面,在一种可能的实现方式中,在第一event消息中携带的消息类型为第二消息类型的情况下,第一中断控制器,还用于将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。这样,第一中断控制器还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
在一种可能的实现方式中,装置还包括第一外设模块,其中,第一外设模块,用于在触发第一事件时,产生第一中断消息;第一外设模块,还用于向第一中断控制器发送第一中断消息;第一中断控制器,具体用于接收第一外设模块发送的第一中断消息。
结合第一方面,在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
图8为本申请实施例提供的一种中断消息处理方法的流程示意图。
S801、获取第一中断消息。
S802、将第一中断消息转换为第一event消息。
在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;在将第一中断消息转换为第一event消息之前,方法还包括:获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断消息转换为第一event消息,具体包括:在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
在一种可能的实现方式中,方法还包括:在确定出一个或多个需要转成event消息的中断消息的标识中不包括第一中断消息的标识的情况下,通过第一中断消息控制第一CPU在内核态从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入 内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
在一种可能的实现方式中,在获取到第一映射表之前,方法还包括:接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
结合第二方面,在一种可能的实现方式中,将第一中断消息转换为第一event消息,具体包括:从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,第一中断控制器从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
结合第二方面,在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值,第二值与第一值不同;将第一中断消息转换为第一event消息,具体包括:将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,第一中断控制器可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
在一种可能的实现方式中,在第一event消息携带的消息类型为第二消息类型的情况下,方法还包括:将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
这样,第一中断控制器还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
S803、通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。
通过该方法,实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
在一种可能的实现方式中,第一event消息中携带有CPU的标识;通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件,具体包括:在第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
在一种可能的实现方式中,方法还包括:在第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
结合第二方面,在一种可能的实现方式中,获取第一中断消息,具体包括:接收并获取到第一外设模块发送的第一中断消息。
结合第二方面,在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
图9为本申请实施例提供的另一种中断消息处理装置的流程示意图。
一种可能的实施方式中,装置900可以包括获取单元901、转换单元902和处理单元903。该装置900可用于执行图8实施例所示的一种中断消息处理方法。
其中,获取单元901,用于获取第一中断消息。
转换单元902,用于将第一中断消息转换为第一event消息。
处理单元903,用于通过第一event消息控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。
实现了通过中断消息的方式唤醒CPU时,将中断消息转化为event消息,实现对点唤醒CPU,缩短了处理中断消息的时延。
在一种可能的实现方式中,第一event消息中携带有CPU的标识。处理单元903,具体用于在第一event消息中携带的CPU的标识为第一CPU的标识,且第一CPU处于低功耗模式的情况下,控制第一CPU在用户态从低功耗模式转换为非低功耗模式,并在用户态处理第一事件。这样,第一event消息中携带有CPU的标识,可以实现点对点唤醒CPU。
在一种可能的实现方式中,处理单元903,还用于在第一event消息中携带的CPU的标识不是第一CPU的标识,和/或第一CPU处于非低功耗模式的情况下,丢弃第一event消息。
这样,第一CPU在接收到第一event消息后,会判断第一event消息是否是发给自己的,若是,则唤醒,处理第一事件,若否,则继续处于低功耗模式。
在一种可能的实现方式中,第一中断消息中还包括有第一中断消息的标识;转换单元902,具体用于在将第一中断消息转换为第一event消息之前,方法还包括:获取到第一映射表,第一映射表中包括一个或多个需要转成event消息的中断消息的标识;第一中断消息转换为第一event消息,具体包括:在确定出一个或多个需要转成event消息的中断消息的标识中包括第一中断消息的标识的情况下,将第一中断消息转换为第一event消息。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。对于需要装换为event消息的中断消息,可以将中断消息转换为event消息,直接在用户态响应该event消息。
在一种可能的实现方式中,转换单元902,还用于在确定出一个或多个需要转成event消息的中断消息的标识中不包括第一中断消息的标识的情况下,通过第一中断消息控制第一CPU在内核态从低功耗模式转换为非低功耗模式,再从内核态切换为用户态,并在用户态处理第一事件。
这样,对于不需要装换为event消息的中断消息,还是按照原本的执行流程执行中断消息,即先陷入内核态响应中断消息,在由内核态切换为用户态,在用户态执行任务事项。
在一种可能的实现方式中,获取单元901还用于在获取到第一映射表之前,接收第一映射表,并将第一映射表中的一个或多个需要转成event消息的中断消息的标识保存至内存。
这样,开发人员可以配置需将中断消息转换为event消息的对应的中断消息的标识。实现按需求将某些中断消息转换为event消息,某些中断消息可以不转换为event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;其中,第一消息类型用于指示第一中断消息的类型为中断消息,第一CPU的标识用于指示处理第一中断消息的CPU的标识;第一event消息中携带有第二消息类型、第一CPU的标识,其中,第二消息类型用于指示第一event消息的类型为event消息。
在一种可能的实现方式中,转换单元902,具体用于从第一中断消息中获取到第一CPU的标识,基于第一CPU的标识和第二消息类型得到第一event消息。
这样,转换单元902可以从第一中断消息中获取到字段信息,再基于获取到的字段信息生成第一event消息。
在一种可能的实现方式中,第一中断消息携带有第一消息类型、第一外设模块的标识、第一CPU的标识;第一event消息携带有第一消息类型或者第二消息类型、第一外设模块的标识、第一CPU的标识。
在一种可能的实现方式中,第一中断消息和第一event消息中还包括event标识字段,其中,第一中断消息中event标识字段的取值为第一值,第一event消息中event标识字段的取值为第二值,第二值与第一值不同;将第一中断消息转换为第一event消息,具体包括:将第一中断消息中event标识字段的取值修改为第二值,得到第一event消息。
这样,转换单元902可以直接在第一中断消息中修改event标识字段的取值,得到第一event消息。即在第一中断消息和第一event消息中event标识字段的取值不同。
在一种可能的实现方式中,在第一event消息携带的消息类型为第二消息类型的情况下,转换单元902还用于将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
这样,转换单元902还需将第一中断消息中第一消息类型修改为第二消息类型,得到第一event消息。
在一种可能的实现方式中,低功耗模式为:第一CPU停止运行;非低功耗模式为:第一CPU运行。
可选的,在CPU处于低功耗状态时,CPU中的取址单元、执行单元等功能单元都停止运行了在CPU处于非低功耗状态时,CPU内的取址单元、执行单元等功能单元开始运行。
在一种可能的实现方式中,获取单元901,具体用于接收并获取到第一外设模块发送的第一中断消息。
在一种可能的实现方式中,第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
本申请还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述图8实施例中提供的一种中断消息处理方法。
本申请还提供了一种计算机程序产品,当计算机程序产品在装置上运行时,使得装置执行上述图8实施例中提供的一种中断消息处理方法。
本申请实施例还提供了一种芯片,芯片包括处理器和通信接口,处理器用于从该通信接口调用并运行指令,当该处理器执行指令时,使得该芯片执行上述图8实施例中提供的一种中断消息处理方法。
本申请实施例提供了一种芯片系统,在一种可能的设计中,该芯片系统包括图7实施例所述的第一CPU和第一中断控制器。所述第一CPU和第一中断控制器,用于实现图8实施例中提供的一种中断消息处理方法。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器,用于保存一种中断消息处理方法必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
本申请的各实施方式可以任意进行组合,以实现不同的技术效果。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述 计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。
总之,以上所述仅为本发明技术方案的实施例而已,并非用于限定本发明的保护范围。凡根据本发明的揭露,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (30)

  1. 一种中断消息处理装置,其特征在于,所述芯片包括第一CPU、第一中断控制器,所述第一中断控制器与所述第一CPU通过总线通信,其中,
    所述第一中断控制器,用于接收第一中断消息,将所述第一中断消息转换为第一event消息,并将所述第一event消息发送至所述第一CPU;
    所述第一CPU,用于在用户态响应于所述第一event消息,从所述低功耗模式转换为所述非低功耗模式,并在所述用户态处理第一事件。
  2. 根据权利要求1所述的装置,其特征在于,所述第一event消息中携带有CPU的标识;
    所述第一CPU,具体用于确认出所述第一event消息中携带的所述CPU的标识为所述第一CPU的标识,且所述第一CPU处于所述低功耗模式的情况下,从所述低功耗模式转换为所述非低功耗模式,并在所述用户态处理所述第一事件。
  3. 根据权利要求2所述的装置,其特征在于,所述第一CPU,还用于在确认出所述第一event消息中携带的所述CPU的标识不是所述第一CPU的标识,和/或所述第一CPU处于所述非低功耗模式的情况下,丢弃所述第一event消息。
  4. 根据权利要求1-3任一项所述的装置,其特征在于,所述第一中断消息中还包括有所述第一中断消息的标识;
    所述第一中断控制器,还用于获取到第一映射表,所述第一映射表中包括一个或多个需要转成event消息的中断消息的标识;
    所述第一中断控制器,具体用于在确定出所述一个或多个需要转成event消息的中断消息的标识中包括所述第一中断消息的标识的情况下,将所述第一中断消息转换为所述第一event消息,并将所述第一event消息发送至所述第一CPU。
  5. 根据权利要求4所述的装置,其特征在于,所述第一中断控制器,还用于在确定出所述一个或多个需要转成event消息的中断消息的标识中不包括所述第一中断消息的标识的情况下,发送所述第一中断消息给所述第一CPU;
    所述第一CPU,还用于在接收到所述第一中断消息后,在内核态响应所述第一中断消息,从所述低功耗模式转换为非低功耗模式,再从所述内核态切换为所述用户态,并在所述用户态处理所述第一事件。
  6. 根据权利要求4或5所述的装置,其特征在于,所述第一中断控制器,还用于接收所述第一映射表,并将所述第一映射表中的所述一个或多个需要转成event消息的中断消息的标识保存至内存。
  7. 根据权利要求1-6任一项所述的装置,其特征在于,所述第一中断消息携带有第一消息类型、所述第一外设模块的标识、所述第一CPU的标识;其中,所述第一消息类型用于指示所述第一中断消息的类型为中断消息,所述第一CPU的标识用于指示处理所述第一中断消息的CPU的标识;
    所述第一event消息中携带有第二消息类型、所述第一CPU的标识,其中,所述第二消息类型用于指示所述第一event消息的类型为event消息。
  8. 根据权利要求7所述的装置,其特征在于,所述第一中断控制器,具体用于在接收到所述第一中断消息后,从所述第一中断消息中获取到所述第一CPU的标识,基于所述第一CPU的标识和所述第二消息类型得到所述第一event消息。
  9. 根据权利要求1-6任一项所述的装置,其特征在于,所述第一中断消息携带有第一消息类型、所述第一外设模块的标识、所述第一CPU的标识;
    所述第一event消息携带有所述第一消息类型或者第二消息类型、所述第一外设模块的标识、所述第一CPU的标识。
  10. 根据权利要求9所述的装置,其特征在于,所述第一中断消息和所述第一event消息中还包括event标识字段,其中,所述第一中断消息中event标识字段的取值为第一值,所述第一event消息中event标识字段的取值为第二值,所述第二值与所述第一值不同;
    所述第一中断控制器,具体用于在接收到所述第一中断消息后,将所述第一中断消息中所述event标识字段的取值修改为第二值,得到所述第一event消息。
  11. 根据权利要求9或10所述的装置,其特征在于,在所述第一event消息中携带的消息类型为所述第二消息类型的情况下,所述第一中断控制器,还用于将所述第一中断消息中所述第一消息类型修改为所述第二消息类型,得到所述第一event消息。
  12. 根据权利要求1-11任一项所述的装置,其特征在于,所述低功耗模式为:所述第一CPU停止运行;
    所述非低功耗模式为:所述第一CPU运行。
  13. 根据权利要求1-12任一项所述的装置,其特征在于,所述装置还包括第一外设模块,其中,
    所述第一外设模块,用于在触发所述第一事件时,产生所述第一中断消息;
    所述第一外设模块,还用于向所述第一中断控制器发送所述第一中断消息;
    所述第一中断控制器,具体用于接收所述第一外设模块发送的第一中断消息。
  14. 根据权利要求13所述的装置,其特征在于,所述第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
  15. 一种中断消息处理方法,其特征在于,所述方法包括:
    获取第一中断消息;
    将所述第一中断消息转换为第一event消息;
    通过所述第一event消息控制所述第一CPU在用户态从所述低功耗模式转换为非低功耗模式,并在所述用户态处理第一事件。
  16. 根据权利要求15所述的方法,其特征在于,所述第一event消息中携带有CPU的标识;所述通过所述第一event消息控制所述第一CPU在用户态从所述低功耗模式转换为非低功耗模式,并在所述用户态处理第一事件,具体包括:
    在所述第一event消息中携带的所述CPU的标识为所述第一CPU的标识,且所述第一CPU处于所述低功耗模式的情况下,控制所述第一CPU在所述用户态从所述低功耗模式转换为所述非低功耗模式,并在所述用户态处理所述第一事件。
  17. 根据权利要求16所述的方法,其特征在于,所述方法还包括:
    在所述第一event消息中携带的所述CPU的标识不是所述第一CPU的标识,和/或所述第一CPU处于所述非低功耗模式的情况下,丢弃所述第一event消息。
  18. 根据权利要求15-17任一项所述的方法,其特征在于,所述第一中断消息中还包括有所述第一中断消息的标识;在所述将所述第一中断消息转换为第一event消息之前,所述方法还包括:
    获取到第一映射表,所述第一映射表中包括一个或多个需要转成event消息的中断消息的标识;
    所述第一中断消息转换为第一event消息,具体包括:
    在确定出所述一个或多个需要转成event消息的中断消息的标识中包括所述第一中断消息的标识的情况下,将所述第一中断消息转换为第一event消息。
  19. 根据权利要求18所述的方法,其特征在于,所述方法还包括:
    在确定出所述一个或多个需要转成event消息的中断消息的标识中不包括所述第一中断消息的标识的情况下,通过所述第一中断消息控制所述第一CPU在内核态从所述低功耗模式转换为所述非低功耗模式,再从所述内核态切换为所述用户态,并在所述用户态处理所述第一事件。
  20. 根据权利要求18或19所述的方法,其特征在于,在所述获取到第一映射表之前,所述方法还包括:
    接收所述第一映射表,并将所述第一映射表中的所述一个或多个需要转成event消息的中断消息的标识保存至内存。
  21. 根据权利要求15-20任一项所述的方法,其特征在于,所述第一中断消息携带有第一消息类型、所述第一外设模块的标识、所述第一CPU的标识;其中,所述第一消息类型用于指示所述第一中断消息的类型为中断消息,所述第一CPU的标识用于指示处理所述第一中断消息的CPU的标识;
    所述第一event消息中携带有第二消息类型、所述第一CPU的标识,其中,所述第二消息类型用于指示所述第一event消息的类型为event消息。
  22. 根据权利要求21所述的方法,其特征在于,所述将所述第一中断消息转换为第一event消息,具体包括:
    从所述第一中断消息中获取到所述第一CPU的标识,基于所述第一CPU的标识和所述第二消息类型得到所述第一event消息。
  23. 根据权利要求15-20任一项所述的方法,其特征在于,所述第一中断消息携带有第一消息类型、所述第一外设模块的标识、所述第一CPU的标识;
    所述第一event消息携带有所述第一消息类型或者第二消息类型、所述第一外设模块的标识、所述第一CPU的标识。
  24. 根据权利要求23所述的方法,其特征在于,所述第一中断消息和所述第一event消息中还包括event标识字段,其中,所述第一中断消息中event标识字段的取值为第一值,所述第一event消息中event标识字段的取值为第二值,所述第二值与所述第一值不同;
    所述将所述第一中断消息转换为第一event消息,具体包括:
    将所述第一中断消息中所述event标识字段的取值修改为第二值,得到所述第一event消息。
  25. 根据权利要求23或24所述的方法,其特征在于,在所述第一event消息携带的消息类型为所述第二消息类型的情况下,所述方法还包括:
    将所述第一中断消息中所述第一消息类型修改为所述第二消息类型,得到所述第一event消息。
  26. 根据权利要求15-25任一项所述的方法,其特征在于,所述低功耗模式为:所述第一CPU停止运行;
    所述非低功耗模式为:所述第一CPU运行。
  27. 根据权利要求15-26任一项所述的方法,其特征在于,所述获取第一中断消息,具体包括:
    接收并获取到第一外设模块发送的所述第一中断消息。
  28. 根据权利要求27所述的方法,其特征在于,所述第一外设模块的类型包括以下任意一项:网卡、硬盘、图形处理器GPU、加速处理器APU、AI加速卡NPU。
  29. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述权利要求15-28任意一项所述的方法。
  30. 一种计算机程序产品,其特征在于,当所述计算机程序产品在芯片上运行时,使得所述芯片执行上述权利要求15-28任一项所述的方法。
PCT/CN2023/112829 2022-08-19 2023-08-14 一种中断消息处理方法及装置 WO2024037482A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211003207.5A CN117632533A (zh) 2022-08-19 2022-08-19 一种中断消息处理方法及装置
CN202211003207.5 2022-08-19

Publications (1)

Publication Number Publication Date
WO2024037482A1 true WO2024037482A1 (zh) 2024-02-22

Family

ID=89940734

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/112829 WO2024037482A1 (zh) 2022-08-19 2023-08-14 一种中断消息处理方法及装置

Country Status (2)

Country Link
CN (1) CN117632533A (zh)
WO (1) WO2024037482A1 (zh)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080079852A (ko) * 2007-02-28 2008-09-02 삼성전자주식회사 Cpu 가상화 방법
US20190042730A1 (en) * 2018-03-28 2019-02-07 Intel Corporation Systems, Methods, And Apparatus For Detecting Control Flow Attacks
WO2019091361A1 (zh) * 2017-11-10 2019-05-16 北京金山云网络技术有限公司 一种网卡模式切换方法、装置、电子设备及存储介质
CN113010275A (zh) * 2019-12-20 2021-06-22 大唐移动通信设备有限公司 一种中断处理方法和装置
CN113342554A (zh) * 2021-08-02 2021-09-03 阿里云计算有限公司 Io多路复用方法、介质、设备和操作系统
CN114077379A (zh) * 2020-08-19 2022-02-22 华为技术有限公司 一种计算机设备、异常处理的方法以及中断处理的方法
CN114371907A (zh) * 2020-10-15 2022-04-19 华为技术有限公司 一种芯片系统、处理虚拟中断的方法及相应装置

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080079852A (ko) * 2007-02-28 2008-09-02 삼성전자주식회사 Cpu 가상화 방법
WO2019091361A1 (zh) * 2017-11-10 2019-05-16 北京金山云网络技术有限公司 一种网卡模式切换方法、装置、电子设备及存储介质
US20190042730A1 (en) * 2018-03-28 2019-02-07 Intel Corporation Systems, Methods, And Apparatus For Detecting Control Flow Attacks
CN113010275A (zh) * 2019-12-20 2021-06-22 大唐移动通信设备有限公司 一种中断处理方法和装置
CN114077379A (zh) * 2020-08-19 2022-02-22 华为技术有限公司 一种计算机设备、异常处理的方法以及中断处理的方法
CN114371907A (zh) * 2020-10-15 2022-04-19 华为技术有限公司 一种芯片系统、处理虚拟中断的方法及相应装置
CN113342554A (zh) * 2021-08-02 2021-09-03 阿里云计算有限公司 Io多路复用方法、介质、设备和操作系统

Also Published As

Publication number Publication date
CN117632533A (zh) 2024-03-01

Similar Documents

Publication Publication Date Title
US10551906B2 (en) Methods and apparatus for running and booting inter-processor communication link between independently operable processors
US7577765B2 (en) Advanced power management in generic USB drivers
US7124207B1 (en) I2O command and status batching
WO2021217529A1 (zh) 一种进程间通信的方法及系统
US20040003300A1 (en) Power management architecture for computing devices
JP2003509764A (ja) Canマイクロコントローラにおける電力を節約する方法及びこの方法を実施するcanマイクロコントローラ
KR101551321B1 (ko) 휴대용 컴퓨팅 디바이스에서 요청들을 스케쥴링하기 위한 방법 및 시스템
WO2002031672A2 (en) Method and apparatus for interprocessor communication and peripheral sharing
CN107273141A (zh) 嵌入式实时操作系统
TW200844749A (en) Direct memory access controller
CN116243995B (zh) 通信方法、装置、计算机可读存储介质以及电子设备
WO2020238989A1 (zh) 一种调度任务处理实体的方法及装置
WO2017107816A1 (zh) 一种虚拟化平台中的数据处理方法及装置
US7055046B2 (en) Power management architecture for defining component power states under a global power state and applying a new component power state when a new component power state is greater than a registered power state floor
WO2023011249A1 (zh) Io多路复用方法、介质、设备和操作系统
CN109992314B (zh) 数据上报方法、装置、终端和存储介质
CN107479900B (zh) 一种适用于实时操作系统的热插拔软件方案
WO2024037482A1 (zh) 一种中断消息处理方法及装置
CN116848519A (zh) 硬件接口信号的生成方法、装置及电子设备
CN110401939A (zh) 一种低功耗蓝牙控制器链路层装置
CN114697194B (zh) 阻塞式事件通知方法及装置
CN116136790A (zh) 任务处理方法和装置
CN112039800B (zh) 一种遥测数据的发送方法及装置
WO2023144958A1 (ja) サーバ内遅延制御装置、サーバ内遅延制御方法およびプログラム
CN111160546B (zh) 一种数据处理系统

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

Country of ref document: EP

Kind code of ref document: A1