Processor scheduling for physical machine

By creating virtual processors in virtualization mode and scheduling them based on idle time information, the problem of wasted physical processor resources is solved, and resource utilization and management flexibility are improved.

WO2026066704A1PCT designated stage Publication Date: 2026-04-02CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-08-07
Publication Date
2026-04-02

AI Technical Summary

Technical Problem

In traditional operating systems, physical processor resources are wasted when processes wait for events, resulting in low resource utilization. Existing cgroup scheduling strategies are not flexible enough and cannot manage processor resources finely.

Method used

By switching the host operating system to virtualization mode, a virtual processor for the target process is created, and the new virtual processor is scheduled based on idle time information, thus freeing up physical processor resources.

Benefits of technology

It improves the utilization of physical processors and enables more flexible resource management and elastic computing power allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025113140_02042026_PF_FP_ABST
    Figure CN2025113140_02042026_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a processor scheduling method, device and system for a physical machine, a product, and a storage medium. The physical machine comprises a physical processor, and the physical processor is bound to a target process. The method comprises: switching a running host operating system from a root mode to a virtualization mode, and in the virtualization mode, creating a virtual processor where a target process is located and a new virtual processor; acquiring idle time information, wherein the idle time information represents an idle time during which the target process is in an idle state; and terminating, on a physical processor on the basis of the idle time information, running of the virtual processor where the target process in the idle state is located, and invoking the physical processor to run the new virtual processor.
Need to check novelty before this filing date? Find Prior Art

Description

Processor scheduling of physical machine TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of virtualization, and in particular, to processor scheduling of physical machine. BACKGROUND

[0002] A control group (cgroup) function is provided in a traditional operating system such as Linux, different function groups can be set, each function group includes at least one process, and the processor range used by different function groups can be set through the cgroup function, so as to divide different processor use ranges and use quotas for each function group. In some scenarios, physical processors in a physical machine can be exclusively occupied by certain specific processes, for example, these specific processes can be processes corresponding to services that need to run with high performance, such as processes corresponding to high-performance network cards. However, during the running process of such processes, there can also be a situation where no actual service is executed, for example, the process is polling and waiting for an event, and needs to wait until the event arrives to execute the actual service. Therefore, the waiting process is actually a process in which the process is in an idle state, so the process does not execute the actual service in this process, causing waste of physical processor resources. SUMMARY

[0003] To overcome the problems in the related art, the present disclosure provides a processor scheduling method, device, system, product and storage medium of a physical machine.

[0004] According to a first aspect of an embodiment of the present disclosure, a processor scheduling method of a physical machine is provided, the physical machine includes a physical processor, the physical processor is bound with a target process, and the method includes: switching a running host operating system from a root mode to a virtualization mode, creating a virtual processor where the target process is located and a new virtual processor in the virtualization mode; obtaining idle time information, the idle time information representing an idle time when the target process is in an idle state; based on the idle time information, exiting the virtual processor where the target process in an idle state from the physical processor, and scheduling the physical processor to run the new virtual processor.

[0005] According to a second aspect of the embodiments of the present disclosure, a processor scheduling method of a physical machine is provided, the physical machine comprising a physical processor, the physical processor being bound with a target process, the method being applied to the target process, and the method comprising: predicting idle time information in a process running on the physical processor if it is determined that the process is in an idle state; writing the idle time information into a first sub-region of a shared storage region in a memory; the shared storage region being used for sharing with a virtualization layer in a host operating system of the physical machine, the virtualization layer being used for switching the running host operating system from a root mode to a virtualization mode, after the virtualization mode is created, a virtual processor where the target process is located and a new virtual processor, reading the first sub-region of the shared storage region to obtain the idle time information, based on the idle time information, exiting the virtual processor where the target process is located from running on the physical processor if it is in an idle state, and scheduling the physical processor to run the new virtual processor.

[0006] According to a third aspect of the embodiments of the present disclosure, a processor scheduling system of a physical machine is provided, the physical machine comprising a physical processor and a host operating system running on the physical processor, the physical processor being bound with a target process, and the host operating system having a virtualization layer, the virtualization layer being used for executing the steps of the method of the first aspect, and the target process being used for executing the steps of the method of the second aspect.

[0007] According to a fourth aspect of the embodiments of the present disclosure, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method embodiments of the first aspect or the second aspect when executing the computer program.

[0008] According to a fifth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, having a computer program stored thereon, the computer program being executable by a processor to implement the steps of the method embodiments of the first aspect or the second aspect.

[0009] According to a sixth aspect of the embodiments of the present disclosure, a computer program product is provided, comprising a computer program, the computer program being executable by a processor to implement the steps of the method embodiments of the first aspect or the second aspect.

[0010] The technical scheme provided by the embodiments of the present disclosure can have the following beneficial effects: in the embodiments of the present disclosure, the physical machine includes a physical processor, and the physical processor is bound with a target process; in order to improve the utilization rate of the physical processor, the embodiments of the present disclosure can switch a running host operating system from a root mode to a virtualization mode, to create a virtual processor where the target process is located and a new virtual processor in the virtualization mode, and by obtaining idle time information representing an idle time when the target process is in an idle state, the virtual processor where the target process in the idle state is located can be exited from the physical processor and the physical processor is scheduled to run the new virtual processor. Therefore, through the cooperation of the target process, the embodiments can make the target process bound to the physical processor give up the resources of the physical processor when the target process is idle, so that the physical processor can run the new virtual processor, thereby improving the utilization rate of the physical processor.

[0011] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and are not limiting to the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0012] FIG. 1 is a flowchart of a processor scheduling method of a physical machine according to an exemplary embodiment of the present disclosure.

[0013] FIG. 2A is a schematic diagram of a physical machine according to an exemplary embodiment of the present disclosure.

[0014] FIG. 2B is a schematic diagram of a shared storage area according to an exemplary embodiment of the present disclosure.

[0015] FIG. 3 is a flowchart of a processor scheduling method of a physical machine according to an exemplary embodiment of the present disclosure.

[0016] FIG. 4 is a hardware structure diagram of a computer device where a processor scheduling apparatus of a physical machine is located according to an exemplary embodiment of the present disclosure.

[0017] FIG. 5 is a structure diagram of a processor scheduling apparatus of a physical machine according to an exemplary embodiment of the present disclosure.

[0018] FIG. 6 is a structure diagram of another processor scheduling apparatus of a physical machine according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, like reference numerals refer to like elements unless the context clearly dictates otherwise. The following description of exemplary embodiments is not representative of all possible embodiments consistent with the present disclosure. Instead, they are merely examples of apparatuses and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0020] The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the present disclosure. As used in the present disclosure and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0021] It will be understood that, although the terms first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used only as a shorthand notation to distinguish one item from another. For example, in the absence of a departing from the scope of the present disclosure, a first item can also be termed a second item, and similarly, a second item can also be termed a first item. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining."

[0022] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present disclosure are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0023] In an operating system such as Linux, cgroup is a kernel feature that can be used to limit, record and isolate the use of hardware resources of a control group, where the hardware resources include but are not limited to CPU, memory, disk I / O (input / output), etc. With cgroup, a system administrator can control hardware resources, for example, limit the proportion of processors such as CPU (Central Processing Unit) and / or memory used by a specific process, or count their resource usage, etc. Taking CPU resource allocation as an example, the functions provided by cgroup include: limiting the total CPU usage time of all processes in the control group, and binding the processes in the control group to specific CPU cores and / or memory nodes.

[0024] However, the cgroup-based processor scheduling strategy is relatively fixed, which can result in some cgroup groups corresponding to idle or partially busy processor resources. Therefore, the processor scheduling scheme using cgroup is not flexible enough to finely manage the processor. In a production environment, although cgroup can be dynamically adjusted, the configuration of these cgroup is often an experienced value verified by practice and large-scale deployment, and it is not likely to be frequently changed.

[0025] Therefore, hardware resource control through some virtualization technologies can also be considered, for example, virtualization technologies allow physical CPUs on a physical machine to be abstracted and divided into multiple virtual CPUs (virtual CPUs for short). As an example, the virtualization management tool KVM (Kernel-based Virtual Machine) in the Linux kernel can implement virtualization using Linux kernel modules and some user space tools, allowing multiple virtual machines (VMs) to run on a Linux system, each of which can independently run different operating systems and applications. KVM can allocate virtual CPUs to virtual machines running on the host, and the virtual CPUs are mapped and scheduled to physical CPUs. In KVM, the scheduling of virtual CPUs can be based on various strategies, including round robin, fair scheduling, and real-time scheduling, depending on the implementation of the virtualization management software. The ultimate goal is to ensure the performance of the VM while maximizing the performance of the physical hardware. KVM uses the scheduler of the Linux kernel to mount virtual CPUs on physical CPUs, and KVM also supports advanced functions such as CPU-intensive task priority and memory page migration.

[0026] Virtual CPUs can be dynamically migrated to different physical cores to more efficiently utilize physical resources. This is called virtual CPU migration. For example, if the virtual CPUs on one physical core are lightly loaded while the virtual CPUs on another physical core are heavily loaded, some of the load can be migrated to the lightly loaded core to achieve load balancing. Dynamic scheduling also allows the number of virtual CPUs to be dynamically modified. For example, when the virtual CPUs are running under high load, the number of virtual CPUs can be increased to meet the resource needs of the VM. Administrators can use various monitoring tools to track resource usage and make optimization adjustments based on this data.

[0027] Based on this, the scheduling of the physical processor can be implemented through the idea of virtualization. Embodiments of the present disclosure provide a processor scheduling scheme. Embodiments of the present disclosure can switch a running host operating system from a root mode to a virtualization mode, create a virtual processor where a target process is located and a new virtual processor in the virtualization mode, and predict idle time information of the target process. The virtual processor where the target process in an idle state is exited from the physical processor, and the physical processor is scheduled to run the new virtual processor. Therefore, embodiments of the present disclosure can make the target process bound to the physical processor give up the physical processor when idle, thereby improving the utilization of the physical processor, and providing computing power of the physical processor flexibly and elastically to an upper layer through the virtual processor.

[0028] As shown in FIG. 1, a processor scheduling method of a physical machine is shown according to an exemplary embodiment of the present disclosure. The physical machine includes a physical processor, and the physical processor is bound to a target process. The method can include the following steps.

[0029] In step 102, a running host operating system is switched from a root mode to a virtualization mode, and a virtual processor where a target process is located and a new virtual processor are created in the virtualization mode.

[0030] In step 104, idle time information is obtained, and the idle time information represents an idle time when the target process is in an idle state.

[0031] In step 106, based on the idle time information, the virtual processor where the target process in an idle state is exited from the physical processor, and the physical processor is scheduled to run the new virtual processor.

[0032] As an example, the hardware resources of the physical machine include, but are not limited to, a combination of one or more processors such as a CPU, a graphics processing unit (GPU), a data processing unit (DPU), a tensor processing unit (TPU), a cloud infrastructure processing unit (CIPU), an application specific integrated circuit (ASIC), and the like. The hardware resources of the physical machine can also include any type of storage medium, and other components such as I / O devices, communication components, displays, power components, audio components, and the like. Embodiments of the present disclosure do not limit this.

[0033] The host operating system is system software running on the physical machine, responsible for managing hardware resources and providing a platform so that application programs can run on the operating system and access and utilize hardware resources through the operating system to perform specific tasks. As an example, the host operating system can be a Linux operating system or the like, and the present embodiment is not limited thereto.

[0034] The processor in the present embodiment includes, but is not limited to, a CPU, a GPU, a DPU, or a TPU, and the like. In subsequent embodiments, most of the descriptions take the CPU as an example for illustration.

[0035] In order to provide elastic computing power, the present embodiment can directly create a new virtual processor for the running host operating system, and then realize elastic computing power by scheduling the new virtual processor to run on the physical processor.

[0036] The virtualization mode of KVM needs to start a virtual machine, which is different from the virtualization mode of KVM. In the present embodiment, the running host operating system is switched from root mode to virtualization mode, that is, the running physical CPU is switched to a virtualized processor. Compared with the virtualization mode of KVM, it is more lightweight. Since the running physical CPU is switched to a virtual CPU, the virtualization layer can continue to schedule the virtual CPU to run on the physical CPU. Based on this, the present embodiment creates one or more virtual processors in the virtualization mode.

[0037] In some examples, as shown in FIG. 2A, the present disclosure shows an architecture diagram of a physical machine according to an exemplary embodiment. The physical machine architecture of the present embodiment provides two running modes, root mode and virtualization mode, for the host operating system in the running state. A virtualization layer can be inserted between the hardware resources and the host operating system. The virtualization layer can be located between the hardware resources and the host operating system of the physical machine. The virtualization layer switches the running host operating system from root mode to virtualization mode without the need to reinstall the operating system. Various functions can be flexibly implemented for the running host operating system.

[0038] As an example, the host operating system corresponds to root mode and virtualization mode. The root mode is a working mode in which the host operating system has direct access to hardware resources. The virtualization mode is a working mode in which the virtualization layer virtualizes hardware resources and replaces the host operating system to schedule and access the virtualized resources. The access of the virtualization layer to the hardware resources in the virtualization mode is limited. Compared with the root mode, the virtualization mode can also be referred to as the non-root mode. Accordingly, the host operating system in the virtualization mode can also be referred to as the guest operating system.

[0039] In the embodiment, a lightweight, powerful and efficient virtualization layer can be inserted between the hardware resources and the host operating system. The virtualization layer can be developed in advance and inserted between the hardware resources and the host operating system. The way of inserting the virtualization layer is not limited. For example, the virtualization layer can be inserted when the host operating system is in a normal running state after the host operating system is installed on the physical machine.

[0040] As an example, the virtualization layer can be a software module in the host operating system. The software module can switch the host operating system from the root mode to the virtualization mode when the host operating system is in the root mode. After the switching, the host operating system becomes a guest operating system, and the virtualization layer takes over the management of the hardware resources of the physical machine, that is, the meaning of inserting the virtualization layer between the hardware resources and the host operating system, so that the host operating system uses the hardware resources through the virtualization layer. The switching time from the root mode to the virtualization mode can be various in actual applications, for example, when the resource utilization of the physical CPU is low, or when a preset condition is triggered, or when a set instruction is received, and the embodiment is not limited in this regard.

[0041] After the host operating system is switched from the root mode to the virtualization mode, the existing physical machine CPU can be switched to the corresponding virtual CPU, for example, the CPU of the binding target process of the embodiment, that is, the virtual CPU where the target process is located. In the virtualization mode, the embodiment further creates new virtual CPUs. The newly created virtual CPUs can be one or more, which can be flexibly configured according to actual needs, and the embodiment is not limited in this regard.

[0042] As an example, it is assumed that the physical machine includes four physical CPUs. After the host operating system is switched from the root mode to the virtualization mode, the four physical CPUs can be switched to the corresponding virtual CPUs. The embodiment can further create n virtual CPUs on the basis of the four switched virtual CPUs. In order to distinguish the virtual CPUs switched from the physical CPUs, the newly created virtual CPUs are referred to as newly created virtual CPUs. In this way, the total number of virtual CPUs is the four switched virtual CPUs plus the n newly created virtual CPUs.

[0043] As an example, in the process of switching from the root mode to the virtualization mode of the host operating system, the virtualization layer can create a corresponding physical description structure for each physical CPU and a corresponding virtualization description structure for the virtual CPU, the physical description structure of each physical CPU corresponding to the virtualization description structure. The physical description structure is used to save the context information of the physical CPU running in the root mode when switching modes, and the virtualization description structure is used to synchronize the context information in the physical description structure when switching modes. The virtualization layer manages the virtual CPU switched from the physical CPU through the virtualization description structure.

[0044] As an example, there can be various ways to create a new virtual processor; for example, the virtual processor switched from the physical processor described above corresponds to a virtualization description structure, in order to create a new virtual processor, a virtualization description structure can be newly created, and optionally, a series of registers and the like can be configured, which is implemented by the virtual processor creation function of the virtualization layer, and the present embodiment does not limit this. For example, the virtualization description structure of the new virtual processor here is similar to the virtualization description structure corresponding to the physical CPU described above, for example, the fields of the two are the same, but the specific field values are different. Each newly created virtualization description structure represents a newly created virtual processor, and the corresponding newly created virtual processor can be managed through the virtualization description structure. The specific management manner is not limited by the present embodiment.

[0045] As an example, for the virtualization layer of the physical machine bottom layer in the present embodiment, the virtual processor is a running task that can be scheduled to run on the physical CPU, and on the newly created virtual processor, the virtual processor can be used to run any task, similar to the virtual machine of KVM, except that the creation method of the virtual processor in the present embodiment is different from KVM, and the virtual processor is managed by the virtualization layer. As an example, various user tasks such as common user processes can run on the virtual processor of the present embodiment, and user processes can be bound to the newly created virtual processor as needed, and the like, which is not limited by the present embodiment. Therefore, by scheduling the newly created virtual processor to run on the physical CPU, the present embodiment can provide elastic computing power for the upper layer, and how the virtualization layer of the bottom layer schedules the newly created virtual processor according to the busy / idle state of the physical CPU is transparent to the upper layer task, which can maintain the transparency to the original running mode.

[0046] As an example, a scheduler for scheduling physical processors can be implemented in the virtualization layer to schedule tasks run by the physical processors, such as the virtual CPUs (the virtual CPU switched over by the physical CPU + the n newly created virtual CPUs) described above. The embodiment method can be applied to the scheduler of the virtualization layer, and optionally, the scheduler can be run on each physical CPU, i.e., the embodiment method can be applied to each physical CPU.

[0047] As an example, the tasks run on the physical CPU can be any of the virtual CPU switched over by the physical CPU, the n newly created virtual CPUs, and the task of the operating system, and the priorities can be set based on the above order. In a scheduling period, the virtualization layer can allocate the running time based on the priorities for the above three tasks, for example, assuming that the duration of a scheduling period is 10 ms, the duration can be proportionally allocated to the above three, for example, the running time allocated to the virtual CPU switched over by the physical CPU is the largest, followed by the running time of the newly created virtual CPU, and finally the running time of the task of the operating system.

[0048] As an example, there are multiple physical processors on the physical machine, and the n newly created virtual CPUs can be scheduled to any physical processor, or the range of physical processors on which the newly created virtual CPUs can run can be set as needed. When a newly created virtual CPU runs on a certain physical processor, the scheduler running on other physical processors will no longer schedule the newly created virtual CPU to run.

[0049] The embodiment does not limit the target process to which the physical processor is bound, which can be determined based on the actual application scenario; as an example, the physical processor and the bound target process can be in a one-to-one relationship; of course, other situations can also occur in actual applications, such as many-to-one, etc., which are not limited by the embodiment.

[0050] The physical processor bound by the target process can be exclusively occupied by the target process and cannot run other processes. For example, the target process can be a process corresponding to a service that needs to run at high performance, such as a process corresponding to a high-performance network card, and the like. Because these processes contain services that need to run at high performance, the physical processors exclusively allocated by the processes are allocated. Then, during the running of the processes, the processes can also be in a state of not performing actual services, for example, the processes are polling and waiting for an event and need to perform actual services when the event arrives. Therefore, the waiting process is actually a process in which the process is idle, and therefore the process does not perform actual services during the process, which causes waste of physical processor resources. In order to utilize the resources of the physical processor during this process, the embodiment switches to a virtualization mode by step 102, the physical processor is switched to a virtual processor, the target process corresponds to the switched virtual processor, and the virtualization layer can schedule the physical processor to run the virtual processor (including the virtual processor corresponding to the target process switched by the physical processor and the new virtual processor) by creating a new virtual processor. Then, by steps 104 to 106, the target process can run the new virtual processor during the idle process, and the utilization rate of the physical processor is improved.

[0051] In actual applications, the idle time information can be predicted in various ways, for example, based on the historical running of the target process on the physical processor. The prediction process can be performed by the target process and notified to the virtualization layer, or performed by the virtualization layer.

[0052] As an example, the idle time information can be predicted after the target process is in an idle state. For example, during the running of the target process, a function for implementing an actual service needs to be executed, and a function for polling and waiting for an event needs to be executed. If the function for implementing the actual service is executed, the target process is in a working state, i.e., a busy state, and is not in an idle state. If the function for polling and waiting for an event is executed, the target process is in an idle state. Therefore, whether the target process is in an idle state during the running of the physical processor can be determined based thereon.

[0053] As an example, the target process can notify the virtualization layer after being in an idle state, and then the virtualization layer can predict the idle time information of the target process. The target process can also predict the idle time information after being in an idle state and notify the virtualization layer.

[0054] Based on this, the embodiment can accurately utilize the busy and idle states of the processes through the cooperation of the target process, better utilize the physical CPU resources, and thus improve the utilization rate of the resources.

[0055] In actual application, the communication between the target process and the virtualization layer on the above idle state or idle time information can be in multiple ways. For example, the system call can be used, for example, the target process schedules the vmcall function of the virtualization layer, and the virtualization layer is notified by calling the function.

[0056] In some other examples, in order to reduce the overhead of communication between the target process and the virtualization layer, the embodiment designs a shared storage area in the memory which can be shared between the target process and the virtualization layer. For example, the above obtaining idle time information can include: accessing a shared storage area in the memory shared with the target process; the shared storage area includes a first sub-area for storing the idle time information, and the idle time information is determined after the target process is in an idle state and written to the first sub-area during the process of running on the physical processor; reading the idle time information from the first sub-area in the shared storage area.

[0057] The virtualization layer can manage the hardware resources of the physical machine, and the virtualization layer can allocate a shared storage area in the memory. Optionally, the shared storage area can include a first sub-area for storing idle time information, and the first sub-area can be written only by the target process and read only by the virtualization layer, avoiding read-write competition. The size of the first sub-area can be set according to actual needs, and the embodiment does not limit this.

[0058] In this way, the target process can write the idle time information into the first sub-area after predicting the idle time information, and the virtualization layer can read the idle time information by accessing the area. Optionally, the first sub-area can be used to indicate to the virtualization layer that the target process does not have idle time information by not storing idle time information or storing a marker representing that it does not have idle time information. Based on this, the above-mentioned embodiment can communicate between the target process and the virtualization layer with low overhead, so that the virtualization layer can determine the idle state and idle time information of the target process.

[0059] Optionally, the idle time information can be represented in multiple ways, for example, the idle termination time. As an example, the target process determines that it is in an idle state at the current time t1, and then determines that the idle duration is k, and the idle termination time can be t1+k. Optionally, the determined idle termination time t1+k can be directly written into the first sub-area as idle time information; or it can also be appropriately reduced based on t1+k as needed, for example, in the case of a large predicted idle duration k. The actual implementation can be flexibly configured as needed, and the embodiment does not limit this.

[0060] In some other examples, the shared memory region can further include a second sub-region for storing indication information; after reading the idle time information from the first sub-region, write the indication information indicating that the idle time information has been read into the second sub-region; the target process is configured to access the second sub-region of the shared memory region during running on the physical processor, if the indication information is read and the current time is not the end time of the idle time indicated by the idle time information, then suspend predicting the idle time information, if the indication information is not read, then predict the idle time information and write it into the first sub-region.

[0061] Optionally, the shared memory region can be a continuous memory region, the size of the first sub-region and the second sub-region, and the order before and after the shared memory region can be flexibly configured according to actual needs. As an example, the first 64 bits of the shared memory region can be the first sub-region, and the 64 bits after the first sub-region can be the second sub-region. Of course, in actual application, if the shared memory region is a non-continuous memory region, the first sub-region and the second sub-region are also optional, and the embodiment does not limit this.

[0062] The second sub-region is configured to store the indication information indicating that the virtualization layer has read the idle time information, which can be read-only by the target process and write-only by the virtualization layer, so as to avoid read-write competition. In this way, the virtualization layer can deliver the message that it has read the idle time information to the target process, so that the virtualization layer schedules the physical processor to exit running the target process to run the virtual processor for a certain time length, and then the virtual processor exits running and the target process is allowed to run again. The virtual processor does not necessarily run to the end time of the idle time indicated by the idle time information.

[0063] For example, the current time is t1, the target process predicts the end time of the idle time to be t1+k, after the end time of the idle time is written into the first sub-region, the virtualization layer schedules the virtual processor to run for a certain time length and then exits running, and then the target process is re-scheduled to run on the physical processor, the current time is t2, the target process finds that the current time t2 is less than t1+k, that is, it has not reached the last predicted end time of the idle time, and the target process can not update the idle time information this time.

[0064] In addition, if the target process accesses the second sub-region and finds that no indication information indicating that the virtualization layer has read the idle time information is stored, the target process can predict the idle time information and write it into the first sub-region in the idle state.

[0065] Based on this, through the above-mentioned embodiments, the target process and the virtualization layer can be communicated at a lower cost, so that the target process can determine whether the virtualization layer has read the idle time information.

[0066] In some examples, the scheduling the physical processor to run the virtual processor can include: allocating a current running duration of the current scheduling to the virtual processor based on the idle duration indicated by the future idle time information, and scheduling the physical processor to run the new virtual processor based on the current running duration, so that the new virtual processor exits running on the physical processor when the running duration of the new virtual processor reaches the current running duration.

[0067] In actual applications, the running duration, i.e., the time slice, allocated to the new virtual processor can be flexibly set as needed, for example, it can be a fixed time slice set for each scheduling period, or different time slices set for different scheduling periods, or a time slice set according to the running situation of the physical processor, etc., which is not limited in the embodiment. In the embodiment, the local running duration allocated to the new virtual processor is determined based on the idle duration indicated by the future idle time information, and is not more than the idle termination time, so that the new virtual processor does not affect the execution of the target process.

[0068] After the current running duration is allocated, the physical processor can be scheduled to run the new virtual processor based on the current running duration, so that the new virtual processor exits running on the physical processor when the running duration of the new virtual processor reaches the current running duration, thereby not affecting the service of the target process.

[0069] In actual applications, when the virtual processor runs on the physical processor, some events that need to be executed by the target process may occur. In order to let the target process resume running in time, in some examples, after the step of exiting the target process in the idle state from the physical processor, the method can further include: if a preset running event sent to the virtual processor where the target process is located is detected, running the new virtual processor on the physical processor, and scheduling the virtual processor where the target process is located to run on the physical processor.

[0070] Optionally, the preset running event sent to the virtual processor where the target process is located can be configured as needed, which is not limited in the embodiment. As an example, it can be an IPI (Inter-Processor Interrupts, processor interrupt) or an external interrupt event sent to the target process, which can be captured by the virtualization layer. As an example, the event here can be the event that the target process is polling and waiting in the foregoing example.

[0071] When detecting the events, the embodiment can run the new virtual processor from the physical processor, specifically, sending an interrupt instruction, for example, a custom virtual interrupt instruction, to the running new virtual processor, so that the new virtual processor exits from the physical processor, and then the virtual processor where the target process is located can be scheduled to resume running on the physical processor, so as to not affect the service of the target process.

[0072] In some examples, the shared storage area further includes a third sub-area for storing an emergency scheduling mark; the method further includes: if detecting a preset running event sent to the virtual processor where the target process is located, writing the emergency scheduling mark in the third sub-area; and the target process is configured to clear the information stored in the first sub-area and suspend the prediction of the idle time information after reading the emergency scheduling mark stored in the third sub-area during the process of running on the physical processor.

[0073] The embodiment does not limit the specific implementation of the third sub-area, and the size and order of the third sub-area in the shared storage area can be flexibly set according to actual needs.

[0074] The third sub-area of the embodiment can be read-only for the target process and write-only for the virtualization layer, so as to avoid read-write competition. The third sub-area is used to store the emergency scheduling message transmitted by the virtualization layer to the target process. In the above example, the virtualization layer detects a preset running event sent to the virtual processor where the target process is located, exits the new virtual processor from the physical processor, and schedules the virtual processor where the target process is located to run on the physical processor, so that the target process needs to handle the event next time. In order not to affect the service of the target process, the target process can access the third sub-area to find that the emergency scheduling mark is stored in the third sub-area, and then clear the information stored in the first sub-area, regardless of whether the stored idle time information has been completed or not, and suspend the prediction of the idle time information. Thus, the virtualization layer can find that the information stored in the first sub-area is cleared, determine that the target process is not in the idle state at present, and suspend the physical processor from scheduling and running the virtual processor.

[0075] Optionally, the target process can continue running for a certain duration, for example, a threshold value can be set, and after the target process continues running for a certain duration and reaches the threshold value, the target process does not need to perform the service and is in the idle state for a certain duration, and then the idle time information can be predicted again to give up the running of the physical processor.

[0076] In some examples, after the step of scheduling the physical processor to run the virtual processor, the method can further include: after the new virtual processor exits running from the physical processor, counting a running duration of the new virtual processor this time; and in response to detecting that a total running duration of the new virtual processor in a recent set time period reaches a set duration threshold, suspending the exiting of the virtual processor where the target process is in an idle state from the physical processor.

[0077] In this embodiment, in order to avoid that the new virtual CPU runs too much on the physical processor and affects the normal business running of the target process, the virtualization layer can also count a total duration of the target process actively given up in a period of time, and if the given up duration is too much, the actively giving up can be suspended for a period of time, so as to avoid the business performance fluctuation caused by the inaccurate idle time prediction algorithm.

[0078] Next, the following embodiments are used for illustration. The following embodiments take the processor as the CPU as an example. It can be understood that in actual application, the CPU in the embodiments can be replaced by other types of processors, such as GPU, and the like, and the embodiments are not limited thereto.

[0079] The embodiment can be applied to the virtualization layer, and the running host operating system can be switched from the root mode to the virtualization mode, and at least one virtual CPU can be created in the virtualization mode.

[0080] Since the newly created virtual CPU does not have a fixed physical CPU corresponding thereto, the physical CPU that each newly created virtual CPU can run on can be set first, and then the scheduler can schedule each virtual CPU to run on the physical CPU that the virtual CPU can run on.

[0081] The scheduler of the virtualization layer can set a scheduling priority for each newly created virtual CPU, and the priority of the newly created virtual CPU can be set to be not higher than the priority of other virtual CPUs directly switched from the physical CPU, but higher than the priority of the background task. The time slice of the newly created virtual CPU that can run on the physical CPU can also be set, so that the scheduler of the virtualization layer allocates a certain time slice to the virtual CPU for use in each scheduling period.

[0082] Through the above setting, in the scheduling logic of the guest operating system, a certain process can be scheduled to run on the newly created virtual CPU, just like other CPUs.

[0083] The physical processor is bound with the target process, and when the virtualization layer switches the running host operating system from the root mode to the virtualization mode, the physical processor also has the virtual CPU switched thereto, that is, the virtual CPU where the target process is located.

[0084] Considering that some processes in the client operating system that need high performance running are likely to be bound to the CPU switched from the physical CPU, these processes need to achieve high performance running when performing services; however, the processes can also be in an idle state, such as in a poll state but without specific services, which can cause waste of physical resources.

[0085] In the actual scenario, in the existing scheduling logic of the virtualization layer, the time slice is allocated to the virtual CPU for running by the scheduler, but for the physical CPU of the bound target process, if it is explicitly known that the target process running thereon is currently in an idle state, the time slice can also be actively given up for the CPU to run a newly created virtual CPU.

[0086] In order to enable the target process to actively give up the time slice, the process that can give up the time slice can be selected first; in actual implementation, the specific way of selecting the target process can be flexibly configured according to actual needs, which is not limited in this embodiment. The prediction function of future idle time can be added to the target process, and optionally, the prediction of future idle time can be performed before and after the execution of the poll processing function.

[0087] As an example, the interval time between each busy running time period can be counted, for example, the next future idle time can be predicted based on the last 10 times of non-busy time period. Optionally, the implementation manner of prediction can use average value, linear prediction, or AI intelligent prediction, etc.

[0088] After obtaining the predicted current idle time slice length, the idle time information needs to be notified to the virtualization layer, and the notification manner can be various, for example, the notification can be realized through the direct system call manner, for example, through the vmcall function, so that the virtualization layer obtains the idle time information.

[0089] Since the scheduling period of the underlying scheduler is very short, the notification overhead of such frequent vmcall calls is large. Based on this, this embodiment also designs a shared memory to realize the notification of the predicted idle time information of the target process to the virtualization layer, and a shared storage area can be allocated for each physical CPU to store the information.

[0090] As an example, the communication manner of the shared storage area can be agreed; for example, as shown in FIG. 2B, the shared storage area can be designed as follows: ① the first sub-area is used to store the predicted idle time information; the target process of the upper layer only writes, and the underlying scheduler only reads; ② the second sub-area is used to store the indication information; the target process of the upper layer only reads, and the underlying scheduler only writes; ③ the third sub-area is used to store the emergency scheduling mark; the upper layer process only reads, and the underlying scheduler only writes.

[0091] The size of the three sub-areas can be set according to the size of the stored information, and the embodiment is not limited in this regard.

[0092] Optionally, in actual applications, the shared storage area can be further extended as needed, for example, a fourth sub-area can be further included for storing an allowed running time, the information can be updated by the client operating system, the information can be configured, and can be smaller than the predicted idle time information (the allowed running time is smaller than the idle termination time). Alternatively, a fifth sub-area can be further included for storing an actual running time set by the virtualization layer, the information can be updated by the virtualization layer. Alternatively, a sixth sub-area can be further included for storing a start running time set by the virtualization layer, the information can be updated by the virtualization layer. These information can be used for more accurate scheduling and prediction, and other designs can be used in actual applications, and the embodiment is not limited in this regard.

[0093] The target process can predict the idle time slice that can be given up, for example, the idle time information predicted by the target process when in the idle state can be the idle termination time. Optionally, the idle time slice can be long, and the determined idle termination time can be directly written to the first sub-region in the shared storage area. Alternatively, it can also be written after a certain reduction, and such processing is considered that the underlying is scheduling physical CPUs according to the scheduling period, and a longer idle time slice is more than the scheduling period, which is meaningless, and the target process can temporarily store the predicted idle time slice in the process local. Next time the target process runs on the physical CPU again, the current busy and idle state and the temporarily stored idle time slice can be used to determine the new idle time slice. For example, the currently predicted idle time slice is 10ms, which can be stored in the process local, and the idle termination time can be determined based on the current time and the predicted idle time slice and written to the first sub-region. The underlying scheduler can read the idle time information stored in the first sub-region and store it locally, and determine the time slice of the new virtual CPU. For example, it can be appropriately reduced based on the underlying scheduling period, for example, it can be 3ms. Next time the target process is scheduled to run on the physical CPU, the target process can determine the idle time information written to the first sub-region based on the current time. For example, when the virtual CPU of the target process runs on the physical CPU again, it is found that the target process is currently in the idle state, based on the current time and the locally stored idle termination time, it is found that the idle termination time has not been reached, the target process can not need to write the idle time information again, or it can write new idle time information as needed. For the underlying scheduler, in the next scheduling period, the time slice of the new virtual CPU can be determined again based on the locally stored idle time information. For example, there are 8ms to the locally stored idle termination time, then the new idle time slice is directly obtained as 8ms, and then the idle time slice of the new virtual CPU is determined as 3ms.

[0094] When the target process runs to the trap-out on the physical CPU which the target process voluntarily gives up the time slice, the underlying scheduler can read the idle time information which can be given up through the first sub-region of the shared memory region; for example, if the first sub-region of the shared memory region stores a data value, the scheduler can read the idle time information and store it in the local memory space of the virtualization layer scheduler, and write an indication information in the second sub-region of the shared memory region to indicate that the idle time information has been read; next time when the physical processor runs the target process, if the target process accesses the shared memory region and finds that the idle time information has been read through the second sub-region, and then the current time reaches the idle termination time, it is not necessary to write the idle time information again. Or, when the idle time information stored in the first sub-region expires, or the third sub-region sets an emergency scheduling flag, the information stored in the second sub-region will be updated, for example, emptied or set to a value indicating that it has not been read.

[0095] In the above embodiment, the virtualization layer stores the idle time information in the local memory in the shared memory region, in order to facilitate the calculation of the actual allowed running time in the local memory, because the value cannot be inconsistent before and after the calculation; at the same time, in order not to affect the subsequent upper layer to continue to update; for example, half way through the running, it is found that it is not idle and needs to be cleaned up; or the prediction algorithm will also evolve, and it is found that the previous prediction is not accurate, and a new value needs to be updated; in fact, the scheduler can check whether the future idle time stored in the shared memory region has changed before using the locally stored idle time slice, and then make the corresponding calculation. For example, first compare whether the idle time information stored in the local memory and the future idle time stored in the shared memory region are consistent, and if they are consistent, directly calculate the time slice that can be allocated to the new virtual CPU, and use the locally stored value in the calculation process; if they are not consistent, update the local value and then calculate.

[0096] When the scheduler schedules the physical CPU to run the new virtual CPU, it can determine whether there is an idle time slice voluntarily given up at this time through the read idle time information, and can convert the idle time information into a future deadline, that is, it can run to a certain time in the future, that is, the idle termination time. Among them, the idle termination time written by the target process in the first sub-region of the shared memory region can be different from the deadline read and stored by the scheduler in the local memory; for example, the scheduler can reduce the deadline based on some strategies based on the idle termination time determined by the target process.

[0097] The scheduler can calculate the running time of the current scheduling cycle according to the deadline each time the virtual processor is scheduled to run. Optionally, the running time of each time can be set to an upper limit, i.e. cannot be greater than a certain threshold, which can be a scheduling cycle, or the maximum time slice that can be executed at the current priority, etc. The specific threshold can be set as needed.

[0098] When the virtual CPU runs to the trap-out, i.e. the virtual CPU stops running from the physical CPU, it can be checked whether it is timed out (i.e. whether it exceeds the allocated running time of the current time), and at the same time, it can also be checked whether the consumed time slice reaches the maximum idle time given up. If it reaches, it will also be given up in time. Among them, the maximum idle time given up here can be smaller than the idle termination time deadline. The maximum idle time given up can be stored in the fourth sub-area mentioned above.

[0099] When the virtual CPU runs out, it can be checked whether the deadline of active giving up is due. If it is due, the underlying scheduler can clean up the information stored in the second sub-area. When the target process predicts the idle time information, it finds that the information in the second sub-area is cleaned up, and then it can empty or update the idle time information in the first sub-area according to the busy and idle state.

[0100] In addition, in order to avoid that the virtual CPU runs too much and affects the normal business running of the target process, the total time of active giving up in a period of time is also counted. If it gives up too much, it will suspend the active giving up for a period of time to avoid business performance fluctuations caused by inaccurate prediction algorithm.

[0101] For the underlying scheduler, if it detects that the IPI or external interrupt sent to the target process, it can send an interrupt instruction (such as a custom virtual interrupt) to the virtual CPU running to make the virtual CPU exit running, and then schedule the physical processor to resume running the target process. At the same time, an emergency scheduling flag can be set, which can be stored in the third sub-area of the shared storage area. This information is only written by the underlying and only read by the target process, avoiding read-write competition. At the same time, the second sub-area can be emptied, which indirectly makes the target process run after being run, finds that the third sub-area is written with the flag to clean up the first sub-area. If the information is written in the third sub-area, after a certain threshold delay, the underlying scheduler can automatically empty the third sub-area at the beginning of each scheduling cycle.

[0102] If the target process identifies the emergency scheduling mark during runtime, it indicates that a burst scenario requiring execution is encountered, at which time the time slice yield is stopped and the previously given expected idle information is cleared, regardless of whether the time slice yield is completed; and the target process continues to run for a period of time until a certain time threshold is reached without a task requiring execution, at which time the time slice yield can be restarted.

[0103] Optionally, the emergency scheduling can also be performed in other manners, for example, if the above manners do not well coordinate the relationship between the time slice yield and the emergency response, other manners such as reserving a user mode interface to notify the underlying scheduler to urgently wake up the upper layer application and modifying the related threshold value to change the time slice yield strategy can also be used; further, the optimal threshold value setting can be deposited for different scenarios. As an example, the modification of the related threshold value can be selecting a prediction algorithm, setting the maximum running time on a single physical CPU (i.e., the information stored in the fourth sub-region described above, that is, the time slice ratio of each scheduling cycle that the new virtual CPU can run) or setting the idle time slice ratio occupied by all new virtual CPUs, and the like.

[0104] As shown in FIG. 3, it is a processor scheduling method of a physical machine according to an exemplary embodiment of the present disclosure, the physical machine includes a physical processor, the target process is bound to the physical processor, the method is applied to the target process, and the method includes the following steps.

[0105] In step 302, during the running of the process on the physical processor, if it is determined to be in an idle state, the idle time information is predicted.

[0106] In step 304, the idle time information is written into a first sub-region of a shared storage area in memory; the shared storage area is used to share with a virtualization layer in a host operating system of the physical machine, the virtualization layer is used to switch the running host operating system from a root mode to a virtualization mode, after the virtualization mode is created, the target process is in a virtual processor and a new virtual processor, the first sub-region in the shared storage area is read to obtain the idle time information, based on the idle time information, the target process in the idle state is exited from the running of the virtual processor on the physical processor, and the physical processor is scheduled to run the new virtual processor.

[0107] The implementation process of the present embodiment can refer to the description of the foregoing embodiments, which will not be described here.

[0108] Correspondingly, the disclosure also provides a processor scheduling system of a physical machine, as described in the foregoing embodiments, please see Fig. 2A, the physical machine includes a physical processor and a host operating system running on the physical processor, and the virtualization layer and the target process can be used to execute the steps of the foregoing embodiments.

[0109] As an example, the virtualization layer can switch the running host operating system from the root mode to the virtualization mode when needed. For example, the physical machine can include hardware resources, the hardware resources including at least one physical computing resource object and a physical address space, the physical address space having a host physical address, the host operating system running on the physical computing resource object; switching the running host operating system from the root mode to the virtualization mode includes: creating a memory page table for storing a mapping relationship between a guest physical address in the virtualization mode and a host physical address in the root mode; creating an information carrying object required during mode switching, the information carrying object being used to synchronize context information between the root mode and the virtualization mode; switching the running host operating system from the root mode to the virtualization mode based on the information carrying object and the memory page table.

[0110] Optionally, the information carrying object required during mode switching can be created, including: for any physical computing resource object, creating a physical descriptor structure, the physical descriptor structure being used to save context information of any physical computing resource in the root mode during mode switching; for any physical computing resource object, creating a virtualization descriptor structure and initializing, the virtualization descriptor structure being used to synchronize the context information in the physical descriptor structure during mode switching; for any physical computing resource object, creating a virtualization control structure and initializing, the virtualization control structure being used to save running state information and running control information of any physical computing resource object in the virtualization mode.

[0111] Optionally, the running host operating system can be switched from the root mode to the virtualization mode based on the information carrying object and the memory page table, including: in the case of mode switching of a target physical computing resource object, saving the context information of the target physical computing resource object in the root mode to the physical descriptor structure corresponding to the target physical computing resource object; synchronizing the values of each register and the configuration information of the segment register in the context information in the physical descriptor structure to the virtualization descriptor structure and the virtualization control structure corresponding to the target physical computing resource object, respectively; controlling the target physical computing resource object to run according to the virtualization descriptor structure, the virtualization control structure and the memory page table, so as to switch the running host operating system from the root mode to the virtualization mode.

[0112] Further optionally, the context information of the target physical computing resource object in the root mode is saved into the physical descriptor structure corresponding to the target physical computing resource object, including: saving the values of the registers in the context information and the top and bottom addresses of the second stack in the physical descriptor structure, the second stack being the stack used by the target physical computing resource object in the root mode; switching the second stack used by the target physical computing resource object in the root mode to the first stack corresponding to the target physical computing resource object in the virtualization mode.

[0113] Further optionally, the target physical computing resource object is controlled to run according to the virtualization descriptor structure, the virtualization control structure and the memory page table, including: loading the values of the special registers in the virtualization control structure and the virtualization descriptor structure; injecting the running control information in the virtualization control structure into the target physical computing resource object, and loading the values of the general registers in the virtualization descriptor structure; executing the mode switching instruction to control the target physical computing resource object to enter the virtualization mode and start running from the first instruction, and in the running process, performing memory management and access based on the memory page table.

[0114] Corresponding to the foregoing embodiments of the processor scheduling method of the physical machine, the present disclosure further provides embodiments of a processor scheduling apparatus of the physical machine and a computer device to which the processor scheduling apparatus is applied.

[0115] The embodiments of the processor scheduling apparatus of the physical machine of the present disclosure can be applied to a computer device, such as a server or a terminal device. The apparatus embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking the software implementation as an example, as a logically meaningful apparatus, the processor scheduling apparatus of the present disclosure is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory and running by the processor. From the hardware aspect, as shown in FIG. 4, it is a hardware structure diagram of the computer device to which the processor scheduling apparatus of the physical machine of the present disclosure is applied. In addition to the processor 410, the network interface 420, the memory 430 and the non-volatile memory 440 shown in FIG. 4, the computer device to which the processor scheduling apparatus of the physical machine is applied in the embodiments usually includes other hardware according to the actual functions of the computer device, and thus will not be described here.

[0116] As shown in Fig. 5, it is a structure diagram of a processor scheduling apparatus of a physical machine according to an exemplary embodiment of the present disclosure, the physical machine comprising a physical processor, the physical processor being bound with a target process, the apparatus comprising: a creating module 51 configured to: switch a running host operating system from a root mode to a virtualization mode, and create a virtual processor in the virtualization mode; an obtaining module 52 configured to: obtain predicted idle time information of the target process after being in an idle state; and a scheduling module 53 configured to: based on the idle time information, exit the target process in the idle state from running on the physical processor, and schedule the physical processor to run the virtual processor.

[0117] As shown in Fig. 6, it is a structure diagram of a processor scheduling apparatus of a physical machine according to an exemplary embodiment of the present disclosure, the physical machine comprising a physical processor, the physical processor being bound with a target process, the apparatus being applied to the target process, the apparatus comprising: a predicting module 61 configured to: during a process running on the physical processor, if it is determined that the process is in an idle state, predict idle time information; and a writing module 62 configured to: write the idle time information into a first sub-region of a shared storage region in a memory; the shared storage region being configured to be shared with a virtualization layer in a host operating system of the physical machine, so that the virtualization layer switches a running host operating system from a root mode to a virtualization mode, and after creating a virtual processor in the virtualization mode, reads the first sub-region of the shared storage region to obtain the idle time information, based on the idle time information, exits the target process in the idle state from running on the physical processor, and schedules the physical processor to run the virtual processor.

[0118] The implementation process of the functions and roles of each module in the processor scheduling apparatus of the physical machine is specifically described in the implementation process of the corresponding steps in the processor scheduling method of the physical machine, which will not be repeated here.

[0119] Correspondingly, the present disclosure also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the processor scheduling method of the physical machine.

[0120] Correspondingly, the present disclosure also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the processor scheduling method of the physical machine when executing the program.

[0121] Correspondingly, the present disclosure also provides a computer readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps of the processor scheduling method of the physical machine.

[0122] For the device embodiment, since it basically corresponds to the method embodiment, the relevant part can be seen from the part of the method embodiment. The device embodiment described above is only illustrative, wherein the modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical modules, i.e., can be located in one place or distributed to multiple network modules. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present disclosure. Those skilled in the art can understand and implement without creative labor.

[0123] The above embodiments can be applied to one or more computer devices, which are devices capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions. The hardware of the computer device includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0124] The computer device can be any electronic product capable of human-computer interaction with the user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive Internet Protocol Television (IPTV), a smart wearable device, etc.

[0125] The computer device can also include a network device and / or a user device. The network device includes but is not limited to a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.

[0126] The network in which the computer device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0127] The above describes particular embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order and still accomplish the desired result. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous or necessary.

[0128] The division of steps in the above methods is only for the sake of clarity, and in implementation, one step can be combined or some steps can be split and decomposed into multiple steps, as long as the same logical relationship is included, which is within the protection scope of the patent; adding insignificant modifications or introducing insignificant designs in the algorithm or process, but not changing the core design of the algorithm and process, are within the protection scope of the application.

[0129] While the present disclosure contains many specific embodiments, these should not be construed as limiting any of the claims hereto in scope or requirement except to the specific embodiments described. Certain features that are, for clarity, described above and illustrated in the drawings can be combined or eliminated, and other features can be added. Further, while the application has been described here with reference to particular embodiments, it is not intended to be limited to the details described, since additional embodiments and / or variations can be possible according to the detailed description and the annexed drawings. In other instances, well-known structures and functions have not been described in detail so as not to unnecessarily obscure aspects of the application. It will be understood by those within the art that, in general, terms used herein, and especially

[0130] Where a term is introduced as "specific example" or "some examples" or the like, this is intended to mean that the specific feature, structure, material, or characteristic being described is included in at least one embodiment or example of the present disclosure. The illustrative appearance of the above-mentioned terms in the detailed description is not necessarily intended to identify the same embodiment or example. Moreover, the description of particular features, structures, materials, or characteristics is intended to bring about a better understanding for at least one embodiment or example, and it is not intended to mean that all or even some embodiments or examples necessarily include the particular feature, structure, material, or characteristic.

[0131] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The present disclosure is intended to cover any and all variations of the present disclosure comprising features of the disclosure that are within the spirit and scope of the claims. It is submitted that the true scope of the present disclosure is not limited to the specific embodiments disclosed, but is in accordance with the appended claims.

[0132] It is to be understood that the present disclosure is not limited to the precise construction herein described and as shown in the drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope thereof. The scope of the present disclosure is limited only by the claims appended hereto.

[0133] The above description is merely the preferred embodiment of this disclosure, and is not used to limit this disclosure. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this disclosure should be included in the scope of this disclosure.

Claims

1. A processor scheduling method of a physical machine, the physical machine comprising a physical processor, the physical processor being bound with a target process, the method comprising: switching a running host operating system from a root mode to a virtualization mode, in the virtualization mode, creating a virtual processor where the target process is located and a new virtual processor; acquiring idle time information, the idle time information representing an idle time when the target process is in an idle state; based on the idle time information, exiting the virtual processor where the target process is in the idle state from the physical processor, and scheduling the physical processor to run the new virtual processor.

2. The method of claim 1, the acquiring idle time information comprising: accessing a shared storage area in a memory shared by the target process, the shared storage area comprising a first sub-area for storing the idle time information, the idle time information being determined after the target process is in the idle state and written into the first sub-area during a process of the target process running on the physical processor; reading the idle time information from the first sub-area in the shared storage area.

3. The method of claim 2, the shared storage area further comprising a second sub-area for storing indication information; after reading the idle time information from the first sub-area, writing indication information representing that the idle time information has been read into the second sub-area, the target process being configured to access the second sub-area of the shared storage area during the process of the target process running on the physical processor, if the indication information is read and a current idle termination time indicated by the idle time information has not been reached, suspending prediction of idle time information, if the indication information is not read, predicting idle time information and writing into the first sub-area.

4. The method of claim 2, after the step of exiting the virtual processor where the target process is in the idle state from the physical processor, the method further comprising: if a preset running event sent to the virtual processor where the target process is located is detected, exiting the new virtual processor from the physical processor and scheduling the virtual processor where the target process is located to run on the physical processor.

5. The method of claim 4, the shared storage area further comprising a third sub-area for storing an emergency scheduling flag, the method further comprising: if the preset running event sent to the virtual processor where the target process is located is detected, writing the emergency scheduling flag into the third sub-area; the target process being configured to read the emergency scheduling flag stored in the third sub-area during the process of the target process running on the physical processor, clear the information stored in the first sub-area, and suspend prediction of the idle time information.

6. The method of claim 1, the scheduling the physical processor to run the new virtual processor comprising: allocating, based on the idle duration indicated by the idle time information, a current running duration for the new virtual processor in the current scheduling, and scheduling the physical processor to run the new virtual processor based on the current running duration, so that the new virtual processor stops running on the physical processor when the running duration of the new virtual processor reaches the current running duration.

7. The method of claim 1, after the step of scheduling the physical processor to run the new virtual processor, the method further comprises: counting the current running duration of the new virtual processor after the new virtual processor stops running on the physical processor; suspending the new virtual processor from stopping running on the physical processor in the idle state in response to detecting that the total running duration of the new virtual processor in the recent setting time period reaches the setting duration threshold.

8. A processor scheduling method of a physical machine, the physical machine comprising a physical processor, the physical processor binding a target process, the method being applied to the target process, the method comprising: predicting idle time information if determining in the idle state during the process running on the physical processor; writing the idle time information into a first sub-region of a shared storage region in a memory; the shared storage region being used for sharing with a virtualization layer in a host operating system of the physical machine, the virtualization layer being used for switching the running host operating system from a root mode to a virtualization mode, after creating a virtual processor of the target process and a new virtual processor in the virtualization mode, reading the first sub-region of the shared storage region to obtain the idle time information, based on the idle time information, stopping the virtual processor of the target process from running on the physical processor in the idle state, and scheduling the physical processor to run the virtual processor.

9. The method of claim 8, the shared memory region further comprising a second sub-region for storing indication information; wherein, the indication information being written into the second sub-region by the virtualization layer after reading the idle time information from the first sub-region, the indication information being used to represent that the virtualization layer has read the idle time information; the predicting idle time information if determining in the idle state, comprising: accessing a second sub-region of the shared storage region; suspending the predicting idle time information if reading the indication information and not reaching the idle termination time indicated by the idle time information; if not reading the indication information, predicting the idle time information and writing into the first sub-region.

10. The method of claim 8, the shared storage region further comprising a third sub-region used for storing an emergency scheduling mark, the emergency scheduling mark being written into the third sub-region by the virtualization layer after detecting a preset running event sent to the virtual processor of the target process; the method further comprising: if reading that the third sub-region of the shared storage region stores the emergency scheduling mark, clearing the information stored in the first sub-region, and suspending the predicting of the idle time information.

11. A processor scheduling system of a physical machine, the physical machine comprising a physical processor and a host operating system running on the physical processor, the physical processor having a target process bound thereto, the host operating system having a virtualization layer therein, the virtualization layer configured to perform the steps of any of the methods of claims 1 to 7, the target process configured to perform the steps of any of the methods of claims 8 to 10.

12. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, The processor implements the steps of any of the methods of claims 1 to 10 when executing the computer program.

13. A computer program product comprising a computer program which, when executed by a processor, implements the steps of any of the methods of claims 1 to 10.

14. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of any of the methods of claims 1 to 10.

Citation Information

Patent Citations

  • Task scheduling method, virtual machine, physical host and storage medium

    CN114327814A

  • Resource scheduling method and device

    CN114579302A

  • Computer system, virtual machine monitor and scheduling method for virtual machine monitor

    US20110010713A1