Nothing Special   »   [go: up one dir, main page]

CN113296938A - Task isolation method, device, operating system, equipment and storage medium - Google Patents

Task isolation method, device, operating system, equipment and storage medium Download PDF

Info

Publication number
CN113296938A
CN113296938A CN202110199647.1A CN202110199647A CN113296938A CN 113296938 A CN113296938 A CN 113296938A CN 202110199647 A CN202110199647 A CN 202110199647A CN 113296938 A CN113296938 A CN 113296938A
Authority
CN
China
Prior art keywords
processor
task
operating system
identifier
cpu
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202110199647.1A
Other languages
Chinese (zh)
Inventor
王贇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202110199647.1A priority Critical patent/CN113296938A/en
Publication of CN113296938A publication Critical patent/CN113296938A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • 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
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention provides a task isolation method, a task isolation device, an operating system, equipment and a storage medium, wherein the method comprises the following steps: the operating system kernel receives a first processor identifier input by a user through a preset interface, the preset interface is registered in the operating system kernel in advance, and the first processor identifier is an identifier of an isolated processor. The operating system kernel determines a first task of a user mode without carrying out processor resource configuration in tasks contained in a root node of a target control group corresponding to the processor subsystem, and binds the first task with a second processor identifier, wherein the second processor identifier is the identifier of the processor which is not isolated. Based on the preset interface registered in the operating system kernel, when the CPU isolation configuration needs to be updated, a user can input the CPU identification needing isolation to the preset interface as required, so that the operating system kernel can be triggered to automatically complete the identification and isolation processing of a specific isolation object, and the implementation is convenient and efficient.

Description

Task isolation method, device, operating system, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, an operating system, a device, and a storage medium for task isolation.
Background
Currently, many electronic devices use an embedded operating system, which generally includes hardware such as a plurality of processors (CPUs), a memory, a universal device interface, and software such as an operating system kernel and an application program of a user.
In an embedded operating system comprising a plurality of CPUs, the isolation of the CPUs can be realized in a static isolation mode, some key tasks (which can be specified by a user) can be configured on the isolated CPUs to run, and the interference of other tasks on the key tasks is prevented, so that the safe and efficient running of the key tasks is guaranteed.
Currently, the static isolation manner for implementing isolation of a CPU means that a user isolates a CPU specified in an isolation CPU (isoucpus) parameter by configuring the parameter, and then the user can bind a critical task and the isolated CPU together, so that the critical task can monopolize the bound CPU.
However, when the static isolation manner is adopted, the system needs to be restarted to enable the configured isolpus parameter to take effect, which means that if the isolpus parameter is to be updated, the system needs to be restarted again after the isolpus parameter is updated to enable the updated isolpus parameter to take effect, and the operation is complex and the efficiency is low.
Disclosure of Invention
Embodiments of the present invention provide a task isolation method, device, operating system, device, and storage medium, which can implement efficient and dynamic binding of a task not controlled by a resource to an un-isolated CPU as needed.
In a first aspect, an embodiment of the present invention provides a task isolation method, which is applied to an operating system kernel, and the method includes:
receiving a first processor identifier input by a user through a preset interface, wherein the preset interface is registered in an operating system kernel in advance, and the first processor identifier is an identifier of an isolated processor;
determining a first task of a user state without processor resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a processor subsystem;
binding the first task with a second processor identification, the second processor identification being an identification of the non-isolated processor, the second processor identification being determined by the first processor identification and all processor identifications of the operating system kernel record.
In a second aspect, an embodiment of the present invention provides a task isolation device, located in an operating system kernel, where the task isolation device includes:
the receiving module is used for receiving a first processor identifier input by a user through a preset interface, wherein the preset interface is registered in the kernel of the operating system in advance, and the first processor identifier is an identifier of an isolated processor;
the system comprises a determining module, a processing module and a processing module, wherein the determining module is used for determining a first task in a user state without processor resource configuration in tasks contained in a root node of a target control group, and the target control group corresponds to a processor subsystem;
and the binding module is used for binding the first task with a second processor identifier, wherein the second processor identifier is the identifier of the processor which is not isolated, and the second processor identifier is determined by the first processor identifier and all the processor identifiers recorded by the operating system kernel.
In a third aspect, an embodiment of the present invention provides an operating system, including:
the system comprises a plurality of processors and an operating system kernel, wherein a preset interface is registered in the operating system kernel, and the operating system kernel is used for:
receiving a first processor identifier input by a user through a preset interface, wherein the first processor identifier is the identifier of an isolated processor;
determining a first task of a user state without processor resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a processor subsystem;
binding the first task with a second processor identification, the second processor identification being an identification of the non-isolated processor, the second processor identification being determined by the first processor identification and all processor identifications of the operating system kernel record.
In a fourth aspect, an embodiment of the present invention provides an electronic device, including: the system comprises a memory, a plurality of processors and an operating system kernel; wherein the memory has stored thereon executable code which, when executed by the operating system kernel, causes the operating system kernel to at least implement the task isolation method of the first aspect.
In a fifth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium having stored thereon executable code, which when executed by an operating system kernel of an electronic device, causes the operating system kernel to implement at least the task isolation method according to the first aspect.
In the solution provided by the embodiment of the present invention, an interface is registered in advance in the kernel of the operating system, so that a user can perform a write operation on the interface to trigger the kernel of the operating system to automatically perform a subsequent task isolation step. The user writes an identifier of the CPU which the user wants to isolate currently into the preset interface, which is called a first CPU identifier. And isolating the corresponding CPU based on the first CPU identification input by the user. In practical applications, there are some special tasks in the operating system, and these tasks are not controlled by resources, that is, the user does not limit which CPU resources these tasks may not use (i.e., the tasks are not configured with CPU resources), so that these tasks may actually use all CPUs, which will interfere with the tasks running on the isolated CPU, and therefore these tasks need to be identified and the CPU resources that these tasks may use are limited. For this purpose, first, after receiving a first CPU identifier currently input by a user, an operating system kernel determines a first task in a user state without CPU resource configuration from tasks included in a root node of a target control group (cgroup), where the target cgroup corresponds to a CPU subsystem. The first task is the above-mentioned task that is not resource-controlled. And then, the operating system kernel binds the first task with a second CPU identifier, wherein the second CPU identifier is the identifier of the CPU except the isolated CPU in the plurality of CPUs contained in the operating system, namely the identifier of the CPU which is not isolated. The first task is bound with the second CPU identifier, which means that the CPU which can be used by the first task is limited to be an un-isolated CPU, so that the first task which is not controlled by resources cannot be subsequently operated on the isolated CPU, and the operation safety of the task on the isolated CPU is ensured.
According to the scheme, based on the preset interface registered in the operating system kernel, when the CPU isolation configuration needs to be updated, a user can input the CPU identification needing isolation to the preset interface as required, so that the operating system kernel can be triggered to automatically complete the identification of the user mode task which is not controlled by resources and the processing of binding the identified user mode task to the CPU which is not isolated, and the convenience and the high efficiency are realized.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a cgroup tree according to an embodiment of the present invention;
FIG. 2 is a flowchart of a task isolation method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a first task identification method according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a task isolation execution scenario according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a task isolation device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an operating system according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention 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, and "a plurality" typically includes at least two.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
Before introducing the task isolation scheme provided by the embodiments of the present invention, a brief description of several concepts involved herein is provided:
task (task): a task is the most basic unit of program control by an operating system. In practical applications, a task may be a process or a thread running in an operating system, and thus the task may be understood as the same as the process or the thread in this document.
Control group (cgroup): the cgroup is a mechanism for managing processes (i.e., tasks) in groups, and in view of a user layer, the cgroup technology organizes all processes in an operating system into an independent tree, each tree contains all processes of the operating system, each node of the tree is a process group, and each tree is associated with one or more subsystems (subsystems). There may be many cgroup trees in the operating system. The role of the tree is to group processes and the role of the subsystem is to operate on these groups.
The subsystems involved in cgroup include, but are not limited to, the following subsystems:
device: device rights control
CPU controlling CPU occupancy rate
cpuiset: allocating designated CPU and memory nodes
memory: limiting the upper limit of memory usage
cpu act: and counting the use condition of the CPU.
For ease of understanding, the constituent structure of a cgroup tree is illustrated below in conjunction with fig. 1. Assuming that an operating system includes 100 tasks (i.e., 100 processes) from task 1 to task 100, a user may create a tree as illustrated in fig. 1, where a root node Boot includes 70 tasks from task 1 to task 70, two child nodes are created under the root node, which are respectively denoted as child node a and child node B, the child node a includes 10 tasks from task 71 to task 80, and the child node B includes 10 tasks from task 91 to task 100. Under the child node a, a child node a1 and a child node a2 are created, 8 tasks of 81 to 88 are included in the child node a1, and 2 tasks of 89 to 90 are included in the child node a 2.
Scheduling domain (scheduled _ domain): in order to describe the affinity between the CPU and the CPU, a scheduling domain is introduced. Based on the scheduling domain, load balancing between the CPUs can be performed. Through the description of the scheduling domain, the kernel of the operating system can know the genetic relationship between the CPU and the CPU. For CPUs with far relation, processes are migrated among the CPUs as few as possible; for CPU with close relationship, more process migration can be tolerated.
Tasks that are not subject to resource management: may be colloquially referred to as a wild task, refers to a task for which CPU resource allocation is not performed, possibly originating from the operating system itself or from a daemon process of some service.
CPU Isolation (CPU Isolation): meaning that the CPU of the specified scope is isolated, ensuring that all of the above running tasks are critical tasks that are approved or specified by the user.
And (3) static isolation of the CPU: after the CPU isolation configuration (i.e., configuring the isolated CPU range) is in effect, the isolated CPU range cannot be reassigned, i.e., the CPU isolation configuration cannot be updated, unless the system is restarted.
Dynamic isolation of the CPU: the isolated CPU range can be reassigned at any time without restarting the system, and the system can take effect immediately.
Currently, the performance of the critical service can be ensured by using a CPU static isolation technology, that is, by configuring CPU isolation to ensure that the critical service runs on the isolated CPU. However, since the system needs to be restarted after configuration to enable the configuration to be effective, the critical service does not always need so many CPUs, and a serious resource waste phenomenon exists in daily life, a dynamic isolation technology is needed to modify the CPU isolation range at any time, so that the CPU resources are better utilized, the cost is saved, and the overall service performance is improved. The dynamic isolation technology is simply a technology for dynamically updating the CPU isolation configuration as required and enabling the configuration to take effect without restarting a system.
However, there is a difficulty that many wild tasks are not controlled by resources, and they may be some system tasks, or daemon processes of some services, or some business processes that are not yet controlled, and to isolate these tasks that are not controlled by resources, the existing technologies cannot meet the requirement of dynamic isolation of the CPU.
Based on this, the embodiment of the present invention provides a CPU dynamic isolation technique for a task not subject to resource control, which is a technique capable of dynamically performing CPU isolation under the condition that an isolation target is not subject to resource control, and can simply and effectively perform CPU resource dynamic isolation on a wild task, that is, dynamically limit the task not subject to resource control to run on the un-isolated CPU according to a configuration requirement of dynamically updating the isolated CPU, so as to avoid interference of the task not subject to resource control on a key task specified by a user.
Therefore, in the embodiment of the present invention, task isolation may be considered as: tasks that are not subject to resource management are run on the un-isolated CPU in isolation. Therefore, the CPU isolation is the basis for realizing task isolation.
For example, assuming that the user-specified key task is task a, the task that is not controlled by the resource is task B, and assuming that the operating system includes 16 CPUs, namely, CPUs 0 to 15, when the isolated CPUs configured for the first time are CPUs 0 to 3, task a runs on one of CPUs 0 to 3, and at this time, task B should be limited to run on CPUs 4 to 15. When the isolated CPUs of the second configuration are the CPUs 0 to 5, the task a is executed on any one of the CPUs 0 to 5, and at this time, the task B should be limited to be executed on the CPUs 6 to 15.
The following describes in detail the execution process of the task isolation scheme provided by the embodiment of the present invention.
Fig. 2 is a flowchart of a task isolation method according to an embodiment of the present invention, and as shown in fig. 2, the method includes the following steps:
201. the method comprises the steps that an operating system kernel receives a first CPU identification input by a user through a preset interface, the preset interface is registered in the operating system kernel in advance, and the first CPU identification is an identification of an isolated CPU.
In the embodiment of the invention, an interface is registered in the kernel of the operating system in advance so as to trigger the dynamic isolation configuration of the CPU through the preset interface.
The preset interfaces registered in the operating system kernel are represented as: and the/proc/dyn _ isolpus is used for calling the preset interface to input a new isolated CPU range when a user wants to update the isolation configuration of the CPU.
The identity of the currently input isolated CPU is referred to herein as the first CPU identity. Assuming that the operating system has 16 CPUs 0-15 in common, the first CPU identifier may be, for example, CPU 0-CPU 9, and the CPUs needing to be isolated currently are 10 CPUs 0-CPU 9.
Assuming CPUs 0-9 are currently isolated, the user may enter:
echo '0-9' >/proc/dyn _ isol cpus.
If CPU7, CPU8 is to be set aside later for its purpose, then the following may be re-entered:
echo "0-6, 9" >/proc/dyn _ isolpus.
If the isolation is to be cancelled, i.e. none of the CPUs is isolated, then the following can be entered:
echo >/proc/dyn _ isolpus.
That is, the user can dynamically input the corresponding CPU isolation configuration parameters in the preset interface as required.
The CPU identification needing to be isolated is configured to the preset interface to trigger the kernel of the operating system to automatically execute the following operation steps, and the processing corresponding to the CPU isolation configuration operation is completed.
It should be noted that the preset interface is registered in the os kernel, and the following steps are also executed by the os kernel, that is, the preset interface is not executed in the user mode, but executed in the kernel mode, so that the performance overhead is low.
202. The operating system kernel determines a first task of a user mode without CPU resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a CPU subsystem.
203. And the operating system kernel binds the first task with a second CPU identifier, wherein the second CPU identifier is the identifier of the CPU which is not isolated, and the second CPU identifier is determined by the first CPU identifier and all the CPU identifiers recorded by the operating system kernel.
Assuming a total of N CPUs in the operating system, the first CPU identification corresponds to the isolated CPU being M of the M CPUs, and the second identification corresponds to the remaining (N-M) CPUs. For example, the first CPU id corresponds to CPUs 0 to 9, and the second CPU id corresponds to 6 CPUs 10 to 15.
On the basis that a user inputs a first CPU identifier through a preset interface, the task isolation purpose at the moment is as follows: the method comprises the steps of identifying tasks which are not controlled by resources and contained in a current operating system, and binding the tasks to a current non-isolated CPU, namely limiting the range of the CPU which can be used by the tasks to the non-isolated CPU so as to avoid interference on the tasks running on the isolated CPU.
Based on this, on one hand, optionally, the user may trigger a binding request according to the first CPU identifier, where the binding request includes an identifier of the second task and the first processor identifier, and at this time, the operating system kernel binds the second task and the target CPU in the isolated CPUs based on the binding request triggered by the user. Wherein the second task is specified by the user. The operating system kernel learns that the second task needs to be bound to the isolated CPUs according to the first CPU identification, and when the first CPU identification corresponds to the CPUs, the operating system kernel can determine a target CPU bound with the second task according to modes such as load balancing and the like.
On the other hand, it is necessary to identify the first tasks in the operating system that are not controlled by the resource, and bind these first tasks to the CPU that is not isolated, i.e., to the second CPU identity.
Specifically, the objects to be identified in the embodiment of the present invention are: the first task of the user mode, which is not controlled by the resource, i.e., does not perform the processor resource configuration, in the root node of the target control group (cgroup) corresponding to the CPU subsystem is simply a task that is not bound by the CPU under the CPU cgroup root node and does not include the kernel task.
Since the CPU resources are allocated here, the traversal range of the first task is: the root node of the target control group (cgroup) corresponding to the CPU subsystem is referred to as the CPU cgroup root node for short.
In this embodiment, the first task is only for the user-mode task, and the kernel-mode task is not taken into consideration.
The reason why the kernel-mode tasks (such as various kernel processes) are not isolated is very simple, because the kernel-mode tasks are often designed uniquely, and cause great influence on an operating system after problems occur, and even possibly cause downtime, and the kernel-mode tasks (such as kworker) bound on an isolated CPU also exist under the condition of static isolation, so that the kernel-mode tasks are excluded from objects needing to be identified due to stability.
The specific identification process of the first task will be specifically described below.
And after the first task is identified, reconfiguring the CPU range bound by the first task as the non-isolated CPU corresponding to the second CPU identification. In the above example, the bound CPU range of the first task is set to be the CPUs 10 to 15, so that the subsequent first task can only use the CPUs of the CPUs 10 to 15, and cannot run to the isolated CPUs 0 to 9.
It should be noted that the first task is currently running on a certain CPU, and if the current CPU is the isolated CPU corresponding to the first CPU identifier, the first task needs to be migrated to the non-isolated CPU corresponding to the second CPU identifier. For example, if the first task is currently running on the CPU5, the first task needs to be migrated from the CPU5 to one of the CPUs 10 to 15, which may be any one of the CPUs 10 to 15, or which CPU needs to be migrated may be determined according to a policy such as load balancing.
In addition, it is worth explaining that tasks are generated continuously in the operating system, and the dynamic isolation of the CPU is performed by the operating system kernel, so that not only a new CPU isolation configuration can take effect on a new subsequently generated task, but also the new CPU isolation configuration can take effect on an existing task under the CPU cgroup root node, and no task omission occurs. Specifically, after a current user triggers a new CPU isolation configuration by inputting a first CPU identifier, if a new task is generated and the user does not perform a binding setting on the new task for which CPU the new task needs to be bound, the newly generated task is added to a CPU cgroup root node, and in the process of traversing the first task by an operating system kernel under the root node, a traversal result includes the new task and other tasks that have existed in the root node before, so that the new CPU isolation configuration will take effect on all the traversed first tasks, that is, the first tasks will be bound to the uninsulated CPUs corresponding to the second CPU identifiers.
Based on the CPU corresponding to the first CPU identifier that is currently input by the user and needs to be isolated, the operating system kernel may update the CPU identifier corresponding to the scheduling domain to the second CPU identifier, in addition to completing the identification of the first task and the binding operation of the CPU that can be used by the first task (the CPU corresponding to the second CPU identifier), that is, the operating system kernel needs to correspondingly reconstruct the scheduling domain according to the CPU isolation configuration operation of the current user, so as to indicate that subsequent load balancing is performed only for these non-isolated CPUs corresponding to the second CPU identifier.
In addition, it is mentioned above that, in the embodiment of the present invention, the first task that needs to be traversed in the CPU cluster root node is a user-mode task, and does not include a kernel-mode task, which means that the kernel-mode task cannot be limited to work on an un-isolated CPU, and only the kernel-mode task need not be considered in the process of traversing the first task, and a special processing means may be provided for the kernel-mode task. Specifically, in the embodiment of the present invention, optionally, the limitation processing of the used CPU may be performed for a special kernel-mode task:
and the kernel of the operating system determines the kernel-mode task of the unbound CPU and binds the kernel-mode task with the second CPU identifier.
In practical applications, some kernel-mode tasks may be bound to some CPUs to run, for example, to isolated CPUs, and some kernel-mode tasks may not be bound to CPUs, for example, unbounded kworker. For these kernel-mode tasks (e.g., unbounded kworker), it may be bound with the un-isolated CPUs corresponding to the second CPU identifiers, so that these kernel-mode tasks may be limited to be only able to run on these un-isolated CPUs, and interference to the tasks running on the isolated CPUs is avoided.
In summary, when a user needs to update the isolation configuration of the CPU, a new CPU identifier that needs to be isolated may be input to a preset interface in the kernel of the operating system, and based on the CPU identifier that needs to be isolated and input by the user, the kernel of the operating system automatically performs the subsequent processing steps of the CPU dynamic isolation: and identifying a first task which is not currently controlled by the resource, and isolating the first task to the un-isolated CPU to run so as to realize the isolation of the first task from the running environment of other tasks running on the isolated CPU. In the execution process, the operating system does not need to be restarted, the processing result is immediately effective, the user operation is simple, and only one read-write operation of the preset interface needs to be executed.
The following describes the identification process of the first task that is not subject to resource control.
Fig. 3 is a flowchart of a first task identification method according to an embodiment of the present invention, and as shown in fig. 3, the identification process may include the following steps:
301. the operating system kernel can filter out at least one user-mode task from the tasks contained in the root node of the target control group according to the stored task types of the tasks.
302. For a target user state task in the at least one user state task, if the CPU bound to the target user state task corresponds to a third CPU identifier, the operating system kernel determines that the first task includes the target user state task, where the third CPU identifier is an identifier of a CPU that was not isolated before the first CPU identifier was received.
The kernel of the operating system can maintain the task types of all tasks generated in the operating system, and based on the task types, the kernel of the operating system can traverse all user-mode tasks existing in a root node of a CPU (central processing unit) group as at least one user-mode task.
Next, for any user mode task of the at least one user mode task, called a target user mode task, it needs to determine whether the target user mode task is an action target of a CPU isolation configuration triggered by a current user, where the CPU isolation configuration triggered by the current user is triggered by the user inputting a first CPU identifier through a preset interface, that is, a CPU corresponding to the first CPU identifier needs to be isolated currently.
In summary, if the target user-mode task currently has a bound CPU range of all CPUs that are not currently isolated, the target user-mode task is included in the first task.
The "all CPUs not isolated at present" are the CPUs corresponding to the third CPU identifier in the above, that is, the non-isolated CPUs corresponding to the currently active CPU isolation configuration.
When a CPU isolation configuration x is input by the user at time T1 (i.e. when a CPU identifier that needs to be isolated is input through the preset interface), the CPU isolation configuration x will take effect after the operating system kernel executes the above steps 201 and 203. When the user re-inputs a CPU isolation configuration y at a later time T2, the CPU isolation configuration x is already in effect, and the "all CPUs not isolated at present" is the CPU isolation configuration x corresponding to the CPU isolation configuration x, that is, the CPU indicated in the CPU isolation configuration x that is not isolated.
Therefore, it can be seen that, assuming that the CPU identifier input by the current user and required to be isolated is the first CPU identifier, in the process of completing the CPU isolation processing corresponding to the first CPU identifier, the configuration information input by the user at the last time is required to be used: the CPU id that was not isolated during the last configuration is referred to as the third CPU id. And if the CPU identification currently bound by the target user-state task is the third CPU identification, the target user-state task is included in the first task.
For ease of understanding, the following is illustrated in connection with FIG. 4. Assuming that the operating system includes 16 CPUs 0 to 15, initially, assuming that the user does not input any parameter to the preset interface, that is, the user does not trigger the CPU isolation configuration, at this time, the operating system kernel traverses user-mode tasks with bound CPU ranges of CPUs 0 to 15 in the CPU cgroup root node, the traversed user-mode tasks serve as first tasks, and the operating system kernel limits the CPU range bound by the first tasks to be the CPUs 0 to 15 (because there is no CPU that needs to be isolated at this time, all CPUs are non-isolated CPUs).
Thereafter, as shown in fig. 4, at time T1, the user performs once CPU isolation configuration on the preset interface, and the input CPUs to be isolated are identified as CPUs 0 to 9. At this time, the operating system kernel isolates the CPUs 0 to 9, and traverses the bound user-mode tasks with the CPU ranges from the CPU0 to the CPU15 in the CPU cgroup root node: task a 1-task am. The reason why the user-mode task with bound CPU ranges from the CPU0 to the CPU15 is traversed as the first task is that before the current CPU isolation configuration, the uninsulated CPUs constrained in the CPU isolation configuration that has been validated are the CPUs 0 to 15. And then, the operating system kernel binds the traversed first task with the CPUs 10-15, so that the current CPU isolation configuration is effective. The reason why the tasks are bound to the CPUs 10 to 15 is that the CPUs 0 to 9 are isolated in the present CPU isolation configuration, and the first task not controlled by the resource needs to be bound to the non-isolated CPUs 10 to 15.
Then, as shown in fig. 4, at time T2, the user performs another CPU isolation configuration on the preset interface, and the input CPUs required to be isolated are identified as CPUs 0 to 6. At this time, the operating system kernel isolates the CPUs 0 to 6, and traverses the bound user-mode tasks with the CPU ranges from the CPU10 to the CPU15 in the CPU cgroup root node: task b 1-task bk. The reason why the user-mode task with bound CPU ranges from the CPU10 to the CPU15 is traversed as the first task is that before the current CPU isolation configuration, the uninsulated CPUs constrained in the CPU isolation configuration that has been validated are the CPUs 10 to 15. And then, the operating system kernel binds the traversed first task with the CPUs 7-15, so that the current CPU isolation configuration is effective.
Based on the above example, if a user-mode task d is initially configured by the user to be bound to the CPUs 10 to 15, the user-mode task d may also be included in the first task in the process of executing the CPU isolation configuration input at the time T2.
The task isolation device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these means can each be constructed using commercially available hardware components and by performing the steps taught in this disclosure.
Fig. 5 is a schematic structural diagram of a task isolation device according to an embodiment of the present invention, where the task isolation device is located in an operating system kernel. As shown in fig. 5, the apparatus includes: the device comprises a receiving module 11, a determining module 12 and a binding module 13.
The receiving module 11 is configured to receive a first processor identifier input by a user through a preset interface, where the preset interface is pre-registered in the kernel of the operating system, and the first processor identifier is an identifier of an isolated processor.
The determining module 12 is configured to determine, among tasks included in a root node of a target control group, a first task in a user state where processor resource configuration is not performed, where the target control group corresponds to a processor subsystem.
A binding module 13, configured to bind the first task with a second processor identifier, where the second processor identifier is an identifier of an uninsulated processor, and the second processor identifier is determined by the first processor identifier and all processor identifiers recorded by the operating system kernel.
Optionally, the apparatus further comprises: a migration module, configured to migrate the first task to the non-isolated processor if it is determined that the first task is currently running on the isolated processor.
Optionally, the binding module 13 is further configured to: receiving a binding request triggered by a user, wherein the binding request comprises an identifier of a second task and an identifier of the first processor; and binding the second task with a target processor in the isolated processor according to the first processor identifier.
Optionally, the determining module 12 is specifically configured to: filtering at least one user-mode task from the tasks contained in the root node of the target control group according to the stored task types of the tasks; for a target user state task in the at least one user state task, if a processor bound to the target user state task corresponds to a third processor identifier, determining that the first task comprises the target user state task; wherein the third processor identification is an identification of a processor that was not isolated prior to receiving the first processor identification.
Optionally, the apparatus further comprises: and the scheduling domain updating module is used for updating the processor identifier corresponding to the scheduling domain to the second processor identifier.
Optionally, the binding module 13 is further configured to: determining a kernel-mode task of an unbound processor; binding the kernel-mode task with the second processor identification.
The device shown in fig. 5 may perform the task isolation method provided in the foregoing embodiment, and the detailed execution process and technical effect refer to the description in the foregoing embodiment, which is not described herein again.
Fig. 6 is a schematic structural diagram of an operating system according to an embodiment of the present invention, as shown in fig. 6, the operating system includes a plurality of processors (CPU 0-CPU 15 shown in fig. 6) and an operating system kernel, where a preset interface is registered in the operating system kernel. The operating system kernel is to:
receiving a first processor identifier input by a user through a preset interface, wherein the first processor identifier is the identifier of an isolated processor;
determining a first task of a user state without processor resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a processor subsystem;
binding the first task with a second processor identification, the second processor identification being an identification of the non-isolated processor, the second processor identification being determined by the first processor identification and all processor identifications of the operating system kernel record.
For the detailed execution process and technical effect of the operating system kernel, reference is made to the description in the foregoing embodiments, and details are not described here.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 7, the electronic device may include: memory, a plurality of processors, an operating system kernel. Wherein the memory has stored thereon executable code which, when executed by the operating system kernel, causes the operating system kernel to implement at least the task isolation method as provided in the preceding embodiments.
Additionally, embodiments of the present invention provide a non-transitory machine-readable storage medium having stored thereon executable code that, when executed by a processor of an electronic device, causes the processor to at least implement a task isolation method as provided in the preceding embodiments.
The above-described apparatus embodiments are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described aspects and portions of the present technology which contribute substantially or in part to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including without limitation disk storage, CD-ROM, optical storage, and the like.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A task isolation method is applied to an operating system kernel, and comprises the following steps:
receiving a first processor identifier input by a user through a preset interface, wherein the preset interface is registered in an operating system kernel in advance, and the first processor identifier is an identifier of an isolated processor;
determining a first task of a user state without processor resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a processor subsystem;
binding the first task with a second processor identification, the second processor identification being an identification of the non-isolated processor, the second processor identification being determined by the first processor identification and all processor identifications of the operating system kernel record.
2. The method of claim 1, further comprising:
if it is determined that the first task is currently running on the isolated processor, migrating the first task to the non-isolated processor.
3. The method of claim 1, further comprising:
receiving a binding request triggered by a user, wherein the binding request comprises an identifier of a second task and an identifier of the first processor;
and binding the second task with a target processor in the isolated processor according to the first processor identifier.
4. The method according to claim 1, wherein the determining a first task in a user mode without performing processor resource configuration from among the tasks included in the root node of the target control group comprises:
filtering at least one user-mode task from the tasks contained in the root node of the target control group according to the stored task types of the tasks;
for a target user state task in the at least one user state task, if a processor bound to the target user state task corresponds to a third processor identifier, determining that the first task comprises the target user state task; wherein the third processor identification is an identification of a processor that was not isolated prior to receiving the first processor identification.
5. The method of claim 1, further comprising:
and updating the processor identifier corresponding to the scheduling domain to the second processor identifier.
6. The method of claim 1, further comprising:
determining a kernel-mode task of an unbound processor;
binding the kernel-mode task with the second processor identification.
7. An isolated running device of a task, located in an operating system kernel, the device comprising:
the receiving module is used for receiving a first processor identifier input by a user through a preset interface, wherein the preset interface is registered in the kernel of the operating system in advance, and the first processor identifier is an identifier of an isolated processor;
the system comprises a determining module, a processing module and a processing module, wherein the determining module is used for determining a first task in a user state without processor resource configuration in tasks contained in a root node of a target control group, and the target control group corresponds to a processor subsystem;
and the binding module is used for binding the first task with a second processor identifier, wherein the second processor identifier is the identifier of the processor which is not isolated, and the second processor identifier is determined by the first processor identifier and all the processor identifiers recorded by the operating system kernel.
8. An operating system, comprising: the system comprises a plurality of processors and an operating system kernel, wherein a preset interface is registered in the operating system kernel, and the operating system kernel is used for:
receiving a first processor identifier input by a user through a preset interface, wherein the first processor identifier is the identifier of an isolated processor;
determining a first task of a user state without processor resource configuration in tasks contained in a root node of a target control group, wherein the target control group corresponds to a processor subsystem;
binding the first task with a second processor identification, the second processor identification being an identification of the non-isolated processor, the second processor identification being determined by the first processor identification and all processor identifications of the operating system kernel record.
9. An electronic device, comprising: the system comprises a memory, a plurality of processors and an operating system kernel; wherein the memory has stored thereon executable code which, when executed by the operating system kernel, causes the operating system kernel to perform the task isolation method of any of claims 1 to 6.
10. A non-transitory machine-readable storage medium having stored thereon executable code that, when executed by an operating system kernel of an electronic device, causes the operating system kernel to perform the task isolation method of any of claims 1 to 6.
CN202110199647.1A 2021-02-22 2021-02-22 Task isolation method, device, operating system, equipment and storage medium Pending CN113296938A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110199647.1A CN113296938A (en) 2021-02-22 2021-02-22 Task isolation method, device, operating system, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110199647.1A CN113296938A (en) 2021-02-22 2021-02-22 Task isolation method, device, operating system, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113296938A true CN113296938A (en) 2021-08-24

Family

ID=77319042

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110199647.1A Pending CN113296938A (en) 2021-02-22 2021-02-22 Task isolation method, device, operating system, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113296938A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024174754A1 (en) * 2023-02-22 2024-08-29 中兴通讯股份有限公司 Processor resource management method and apparatus, cloud computing device, and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024174754A1 (en) * 2023-02-22 2024-08-29 中兴通讯股份有限公司 Processor resource management method and apparatus, cloud computing device, and storage medium

Similar Documents

Publication Publication Date Title
US20230229501A1 (en) Hyper-convergence with scheduler extensions for software-defined container storage solutions
US11748006B1 (en) Mount path management for virtual storage volumes in a containerized storage environment
US9760395B2 (en) Monitoring hypervisor and provisioned instances of hosted virtual machines using monitoring templates
US7349970B2 (en) Workload management of stateful program entities
US9069465B2 (en) Computer system, management method of computer resource and program
US8510815B2 (en) Virtual computer system, access control method and communication device for the same
US11924117B2 (en) Automated local scaling of compute instances
US9727358B2 (en) Failover detection and treatment in checkpoint systems
GB2437145A (en) Dynamically allocating resources used by software
US11449241B2 (en) Customizable lock management for distributed resources
CN111857951A (en) Containerized deployment platform and deployment method
CN106484542B (en) Method and device for processing overlapping node event in distributed system
CN116954816A (en) Container cluster control method, device, equipment and computer storage medium
US20210026675A1 (en) Guest-driven virtual machine snapshots
CN113296938A (en) Task isolation method, device, operating system, equipment and storage medium
US11900141B2 (en) Direct access storage for persistent services in a distributed storage system
US20240111755A1 (en) Two-phase commit using reserved log sequence values
US20230229478A1 (en) On-boarding virtual infrastructure management server appliances to be managed from the cloud
US20230244528A1 (en) Service update management
US9672083B2 (en) Operating a program code object in conjunction with an application context
US12131176B2 (en) Cluster leader selection via ping tasks of service instances
US20230281054A1 (en) Computer System Execution Environment Builder Tool
US8229943B2 (en) System and method for modifying an executing query
WO2022086316A1 (en) Method for monitoring live migration of virtual machine

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination