PreemptRT-based application real-time automatic optimization method and system

By analyzing the application's soft resources and process relationships, dynamically allocating hardware resources and optimizing CPU affinity, the problem of applying real-time jitter in the Preempt_RT system is solved, improving the system's real-timeness and reducing business jitter.

CN120276870AActive Publication Date: 2025-07-08KYLIN CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510765860.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-07-08
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

The prior art cannot automatically analyze the real-time dependencies applied in the Preempt_RT system, resulting in difficulty in reducing real-time jitter.

Method used

By obtaining the soft resources and processes of the specified application, establishing a collection of process relationships, dynamically allocating hardware resources and setting priority, combining memory usage and CPU resources, optimize the CPU affinity and NUMA node configuration of the process.

Benefits of technology

Real-time improvement and business jitter reduction in application under the Preempt_RT system are achieved, reducing investment in engineers and software experts who improve real-time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276870A_ABST
    Figure CN120276870A_ABST
Patent Text Reader

Abstract

The invention discloses an application real-time automatic optimization method and system based on PreemptRT, and the method comprises the steps: obtaining a soft resource of a specified application, then obtaining all processes using the soft resource of the specified application, and recursively establishing a process relation set with the soft resource as a dependency approach; acquiring hard resources corresponding to the process relationship set, and setting priorities of the hard resources and priorities of processes in the process relationship set; the method comprises the following steps: dynamically allocating exclusive memory areas for soft resources and each process in real time according to a memory use condition, dynamically setting CPU affinity corresponding to hard resources and each process in real time according to a CPU resource condition, and setting an NUMA node where each process is located according to a dependency relationship of the soft resources. According to the method, the dependency relationship of the specified application can be automatically analyzed, and hardware resources are allocated in an optimal mode, so that the real-time performance of the application in a PreemptRT system is improved, and jitter generated during operation of a service is reduced as much as possible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and particularly to an automated optimization method and system for application real-time performance based on Preempt_RT. Background Art

[0002] With the development of robotics and autonomous driving technologies, more and more Linux real-time requirements have been put forward. Although the Linux system can significantly improve the real-time performance of the operating system through the Preempt_RT soft real-time patch (abbreviated as the Preempt_RT system), improving the real-time performance of the operating system is only the first step. More importantly, it is how to deploy applications in a reasonable and correct manner in the Preempt_RT system.

[0003] In general, in the two application scenarios of ROS and autonomous driving, there are many application associations, so that many factors need to be considered when deploying applications, such as the relationships among the CPU, memory, locks, and semaphores, so as to sort out a reasonable configuration method to enable the application to truly reduce business jitter and suppress the real-time performance expectation within an acceptable range. Summary of the Invention

[0004] The technical problem to be solved by the present invention: Currently, there is no technology or method that can automatically analyze the real-time dependency relationships of applications, thereby reducing the real-time jitter of applications on the Preempt_RT system.

[0005] In view of the above problems in the prior art, an automated optimization method and system for application real-time performance based on Preempt_RT are provided, which can automatically analyze the dependency relationships of specified applications and allocate hardware resources in an optimal manner, thereby improving the real-time performance of applications under the Preempt_RT system and reducing the jitter generated during the operation of the service as much as possible.

[0006] To solve the above technical problems, the technical solution adopted by the present invention is as follows: An automated optimization method for application real-time performance based on Preempt_RT, comprising the following steps: S1) Obtain the soft resources of the specified application, then obtain all processes that use the soft resources of the specified application, and recursively establish a process relationship set with the soft resources as the dependency path; S2) Obtain the hard resources corresponding to each process in the process relationship set, and set the priorities of the hard resources and each process in the process relationship set; S3) Dynamically allocate exclusive memory areas for the processes in the soft resource and process relationship set according to the memory usage in real time, and dynamically set the CPU affinity corresponding to each process in the hard resource and process relationship set according to the CPU resource situation in real time. At the same time, set the NUMA nodes where each process in the process relationship set is located according to the dependency relationship of the soft resources.

[0007] Further, when recursively establishing a process relationship set with soft resources as the dependency path, it includes the following steps: S11) Add the specified application and all processes using the soft resources of the specified application to the process relationship set. All processes using the soft resources of the specified application are used as the dependent processes of the specified application, and the dependent processes use the used soft resources as the dependency path; S12) Traverse the newly added dependent processes in the process relationship set, obtain all the soft resources of the current process, and then obtain all the processes using the soft resources of the current process as the dependent processes of the current process, and add all the dependent processes of the current process to the process relationship set; S13) Jump to execute step S12 until there are no newly added dependent processes.

[0008] Further, the hard resources include interrupt handlers, soft interrupts, and work queues. When setting the priorities of the hard resources and each process in the process relationship set, it includes the following steps: S21) Set the priority of the specified application to the lowest priority; S22) Set the priority of the interrupt handler in the high priority interval of the first priority interval, set the priority of the soft interrupt in the medium priority interval of the first priority interval, and set the priority of the work queue in the low priority interval of the first priority interval; S23) Set the priority of each process in the process relationship set in the second priority interval. The lower limit of the second priority interval is higher than the lowest priority, and the upper limit of the second priority interval is lower than the lower limit of the first priority interval.

[0009] Further, when setting the priority of each process in the process relationship set in the second priority interval, it includes: If the current process is not a dependent process of other processes, the priority of the current process is the default value. If the current process is a dependent process of other processes, the priority of the current process is greater than the maximum value of the priorities of all processes depending on the current process and less than the upper limit of the second priority interval.

[0010] Further, when dynamically allocating exclusive memory areas for the processes in the soft resource and process relationship set according to the memory usage in real time, it includes the following steps: Detect the sum of the maximum memory usage of all soft resources of the specified application, and detect the sum of the peak memory usage of all processes in the process relationship set; If the available memory is greater than the sum of the sum of the maximum memory usage of all soft resources and the sum of the peak memory usage of all processes, provide corresponding exclusive memory areas for the soft resources and processes respectively, and the size of the exclusive memory area of the soft resources is the sum of the maximum memory usage of all soft resources, and the size of the exclusive memory area of the processes is the sum of the peak memory usage of all processes; If the available memory is less than the sum of the sum of the maximum memory usage of all soft resources and the sum of the peak memory usage of all processes, and greater than the sum of the peak memory usage of all processes, provide corresponding exclusive memory areas for the soft resources and processes respectively, and the size of the exclusive memory area of the processes is the sum of the peak memory usage of all processes, and the size of the exclusive memory area of the soft resources is the remaining size after subtracting the exclusive memory area of the processes from the available memory; If the available memory is less than the sum of the peak memory usage of all processes, provide a corresponding exclusive memory area for the processes, and after putting the specified application into the exclusive memory area, then in the order from largest to smallest priority, put each process in the process relationship set into the exclusive memory area in turn until the exclusive memory area is full or the remaining space in the exclusive memory area is less than the size of a single process.

[0011] Further, when dynamically setting the CPU affinity corresponding to the hard resources and each process in the process relationship set according to the CPU resource situation in real time, the following steps are included: Reserve a specified number of CPUs as schedulable CPUs, and set the remaining CPUs as non-schedulable CPUs; Set each type of hard resource and the different tasks corresponding to all processes in the process relationship set to the corresponding non-schedulable CPUs respectively; If there is insufficient CPU resource when setting each type of hard resource and the different tasks corresponding to all processes in the process relationship set to the corresponding non-schedulable CPUs respectively, set each type of hard resource to the corresponding non-schedulable CPU respectively, and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs; If there is insufficient CPU resource when setting each type of hard resource to the corresponding non-schedulable CPU respectively and then allocating the tasks corresponding to all processes to the remaining non-schedulable CPUs, set all hard resources of the same interrupt to the corresponding non-schedulable CPU, and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs; If all the hard resources of the same interruption are set to the corresponding non-schedulable CPUs, and then when all the tasks corresponding to the processes are assigned to the remaining non-schedulable CPUs, if there is insufficient CPU resource, set all the hard resources corresponding to the process relationship set to the corresponding non-schedulable CPUs, and then assign all the tasks corresponding to the processes to the remaining non-schedulable CPUs; If all the hard resources corresponding to the process relationship set are set to the corresponding non-schedulable CPUs, and then when all the tasks corresponding to the processes are assigned to the remaining non-schedulable CPUs, if there is insufficient CPU resource, according to the actual business volume, set both the tasks and the hard resources corresponding to the processes with a business volume less than the preset threshold to the same non-schedulable CPU, and set the tasks and the hard resources corresponding to the processes with a business volume greater than the preset threshold to different non-schedulable CPUs respectively.

[0012] Furthermore, the soft resources include pipelines, message queues, shared memories, semaphores, signals, and sockets. When setting the NUMA nodes where each process in the process relationship set is located according to the dependency relationship of the soft resources, it includes: assigning the processes that use pipelines or shared memories or sockets as soft resources to the same NUMA node, and for the processes that use message queues or semaphores or signals as soft resources, if they cannot be assigned to the same NUMA node, then assign them to different NUMA nodes.

[0013] The present invention also provides an automated optimization system for application real-time performance based on Preempt_RT, including a microprocessor and a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and the microprocessor executes the computer program to implement the steps of the automated optimization method for application real-time performance based on Preempt_RT.

[0014] The present invention also provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the automated optimization method for application real-time performance based on Preempt_RT.

[0015] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the steps of the automated optimization method for application real-time performance based on Preempt_RT.

[0016] Compared with the prior art, the advantages of the present invention are: The present invention takes a specified application as the starting point, obtains all its soft resources, and then obtains the set of processes using these soft resources with the help of the soft resources. Taking the processes in the set of processes as the new starting point, all their soft resources and the new dependent processes using the soft resources are obtained to get the process dependency set. Through recursive operations, a process relationship set with soft resources as the dependency path is established. The automatic analysis of the dependency relationship of the specified application is realized.

[0017] The present invention obtains the set of hard resources corresponding to each process relationship set, sets the priorities of the hard resources and the priorities of each process relationship set according to preset rules, combines the priorities of the process relationship sets with the memory usage situation, dynamically allocates exclusive memory areas for the soft resources and processes in real time, and flexibly allocates the CPU affinity of the hard resources and each process according to the CPU resource situation. At the same time, the NUMA nodes where the processes are located are reasonably set according to the dependency relationship of the soft resources, so as to allocate hardware resources in the optimal way, and can combine the characteristics of the hardware itself to achieve the purpose of improving the real-time performance of the application and reducing the jitter of business operation. Brief Description of the Drawings

[0018] Figure 1 is a brief flowchart of an embodiment of the present invention.

[0019] Figure 2 is a detailed flowchart of an embodiment of the present invention.

[0020] Figure 3 is a topological schematic diagram of the specified application and the process relationship set.

[0021] Figure 4 is a topological schematic diagram of the specified application, the process relationship set and the set of hard resources.

[0022] Figure 5 is a topological schematic diagram of the specified application, the process relationship set and the set of hard resources after setting priorities.

[0023] Figure 6 is a topological schematic diagram of the specified application, the process relationship set and the set of hard resources after setting the CPU affinity and NUMA nodes. Detailed Embodiments

[0024] The present invention will be further described below in conjunction with the accompanying drawings of the specification and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.

[0025] Embodiment 1 This embodiment proposes an automatic optimization method for application real-time performance based on Preempt_RT. Based on the Preempt_RT system, it automatically identifies the dependency relationships between an application and other applications or threads, and automatically allocates device resources, thereby minimizing the real-time jitter of services caused by other dependent applications as much as possible.

[0026] As Figure 1 shown, the method of this embodiment includes the following steps: S1) Obtain the soft resources of the specified application, then obtain all processes that use the soft resources of the specified application, and recursively establish a process relationship set with the soft resources as the dependency path; S2) Obtain the hard resources corresponding to each process in the process relationship set, and set the priorities of the hard resources and each process in the process relationship set; S3) Dynamically allocate exclusive memory areas for the soft resources and the processes in the process relationship set in real time according to the memory usage situation, and dynamically set the CPU affinity corresponding to the hard resources and each process in the process relationship set in real time according to the CPU resource situation. At the same time, set the NUMA nodes where each process in the process relationship set is located according to the dependency relationship of the soft resources.

[0027] Next, in combination with the attached Figure 2 , the relevant steps will be specifically described.

[0028] In this embodiment, through step S1, taking the specified application as the analysis entry point, all soft resources of this application are obtained to form a software resource set. Taking these soft resources as the dependency path, a process set that uses these soft resources is obtained. Then, all processes in the process set are used as the analysis entry point in turn, and a complete process relationship set is established recursively. As Figure 2 shown, step S1 of this embodiment includes the following steps: S101) Download the kernel with Preempt_RT characteristics and restart the system. In this embodiment, a domestic FT2000+ / 64-core server is used as the hardware, and the device is installed with the Galaxy Kylin Advanced Server Operating System V10 system; S102) The user selects the specified application APP. Taking the specified application APP as the analysis entry point, list the set SRSet of soft resources of this application through system tools (such as lsof), including pipes, message queues, shared memory, semaphores, signals, sockets, etc.; S103) Taking the soft resources as the dependency path, obtain the process set APPPSet that uses the soft resources in the set SRSet. Specifically, by checking the usage situation of these soft resources, it can be determined which processes are using these resources. For example, by checking the access permissions of the shared memory, the processes accessing the shared memory can be found; S104) Recursively establish a set of process relationships PSet with soft resources as the dependency path, including the following steps: S11) Add the specified application and all processes in the process set APPPSet to the process relationship set. All processes in the process set APPPSet are the dependent processes of the specified application, and the dependent processes use the soft resources as the dependency path; In this embodiment, a process that uses the soft resources of the specified application or the specified process is called a dependent process. For example, if other processes B / C / D use the soft resources of process A, then other processes B / C / D are the dependent processes of process A. When processes B / C / D complete certain operations, process A may be able to continue to execute. At this time, processes B / C / D are the factors affecting the real-time performance of process A, and the execution of process A depends on processes B / C / D to complete their corresponding operations; S12) Traverse the newly added dependent processes in the process relationship set, obtain all the soft resources of the current process, and then obtain all the processes that use the soft resources of the current process by checking the usage of the soft resources. When obtaining all the soft resources of the current process, the soft resources of the process are also obtained through system tools such as lsof; After obtaining all the dependent processes of the current process, add all the dependent processes of the current process to the process relationship set; S13) Jump to step S12 until there are no newly added dependent processes.

[0029] Through the above steps, in this embodiment, all processes in the process set APPPSet are used as the analysis entry in turn, and steps S12 and S13 are executed recursively to mine dependent processes, and a complete process relationship set PSet = {PSet1,..., PSetN} is established. PSetN is the process that meets the requirements during the traversal, that is, the process has a dependent process that uses its soft resources, and the dependent process obtained by each recursion is dependent on the process where the soft resources it uses are located.

[0030] For example, in the first iteration, obtain the soft resources of the process with PID 1 and find that its soft resources include shared memory segment A.

[0031] Check the usage of shared memory segment A and find that the process with PID 2 uses this shared memory.

[0032] Therefore, add the process with PID 2 to the process relationship set that already contains the process with PID 1, and get: {1, 2}. The process with PID 1 depends on the process with PID 2, and uses shared memory segment A as the dependency path Then, in the second iteration, obtain the soft resources of the newly added dependent process, that is, the process with PID 2, in the process relationship set {1, 2}.

[0033] Assume that the soft resource with PID 2 includes pipeline B, and upon checking the usage of pipeline B, it is found that the process with PID 3 is also using this pipeline.

[0034] Therefore, it is necessary to add the process with PID 3 to the process relationship set, resulting in: {1, 2, 3}. At this time, the process with PID 2 depends on the process with PID 3, and the dependency path is pipeline B.

[0035] Subsequent iterations continue to analyze the processes in the newly added process relationship set until no new dependent processes are found.

[0036] S105) Establish a topology graph for the process relationship set. Specifically, a topology graph is created with the specified application APP and other processes in the process relationship set PSet using the soft resource SRSet as the link. As Figure 3 shown, among which processes PSet1~PSet7 depend on each other and on the specified application APP through different soft resources as the dependency paths.

[0037] In this embodiment, through step S2, the hard resources and device information used by all processes in the process relationship set are obtained to get the hardware resource set, and by setting the priorities of the hard resources, the priorities of the processes using the hardware resources are determined. It includes the following steps: S201) Respectively obtain the hard resources used by all processes in the process relationship set to get the set HRSet of hard resources corresponding to each process. Specifically, by using the lsof command, it can be seen which devices each process uses, and thus the hard resource information corresponding to these devices can be obtained, including devices, interrupts, interrupt handlers, soft interrupts, work queues, etc. The topology graph of the set of hard resources is increased as Figure 4 shown; S202) Obtain the hardware device information, including the available CPU list, Numa topology structure, and memory information; S203) Set the priorities of the hard resources and each process in the process relationship set, including the following steps: S21) Set the priority of the specified application APP to the lowest priority. In this embodiment, the lowest priority is FIFO15; S22) Set the priority of the set of hard resources within the first priority interval, where the priority of the interrupt handler is in the high priority interval within the first priority interval, the priority of the soft interrupt is in the medium priority interval within the first priority interval, and the priority of the work queue is in the low priority interval within the first priority interval.

[0038] In this embodiment, the first priority range is FIFO[70 - 99], the high - priority range is FIFO[90 - 99], the medium - priority range is FIFO[80 - 89], and the low - priority range is FIFO [70 - 79]. Therefore, the detailed priority settings for hard resources are as follows: the interrupt Handler is set to [90 - 99], the soft interrupt is set to [80 - 89], and the work queue is set to [70 - 79]; S23) Set the priority of each process in the process relationship set to be within the second priority range. The lower limit of the second priority range is higher than the lowest priority, and the upper limit of the second priority range is lower than the lower limit of the first priority range. In this embodiment, the second priority range is FIFO[20 - 69]. When setting the priority of each process in the process relationship set to be within the second priority range, it includes: If the current process is not a dependent process of other processes, that is, when the current process is a process in the process set APPPSet that uses the soft resources of the specified application, the priority of the current process is the default value of 45. If the current process is a dependent process of other processes, then the priority of the current process is greater than the maximum value of the priorities of all processes that depend on the current process and less than the upper limit of the second priority range. The topology graph after adding priorities is as Figure 5 shown. Based on the priorities in the graph, when an external event arrives at the device, the program that is executed first is the interrupt Handler, followed by the soft interrupt, and then the work queue. After all the above three are executed, the data will be passed to the specified application through the process relationship set. All processes in the process relationship set perform operations in the order of highest to lowest priority. Processes in the process relationship set with lower priority need to wait for processes in the process relationship set with higher priority to perform corresponding operations before performing relevant operations. Finally, after waiting for all processes to complete their relevant operations, the operations of the specified application are executed.

[0039] In this embodiment, through step S3, the memory usage of all software resource sets is detected, and exclusive access to the memory of the customer - specified application APP is preferentially guaranteed. Also, according to the hardware NUMA situation and memory usage, the CPU affinity of all processes in the process set is set. Specifically, it includes the following steps: S301) Dynamically allocate exclusive memory areas for soft resources and processes in the process relationship set in real - time according to the memory usage to set the memory of each process, including the following steps: Detect the sum of the maximum memory usage amounts of all soft resources in the set of soft resources of the specified application. Specifically, detect the sum of the maximum memory usage amounts of all pipes, message queues, and shared memories in the soft resource set SRSet, which is SumSRMem; Detect the sum of the peak memory usage amounts of all processes in the process relationship set, which is SumPMem; If the device memory is sufficient, an exclusive memory area is provided for SumPMem and SumSRMem. Specifically, if the available memory is greater than the sum of SumPMem and SumSRMem, exclusive memory areas are provided for the soft resources and processes respectively. The size of the exclusive memory area for the soft resources is the sum of the maximum memory usage of all soft resources, i.e., SumPMem, and the size of the exclusive memory area for the processes is the sum of the peak memory usage of all processes, i.e., SumSRMem; If the memory is insufficient, SumPMem is given priority. Specifically, if the available memory is less than the sum of SumPMem and SumSRMem and greater than the sum of the peak memory usage of all processes, i.e., SumPMem, exclusive memory areas are provided for the soft resources and processes respectively. The size of the exclusive memory area for the processes is the sum of the peak memory usage of all processes, i.e., SumPMem, and the size of the exclusive memory area for the soft resources is the remaining size after subtracting the exclusive memory area of the processes from the available memory; If the memory cannot satisfy SumPMem, the specified application APP is given priority, and then the processes with higher priorities are considered. Specifically, if the available memory is less than the sum of the peak memory usage of all processes, i.e., SumPMem, an exclusive memory area is provided for the processes. After placing the specified application APP in the exclusive memory area, each process in the process relationship set is placed in the exclusive memory area in descending order of priority until the exclusive memory area is full or the remaining space in the exclusive memory area is less than the size of a single process.

[0040] S302) Dynamically set the CPU affinity corresponding to the hard resources and each process in the process relationship set according to the CPU resource situation in real time, and set the NUMA node where each process in the process relationship set is located according to the dependency relationship of the soft resources, so as to set the NUMA node and CPU affinity of each process, including the following steps: Reserve a specified number of CPUs as schedulable CPUs, and set the remaining CPUs as non-schedulable CPUs. Specifically, in this embodiment, 1-4 CPUs are reserved as Linux schedulable CPUs, i.e., SCPUSet, and the remaining CPUs are all set as non-schedulable CPUs, i.e., ISCPUSet; If the number of CPUs is sufficient, set the interrupt handlers, soft interrupts, and work queues of the hard resource set HRSet to different CPUs in ISCPUSet. Additionally, set the different tasks corresponding to each process in the process relationship set PSet to different CPUs in ISCPUSet. Specifically, if the number of non-schedulable CPUs is greater than the number of CPUs required to set each type of hard resource and the different tasks corresponding to all processes in the process relationship set to their respective non-schedulable CPUs, then set each type of hard resource and each task to their respective non-schedulable CPUs; If the number of CPUs is insufficient, prioritize ensuring the CPU resources of HRSet. Specifically, if there is insufficient CPU resource when setting each type of hard resource and the different tasks corresponding to all processes in the process relationship set to their respective non-schedulable CPUs, that is, the number of non-schedulable CPUs is less than the number of CPUs required to set each type of hard resource and the different tasks corresponding to all processes in the process relationship set to their respective non-schedulable CPUs, but greater than the number of CPUs required to set each type of hard resource to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs, set each type of hard resource to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs; If the CPU resource is still insufficient, then consider setting the interrupt handlers, soft interrupts, and work queues of the same interrupt to the same CPU, ensuring that different interrupts are on different CPUs. Specifically, if there is insufficient CPU resource when setting each type of hard resource to its respective non-schedulable CPU and then allocating the tasks corresponding to all processes to the remaining non-schedulable CPUs, but greater than the number of CPUs required to set all the hard resources of the same interrupt to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs, set all the hard resources of the same interrupt to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs; If the CPU resource is still insufficient, then consider having the HRSet used by PSet on the same CPU. Specifically, if there is insufficient CPU resource when setting all the hard resources of the same interrupt to its respective non-schedulable CPU and then allocating the tasks corresponding to all processes to the remaining non-schedulable CPUs, but greater than the number of CPUs required to set all the hard resources corresponding to the process relationship set to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs, set all the hard resources corresponding to the process relationship set to its respective non-schedulable CPU and then allocate the tasks corresponding to all processes to the remaining non-schedulable CPUs; If the CPU resources are still insufficient, according to the actual business volume, processes with small business volumes and HRSet can be set on the same CPU. Specifically, if all the hard resources corresponding to the process relationship set are set on the corresponding non-schedulable CPUs, and then when the tasks corresponding to all processes are assigned to the remaining non-schedulable CPUs, if the CPU resources are insufficient, according to the actual business volume size, the tasks and hard resources corresponding to processes with a business volume less than the preset threshold are both set on the same non-schedulable CPU, and the tasks and hard resources corresponding to processes with a business volume greater than the preset threshold are set on different non-schedulable CPUs respectively.

[0041] Processes that use soft resources such as pipes or shared memory or sockets are assigned to the same NUMA node. For processes that use soft resources such as message queues or semaphores or signals, if they cannot be assigned to the same NUMA node, they are assigned to different NUMA nodes.

[0042] After setting the NUMA nodes and CPU affinity for each process through the above steps, the topology diagram is as Figure 6 shown, realizing the flexible allocation of CPU resources and the reasonable setting of the NUMA nodes where the processes are located.

[0043] Embodiment 2 This embodiment proposes an automated real-time optimization system for applications based on Preempt_RT, including a microprocessor and a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and the microprocessor executes the computer program to implement the steps of the automated real-time optimization method for applications based on Preempt_RT described in Embodiment 1.

[0044] This embodiment also proposes a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the automated real-time optimization method for applications based on Preempt_RT described in Embodiment 1.

[0045] This embodiment also proposes a computer program product, including a computer program. When the computer program is executed by a processor, it implements the steps of the automated real-time optimization method for applications based on Preempt_RT described in Embodiment 1.

[0046] In summary, the present invention proposes an automated optimization method and system for application real-time performance based on Preempt_RT. Based on the Preempt_RT system as the basic environment, it enables a Linux system supporting the Preempt_RT feature to take a specified application APP as the entry point, obtain its soft resource SRSet including pipes, etc., and then obtain the process set APPPSet that uses these resources with the help of the soft resources. Through recursive operations, a complete process relationship set PSet is established with the processes in APPPSet as the new entry points, and a topology map of the APP and PSet is made based on SRSet. The dependency relationship of the application specified by the customer is automatically analyzed. In addition, the present invention obtains the hard resources HRSet including devices, etc. used by the processes in the PSet set and the hardware device information, and sets the priorities of the processes using the hardware resources according to the established rules. It detects the memory usage of SRSet and PSet, and allocates an exclusive memory area for them according to the device memory status. A part of the CPU is reserved for the Linux schedulable CPU, the tasks in HRSet and PSet are set to the non-schedulable CPU, and flexible allocation is performed according to the CPU resource situation. At the same time, according to the soft resource dependency relationship, the NUMA nodes where the processes in the PSet set are located are reasonably set. Combining the characteristics of the hardware itself, it improves the real-time performance of the application, reduces the jitter of business operation, and thus avoids investing senior engineers or even software experts in the business of improving real-time performance, thereby reducing the investment in software R & D costs.

[0047] The above is only the preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions within the idea of the present invention belong to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art in this technical field, several improvements and refinements made without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. An automated optimization method for application real-time performance based on Preempt_RT, characterized in that It includes the following steps: S1) Obtain the soft resources of the specified application, then obtain all the processes using the soft resources of the specified application, and recursively establish a set of process relationships with the soft resources as the dependency paths; S2) Obtain the hard resources corresponding to each process in the set of process relationships, set the priorities of the hard resources and the priorities of each process in the set of process relationships; S3) Dynamically allocate exclusive memory areas for the soft resources and the processes in the set of process relationships according to the memory usage in real time, dynamically set the CPU affinity corresponding to the hard resources and the processes in the set of process relationships according to the CPU resource situation in real time, and set the NUMA nodes where each process in the set of process relationships is located according to the dependency relationship of the soft resources.

2. The real-time automation optimization method for applications based on Preempt_RT according to claim 1, wherein When recursively establishing a set of process relationships with the soft resources as the dependency paths, it includes the following steps: S11) Add the specified application and all the processes using the soft resources of the specified application to the set of process relationships. All the processes using the soft resources of the specified application are used as the dependent processes of the specified application, and the dependent processes use the used soft resources as the dependency paths; S12) Traverse the newly added dependent processes in the set of process relationships, obtain all the soft resources of the current process, then obtain all the processes using the soft resources of the current process as the dependent processes of the current process, and add all the dependent processes of the current process to the set of process relationships; S13) Jump to execute step S12 until there are no newly added dependent processes.

3. The real-time automation optimization method for applications based on Preempt_RT according to claim 1, wherein The hard resources include interrupt Handlers, soft interrupts, and work queues. When setting the priorities of the hard resources and the priorities of each process in the set of process relationships, it includes the following steps: S21) Set the priority of the specified application to the lowest priority; S22) Set the priority of the interrupt Handler to the high priority range in the first priority range, set the priority of the soft interrupt to the medium priority range in the first priority range, and set the priority of the work queue to the low priority range in the first priority range; S23) Set the priority of each process in the set of process relationships to be in the second priority range. The lower limit of the second priority range is higher than the lowest priority, and the upper limit of the second priority range is lower than the lower limit of the first priority range.

4. The real-time automation optimization method for applications based on Preempt_RT according to claim 3, wherein When setting the priority of each process in the set of process relationships to be in the second priority range, it includes: If the current process is not a dependent process of other processes, the priority of the current process is the default value. If the current process is a dependent process of other processes, the priority of the current process is greater than the maximum value of the priorities of all the processes depending on the current process and less than the upper limit of the second priority range.

5. The real-time automation optimization method for applications based on Preempt_RT according to claim 1, characterized in that When dynamically allocating exclusive memory areas for the soft resources and the processes in the set of process relationships according to the memory usage in real time, it includes the following steps: Detect the sum of the maximum memory usage amounts of all the soft resources of the specified application, and detect the sum of the peak memory usage amounts of all the processes in the set of process relationships; If the available memory is greater than the sum of the maximum memory usages of all soft resources and the sum of the peak memory usages of all processes, exclusive memory regions are provided for the soft resources and processes respectively. The size of the exclusive memory region for the soft resources is the sum of the maximum memory usages of all soft resources, and the size of the exclusive memory region for the processes is the sum of the peak memory usages of all processes. If the available memory is less than the sum of the maximum memory usages of all soft resources and the sum of the peak memory usages of all processes, and greater than the sum of the peak memory usages of all processes, exclusive memory regions are provided for the soft resources and processes respectively. The size of the exclusive memory region for the processes is the sum of the peak memory usages of all processes, and the size of the exclusive memory region for the soft resources is the remaining size after subtracting the exclusive memory region of the processes from the available memory. If the available memory is less than the sum of the peak memory usages of all processes, an exclusive memory region is provided for the processes. After placing the specified application in the exclusive memory region, each process in the process relationship set is placed in the exclusive memory region in descending order of priority until the exclusive memory region is full or the remaining space in the exclusive memory region is less than the size of a single process.

6. The real-time automation optimization method for applications based on Preempt_RT according to claim 1, characterized in that When dynamically setting the CPU affinity corresponding to the hard resources and each process in the process relationship set according to the CPU resource situation in real time, the following steps are included: Reserve a specified number of CPUs as schedulable CPUs, and set the remaining CPUs as non - schedulable CPUs. Set each type of hard resource and the different tasks corresponding to all processes in the process relationship set to the corresponding non - schedulable CPUs respectively. If there is insufficient CPU resource when setting each type of hard resource and the different tasks corresponding to all processes in the process relationship set to the corresponding non - schedulable CPUs respectively, set each type of hard resource to the corresponding non - schedulable CPU respectively, and then allocate the tasks corresponding to all processes to the remaining non - schedulable CPUs. If there is insufficient CPU resource when setting each type of hard resource to the corresponding non - schedulable CPU respectively and then allocating the tasks corresponding to all processes to the remaining non - schedulable CPUs, set all hard resources of the same interrupt to the corresponding non - schedulable CPU, and then allocate the tasks corresponding to all processes to the remaining non - schedulable CPUs. If there is insufficient CPU resource when setting all hard resources of the same interrupt to the corresponding non - schedulable CPU and then allocating the tasks corresponding to all processes to the remaining non - schedulable CPUs, set all hard resources corresponding to the process relationship set to the corresponding non - schedulable CPU, and then allocate the tasks corresponding to all processes to the remaining non - schedulable CPUs. If all the hard resources corresponding to the process relationship set are set to the corresponding non-schedulable CPUs, and then all the tasks corresponding to the processes are assigned to the remaining non-schedulable CPUs, and there is insufficient CPU resource, according to the actual business volume, the tasks and hard resources corresponding to the processes with business volume less than the preset threshold are both set to the same non-schedulable CPU, and the tasks and hard resources corresponding to the processes with business volume greater than the preset threshold are respectively set to different non-schedulable CPUs.

7. The real-time automation optimization method for applications based on Preempt_RT according to claim 1, characterized in that The soft resources include pipes, message queues, shared memories, semaphores, signals, and sockets. When setting the NUMA nodes where each process in the process relationship set is located according to the dependency relationship of the soft resources, it includes: assigning the processes that use soft resources such as pipes or shared memories or sockets to the same NUMA node. For the processes that use soft resources such as message queues or semaphores or signals, if they cannot be assigned to the same NUMA node, they are assigned to different NUMA nodes.

8. An application real-time automation optimization system based on Preempt_RT, characterized in that, It includes a microprocessor and a computer-readable storage medium, and a computer program is stored in the computer-readable storage medium. The microprocessor executes the computer program to implement the steps of the Preempt_RT-based application real-time automation optimization method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, it implements the steps of the Preempt_RT-based application real-time automation optimization method according to any one of claims 1 to 7.

10. A computer program product, characterized in that, It includes a computer program, and when the computer program is executed by a processor, it implements the steps of the Preempt_RT-based application real-time automation optimization method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Application program processing method and device, electronic equipment and computer readable storage medium

    CN109992369A

  • Linux server multi-application process scheduling method based on shared memory

    CN115629827A

  • Vehicle-mounted process resource management method and system and vehicle

    CN119322666A

  • Intelligent scheduling system and method based on calculation power demand prediction

    CN120066720A

  • Affinity mask assignment system and method for multiprocessor systems

    US20050108713A1