Interruption load balancing optimization method and device
By adjusting the CPU affinity core through the interrupt load balancing monitoring service, the interrupt load distribution is optimized, which solves the problem of uneven interrupt load in the Linux kernel, reduces the occurrence of CPU soft lock, and improves system stability.
Patent Information
- Application Number
- CN202211297425.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-21
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-10-21
AI Technical Summary
The interrupt load balancing mechanism in the existing Linux kernel cannot effectively balance the load, causing some CPU cores to be overly busy, increasing the probability of soft lock and affecting system stability.
By adding interrupt load balancing monitoring services, monitoring the CPU and CPU core load, adjusting the original CPU affinity core of the interrupt, optimizing interrupt load distribution, and reducing the probability of CPU soft lock.
It achieves balanced processing of interrupt load, significantly reduces the probability of CPU soft lock, and improves system stability.
Smart Images

Figure CN115756825B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of interruption loads, and in particular to an interruption load balancing optimization method and device. Background Art
[0002] The server is under excessive operating pressure. For example, during a stress test of the server disk, a large backlog of tasks often cannot be executed on a CPU, resulting in a soft lockup. This soft lockup log, along with corresponding register information and call trace information, appears in the system log.
[0003] Soft lock occurs when a kernel thread or a user process trapped in kernel mode occupies the CPU for an excessively long period, exceeding the permitted threshold. Reducing the workload on the CPU significantly reduces the likelihood of soft lock. This issue can impact the smooth operation of customer services, reduce efficiency, and, in severe cases, cause system freezes or system downtime.
[0004] Soft lock is a common problem in mainstream Linux operating systems (such as Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8, SUSE Linux Enterprise Server, Ubuntu, and Debian) with high disk workloads. While existing mechanisms for detecting CPU deadlocks (soft and hard) in the Linux kernel are relatively well-developed, the interrupt load balancing mechanism within the Linux kernel is less than ideal. This is especially true for SATA and sSATA controllers running SATA and SAS disks. Actual interrupts are still concentrated on a few CPU cores, causing them to become overly busy while other CPU cores enter a power-saving state due to idle time. This significantly increases the probability of soft locks in overly busy CPU cores.
[0005] Figure 1This is a schematic diagram of the current interrupt load balancing principle. When a user submits a disk read or write instruction (for example, the fio random read instruction: fio --name=r_4k --filename= / dev / sdb --ioengine=libaio --numjobs=4 --iodepth=128 --rw=randread --blocksize=4k --time_based --runtime=600 --direct=1), the kernel first searches for the disk controller corresponding to the disk where the disk or file system is located, and then obtains the list of interrupt numbers assigned by the kernel to the disk controller. First, the CPU affinity list of the first interrupt number is obtained, and the first fio read task is assigned to the first CPU affinity core. Then, the second fio read task is assigned to the second CPU affinity core of the first interrupt number. If there are unassigned fio read tasks, the tasks are assigned to the CPU affinity core corresponding to the first interrupt number in turn, until the CPU affinity core list corresponding to the first interrupt number is traversed. If there are unassigned fio read tasks, continue to obtain the CPU affinity list corresponding to the second interrupt number, and assign tasks to the corresponding CPU affinity cores according to the CPU affinity order of the second interrupt number, until all tasks are assigned or the traversal of the CPU affinity list of the second interrupt number is completed. If there are still unassigned fio read tasks, then by analogy, assign tasks to the CPU affinity cores of other interrupt numbers corresponding to the disk controller until all tasks are assigned. If there are still unassigned tasks after traversing all CPU affinity cores corresponding to all interrupt numbers, then the interrupt number is set to the first interrupt number corresponding to the disk controller, and according to the same rules, traverse the CPU affinity core lists corresponding to each interrupt to assign tasks until all tasks are assigned.
[0006] The current interrupt load balancing mechanism in the Linux kernel cannot effectively balance the load for the following reasons:
[0007] (1) A SATA or sSATA controller can connect up to 15 disks. These 15 disks share one interrupt number corresponding to one controller. When all disks under a controller are stress-tested or the business load is increased at the same time, the CPU interrupts of all disk tasks will be very concentrated.
[0008] (2) The CPU affinity list corresponding to the controller interrupt number is determined by the controller driver. The controller driver will select the CPU closest to the physical location of the controller as the affinity CPU. For example, the interrupt of the SATA controller connected to the PCH will select CPU 0 as the affinity CPU, and the core under CPU 0 as the affinity CPU core. At the same time, the core of CPU 0 is not only responsible for processing disk interrupts, but also has many other tasks running on the core of CPU 0. If the load at this time is too heavy, the probability of soft lock increases.
[0009] (3) The number of disk read and write tasks is limited. According to the interrupt allocation principle of the existing technology, interrupts will be more concentrated on the first few CPU affinity cores, resulting in excessive load on the first few affinity cores, which in turn increases the probability of soft lock on these CPU cores. Summary of the Invention
[0010] To solve the above problems, the present invention provides an interrupt load balancing optimization method and device. By adding an interrupt load balancing monitoring service, monitoring the load of the CPU and the cores on the CPU, adjusting the original CPU affinity core of the interrupt, achieving balanced processing of the interrupt load, and reducing the probability of CPU soft lock.
[0011] In a first aspect, the technical solution of the present invention provides an interrupt load balancing optimization method, comprising the following steps:
[0012] Receive the interrupt load task fed back by the kernel and obtain the physical CPU list with hard disk affinity of the disk controller based on the links of each component of the server;
[0013] Get the original CPU affinity core list corresponding to the interrupt number, and obtain the physical CPU where each CPU affinity core is located through the kernel, which is recorded as the original physical CPU;
[0014] Calculate the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, delete the CPU affinity core corresponding to the original physical CPU from the original CPU affinity core list. Select a physical CPU with a load less than the first load threshold and the smallest load from the hard disk affinity physical CPU list, select CPU cores from the physical CPU and add them to the original CPU affinity core list to obtain an optimized CPU affinity core list. The number of CPU cores added to the original CPU affinity core list is the same as the number of CPU affinity cores deleted.
[0015] Send the optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks.
[0016] Furthermore, the calculation of physical CPU workload specifically includes:
[0017] Get the number of ready tasks and waiting tasks of all CPU cores on the physical CPU from the kernel;
[0018] The workload of the physical CPU is obtained by adding the number of ready tasks and the number of waiting tasks.
[0019] Furthermore, the method specifically comprises the following steps:
[0020] Select a physical CPU with a load less than a first load threshold and the smallest load from the physical CPU list with hard disk affinity;
[0021] Sort the CPU cores on the selected physical CPU according to load size;
[0022] Select the same number of CPU cores with light load as the deleted CPU affinity cores and add them to the original CPU affinity core list to obtain the optimized CPU affinity core list.
[0023] Furthermore, the method further comprises the following steps:
[0024] If the loads of all physical CPUs in the hard disk affinity physical CPU list exceed the first load threshold, the physical CPU with the smallest load is selected from the remaining original physical CPUs in the original physical CPUs, the CPU cores on the physical CPU are sorted according to the load size, and the CPU cores with the same number of small loads as the deleted CPU affinity cores are selected and added to the original CPU affinity core list to obtain the optimized CPU affinity core list.
[0025] Furthermore, the method further comprises the following steps:
[0026] All CPU affinity cores in the optimized CPU affinity core list are sorted according to load size, with CPU affinity cores with light loads being ranked higher and CPU affinity cores with heavy loads being ranked lower, thereby obtaining an optimized CPU affinity core list after priority adjustment;
[0027] Deleting the CPU affinity cores whose workloads exceed the second load threshold from the priority-adjusted optimized CPU affinity core list to obtain a final optimized CPU affinity core list;
[0028] Send the final optimized CPU affinity core list to the interrupt load task.
[0029] Furthermore, the method further comprises the following steps:
[0030] First, obtain the original CPU affinity core list of the first interrupt number for optimization;
[0031] If there are still unassigned disk read and write tasks after the final optimized CPU affinity core list of the first interrupt number is traversed, the original CPU affinity core list of the second interrupt number is obtained for optimization, and so on, until all disk read and write tasks are assigned.
[0032] Furthermore, the method further comprises the following steps:
[0033] During the execution of the interrupt load task, the CPU affinity core list corresponding to each interrupt number is optimized regularly.
[0034] Furthermore, the method further comprises the following steps:
[0035] When the user submits a disk read / write instruction, the kernel detects whether the interrupt load balancing monitoring service is in working state;
[0036] If it is not in working state, wake up the interrupt load balancing monitoring service and notify it to receive the interrupt load task fed back by the kernel to optimize the CPU affinity core list;
[0037] If it is in working state, it will directly notify the interrupt load balancing monitoring service to receive the interrupt load task fed back by the kernel to optimize the CPU affinity core list.
[0038] Furthermore, the method further comprises the following steps:
[0039] If there are no pending tasks in the interruption load balancing monitoring service and all tasks have been completed, the interruption load balancing monitoring service is suspended and the memory space occupied by the interruption load balancing monitoring service is cleared.
[0040] In a second aspect, the technical solution of the present invention provides an interruption load balancing optimization device, comprising:
[0041] Interrupt balancing task receiving module: receives interrupt load tasks fed back by the kernel and obtains the physical CPU list of the disk controller's hard disk affinity based on the links of each server component;
[0042] CPU affinity acquisition module: obtains the original CPU affinity core list corresponding to the interrupt number, and obtains the physical CPU where each CPU affinity core is located through the kernel, which is recorded as the original physical CPU;
[0043] The CPU load monitoring module calculates the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, the CPU affinity core corresponding to the original physical CPU is deleted from the original CPU affinity core list. The CPU core of the physical CPU with the smallest load is obtained from the hard disk affinity physical CPU list and added to the original CPU affinity core list to obtain an optimized CPU affinity core list. The number of CPU cores added to the original CPU affinity core list is the same as the number of CPU cores deleted.
[0044] The CPU core load monitoring module sorts all CPU affinity cores in the optimized CPU affinity core list according to their load sizes, with CPU affinity cores with smaller loads ranked higher and CPU affinity cores with larger loads ranked lower, thereby obtaining a priority-adjusted optimized CPU affinity core list. CPU affinity cores whose workloads exceed a second load threshold in the priority-adjusted optimized CPU affinity core list are deleted to obtain a final optimized CPU affinity core list.
[0045] CPU affinity refresh module: sends the final optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks;
[0046] CPU affinity real-time monitoring and adjustment module: During the execution of interrupt load tasks, the CPU affinity core list corresponding to each interrupt number is regularly optimized;
[0047] Interrupt load balancing end module: If there are no pending tasks in the interrupt load balancing monitoring service and all tasks have ended, the interrupt load balancing monitoring service will be suspended and the memory space occupied by the interrupt load balancing monitoring service will be cleared.
[0048] The interrupt load balancing optimization method and device provided by the present invention have the following beneficial effects compared with the prior art: by adding an interrupt load balancing monitoring service, the load of the physical CPU where the CPU affinity core corresponding to the interrupt number assigned by the driver is located is monitored, and the CPU affinity core on the physical CPU whose load exceeds "threshold 1" is deleted from the CPU affinity core list; and by monitoring the load conditions on the hardware affinity physical CPU and other physical CPUs, CPU cores are selected from the physical CPU with a load below the first load threshold and the smallest load to fill in the CPU affinity core list to obtain an optimized CPU affinity core list, and tasks are allocated to achieve the purpose of CPU interrupt load balancing, greatly reducing the probability of CPU soft lock. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions of the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0050] Figure 1 This is a schematic diagram of the current interrupt load balancing principle.
[0051] Figure 2 This is a schematic diagram of the architecture of an interrupt load balancing optimization method provided by an embodiment of the present invention.
[0052] Figure 3 This is a flow chart of an interrupt load balancing optimization method provided by an embodiment of the present invention.
[0053] Figure 4 This is a flow chart of an interrupt load balancing optimization method provided by an embodiment of the present invention.
[0054] Figure 5 This is a schematic block diagram of the structure of an interrupt load balancing optimization device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0055] Some terms involved in the present invention are explained below.
[0056] CPU affinity list: It is a list of CPU cores corresponding to the interrupt numbers defined by the device driver. When the device has read or write access tasks, the kernel will give priority to assigning tasks to the CPUs in the CPU affinity list.
[0057] fio is a disk stress testing tool that can perform pressure tests on disk read and write tasks, and concurrently process multiple fio read and write tasks on the disk.
[0058] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the embodiments described are only a part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making any creative efforts are within the scope of protection of the present application.
[0059] Figure 2This is a schematic diagram of the architecture of an interrupt load balancing optimization method provided by an embodiment of the present invention. The method wakes up the interrupt load balancing monitoring service when the user submits a disk read or write instruction. Through the interrupt load balancing monitoring service, the load of the CPU and the cores on the CPU are monitored, the original CPU affinity core of the interrupt is adjusted, and a new CPU affinity list is fed back to achieve balanced processing of the interrupt load and reduce the probability of CPU soft lock.
[0060] Figure 3 FIG. 1 is a flow chart of an interrupt load balancing optimization method provided by an embodiment of the present invention. Figure 3 As shown, after the method triggers the interruption load balancing monitoring service, the optimization of the interruption load balancing is mainly achieved through the following steps.
[0061] S1 receives the interrupt load task fed back by the kernel and obtains the physical CPU list with hard disk affinity of the disk controller based on the links of each component of the server.
[0062] The hard disk affinity physical CPU list is a list of physical CPUs that are closer to the disk controller link.
[0063] When a user submits a disk read or write instruction, the interrupt load balancing monitoring service is triggered to receive the interrupt load task fed back by the kernel. The interrupt load balancing monitoring service obtains the physical CPU list with hard disk affinity and continues with subsequent steps.
[0064] S2, obtain the original CPU affinity core list corresponding to the interrupt number, and obtain the physical CPU where each CPU affinity core is located through the kernel, which is recorded as the original physical CPU.
[0065] The obtained original CPU affinity core list is saved in the CPU affinity core list in the task data structure, and then the physical CPU where each CPU affinity core in the list is located is obtained through the kernel.
[0066] S3. Calculate the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, delete the CPU affinity core corresponding to the original physical CPU from the original CPU affinity core list. Select a physical CPU with a load less than the first load threshold and the smallest load from the hard disk affinity physical CPU list, select a CPU core from the physical CPU, and add it to the original CPU affinity core list to obtain an optimized CPU affinity core list. The number of CPU cores added to the original CPU affinity core list is the same as the number of CPU affinity cores deleted.
[0067] The physical CPU workload is calculated by adding the number of ready tasks and waiting tasks of all CPU cores on the physical CPU. Therefore, the kernel first obtains the number of ready tasks and waiting tasks of all CPU cores on the physical CPU, and then adds the number of ready tasks and waiting tasks to obtain the physical CPU workload.
[0068] It should be noted that both the original physical CPU workload and the physical CPU load in the hardware affinity physical CPU list are calculated using the above method.
[0069] A first load threshold is pre-configured, and all original physical CPUs whose workloads exceed the first load threshold are found. The CPU affinity cores of these original physical CPUs are deleted from the original CPU affinity core list. After that, the CPU affinity core list needs to be supplemented. Therefore, a physical CPU with a load less than the first load threshold and the smallest load is selected from the hard disk affinity physical CPU list, and CPU cores are selected from this physical CPU to supplement the original CPU affinity core list, thereby obtaining an optimized CPU affinity core list.
[0070] S4, sends the optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks.
[0071] The interrupt load task allocates disk read and write tasks according to the optimized CPU affinity core list and executes disk read and write tasks. Since the load of the physical CPU corresponding to each CPU core in the optimized CPU affinity core list is relatively small, the probability of soft lock is reduced.
[0072] An embodiment of the present invention provides an interrupt load balancing optimization method, which adds an interrupt load balancing monitoring service to monitor the load of the physical CPU where the CPU affinity core corresponding to the interrupt number assigned by the driver is located, deletes the CPU affinity core on the physical CPU whose load exceeds "threshold 1" from the CPU affinity core list, and monitors the load conditions on the hardware affinity physical CPU and other physical CPUs, selects CPU cores from the physical CPU with a load below the first load threshold and the smallest load to fill in the CPU affinity core list to obtain an optimized CPU affinity core list, and distributes tasks to achieve the purpose of CPU interrupt load balancing, thereby greatly reducing the probability of CPU soft lock.
[0073] Figure 4 FIG. 1 is a flow chart of an interrupt load balancing optimization method provided by an embodiment of the present invention. Figure 4 As shown, the method includes the following processes.
[0074] 1) Interrupt load balancing monitoring service wake-up
[0075] When the user submits a disk read or write instruction, the kernel detects whether the interrupt load balancing monitoring service is in working condition. If it is not in working condition, the kernel wakes up the interrupt load balancing monitoring service and notifies the interrupt load balancing monitoring service to receive the interrupt load task fed back by the kernel for CPU affinity core list optimization. If it is in working condition, the kernel directly notifies the interrupt load balancing monitoring service to receive the interrupt load task fed back by the kernel for CPU affinity core list optimization.
[0076] 2) Interrupt load task reception
[0077] The interrupt load task receives kernel feedback and obtains the physical CPU list with hardware affinity for the disk controller based on the links between various server components, that is, the list of physical CPUs that are closer to the disk controller link.
[0078] 3) CPU affinity acquisition
[0079] Get the original CPU affinity core list corresponding to the interrupt number and save it in the CPU affinity core list in the task data structure. Then get the physical CPU where these CPU affinity cores are located through the kernel and record it as the original physical CPU.
[0080] 4) CPU load monitoring
[0081] a. Query the kernel for the number of ready and waiting tasks for all CPU cores on the original physical CPU. Add these numbers to obtain the workload of the original physical CPU. Identify all original physical CPUs whose workload exceeds "Load Threshold 1" and remove the CPU affinity cores corresponding to these original physical CPUs from the original CPU affinity core list.
[0082] b. After the CPU affinity cores are deleted, the load conditions of all physical CPUs in the hardware affinity physical CPU list obtained in 2) are traversed. The physical CPU with the smallest load and a load less than "Load Threshold 1" is selected. The CPU cores on this physical CPU are sorted by load size. The same number of CPU cores with the smallest loads as the deleted CPU affinity cores are selected and added to the original CPU affinity core list to obtain the optimized CPU affinity core list.
[0083] c. If the loads of all physical CPUs in the disk affinity physical CPU list exceed Load Threshold 1, the system selects the physical CPU with the lightest load from the remaining original physical CPUs. Then, sort the CPU cores on this physical CPU by load. The system selects the same number of CPU cores with the same load as the deleted CPU affinity cores and adds them to the original CPU affinity core list to obtain the optimized CPU affinity core list.
[0084] 5) CPU core load monitoring
[0085] Traverse 4) to obtain the optimized CPU affinity core list and obtain the load of each CPU affinity core. After the traversal is completed, all CPU affinity cores in the optimized CPU affinity core list are sorted according to load size, with CPU affinity cores with light loads ranked higher and CPU affinity cores with heavy loads ranked lower, to obtain the optimized CPU affinity core list after priority adjustment.
[0086] Then, the CPU affinity cores whose workloads exceed the "load threshold 2" in the priority-adjusted optimized CPU affinity core list are deleted to obtain a final optimized CPU affinity core list.
[0087] 6) CPU affinity refresh
[0088] The final optimized CPU affinity core list is sent to the interrupt load task for disk read and write task allocation.
[0089] The order of the final optimized CPU affinity list is the affinity order. It should be noted that when the interrupt load task begins execution, the interrupt load balancing monitoring service first obtains the original CPU affinity list for the first interrupt number. The final optimized CPU affinity list sent to the interrupt load task is also the list for the first interrupt number. Afterwards, the interrupt load task first assigns the first fio read task to the first affinity CPU core for the first interrupt number, then assigns the second fio read task to the second affinity CPU core for the first interrupt number. If there are unassigned fio read tasks, they are assigned to the CPU affinity cores corresponding to the first interrupt number in sequence, until the CPU core lists corresponding to the first interrupt number are completely traversed or the tasks are assigned.
[0090] If there are still unassigned disk read / write tasks after traversing the final optimized CPU affinity core list of the first interrupt number, the original CPU affinity core list of the second interrupt number is obtained and steps 3), 4), and 5) are executed for optimization, and so on, until all disk read / write tasks are assigned.
[0091] 7) Real-time monitoring and adjustment of CPU affinity
[0092] During the execution of the interrupt load task, the CPU affinity core list corresponding to each interrupt number is regularly optimized. Specifically, according to the working methods 3), 4), and 5), the workload of the physical CPU and CPU affinity core corresponding to each interrupt number of the task is regularly monitored. Based on the workload of the physical CPU and the CPU affinity core, the CPU cores on the physical CPU with a load exceeding the threshold are removed from the CPU affinity core list, and the idle or lightly loaded CPU cores on the physical CPU with an idle or lightly loaded one are added. The CPU affinity core list is regularly refreshed and fed back to the original interrupt load module to assign the task to the CPU affinity core for processing.
[0093] 8) Interrupt balancing ends
[0094] If there are no pending tasks in the interruption load balancing monitoring service and all tasks have been completed, the interruption load balancing monitoring service is suspended and the memory space occupied by the interruption load balancing monitoring service is cleared.
[0095] The embodiment of the present invention provides an interrupt load balancing optimization method to address the problem of interrupt load imbalance in the prior art, where interrupts are more concentrated on a few CPU cores, causing soft locks in individual CPU cores and thus affecting stable system operation. The method adds an interrupt load balancing monitoring service to monitor the load of the physical CPU where the CPU affinity core corresponding to the interrupt number assigned by the driver is located, deletes the CPU affinity core on the physical CPU whose load exceeds "threshold 1" from the CPU affinity core list, and screens out CPU cores whose CPU core load is less than "threshold 2" in order of load from small to large by monitoring the load on the hardware affinity physical CPU and other physical CPUs, and completes the CPU affinity core list. The CPU affinity core list, which has been refreshed in order of load from small to large, is used to allocate tasks, and the load of the physical CPU and the CPU cores in the CPU affinity core list is monitored in a timely manner to refresh the CPU affinity core list corresponding to the interrupt, thereby achieving the purpose of CPU interrupt load balancing and greatly reducing the probability of CPU soft lock.
[0096] An embodiment of an interruption load balancing optimization method is described in detail above. Based on the interruption load balancing optimization method described in the above embodiment, an embodiment of the present invention further provides an interruption load balancing optimization device corresponding to the method.
[0097] Figure 5 This is a schematic block diagram of the structure of an interrupt load balancing optimization device provided by an embodiment of the present invention. Figure 5As shown, the device includes: an interrupt balancing task receiving module, a CPU affinity obtaining module, a CPU core load monitoring module, a CPU load monitoring module, a CPU affinity refreshing module, a CPU affinity real-time monitoring and adjustment module, and an interrupt load balancing ending module.
[0098] Interrupt balancing task receiving module: receives the interrupt load task feedback from the kernel and obtains the physical CPU list of the disk controller's hard disk affinity based on the links of each component of the server.
[0099] CPU affinity acquisition module: obtains the original CPU affinity core list corresponding to the interrupt number, and obtains the physical CPU where each CPU affinity core is located through the kernel, which is recorded as the original physical CPU.
[0100] CPU load monitoring module: calculates the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, the CPU affinity core corresponding to the original physical CPU is deleted from the original CPU affinity core list, and the CPU core of the physical CPU with the smallest load is obtained from the hard disk affinity physical CPU list and added to the original CPU affinity core list to obtain an optimized CPU affinity core list, where the number of CPU cores added to the original CPU affinity core list is the same as the number of CPU affinity cores deleted.
[0101] CPU core load monitoring module: sorts all CPU affinity cores in the optimized CPU affinity core list according to load size, with CPU affinity cores with light loads ranked higher and CPU affinity cores with heavy loads ranked lower, to obtain a priority-adjusted optimized CPU affinity core list; deletes CPU affinity cores whose workloads exceed a second load threshold in the priority-adjusted optimized CPU affinity core list, to obtain a final optimized CPU affinity core list.
[0102] CPU affinity refresh module: sends the final optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks.
[0103] CPU affinity real-time monitoring and adjustment module: During the execution of interrupt load tasks, the CPU affinity core list corresponding to each interrupt number is regularly optimized.
[0104] Interrupt load balancing end module: If there are no pending tasks in the interrupt load balancing monitoring service and all tasks have ended, the interrupt load balancing monitoring service will be suspended and the memory space occupied by the interrupt load balancing monitoring service will be cleared.
[0105] The interruption load balancing optimization device of this embodiment is used to implement the aforementioned interruption load balancing optimization method. Therefore, the specific implementation method of the device can be seen in the embodiment part of the interruption load balancing optimization method in the previous text. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part and will not be elaborated here.
[0106] In addition, since the interruption load balancing optimization device of this embodiment is used to implement the aforementioned interruption load balancing optimization method, its function corresponds to that of the aforementioned method and will not be described in detail here.
[0107] The above disclosure is only a preferred embodiment of the present invention, but the present invention is not limited thereto. Any non-creative changes that can be thought of by those skilled in the art, as well as several improvements and modifications made without departing from the principles of the present invention, should fall within the scope of protection of the present invention.
Claims
1. A method for optimizing interrupt load balancing, characterized in that: The following steps are involved: The interrupt load task receives kernel feedback and obtains the disk controller's hard disk affinity physical CPU list based on the links between various server components. The hard disk affinity physical CPU list is a list of physical CPUs that are closer to the disk controller link. Get the original CPU affinity core list corresponding to the interrupt number, and use the kernel to obtain the physical CPU where each CPU affinity core is located, which is recorded as the original physical CPU; the CPU that is physically closer to the disk controller is the affinity CPU, and the core under the affinity CPU is the CPU affinity core; Calculate the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, delete the CPU affinity core corresponding to the original physical CPU from the original CPU affinity core list. Select a physical CPU with a load less than the first load threshold and the smallest load from the hard disk affinity physical CPU list, select CPU cores from the physical CPU and add them to the original CPU affinity core list to obtain an optimized CPU affinity core list. The number of CPU cores added to the original CPU affinity core list is the same as the number of CPU affinity cores deleted. All CPU affinity cores in the optimized CPU affinity core list are sorted according to their load sizes, with CPU affinity cores with smaller loads being ranked higher and CPU affinity cores with larger loads being ranked lower, to obtain a priority-adjusted optimized CPU affinity core list; CPU affinity cores whose workloads exceed a second load threshold in the priority-adjusted optimized CPU affinity core list are deleted to obtain a final optimized CPU affinity core list; Send the final optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks; During the execution of the interrupt load task, the CPU affinity core list corresponding to each interrupt number is regularly optimized; If there are no pending tasks in the interruption load balancing monitoring service and all tasks have been completed, the interruption load balancing monitoring service is suspended and the memory space occupied by the interruption load balancing monitoring service is cleared.
2. The interruption load balancing optimization method according to claim 1, characterized in that: Calculation of physical CPU workload, including: Get the number of ready tasks and waiting tasks of all CPU cores on the physical CPU from the kernel; The workload of the physical CPU is obtained by adding the number of ready tasks and the number of waiting tasks.
3. The interruption load balancing optimization method according to claim 2, characterized in that: The method specifically comprises the following steps: Select a physical CPU with a load less than a first load threshold and the smallest load from the physical CPU list with hard disk affinity; Sort the CPU cores on the selected physical CPU according to load size; Select the same number of CPU cores with light load as the deleted CPU affinity cores and add them to the original CPU affinity core list to obtain the optimized CPU affinity core list.
4. The interruption load balancing optimization method according to claim 3, characterized in that: The method further comprises the following steps: If the loads of all physical CPUs in the hard disk affinity physical CPU list exceed the first load threshold, the physical CPU with the smallest load is selected from the remaining original physical CPUs in the original physical CPUs, the CPU cores on the physical CPU are sorted according to the load size, and the CPU cores with the same number of small loads as the deleted CPU affinity cores are selected and added to the original CPU affinity core list to obtain the optimized CPU affinity core list.
5. The interruption load balancing optimization method according to claim 4, characterized in that: The method further comprises the following steps: First, obtain the original CPU affinity core list of the first interrupt number for optimization; If there are still unassigned disk read and write tasks after the final optimized CPU affinity core list of the first interrupt number is traversed, the original CPU affinity core list of the second interrupt number is obtained for optimization, and so on, until all disk read and write tasks are assigned.
6. The interruption load balancing optimization method according to claim 5, characterized in that: The method further comprises the following steps: When the user submits a disk read / write instruction, the kernel detects whether the interrupt load balancing monitoring service is in working state; If it is not in working state, wake up the interrupt load balancing monitoring service and notify it to receive the interrupt load task fed back by the kernel to optimize the CPU affinity core list; If it is in working state, it will directly notify the interrupt load balancing monitoring service to receive the interrupt load task fed back by the kernel to optimize the CPU affinity core list.
7. An interruption load balancing optimization device, characterized in that: include, Interrupt balancing task receiving module: Receives interrupt load tasks fed back by the kernel and obtains the disk controller's hard disk affinity physical CPU list based on the links of various server components. The hard disk affinity physical CPU list is a list of physical CPUs that are closer to the disk controller link. CPU affinity acquisition module: obtains the original CPU affinity core list corresponding to the interrupt number, and obtains the physical CPU where each CPU affinity core is located through the kernel, which is recorded as the original physical CPU; the CPU that is physically closer to the disk controller is the affinity CPU, and the core under the affinity CPU is the CPU affinity core; The CPU load monitoring module calculates the workload of each original physical CPU. If the workload of an original physical CPU exceeds a first load threshold, the CPU affinity core corresponding to the original physical CPU is deleted from the original CPU affinity core list. The CPU core of the physical CPU with the smallest load is obtained from the hard disk affinity physical CPU list and added to the original CPU affinity core list to obtain an optimized CPU affinity core list. The number of CPU cores added to the original CPU affinity core list is the same as the number of CPU cores deleted. The CPU core load monitoring module sorts all CPU affinity cores in the optimized CPU affinity core list according to their load sizes, with CPU affinity cores with smaller loads ranked higher and CPU affinity cores with larger loads ranked lower, thereby obtaining a priority-adjusted optimized CPU affinity core list. CPU affinity cores whose workloads exceed a second load threshold in the priority-adjusted optimized CPU affinity core list are deleted to obtain a final optimized CPU affinity core list. CPU affinity refresh module: sends the final optimized CPU affinity core list to the interrupt load task to allocate disk read and write tasks; CPU affinity real-time monitoring and adjustment module: During the execution of interrupt load tasks, the CPU affinity core list corresponding to each interrupt number is regularly optimized; Interrupt load balancing end module: If there are no pending tasks in the interrupt load balancing monitoring service and all tasks have ended, the interrupt load balancing monitoring service will be suspended and the memory space occupied by the interrupt load balancing monitoring service will be cleared.
Citation Information
Patent Citations
System and method for optimizing interruption resources in multi-core processor
CN103019835A
Interrupt allocation method and device
CN106502786A