A CPU Dynamic Isolation Method Based on a Lightweight Cloud Native Operating System
By processing the CPU isolation function of the kernel code of the lightweight cloud native operating system, providing the CPU isolation interface and cancellation interface, the problem of inflexible CPU scheduling in multi-core processor systems is solved, and flexible management of system resources and performance improvement is achieved.
Patent Information
- Application Number
- CN202510497396.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-04-21
AI Technical Summary
The prior art cannot flexibly customize the scheduling of CPU cores according to task type and priority in a multi-core processor system, resulting in inflexible system resource management and affecting performance.
By performing CPU isolation function processing on the kernel code of the lightweight cloud native operating system, a CPU isolation interface and a CPU cancellation interface are provided, and the system CPU is isolated and cancelled according to the dynamic isolation instructions entered by the user.
It realizes the flexible determination of CPU isolation cores based on user needs, effectively solving the problems of insufficient system resource flexibility and performance degradation caused by the inability to adjust CPU core scheduling as needed by multi-core processor systems.
Smart Images

Figure CN120029738B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CPU scheduling, and specifically relates to a CPU dynamic isolation method based on a lightweight cloud-native operating system. Background Art
[0002] CPU dynamic isolation technology refers to achieving resource isolation between different tasks or processes by dynamically adjusting the allocation of CPU resources. With the increasing diversification and complexity of computing requirements, the limitations of traditional CPU scheduling methods in resource management and task scheduling have gradually emerged. Especially in multi-core processor architectures, how to effectively manage the workloads of each CPU core and avoid resource conflicts has become a challenge. In some high-performance computing, real-time systems, virtualization environments, or applications with special resource requirements, users hope to customize the scheduling of CPU cores according to task types and priorities, such as:
[0003] (1) In applications of multi-core systems, when the CPU occupancy rate of the high-real-time service face core is relatively high, there will still be a situation where high-priority threads (such as watchdog) will be balanced to the high-real-time service face core, resulting in fluctuations in the performance of the high-real-time service face core;
[0004] (2) When the priority of the high-real-time service face thread is set to the highest, if the high-real-time service face thread is scheduled to the control plane core at this time, the high-real-time service face thread will not actively give up the processor, and at this time, it will cause the watchdog thread to starve to death, resulting in a single board reset.
[0005] Currently, the CPU scheduling of multi-core processors mainly still relies on the interface methods of CPU isolation and binding provided by the operating system itself.
[0006] However, when using the interface of CPU isolation and binding provided by the operating system to solve the workloads of each CPU core and avoid resource conflict problems above, it is impossible to adjust the scheduling of CPU cores according to actual needs during the operation of the multi-core processor system, thus unable to flexibly customize the scheduling of CPU cores according to task types and priorities, resulting in inflexible adjustment of system resources and affecting system performance. Summary of the Invention
[0007] Aiming at the above deficiencies in the prior art, a CPU dynamic isolation method based on a lightweight cloud-native operating system provided by the present invention solves the problem that the existing technology cannot flexibly customize the scheduling of CPU cores according to task types and priorities.
[0008] In order to achieve the above invention purpose, the technical solution adopted by the present invention is:
[0009] Provide a CPU dynamic isolation method based on a lightweight cloud-native operating system, which includes the following steps:
[0010] S1. Obtain the kernel code of the lightweight cloud-native operating system, and perform CPU isolation function processing on the kernel code to obtain a CPU isolation interface and a CPU cancellation isolation interface;
[0011] S2. Obtain the dynamic isolation instruction written by the user. If the dynamic isolation instruction is non-zero, determine the isolated core according to the dynamic isolation instruction, and call the CPU isolation interface based on the isolated core to perform isolation processing on the system CPU, where the system CPU is used to indicate the CPU of the lightweight cloud-native operating system;
[0012] S3. If the dynamic isolation instruction is 0, call the CPU cancellation isolation interface to perform cancellation isolation processing on the system CPU;
[0013] Further, the performing CPU isolation function processing on the kernel code to obtain a CPU isolation interface and a CPU cancellation isolation interface includes:
[0014] Build an isolation kernel module based on the CPU isolation function processing. The isolation kernel module includes: a file operation function, a module loading function, and a module unloading function;
[0015] Control the module loading function to create a target file using a creation function. The target file is used to store the dynamic isolation instruction written by the user, and register and associate the file operation function with the target file to obtain the CPU isolation interface;
[0016] Control the module unloading function to remove the target file using a removal function to obtain the CPU cancellation isolation interface.
[0017] Further, based on the CPU isolation function processing, create a CPU dynamic isolation kernel configuration in the lightweight cloud-native operating system, so that the user can complete the CPU dynamic isolation processing of the lightweight cloud-native operating system based on the CPU dynamic isolation kernel configuration.
[0018] Further, the isolation kernel module further includes: a resource release function. The dynamic isolation instruction includes one or more CPUs. The determining the isolated core according to the dynamic isolation instruction and calling the CPU isolation interface based on the isolated core to perform isolation processing on the system CPU includes:
[0019] When the user writes the dynamic isolation instruction, use the file opening function in the file operation function to open the target file;
[0020] Use the file writing function in the said file operation function to write the said dynamic isolation instruction into the target file, determine the isolation core, and based on the isolation core, call the CPU isolation interface to perform isolation processing on the system CPU;
[0021] After the CPU isolation function processing is completed, use the said resource release function to release the memory resources of the file operation function.
[0022] Furthermore, the step of using the file writing function in the said file operation function to write the said dynamic isolation instruction into the target file and determine the isolation core includes:
[0023] Use a decoding function to decode the said dynamic isolation instruction to obtain the target CPU, and store the target CPU in the first field;
[0024] Use a parsing function to parse the first field. If the parsing fails, print the failure information and return;
[0025] If the parsing is successful, use an empty checking function to determine whether the first field is empty. If it is, use an isolation cancellation function to perform isolation cancellation processing. If not, use a subset checking function to determine whether the first field is the same as or a subset of the online CPUs;
[0026] When the first field is not a subset of the online CPUs or is the same as the online CPUs, return invalid information. When the first field is a subset of the online CPUs and is not the same as the online CPUs, return the first CPU mask;
[0027] Use an exclusive function to determine whether CPU0 in the first CPU mask is an exclusive CPU. If it is, return invalid information;
[0028] If not, use the first CPU mask as the isolation core.
[0029] Furthermore, the step of calling the CPU isolation interface based on the isolation core to perform isolation processing on the system CPU includes:
[0030] Use an intersection function to perform an intersection operation on the first CPU mask and the original non-isolated CPU mask to obtain a new maintained CPU isolation mask, and use an equality function to determine whether the new maintained CPU isolation mask is equal to the original non-isolated CPU mask. If it is, return invalid information;
[0031] Otherwise, adopt the intersection function, update the original non-isolated CPU mask based on the new CPU isolation mask to obtain a target non-isolated CPU set, and perform a re-construction scheduling domain process based on the target non-isolated CPU set using a reconstruction function to obtain a scheduling domain processing result;
[0032] Adopt a migration function to perform task migration processing on the scheduling domain processing result, and call the CPU isolation interface to complete the isolation processing of the system CPU.
[0033] Further, the adopting a migration function to perform task migration processing on the scheduling domain processing result includes:
[0034] Obtain a task lock, traverse each process and each thread in the lightweight cloud native operating system based on the task lock, and migrate each process and each thread to the target non-isolated CPU set to obtain a target non-isolated CPU set task;
[0035] Adopt a counting function to increase the reference count of the target non-isolated CPU set task, and release the reference count of the previous task after completing the migration of the current task;
[0036] After the traversal ends, release the reference count of the previous task and unlock the task list to complete the task migration processing of the scheduling domain processing result.
[0037] Further, the calling the CPU isolation cancellation interface to perform isolation cancellation processing on the system CPU includes:
[0038] When the user writes a dynamic isolation instruction, adopt the file writing function to write the dynamic isolation instruction into the target file, and adopt an isolation cancellation function to complete the isolation cancellation processing of the system CPU.
[0039] Further, the adopting an isolation cancellation function to complete the isolation cancellation processing of the system CPU includes:
[0040] Adopt a CPU mask setting function to set the CPU isolation status to the status where all CPUs are to be used;
[0041] Based on the status where all CPUs are to be used, and adopt the reconstruction function to re-construct the system scheduling domain, and call the CPU isolation cancellation interface to complete the isolation cancellation processing of the system CPU.
[0042] The beneficial effects of the present invention are as follows: By processing the kernel code for CPU isolation functions, CPU isolation interfaces and CPU de-isolation interfaces are provided in the kernel code. According to the classification of the dynamic isolation instructions input by the user and in combination with the kernel code interfaces, isolation processing and de-isolation processing are performed on the system CPUs. Through this method, the isolation cores can be flexibly determined when performing isolation processing on the system CPUs, effectively solving the problems of insufficient flexibility of system resources and performance degradation in a multi-core processor system during operation due to the inability to adjust CPU core scheduling as needed. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a schematic flowchart of this method. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0044] The following describes the specific embodiments of the present invention to facilitate those skilled in the art of this technology to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art of this technology, as long as various changes are within the core idea and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions created using the concept of the present invention are within the scope of protection.
[0045] As Figure 1 shown, the CPU dynamic isolation method based on a lightweight cloud-native operating system includes the following steps:
[0046] S1. Obtain the kernel code of the lightweight cloud-native operating system, and perform CPU isolation function processing on the kernel code to obtain a CPU isolation interface and a CPU de-isolation interface;
[0047] Among them, performing CPU isolation function processing on the kernel code is, for example, in the lightweight cloud-native operating system, modifying the kernel code to complete the function of CPU isolation at the kernel level, and exposing interfaces that can perform CPU isolation and de-isolation upward for users to use.
[0048] S2. Obtain the dynamic isolation instructions written by the user. If the dynamic isolation instructions are non-zero, determine the isolation cores according to the dynamic isolation instructions, and call the CPU isolation interface based on the isolation cores to perform isolation processing on the system CPUs, where the system CPUs are used to indicate the CPUs of the lightweight cloud-native operating system;
[0049] S3. If the dynamic isolation instructions are 0, call the CPU de-isolation interface to perform de-isolation processing on the system CPUs.
[0050] Among them, the writing of the dynamic isolation instructions is, for example, that the user writes the CPU numbers corresponding to one or more CPUs in hexadecimal format.
[0051] The CPU dynamic isolation method provided by this embodiment, through processing the CPU isolation function for the kernel code, provides a CPU isolation interface and a CPU cancellation isolation interface in the kernel code, and then combines the kernel code interface according to the dynamic isolation instruction input by the user to perform isolation processing and cancellation isolation processing on the system CPU. Through this method, the isolation core can be flexibly determined according to the actual needs of the user when performing isolation processing on the system CPU, effectively solving the problems of insufficient flexibility of system resources and performance degradation caused by the inability to adjust the CPU core scheduling as needed in a multi-core processor system.
[0052] In a possible implementation, processing the CPU isolation function for the kernel code to obtain a CPU isolation interface and a CPU cancellation isolation interface, for example, includes:
[0053] Building an isolation kernel module based on the CPU isolation function processing, and the isolation kernel module includes: file operation functions, module loading functions, and module unloading functions;
[0054] Among them, the file operation functions, for example, include: file open function exbind_open, file read function seq_read, file offset function seq_lseek, file close function single_release, file write function exbind_write_proc. For the selection of file operation functions, as long as the same functions of file operations in this solution can be implemented, there is no specific limitation here.
[0055] The control module loading function uses the create function to create a target file, which is used to store the dynamic isolation instruction written by the user, and registers and associates the file operation function with the target file to obtain the CPU isolation interface;
[0056] Among them, the module loading function is, for example, the exbind_taskflag_init function, and the create function is, for example, the proc_create function.
[0057] Specifically, this step, for example, includes: using exbind_taskflag_init as the module loading function, calling the proc_create function, creating the isolate_cpus target file in / proc, and registering the relevant file operation functions. If the creation fails, print an error message and return the -ENOMEM invalid message.
[0058] The control module unloading function uses the remove function to remove the target file to obtain the CPU cancellation isolation interface.
[0059] Among them, the module unloading function is, for example, the exbind_taskflag_exit function, and the removal function is, for example, the remove_proc_entry function.
[0060] Specifically, this step includes, for example: using exbind_taskflag_exit as the module unloading function, calling the remove_proc_entry function to remove the / proc / isolate_cpus target file.
[0061] It can be understood that the user space program of this method can dynamically adjust the isolated CPUs by writing to / proc / isolate_cpus; at the same time, by providing a configuration interface through the / proc file system, it conforms to the Linux kernel module design specification and effectively improves the accuracy of isolation processing.
[0062] In a possible implementation, for example, it is also possible to create a CPU dynamic isolation kernel configuration in the lightweight cloud native operating system based on the CPU isolation function, so that the user can complete the CPU dynamic isolation processing of the lightweight cloud native operating system based on the CPU dynamic isolation kernel configuration.
[0063] Among them, the CPU dynamic isolation kernel configuration is, for example, CONFIG_EXCLUSIVE_BIND. Using this configuration for CPU dynamic isolation in the lightweight cloud native operating system significantly improves the overall efficiency, security, and maintainability of the system.
[0064] In a possible implementation, the isolation kernel module further includes: a resource release function. The dynamic isolation instruction includes one or more CPUs. Determine the isolated core according to the dynamic isolation instruction, and call the CPU isolation interface based on the isolated core to perform isolation processing on the system CPU. For example, it includes:
[0065] When the user writes a dynamic isolation instruction, use the file opening function in the file operation function to open the target file;
[0066] Specifically, this step includes, for example: the user writes the dynamic isolation instruction to the / proc / isolate_cpus file. Since the exbind_proc_fops structure is defined in the character device, once a write operation occurs on the file, the character device will call the file operation function in the kernel module; call exbind_open to open the / proc / isolate_cpus file corresponding to the kernel module.
[0067] Use the file writing function in the file operation function to write the dynamic isolation instruction to the target file, determine the isolated core, and call the CPU isolation interface based on the isolated core to perform isolation processing on the system CPU;
[0068] After the CPU isolation function processing is completed, the release resource function is used to release the memory resources of the file operation function.
[0069] Among them, the release resource function is, for example, the single_release function.
[0070] It can be understood that CPU isolation is achieved through the / proc / isolate_cpus file, providing a dynamic, flexible, and efficient resource management method, which is especially suitable for lightweight cloud-native operating systems. Compared with traditional hardware isolation or complex kernel modules, this method simplifies the operation process, improves resource utilization, and at the same time maintains the security of kernel-level isolation.
[0071] In a possible implementation, the file write function in the file operation function is used to write the dynamic isolation instruction into the target file to determine the isolation core, for example, including:
[0072] The decoding function is used to decode the dynamic isolation instruction to obtain the target CPU, and the target CPU is stored in the first field;
[0073] The parsing function is used to parse the first field. If the parsing fails, the failure information is printed and returned;
[0074] If the parsing is successful, the empty-check function is used to determine whether the first field is empty. If so, the cancel isolation function is used to perform the cancel isolation process. If not, the subset-check function is used to determine whether the first field is the same as or a subset of the online CPUs;
[0075] When the first field is not a subset of the online CPUs or is the same as the online CPUs, invalid information is returned. When the first field is a subset of the online CPUs and is not the same as the online CPUs, the first CPU mask is returned;
[0076] The exclusive function is used to determine whether CPU0 in the first CPU mask is an exclusive CPU. If so, invalid information is returned;
[0077] If not, the first CPU mask is used as the isolation core.
[0078] Specifically, this step may include, for example: calling the cpumask_parse_user decoding function to perform CPU mask parsing, storing the parsed target CPU in the first field of doms_new; calling the exbind_read_proc parsing function to parse the CPU mask string in the first field of doms_new provided by the user. If the parsing fails, print an error message and return. If the parsing is successful, call the cpumask_empty function to check if the provided CPU mask doms_new is empty. If it is empty, call the cpumask_equal function to cancel the isolation operation. If it is not empty, call the cpumask_subset function to check if the provided CPU mask doms_new is a subset of the online CPUs or is the same as all online CPUs. If doms_new is not a subset of the online CPUs or is the same as all online CPUs, return invalid - EINVAL. When the first field of doms_new is a subset of the online CPUs and is different from the online CPUs, return the first CPU mask. Call the cpumask_test_cpu exclusive function to check if CPU0 is set as the exclusive CPU. If so, return invalid. If not, determine the first CPU mask as the isolated core.
[0079] It can be understood that exbind_write_proc provides an efficient, secure, and easy - to - use CPU isolation mechanism for lightweight cloud - native operating systems through flexible mask parsing, strict error handling, dynamic resource adjustment, and kernel - level isolation, effectively enhancing the security and efficiency of the isolation operation of lightweight cloud - native operating systems.
[0080] In a possible implementation, based on the isolated core, call the CPU isolation interface to perform isolation processing on the system CPU, including:
[0081] Use the intersection function to perform an intersection operation on the first CPU mask and the original non - isolated CPU mask to obtain a new retained CPU isolation mask, and use the equality function to determine whether the new retained CPU isolation mask is equal to the original non - isolated CPU mask. If so, return invalid information;
[0082] If not, use the intersection function and update the original non - isolated CPU mask based on the new retained CPU isolation mask to obtain the target non - isolated CPU set, and use the reconstruction function to perform re - construction of the scheduling domain processing based on the target non - isolated CPU set to obtain the scheduling domain processing result;
[0083] It can be understood that before this step, for example, the structure field for storing the target variable may also be declared first to store the CPU mask after subsequent isolation.
[0084] Use a migration function to perform task migration processing on the scheduling domain processing result, and call the CPU isolation interface to complete the isolation processing of the system CPU.
[0085] Among them, the intersection function is, for example, the cpumask_subset function, the equality function is, for example, the cpumask_equal function, the update processing is, for example, performed by using the cpumask_andnot function, and the reconstruction function is, for example, the rebuild_sched_domains function.
[0086] Finally, call the migration function to execute task migration.
[0087] It can be understood that this step can isolate the CPU through a simple file writing operation by the user, realizing on-demand CPU isolation, avoiding resource waste; returning invalid information and strictly verifying and checking for emptiness to ensure that the CPU mask provided by the user is legal and effective; at the same time, prohibiting the isolation of CPU0 to avoid system instability. Isolating the CPU at the kernel scheduling level ensures the thoroughness and security of isolation; allocating dedicated CPUs for critical tasks avoids resource contention; the user is unaware of the isolation process, ensuring system stability.
[0088] Implementing CPU isolation through the exbind_write_proc function provides a dynamic, flexible, and efficient resource management method. Its strict input verification, kernel-level isolation, and task migration mechanism can significantly improve the performance and resource utilization rate of lightweight cloud-native operating systems.
[0089] In a possible implementation, using a migration function to perform task migration processing on the scheduling domain processing result, for example, includes:
[0090] Obtain a task lock, traverse each process and each thread in the lightweight cloud-native operating system based on the task lock, and migrate each process and each thread to the target non-isolated CPU set to obtain the target non-isolated CPU set tasks;
[0091] Among them, before performing this step, for example, fields such as struct task_struct *g, *p, *prev can be declared first to store the current process structure, thread structure, and the previous process or thread when traversing system tasks in a loop; declare the cpumask_var_t non_isolated_cpus field to store the dynamically allocated non-isolated CPU mask variable; use the cpumask_copy function to copy the current non-isolated CPU set to the non_isolated_cpus field.
[0092] Increase the reference count of the target non-isolated CPU set tasks using a counting function, and release the reference count of the previous task after completing the migration of the current task;
[0093] Among them, the task lock is, for example, a tasklist lock, and the counting function is, for example, the get_task_struct function.
[0094] After the traversal ends, release the reference count of the previous task and unlock the task list to complete the task migration process for the processing result of the scheduling domain.
[0095] It can be understood that this step ensures that the task is not accidentally released during migration by increasing the reference count of the target task; after the migration is completed, release the reference count of the previous task to avoid memory leakage, and at the same time accurately manage the increase and decrease of task references, effectively improving resource utilization. Through the collaborative design of the migration function and the counting function, the system efficiency, system resource utilization, and system stability are effectively improved, and the improvement is significant compared with traditional task migration technologies, having great value for large-scale promotion.
[0096] In a possible implementation, call the CPU unisolate interface to perform unisolation processing on the system CPUs, for example, including:
[0097] When the user writes a dynamic isolation instruction, use a file write function to write the dynamic isolation instruction to the target file, and use an isolation cancellation function to complete the unisolation processing of the system CPUs.
[0098] Specifically, this step, for example, includes: the user writes the dynamic isolation instruction to the / proc / isolate_cpus file, triggering the kernel's write operation on the file, and at the same time calls the above-mentioned exbind_write_proc function to complete the operation of writing to the target file, and finally uses the isolation cancellation function to complete the unisolation processing of the system CPUs.
[0099] In a possible implementation, use an isolation cancellation function to complete the unisolation processing of the system CPUs, for example, including:
[0100] Use a CPU mask setting function to set the CPU isolation status to the status that all CPUs are to be used;
[0101] Based on the status that all CPUs are to be used, and use a reconstruction function to reconstruct the system scheduling domain, and call the CPU unisolate interface to complete the unisolation processing of the system CPUs.
[0102] Among them, the CPU mask setting function is, for example, the cpumask_setall function, and the reconstruction function is, for example, the rebuild_sched_domains function.
[0103] It is understandable that after performing this step, when running ordinary tasks in the system, the tasks will run to the corresponding CPU cores according to the system scheduling, and there will be no isolated cores.
[0104] It is understandable that this step uses an isolation cancellation function in combination with the system CPU isolation cancellation interface to complete the isolation cancellation process for the system CPU. By the user writing to the / proc / isolate_cpus file, the isolation status can be dynamically adjusted and take effect in real time, greatly improving the isolation cancellation processing speed and task scheduling efficiency.
[0105] This method shows significant advantages in terms of flexibility, efficiency, stability, and compatibility through isolation cancellation functional operations and scheduling domain reconstruction, greatly solving the problems of insufficient flexibility of system resources and performance degradation caused by the inability to adjust CPU core scheduling as needed during the operation of multi-core processor systems.
Claims
1. A CPU dynamic isolation method based on a lightweight cloud native operating system, characterized in that: include: Obtaining kernel code of a lightweight cloud native operating system, and performing CPU isolation function processing on the kernel code to obtain a CPU isolation interface and a CPU isolation cancellation interface; Obtain the dynamic isolation instruction written by the user. If the dynamic isolation instruction is non-zero, determine the isolation core according to the dynamic isolation instruction, and call the CPU isolation interface based on the isolation core to isolate the system CPU. The system CPU is used to indicate the CPU of the lightweight cloud native operating system. If the dynamic isolation instruction is 0, calling the CPU isolation cancellation interface to cancel the isolation process of the system CPU; The performing CPU isolation function processing on the kernel code to obtain a CPU isolation interface and a CPU isolation cancellation interface includes: Building an isolation kernel module based on the CPU isolation function processing, the isolation kernel module includes: a file operation function, a module loading function and a module unloading function; Control the module loading function to use a creation function to create a target file, the target file is used to store the dynamic isolation instruction written by the user, and register and associate the file operation function with the target file to obtain the CPU isolation interface; Control the module uninstall function to remove the target file using a removal function, and obtain the CPU isolation cancellation interface; The isolation kernel module further includes: a resource release function, the dynamic isolation instruction is for one or more system CPUs, the isolation core is determined according to the dynamic isolation instruction, and the CPU isolation interface is called based on the isolation core to isolate the system CPU, including: When the user writes the dynamic isolation instruction, the target file is opened using the file opening function in the file operation function; Using the file writing function in the file operation function, the dynamic isolation instruction is written into the target file, an isolation core is determined, and based on the isolation core, the CPU isolation interface is called to isolate the system CPU; After the CPU isolation function is processed, the resource release function is used to release the memory resources of the file operation function; The step of adopting the file writing function in the file operation function to write the dynamic isolation instruction into the target file and determining the isolation core includes: Decoding the dynamic isolation instruction using a decoding function to obtain a target CPU, and storing the target CPU in a first field; The first field is parsed using a parsing function. If the parsing fails, the failure information is printed and returned. If the parsing is successful, a check-empty function is used to determine whether the first field is empty. If so, a cancel-isolation function is used to cancel the isolation process. If not, a check-subset function is used to determine whether the first field is the same as the online CPU or is a subset of the online CPU. When the first field is not a subset of the online CPU or is the same as the online CPU, invalid information is returned; when the first field is a subset of the online CPU and is not the same as the online CPU, the first CPU mask is returned; Using the exclusive function, determine whether CPU0 in the first CPU mask is the exclusive CPU, and if so, return invalid information; If not, use the first CPU mask as the isolated core; The calling the CPU isolation interface based on the isolation core to perform isolation processing on the system CPU includes: An intersection function is used to perform intersection processing on the first CPU mask and the original non-isolated CPU mask to obtain a new CPU isolation mask, and an equality function is used to determine whether the new CPU isolation mask is equal to the original non-isolated CPU mask. If so, an invalid message is returned; If not, the intersection function is used, and the original non-isolated CPU mask is updated based on the new CPU isolation mask to obtain a target non-isolated CPU set, and a reconstruction function is used based on the target non-isolated CPU set to reconstruct the scheduling domain and obtain a scheduling domain processing result; The migration function is used to perform task migration processing on the scheduling domain processing result, and the CPU isolation interface is called to complete the isolation processing of the system CPU.
2. The method according to claim 1, characterized in that The method further comprises: Based on the CPU isolation function processing, a CPU dynamic isolation kernel configuration is created in the lightweight cloud native operating system, so that the user completes the CPU dynamic isolation processing of the lightweight cloud native operating system based on the CPU dynamic isolation kernel configuration.
3. The method according to claim 1, characterized in that The adopting the migration function to perform task migration processing on the scheduling domain processing result includes: Acquire a task lock, traverse each process and each thread in the lightweight cloud native operating system based on the task lock, and migrate each process and each thread to the target non-isolated CPU set to obtain the target non-isolated CPU set task; Using a counting function to increase the reference count of the target non-isolated CPU set task, and releasing the reference count of the previous task after completing the migration of the current task; After the traversal is completed, the reference count of the previous task is released, and the task list is unlocked, completing the task migration processing of the scheduling domain processing result.
4. The method according to claim 1, characterized in that: The calling of the CPU isolation cancellation interface to cancel isolation processing of the system CPU includes: When the user writes a dynamic isolation instruction, the file write function is used to write the dynamic isolation instruction into the target file, and the isolation cancel function is used to complete the isolation cancellation processing of the system CPU.
5. The method according to claim 4, characterized in that The isolation cancellation function is used to complete the isolation cancellation process of the system CPU, including: Use the CPU mask setting function to set the CPU isolation state to the state where all CPUs are ready to be used; Based on the waiting-for-use status of all the CPUs, the reconstruction function is used to reconstruct the system scheduling domain, and the CPU isolation cancellation interface is called to complete the isolation cancellation processing of the system CPU.
Citation Information
Patent Citations
CPU isolation method and device and storage medium
CN110928601A
Task isolation method and device, operating system, equipment and storage medium
CN113296938A