CPU dynamic isolation method based on lightweight cloud native operating system
By processing the CPU isolation function of the kernel code of the lightweight cloud native operating system, providing a CPU isolation interface and an unisolation interface, and isolating and unisolating the system CPU according to the dynamic isolation instructions input by the user, solving the problem of inflexible CPU scheduling in the existing technology, and improving the flexibility and performance of system resource management.
Patent Information
- Application Number
- CN202510497396.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-04-21
AI Technical Summary
The prior art cannot flexibly schedule the CPU core of a multi-core processor system based on task type and priority, 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 flexibly determining the CPU isolation core based on user needs, effectively solving the problems of inflexible resource management and performance degradation of multi-core processor systems, and improving the flexibility and performance of system resources.
Smart Images

Figure CN120029738A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CPU scheduling, and in particular to a CPU dynamic isolation method based on a lightweight cloud native operating system. Background Art
[0002] CPU dynamic isolation technology is to achieve resource isolation between different tasks or processes by dynamically adjusting the allocation of CPU resources. With the increasing diversity and complexity of computing needs, traditional CPU scheduling methods have gradually exposed their limitations in resource management and task scheduling, especially in multi-core processor architectures. How to effectively manage the workload of each CPU core and avoid resource conflicts has become a challenge. In some high-performance computing, real-time systems, virtualized environments, or applications with special resource requirements, users want to customize the scheduling of CPU cores based on task type and priority, such as: (1) In multi-core system applications, when the CPU occupancy rate of the high-real-time business core is relatively high, high-priority threads (such as watchdog) may still be balanced to the high-real-time business core, causing performance fluctuations of the high-real-time business core. (2) When the priority of the high real-time business plane thread is set to the highest, if the high real-time business plane thread is scheduled to the control plane core, the high real-time business plane thread will not actively give up the processor, which will cause the watchdog thread to starve and cause the board to reset.
[0003] Currently, CPU scheduling of multi-core processors mainly relies on the CPU isolation and binding interface provided by the operating system itself.
[0004] However, when using the CPU isolation and binding interface provided by the operating system to solve the workload of each CPU core and avoid resource conflicts, it is impossible to adjust the scheduling of the CPU core according to actual needs when the multi-core processor system is running, so that the CPU core cannot be flexibly customized according to the task type and priority, resulting in inflexible adjustment of system resources and affecting system performance. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a CPU dynamic isolation method based on a lightweight cloud native operating system, which solves the problem that the existing technology cannot flexibly customize the scheduling of CPU cores according to task types and priorities.
[0006] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is: A CPU dynamic isolation method based on a lightweight cloud native operating system is provided, which includes the following steps: 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 isolation cancellation interface; S2. 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. S3. If the dynamic isolation instruction is 0, calling the CPU isolation cancellation interface to cancel the isolation process of the system CPU; Further, 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; The module uninstall function is controlled to remove the target file using the removal function, and the CPU isolation cancellation interface is obtained.
[0007] Furthermore, 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.
[0008] Further, the isolation kernel module also includes: a resource release function, the dynamic isolation instruction includes one or more 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.
[0009] Further, the adopting of 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, and 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, the first CPU mask is used as the isolated core.
[0010] Further, the calling of 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.
[0011] Further, the adopting of 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.
[0012] Further, calling 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.
[0013] Further, 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 and using the reconstruction function, the system scheduling domain is rebuilt, and the CPU isolation cancellation interface is called to complete the isolation cancellation processing of the system CPU.
[0014] The beneficial effects of the present invention are as follows: the method performs CPU isolation function processing on the kernel code, thereby providing a CPU isolation interface and a CPU cancellation isolation interface in the kernel code, and performs isolation processing and cancellation isolation processing on the system CPU according to the classification of dynamic isolation instructions input by the user and in combination with the kernel code interface. This method can flexibly determine the isolation core when isolating the system CPU, and effectively solve the problem of insufficient system resource flexibility and performance degradation caused by the inability to adjust the CPU core scheduling as needed during the operation of the multi-core processor system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 Schematic diagram of the process of this method. DETAILED DESCRIPTION
[0016] The specific implementation modes of the present invention are described below to facilitate the understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the core idea and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0017] like Figure 1 As shown, the CPU dynamic isolation method based on a lightweight cloud native operating system includes the following steps: 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 isolation cancellation interface; Among them, the CPU isolation function processing of the kernel code is, for example, to modify the kernel code in a lightweight cloud-native operating system, complete the CPU isolation function at the kernel level, and expose an interface that can isolate and cancel the CPU for users to use.
[0018] S2. 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. S3. If the dynamic isolation instruction is 0, the CPU isolation cancellation interface is called to cancel the isolation process of the system CPU.
[0019] The writing of the dynamic isolation instruction is, for example, that the user writes the CPU numbers corresponding to one or more CPUs in hexadecimal format.
[0020] The CPU dynamic isolation method based on a lightweight cloud native operating system provided in this embodiment performs CPU isolation function processing on the kernel code, thereby providing a CPU isolation interface and a CPU cancellation isolation interface in the kernel code, and then performs isolation processing and cancellation isolation processing on the system CPU according to the dynamic isolation instructions input by the user combined with the kernel code interface. This method can flexibly determine the isolation core when isolating the system CPU according to the actual needs of the user, effectively solving the problem of insufficient system resource flexibility and performance degradation caused by the inability to adjust the CPU core scheduling on demand during the operation of the multi-core processor system.
[0021] In a possible implementation, the kernel code is processed with a CPU isolation function to obtain a CPU isolation interface and a CPU isolation cancellation interface, for example, including: Building an isolation kernel module based on CPU isolation function processing, the isolation kernel module includes: file operation function, module loading function and module unloading function; Among them, the file operation function includes, for example: file opening function exbind_open, file reading function seq_read, file offset function seq_lseek, file closing function single_release, file writing function exbind_write_proc. The selection of the file operation function can be any one as long as it can achieve the same function of the file operation of this solution, and no specific limitation is made here.
[0022] The control module loading function uses the creation function to create a target file, the target file is used to store the dynamic isolation instructions written by the user, and the file operation function is registered and associated with the target file to obtain the CPU isolation interface; The module loading function is, for example, the exbind_taskflag_init function, and the creation function is, for example, the proc_create function.
[0023] Specifically, the step includes, for example: using exbind_taskflag_init as a module loading function, calling the proc_create function, creating the isolate_cpus target file in / proc, and registering related file operation functions. If the creation fails, printing an error message and returning -ENOMEM invalid information.
[0024] The control module uninstall function uses the removal function to remove the target file and obtain the CPU isolation cancellation interface.
[0025] The module unloading function is, for example, the exbind_taskflag_exit function, and the removal function is, for example, the remove_proc_entry function.
[0026] Specifically, this step includes, for example: using exbind_taskflag_exit as a module uninstallation function, calling a remove_proc_entry function, and removing a / proc / isolate_cpus target file.
[0027] It can be understood that the user space program of this method can dynamically adjust the isolated CPU by writing / proc / isolate_cpus; at the same time, the configuration interface is provided through the / proc file system, which complies with the Linux kernel module design specification and effectively improves the accuracy of isolation processing.
[0028] In one possible implementation, for example, based on the CPU isolation function processing, a CPU dynamic isolation kernel configuration can be created 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.
[0029] Among them, the CPU dynamic isolation kernel configuration is, for example, CONFIG_EXCLUSIVE_BIND. Using this configuration to perform CPU dynamic isolation in a lightweight cloud-native operating system significantly improves the overall efficiency, security, and maintainability of the system.
[0030] In a possible implementation, the isolation kernel module further includes: a resource release function, the dynamic isolation instruction includes one or more 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, for example, including: When the user writes a dynamic isolation instruction, the target file is opened using the file open function in the file operation function; Specifically, this step includes, for example: the user writes the dynamic isolation instruction into the / proc / isolate_cpus file. Since the exbind_proc_fops structure is defined in the character device, once a write operation occurs to 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.
[0031] The file writing function in the file operation function is used to write the dynamic isolation instruction into the target file, determine the isolation core, and call the CPU isolation interface based on the isolation core to isolate the system CPU; After the CPU isolation function is processed, a resource release function is used to release the memory resources of the file operation function.
[0032] The resource release function is, for example, a single_release function.
[0033] As you can understand, implementing CPU isolation through the / proc / isolate_cpus file provides a dynamic, flexible, and efficient resource management method, which is particularly suitable for lightweight cloud-native operating systems. Compared with traditional hardware isolation or complex kernel modules, this method simplifies the operation process and improves resource utilization while maintaining the security of kernel-level isolation.
[0034] In a possible implementation, a file writing function in a file operation function is used to write a dynamic isolation instruction into a target file, and an isolation core is determined, for example, including: The dynamic isolation instruction is decoded by using a decoding function to obtain a target CPU, and the target CPU is stored in the 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, the empty check function is used to determine whether the first field is empty. If so, the cancel isolation function is used to cancel the isolation process. If not, the subset check function is used to determine whether the first field is the same as the online CPU or whether it 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; Use the exclusive function to determine whether CPU0 in the first CPU mask is the exclusive CPU. If so, return invalid information; If not, the first CPU mask is used as the isolated core.
[0035] Specifically, the step includes, for example: calling the cpumask_parse_user decoding function to parse the CPU mask, and storing the parsed target CPU in the first field of doms_new; calling the exbind_read_proc parsing function to parse the first field of the CPU mask string doms_new provided by the user, and if the parsing fails, printing an error message and returning; if the parsing succeeds, calling the cpumask_empty empty check function to determine whether the provided CPU mask doms_new is empty, and if so, calling the cpumask_equal cancel isolation function to cancel the isolation operation; if not empty The cpumask_subset subset query function is called to determine whether the provided CPU mask doms_new is a subset of the online CPUs, or whether it 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, invalid -EINVAL is returned; when the first field of doms_new is a subset of the online CPUs and is different from the online CPUs, the first CPU mask is returned; the cpumask_test_cpu exclusive function is called to check whether CPU0 is set as the exclusive CPU. If so, invalid is returned; if not, the first CPU mask is determined as an isolated core.
[0036] 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, which effectively ensures the security and efficiency of lightweight cloud-native operating system isolation operations.
[0037] In a possible implementation, the CPU isolation process is performed on the system CPU based on the isolation core calling the CPU isolation interface, including: 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, then the intersection function is used, and the original non-isolated CPU mask is updated based on the new CPU isolation mask to obtain the target non-isolated CPU set, and the reconstruction function is used based on the target non-isolated CPU set to reconstruct the scheduling domain and obtain the scheduling domain processing result; It is understandable that before this step, for example, a structure field storing the target variable may be first declared to store the CPU mask after subsequent isolation.
[0038] The migration function is used to perform task migration processing on the scheduling domain processing results, and the CPU isolation interface is called to complete the isolation processing of the system CPU.
[0039] The intersection function is, for example, a cpumask_subset function, the equality function is, for example, a cpumask_equal function, the update process is, for example, performed by using a cpumask_andnot function, and the reconstruction function is, for example, a rebuild_sched_domains function.
[0040] Finally, call the migration function to perform task migration.
[0041] Understandably, this step can isolate the CPU through a simple file writing operation by the user, realizing on-demand isolation of the CPU and avoiding resource waste; returning invalid information and strictly checking for nulls ensure that the CPU mask provided by the user is legal and valid; at the same time, isolating CPU0 is prohibited 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 competition; users are unaware of the isolation process, ensuring system stability.
[0042] CPU isolation is achieved through the exbind_write_proc function, providing 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 of lightweight cloud-native operating systems.
[0043] In a possible implementation, a migration function is used to perform task migration processing on the scheduling domain processing result, for example, including: Acquire the 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; Before performing this step, for example, the structtask_struct*g,*p,*prev fields may be first declared to store the current process structure, thread structure, and the previous process or thread when looping through system tasks; the cpumask_var_tnon_isolated_cpus field may be declared to store the dynamically allocated non-isolated CPU mask variable; and the cpumask_copy function may be used to copy the current non-isolated CPU set to the non_isolated_cpus field.
[0044] Use the 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; The task lock is, for example, a tasklist lock, and the counting function is, for example, a get_task_struct function.
[0045] After the traversal is completed, the reference count of the previous task is released, and the task list is unlocked to complete the task migration processing of the scheduling domain processing results.
[0046] It is understandable that this step increases the reference count of the target task to ensure that the task is not accidentally released during the migration; after the migration is completed, the reference count of the previous task is released to avoid memory leaks, while accurately managing 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 it is significantly improved compared to traditional task migration technology, and has the value of large-scale promotion.
[0047] In a possible implementation, calling a CPU de-isolation interface to de-isolate the system CPU includes, for example: When the user writes a dynamic isolation instruction, a file write function is used to write the dynamic isolation instruction into a target file, and an isolation cancel function is used to complete the cancellation of isolation of the system CPU.
[0048] Specifically, this step includes, for example: 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 calling the above exbind_write_proc function to complete the write operation to the target file, and finally using the isolation cancellation function to complete the cancellation of the isolation of the system CPU.
[0049] In a possible implementation, an isolation cancellation function is used to complete the isolation cancellation process of the system CPU, for example, 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 state of all CPUs, and using a reconstruction function, the system scheduling domain is rebuilt, and the CPU isolation cancellation interface is called to complete the isolation cancellation process of the system CPU.
[0050] The CPU mask setting function is, for example, a cpumask_setall function, and the reconstruction function is, for example, a rebuild_sched_domains function.
[0051] It can be understood that after performing this step, when running ordinary tasks in the system, the tasks will run to the corresponding CPU core according to the system schedule, and there will be no isolated core.
[0052] It can be understood that this step uses the isolation cancellation function and combines the system CPU isolation cancellation interface to complete the isolation cancellation processing of the system CPU. The isolation status can be dynamically adjusted by the user writing the / proc / isolate_cpus file, which takes effect in real time, greatly improving the isolation cancellation processing speed and task scheduling efficiency.
[0053] This method shows significant advantages in flexibility, efficiency, stability and compatibility by eliminating isolated functional operations and scheduling domain reconstruction, and greatly solves the problem of insufficient system resource flexibility and performance degradation caused by the inability to adjust CPU core scheduling on demand 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, the CPU isolation cancellation interface is called to cancel the isolation process of the system CPU.
2. The method according to claim 1, characterized in that 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; The module uninstall function is controlled to remove the target file using a removal function, and the CPU isolation cancellation interface is obtained.
3. The method according to claim 2, 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.
4. The method according to claim 2, characterized in that: 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.
5. The method according to claim 4, characterized in that 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, and 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, the first CPU mask is used as the isolated core.
6. The method according to claim 5, characterized in that 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.
7. The method according to claim 6, 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.
8. The method according to claim 6, 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.
9. The method according to claim 8, 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
Method for dynamically binding multiple processes with cpu core in operating system
CN117472583A
Processor resource management method and apparatus, cloud computing device, and storage medium
WO2024174754A1