A method, system, device and storage medium for reducing system soft lock probability
By setting read/write thresholds and calling the kernel interrupt daemon thread when the CPU kernel handles disk soft interrupt tasks, the soft lock problem caused by the Linux kernel's inability to cope with high-speed SSDs is solved, and the system can run stably under different disk device types.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2026-03-31
AI Technical Summary
Existing Linux kernel disk task scheduling strategies cannot effectively handle high-speed SSDs and other types of disks, resulting in a high probability of system software lock-up, which can lead to system crashes or shutdowns in severe cases.
By setting read/write thresholds when the CPU kernel processes disk soft interrupt tasks, the current task is terminated and added to the kernel queue when the threshold is exceeded. The kernel interrupt daemon thread is then invoked to transfer unfinished tasks to the next kernel for processing, adapting to both high-speed and slow disk devices.
It effectively reduces the probability of system software lock-up, avoids the CPU being occupied by high-speed disk tasks for a long time, and ensures the stable operation of the system under different disk device types.
Smart Images

Figure CN115543570B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of server system security technology, and specifically relates to a method, system, device and storage medium for reducing the probability of system soft lock. Background Technology
[0002] To improve system performance when handling disk read / write tasks, the operating system avoids frequent switching of CPU cores processing tasks until the disk's hardware queue is full or the block I / O (BIO) tasks destined for that disk have been completed. In the era when disk performance was lower than processor performance, this strategy improved overall disk task processing performance by avoiding frequent CPU context switching. However, with increasingly higher disk performance, especially with the advent of onboard SSDs, read / write tasks are processed much faster by the disk, causing the disk's hardware queue to remain idle. This results in a CPU core continuously processing read / write tasks for a specific SSD. When the time a CPU core is occupied by this task exceeds a soft lock threshold, other disk read / write tasks or other tasks queued on that CPU core cannot be executed, leading to a soft lock. Soft locks reduce system efficiency and, in severe cases, can cause system crashes or shutdowns.
[0003] The current Linux kernel's disk task scheduling strategy is no longer sufficient to handle the rapidly increasing performance of SSDs and other disk types. In actual testing, it was found that Red Hat Enterprise Linux and SUSE Linux Enterprise Server systems exhibit a significantly higher probability of soft lockouts during fio stress testing of onboard SSDs compared to handling ordinary SATA and SAS disk read / write tasks. FIO is an open-source I / O stress testing tool primarily used to test disk / SSD I / O performance, but it can also test the I / O performance of the CPU and network interface controller. The high probability of soft lockouts is due to the fact that when the disk's processing speed exceeds the CPU and kernel's processing speed, the disk, currently undergoing soft interrupt processing, is constantly underutilized, preventing other tasks from running. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention proposes a method, system, device, and storage medium for reducing the probability of system soft locks. By increasing the disk read / write threshold, when the number of disk read / write operations handled by a certain soft interrupt exceeds the threshold, the kernel interrupts the current soft interrupt task and sets up an interrupt protection thread, thereby preventing soft locks from occurring and better adapting to both slow and high-speed disk read / write tasks.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A method for reducing the probability of system soft lock includes the following steps:
[0007] When the first core of the central processing unit processes the first soft interrupt task corresponding to the disk, set the threshold for the disk read / write volume corresponding to the first soft interrupt;
[0008] If the threshold for disk read / write operations is exceeded, the first soft interrupt task is terminated, the second soft interrupt task is executed, and the unfinished first soft interrupt task is added to the second kernel queue.
[0009] Furthermore, the method also includes: if it is determined that the disk read / write volume threshold has not been exceeded, determining whether the disk read / write volume queue of the first soft interrupt has been processed; if it has been processed, then ending the first soft interrupt task.
[0010] Furthermore, the method also includes: if the disk read / write queue of the first soft interrupt has not been processed, determining whether the disk hardware queue is full; if it is full, then ending the first soft interrupt task.
[0011] Furthermore, the method also includes: if the disk hardware queue is not full, determining whether the number of loops of the first soft interrupt task exceeds a quantity threshold; if it exceeds the quantity threshold, adding the unprocessed first soft interrupt task to the second kernel queue.
[0012] Furthermore, the method also includes: if the quantity threshold is not exceeded, determining whether the execution time of the first soft interrupt task exceeds the time threshold; if the time threshold is exceeded, adding the first soft interrupt task that is also not completed to the second kernel queue.
[0013] Furthermore, the process before the central processing unit's first core processes the first soft interrupt task corresponding to the disk also includes:
[0014] The central processing unit's first core obtains the interrupt number corresponding to the disk controller;
[0015] The list of CPU cores corresponding to the disk is determined based on the CPU core list corresponding to the interrupt number and the interrupt load balancing rules.
[0016] The first core is selected from the list of central processing unit cores to send the interrupt request.
[0017] Furthermore, after selecting the first kernel from the list of central processing unit kernels, the upper half of the interrupt request is processed first. After the upper half is processed, the lower half of the interrupt request is placed in the first kernel queue; the lower half of the interrupt request is the first soft interrupt task.
[0018] The present invention also proposes a system for reducing the probability of soft locking in a system, the system comprising a threshold setting module and a first execution module;
[0019] The threshold setting module is used to set the threshold of disk read / write volume corresponding to the first soft interrupt when the first core of the central processing unit processes the first soft interrupt task corresponding to the disk.
[0020] The first execution module is used to terminate the first soft interrupt task and execute the second soft interrupt task if it determines that the threshold of disk read / write volume has been exceeded, and to add the unprocessed first soft interrupt task to the second kernel queue.
[0021] The present invention also proposes an apparatus comprising:
[0022] Memory, used to store computer programs;
[0023] A processor for implementing the steps of the method when executing the computer program.
[0024] The present invention also proposes a readable storage medium, characterized in that the readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method described.
[0025] The effects described in the invention are merely those of the embodiments, and not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects:
[0026] This invention proposes a method and system for reducing the probability of system soft lock. The method includes setting a threshold for the disk read / write volume corresponding to the first soft interrupt when the first core of the central processing unit (CPU) processes the first soft interrupt task. If the threshold is exceeded, the first soft interrupt task is terminated, a second soft interrupt task is executed, and the unfinished first soft interrupt task is added to the second core queue. If the threshold is not exceeded, the system checks whether the disk read / write volume queue for the first soft interrupt has been processed; if so, the first soft interrupt task is terminated. If the disk read / write volume queue for the first soft interrupt has not been processed, the system checks whether the disk hardware queue is full; if so, the first soft interrupt task is terminated. Based on the method for reducing the probability of system soft lock, this invention also proposes a system for reducing the probability of system soft lock. This invention increases the disk read / write threshold; when the number of disk read / write operations processed by the current soft interrupt exceeds the threshold, the kernel interrupts the current soft interrupt task and allows the kernel to execute the next soft interrupt task. In this application, the kernel calls the kernel interrupt daemon thread to add the unprocessed current soft interrupt to the next CPU kernel queue in the CPU kernel list, so that another CPU kernel can continue to process the disk read / write task. Meanwhile, the CPU kernel switches to process other disk read / write tasks, thereby avoiding the CPU kernel being occupied by high-speed disk read / write tasks for a long time, thus avoiding the occurrence of soft lock, and better adapting to both slow and high-speed disk devices for disk read / write tasks. Attached Figure Description
[0027] like Figure 1 This is a flowchart of a method for reducing the probability of system soft lock according to Embodiment 1 of the present invention;
[0028] like Figure 2 This is a schematic diagram of a system for reducing the probability of soft locking in a system, according to Embodiment 2 of the present invention.
[0029] like Figure 3 This is a schematic diagram of a device connection according to Embodiment 2 of the present invention. Detailed Implementation
[0030] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure of the invention, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components, processing techniques, and processes are omitted in this invention to avoid unnecessarily limiting the invention.
[0031] Example 1
[0032] Embodiment 1 of this invention proposes a method to reduce the probability of system soft lock, which is to reduce the probability of system soft lock by controlling the maximum number of bios that a soft interrupt can handle, where bio (Block IO) refers to disk read and write.
[0033] The server is configured with four Intel SSDs as data disks via direct onboard connection. The operating system Red Hat Enterprise Linux 8.4 is installed, and fio stress tests are performed on the four Intel SSDs. It is found that a softlockup occurs during the fio stress test, causing the system to restart.
[0034] The log is as follows:
[0035] [86268.139854]watchdog:BUG:soft lockup-CPU#48stuck for 22s! [kworker / 48:1H:4068]
[0036] ...
[0037] [86268.264326]Workqueue:kblockd blk_mq_run_work_fn
[0038] [86268.269780]RIP:0010:_raw_spin_unlock_irqrestore+0x11 / 0x20
[0039] ...
[0040] [86268.375458]Call Trace:
[0041] [86268.378486]ata_scsi_queuecmd+0x11c / 0x330[libata]
[0042] [86268.384280]scsi_queue_rq+0x5b3 / 0xa70
[0043] [86268.388776]blk_mq_dispatch_rq_list+0xcd / 0x6f0
[0044] [86268.394145]? elv_rb_del+0x1f / 0x30
[0045] [86268.398372]?deadline_remove_request+0x55 / 0xc0
[0046] [86268.403881]?dd_dispatch_request+0x1ba / 0x230
[0047] [86268.409241]blk_mq_do_dispatch_sched+0x11a / 0x160
[0048] [86268.414915]__blk_mq_sched_dispatch_requests+0xfe / 0x160
[0049] [86268.421262]blk_mq_sched_dispatch_requests+0x30 / 0x60
[0050] [86268.427343]__blk_mq_run_hw_queue+0x51 / 0xd0
[0051] [86268.432522]process_one_work+0x1a7 / 0x360
[0052] [86268.437365]worker_thread+0x30 / 0x390
[0053] [86268.441899]?create_worker+0x1a0 / 0x1a0
[0054] [86268.446648]kthread+0x112 / 0x130
[0055] [86268.450713]?kthread_flush_work_fn+0x10 / 0x10
[0056] [86268.456029]ret_from_fork+0x22 / 0x40
[0057] [86268.460369]Kernel panic-not syncing:softlockup:hung tasks
[0058] [86268.696405]kthread+0x112 / 0x130
[0059] [86268.700272]? kthread_flush_work_fn+0x10 / 0x10
[0060] [86268.705565]ret_from_fork+0x22 / 0x40
[0061] By tracing the execution process of the kernel code, it was found that CPU 48 was continuously executing the bio task corresponding to the SDC disk, while the read and write tasks corresponding to the SDD disk were always in a queued state, and thus a soft lock was generated because they could not be executed.
[0062] Therefore, upon checking the conditions for exiting soft interrupt handling, it was found that the current system will only exit a soft interrupt and execute the next soft interrupt when one of the following four conditions is met.
[0063] (1) The BIOS queue has finished processing; (2) The hard disk hardware queue is full; (3) The number of loop iterations for the soft interrupt has reached the maximum number of loop iterations; (4) The execution time of the soft interrupt has reached the maximum execution time.
[0064] When a soft lock occurs, none of the above four conditions are met for high-speed disk devices. The disk processing speed of the SDC disk is too fast, causing the hard disk hardware queue to be constantly full. As a result, the CPU keeps sending BIOS to the hardware queue corresponding to that disk. The CPU is constantly occupied by the disk BIOS task corresponding to the SDC disk, and the disk read and write tasks of the SDD disk cannot get a chance to be executed.
[0065] To address the above situation, this invention proposes a method to reduce the probability of system soft lock. The method includes the following steps: when the first core of the central processing unit processes the first soft interrupt task corresponding to the disk, a threshold for the disk read / write volume corresponding to the first soft interrupt is set; if it is determined that the disk read / write volume threshold is exceeded, the first soft interrupt task is terminated, the second soft interrupt task is executed, and the unprocessed first soft interrupt task is added to the second core queue.
[0066] If the threshold for disk read / write volume is not exceeded, check whether the disk read / write volume queue of the first soft interrupt has been processed. If it has been processed, terminate the first soft interrupt task.
[0067] If the disk read / write queue of the first soft interrupt has not been completed, check if the disk hardware queue is full. If it is full, terminate the first soft interrupt task.
[0068] like Figure 1 This is a flowchart of a method for reducing the probability of system soft lock according to Embodiment 1 of the present invention;
[0069] In step S100, a disk read / write task is generated;
[0070] In step S101, the first core of the central processing unit obtains the interrupt number corresponding to the disk controller.
[0071] In step S102, the list of CPU cores corresponding to the disk is determined based on the CPU core list corresponding to the interrupt number and the interrupt load balancing rules.
[0072] In step S103, a first core is selected from the list of central processing unit cores to send an interrupt request;
[0073] In step S104, an interrupt request is sent to the first kernel;
[0074] In step S105, after selecting the first core from the CPU core list, the upper half of the interrupt request is processed first.
[0075] In step S106, after the upper half of the processing is completed, the lower half of the interrupt request is placed in the first kernel queue; the lower half of the interrupt request is the first soft interrupt task.
[0076] In step S107, the first kernel processes the first soft interrupt task corresponding to the disk.
[0077] In step S108, a threshold for disk read / write operations corresponding to the first soft interrupt is set; it is determined whether the disk read / write operations of the first soft interrupt task exceed the threshold; if they exceed the threshold, step S109 is executed. If they do not exceed the threshold, step S110 is executed.
[0078] In step S109, the first soft interrupt task is terminated, the second soft interrupt task is executed, and the kernel interrupt daemon thread is called. The kernel interrupt daemon thread executes the following process: the unprocessed first soft interrupt task is added to the second kernel queue.
[0079] In step S110, it is determined whether the disk read / write queue of the first soft interrupt has been processed. If it has been processed, step S111 is executed; otherwise, step S112 is executed.
[0080] In step S111, the first soft interrupt task is terminated, and the first kernel executes the second interrupt task.
[0081] In step S112, it is determined whether the hardware queue of the disk is full. If it is full, step S111 is executed; otherwise, step S113 is executed.
[0082] In step S113, it is determined whether the number of loops of the first soft interrupt task exceeds the quantity threshold. If it exceeds the quantity threshold, step S114 is executed; otherwise, step S115 is executed.
[0083] In step S114, the kernel interrupt daemon thread is invoked to add the unprocessed first soft interrupt task to the second kernel queue.
[0084] In step S115, it is determined whether the execution time of the first soft interrupt task exceeds the time threshold, and then step S114 is executed.
[0085] This application proposes a method to reduce the probability of system soft locks. This method involves increasing the bio threshold MAX_BIO_NUM in the kernel. When the number of bios processed by a soft interrupt reaches the bio threshold (MAX_BIO_NUM), the kernel terminates the soft interrupt, and the CPU core executes the next soft interrupt. The kernel then calls the kernel interrupt daemon thread to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list. Another CPU core continues to handle the disk read / write task, while the CPU core that was previously occupied by the soft interrupt handles another disk read / write task. This prevents the CPU core from being occupied by the disk read / write task for an extended period, thus avoiding soft locks.
[0086] In addition, to ensure that the operating system can effectively avoid soft locks when handling read and write operations on both high-speed and slow disk devices, when the number of bios handled by a soft interrupt does not reach the bio threshold (MAX_BIO_NUM), that is, when the disk processing speed is lower than the CPU and kernel processing speed, two conditions are added to check whether the queue has been processed and whether the hard disk hardware queue is full. If either condition is met, the soft interrupt is terminated, and the CPU core is allowed to execute the next soft interrupt.
[0087] If none of the above conditions are met, and the loop count of the soft interrupt reaches the maximum loop count (MAX_SOFTIRQ_NUM), or the execution time of the soft interrupt reaches the maximum execution time (MAX_SOFTIRQ_TIME), then the soft interrupt will also end, allowing the CPU core to execute the next soft interrupt; at the same time, the kernel interrupt daemon thread will be called to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list, so that another CPU core can continue to perform read and write tasks on the disk.
[0088] This ensures that both high-speed and low-speed disk devices can exit the soft interrupt within the soft lock threshold time, allowing other tasks to have a chance to execute, thereby avoiding the occurrence of soft lock.
[0089] Therefore, Embodiment 1 of this invention proposes a method to reduce the probability of system soft lock. The proposed method is to increase the disk read / write threshold. When the number of disk reads and writes in the current soft interrupt processing exceeds the threshold, the kernel interrupts the current soft interrupt task and lets the kernel execute the next soft interrupt task.
[0090] In the method for reducing the probability of system soft lock proposed in Embodiment 1 of this invention, the kernel calls the kernel interrupt daemon thread to add the unprocessed current soft interrupt to the next CPU kernel queue in the CPU kernel list, so that another CPU kernel can continue to process the disk read / write task, while the CPU kernel switches to process other disk read / write tasks. This avoids the CPU kernel being occupied by high-speed disk read / write tasks for a long time, thereby avoiding the occurrence of soft lock and better adapting to both slow and high-speed disk devices for disk read / write tasks.
[0091] Example 2
[0092] Based on the method for reducing the probability of soft locking in a system proposed in Embodiment 1 of this invention, Embodiment 2 of this invention proposes a system for reducing the probability of soft locking in a system, such as... Figure 2 This is a schematic diagram of a system for reducing the probability of system soft lock according to Embodiment 2 of the present invention. The system includes a threshold setting module and a first execution module.
[0093] The threshold setting module is used to set the threshold for disk read / write operations corresponding to the first soft interrupt when the first core of the central processing unit processes the first soft interrupt task corresponding to the disk.
[0094] The first execution module is used to terminate the first soft interrupt task and execute the second soft interrupt task if it determines that the disk read / write threshold has been exceeded, and to add the unprocessed first soft interrupt task to the second kernel queue.
[0095] The system also includes: a second execution module that, if the disk read / write threshold is not exceeded, determines whether the disk read / write queue of the first soft interrupt has been processed; if processed, the first soft interrupt task is terminated. If the disk read / write queue of the first soft interrupt has not been processed, it determines whether the disk hardware queue is full; if full, the first soft interrupt task is terminated.
[0096] The system also includes a third execution module: if the disk hardware queue is not full, the third execution module determines whether the number of loops of the first soft interrupt task exceeds the quantity threshold. If the quantity threshold is exceeded, the unprocessed first soft interrupt task is added to the second kernel queue.
[0097] The system also includes a fourth execution module, which is used to determine whether the execution time of the first soft interrupt task exceeds the time threshold if the quantity threshold is not exceeded. If the time threshold is exceeded, the first soft interrupt task that is also not completed is added to the second kernel queue.
[0098] The system also includes a preprocessing module. The preprocessing module's process includes: before the CPU's first core processes the first soft interrupt task corresponding to the disk, the CPU's first core obtains the interrupt number corresponding to the disk controller; determines the CPU core list corresponding to the disk based on the CPU core list corresponding to the interrupt number and interrupt load balancing rules; and selects a first core from the CPU core list to send the interrupt request. After selecting the first core from the CPU core list, the upper half of the interrupt request is processed first. After the upper half is processed, the lower half of the interrupt request is placed in the first core queue; the lower half of the interrupt request is the first soft interrupt task.
[0099] The system proposed in Embodiment 2 of this invention reduces the probability of system soft lock. By increasing the bio threshold MAX_BIO_NUM in the kernel, when the number of bios processed by a soft interrupt reaches the bio threshold (MAX_BIO_NUM), the kernel terminates the soft interrupt, and the CPU core executes the next soft interrupt. The kernel calls the kernel interrupt daemon thread to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list. Another CPU core continues to process the disk read / write task, while the current CPU core switches to handle other disk read / write tasks, thus preventing the CPU core from being occupied by the disk read / write task for a long time and avoiding soft lock.
[0100] In addition, to ensure that the operating system can effectively avoid soft locks when handling read and write operations on both high-speed and slow disk devices, when the number of bios handled by a soft interrupt does not reach the bio threshold (MAX_BIO_NUM), that is, when the disk processing speed is lower than the CPU and kernel processing speed, two conditions are added to check whether the queue has been processed and whether the hard disk hardware queue is full. If either condition is met, the soft interrupt is terminated, and the CPU core is allowed to execute the next soft interrupt.
[0101] If none of the above conditions are met, and the loop count of the soft interrupt reaches the maximum loop count (MAX_SOFTIRQ_NUM), or the execution time of the soft interrupt reaches the maximum execution time (MAX_SOFTIRQ_TIME), then the soft interrupt will also end, allowing the CPU core to execute the next soft interrupt; at the same time, the kernel interrupt daemon thread will be called to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list, so that another CPU core can continue to perform read and write tasks on the disk.
[0102] This ensures that both high-speed and low-speed disk devices can exit the soft interrupt within the soft lock threshold time, allowing other tasks to have a chance to execute, thereby avoiding the occurrence of soft lock.
[0103] Therefore, Embodiment 2 of this invention proposes a system to reduce the probability of system soft lock. The system proposes to increase the disk read / write threshold. When the number of disk reads and writes in the current soft interrupt processing exceeds the threshold, the kernel interrupts the current soft interrupt task and lets the kernel execute the next soft interrupt task.
[0104] The present invention, in embodiment 2, proposes a method to reduce the probability of system soft lock by having the kernel call the kernel interrupt daemon thread in the system. The unprocessed current soft interrupt is added to the next CPU kernel queue in the CPU kernel list, so that another CPU kernel can continue to process the disk read / write task. Meanwhile, the CPU kernel that was previously processing the soft interrupt is now processing another disk read / write task. This avoids the CPU kernel being occupied by high-speed disk read / write tasks for a long time, thereby preventing soft lock from occurring. This method can better adapt to both slow and high-speed disk devices for disk read / write tasks.
[0105] Example 3
[0106] The present invention also proposes a device, such as Figure 3 The diagram shown is a schematic representation of an electronic device connection according to Embodiment 3 of the present invention, including:
[0107] Memory, used to store computer programs;
[0108] When a processor executes the computer program, the method steps are as follows:
[0109] like Figure 1 This is a flowchart of a method for reducing the probability of system soft lock according to Embodiment 1 of the present invention;
[0110] In step S100, a disk read / write task is generated;
[0111] In step S101, the first core of the central processing unit obtains the interrupt number corresponding to the disk controller.
[0112] In step S102, the list of CPU cores corresponding to the disk is determined based on the CPU core list corresponding to the interrupt number and the interrupt load balancing rules.
[0113] In step S103, a first core is selected from the list of central processing unit cores to send an interrupt request;
[0114] In step S104, an interrupt request is sent to the first kernel;
[0115] In step S105, after selecting the first core from the CPU core list, the upper half of the interrupt request is processed first.
[0116] In step S106, after the upper half of the processing is completed, the lower half of the interrupt request is placed in the first kernel queue; the lower half of the interrupt request is the first soft interrupt task.
[0117] In step S107, the first kernel processes the first soft interrupt task corresponding to the disk.
[0118] In step S108, a threshold for disk read / write operations corresponding to the first soft interrupt is set; it is determined whether the disk read / write operations of the first soft interrupt task exceed the threshold; if they exceed the threshold, step S109 is executed. If they do not exceed the threshold, step S110 is executed.
[0119] In step S109, the first soft interrupt task is terminated, the second soft interrupt task is executed, and the kernel interrupt daemon thread is called. The kernel interrupt daemon thread executes the following process: the unprocessed first soft interrupt task is added to the second kernel queue.
[0120] In step S110, it is determined whether the disk read / write queue of the first soft interrupt has been processed. If it has been processed, step S111 is executed; otherwise, step S112 is executed.
[0121] In step S111, the first soft interrupt task is terminated, and the first kernel executes the second interrupt task.
[0122] In step S112, it is determined whether the hardware queue of the disk is full. If it is full, step S111 is executed; otherwise, step S113 is executed.
[0123] In step S113, it is determined whether the number of loops of the first soft interrupt task exceeds the quantity threshold. If it exceeds the quantity threshold, step S114 is executed; otherwise, step S115 is executed.
[0124] In step S114, the kernel interrupt daemon thread is invoked to add the unprocessed first soft interrupt task to the second kernel queue.
[0125] In step S115, it is determined whether the execution time of the first soft interrupt task exceeds the time threshold, and then step S114 is executed.
[0126] This application proposes a method to reduce the probability of system soft locks. This method involves increasing the bio threshold MAX_BIO_NUM in the kernel. When the number of bios processed by a soft interrupt reaches the bio threshold (MAX_BIO_NUM), the kernel terminates the soft interrupt, and the CPU core executes the next soft interrupt. The kernel then calls the kernel interrupt daemon thread to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list. Another CPU core continues to handle the disk read / write task, while the CPU core that was previously occupied by the soft interrupt handles another disk read / write task. This prevents the CPU core from being occupied by the disk read / write task for an extended period, thus avoiding soft locks.
[0127] In addition, to ensure that the operating system can effectively avoid soft locks when handling read and write operations on both high-speed and slow disk devices, when the number of bios handled by a soft interrupt does not reach the bio threshold (MAX_BIO_NUM), that is, when the disk processing speed is lower than the CPU and kernel processing speed, two conditions are added to check whether the queue has been processed and whether the hard disk hardware queue is full. If either condition is met, the soft interrupt is terminated, and the CPU core is allowed to execute the next soft interrupt.
[0128] If none of the above conditions are met, and the loop count of the soft interrupt reaches the maximum loop count (MAX_SOFTIRQ_NUM), or the execution time of the soft interrupt reaches the maximum execution time (MAX_SOFTIRQ_TIME), then the soft interrupt will also end, allowing the CPU core to execute the next soft interrupt; at the same time, the kernel interrupt daemon thread will be called to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list, so that another CPU core can continue to perform read and write tasks on the disk.
[0129] This ensures that both high-speed and low-speed disk devices can exit the soft interrupt within the soft lock threshold time, allowing other tasks to have a chance to execute, thereby avoiding the occurrence of soft lock.
[0130] Therefore, in the electronic device proposed in Embodiment 3 of the present invention, by increasing the disk read / write threshold, when the number of disk read / write operations in the current soft interrupt processing exceeds the threshold, the kernel interrupts the current soft interrupt task and allows the kernel to execute the next soft interrupt task.
[0131] The third embodiment of this invention proposes an electronic device in which the kernel calls the kernel interrupt daemon thread to add the unprocessed current soft interrupt to the next CPU kernel queue in the CPU kernel list, so that another CPU kernel can continue to process the disk read / write task, while the current CPU kernel switches to process other disk read / write tasks. This avoids the CPU kernel being occupied by high-speed disk read / write tasks for a long time, thereby avoiding the occurrence of soft lock and better adapting to both slow and high-speed disk devices for disk read / write tasks.
[0132] It should be noted that the present invention also provides an electronic device, including: a communication interface capable of interacting with other devices such as network devices; and a processor connected to the communication interface to enable information interaction with other devices, used to execute a method for reducing the probability of system soft lock provided by one or more of the above technical solutions when running a computer program, wherein the computer program is stored in a memory. Of course, in practical applications, the various components in the electronic device are coupled together through a bus system. It is understood that the bus system is used to realize the connection and communication between these components. In addition to a data bus, the bus system also includes a power bus, a control bus, and a status signal bus. The memory in the embodiments of this application is used to store various types of data to support the operation of the electronic device. Examples of this data include any computer program used to operate on the electronic device. It is understood that the memory can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache.By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM). The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memory. The methods disclosed in the embodiments of this application can be applied to or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by integrated logic circuits in the processor hardware or by instructions in software. The processor can be a general-purpose processor, a DSP (Digital Signal Processing, i.e., a chip capable of implementing digital signal processing technology), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in a storage medium, which is located in memory. The processor reads the program from the memory and, in conjunction with its hardware, completes the steps of the aforementioned method. When the processor executes the program, it implements the corresponding processes in the various methods of the embodiments of this application; for simplicity, these will not be elaborated further here.
[0133] Example 4
[0134] The present invention also proposes a readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the following method steps:
[0135] like Figure 1 This is a flowchart of a method for reducing the probability of system soft lock according to Embodiment 1 of the present invention;
[0136] In step S100, a disk read / write task is generated;
[0137] In step S101, the first core of the central processing unit obtains the interrupt number corresponding to the disk controller.
[0138] In step S102, the list of CPU cores corresponding to the disk is determined based on the CPU core list corresponding to the interrupt number and the interrupt load balancing rules.
[0139] In step S103, a first core is selected from the list of central processing unit cores to send an interrupt request;
[0140] In step S104, an interrupt request is sent to the first kernel;
[0141] In step S105, after selecting the first core from the CPU core list, the upper half of the interrupt request is processed first.
[0142] In step S106, after the upper half of the processing is completed, the lower half of the interrupt request is placed in the first kernel queue; the lower half of the interrupt request is the first soft interrupt task.
[0143] In step S107, the first kernel processes the first soft interrupt task corresponding to the disk.
[0144] In step S108, a threshold for disk read / write operations corresponding to the first soft interrupt is set; it is determined whether the disk read / write operations of the first soft interrupt task exceed the threshold; if they exceed the threshold, step S109 is executed. If they do not exceed the threshold, step S110 is executed.
[0145] In step S109, the first soft interrupt task is terminated, the second soft interrupt task is executed, and the kernel interrupt daemon thread is called. The kernel interrupt daemon thread executes the following process: the unprocessed first soft interrupt task is added to the second kernel queue.
[0146] In step S110, it is determined whether the disk read / write queue of the first soft interrupt has been processed. If it has been processed, step S111 is executed; otherwise, step S112 is executed.
[0147] In step S111, the first soft interrupt task is terminated, and the first kernel executes the second interrupt task.
[0148] In step S112, it is determined whether the hardware queue of the disk is full. If it is full, step S111 is executed; otherwise, step S113 is executed.
[0149] In step S113, it is determined whether the number of loops of the first soft interrupt task exceeds the quantity threshold. If it exceeds the quantity threshold, step S114 is executed; otherwise, step S115 is executed.
[0150] In step S114, the kernel interrupt daemon thread is invoked to add the unprocessed first soft interrupt task to the second kernel queue.
[0151] In step S115, it is determined whether the execution time of the first soft interrupt task exceeds the time threshold, and then step S114 is executed.
[0152] This application proposes a method to reduce the probability of system soft locks. This method involves increasing the bio threshold MAX_BIO_NUM in the kernel. When the number of bios processed by a soft interrupt reaches the bio threshold (MAX_BIO_NUM), the kernel terminates the soft interrupt, and the CPU core executes the next soft interrupt. The kernel then calls the kernel interrupt daemon thread to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list. Another CPU core continues to handle the disk read / write task, while the CPU core that was previously occupied by the soft interrupt handles another disk read / write task. This prevents the CPU core from being occupied by the disk read / write task for an extended period, thus avoiding soft locks.
[0153] In addition, to ensure that the operating system can effectively avoid soft locks when handling read and write operations on both high-speed and slow disk devices, when the number of bios handled by a soft interrupt does not reach the bio threshold (MAX_BIO_NUM), that is, when the disk processing speed is lower than the CPU and kernel processing speed, two conditions are added to check whether the queue has been processed and whether the hard disk hardware queue is full. If either condition is met, the soft interrupt is terminated, and the CPU core is allowed to execute the next soft interrupt.
[0154] If none of the above conditions are met, and the loop count of the soft interrupt reaches the maximum loop count (MAX_SOFTIRQ_NUM), or the execution time of the soft interrupt reaches the maximum execution time (MAX_SOFTIRQ_TIME), then the soft interrupt will also end, allowing the CPU core to execute the next soft interrupt; at the same time, the kernel interrupt daemon thread will be called to add the unprocessed soft interrupt to the next CPU core queue in the CPU core list, so that another CPU core can continue to perform read and write tasks on the disk.
[0155] This ensures that both high-speed and low-speed disk devices can exit the soft interrupt within the soft lock threshold time, allowing other tasks to have a chance to execute, thereby avoiding the occurrence of soft lock.
[0156] Therefore, in Embodiment 4 of this invention, a storage medium is proposed that by increasing the disk read / write threshold, when the number of disk reads and writes in the current soft interrupt processing exceeds the threshold, the kernel interrupts the current soft interrupt task and allows the kernel to execute the next soft interrupt task.
[0157] The present invention, in embodiment 3, proposes a method in which the kernel calls the kernel interrupt daemon thread in the storage medium to add the unprocessed current soft interrupt to the next CPU kernel queue in the CPU kernel list, so that another CPU kernel can continue to process the disk read / write task, while the CPU kernel switches to process other disk read / write tasks. This avoids the CPU kernel being occupied by high-speed disk read / write tasks for a long time, thereby avoiding the occurrence of soft lock and better adapting to both slow and high-speed disk devices for disk read / write tasks.
[0158] This application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory that stores a computer program, which can be executed by a processor to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0159] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks. Alternatively, if the integrated units of this application are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0160] For a description of the relevant parts of the processing device and storage medium for reducing the probability of system soft lock provided in the embodiments of this application, please refer to the detailed description of the corresponding parts in the method for reducing the probability of system soft lock provided in Embodiment 1 of this application, and will not be repeated here.
[0161] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that the elements inherent in a process, method, article, or apparatus that includes a list of elements are included. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Additionally, portions of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.
[0162] While specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art can make other modifications or variations based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method of reducing system soft lock probability, the method comprising: The method comprises the following steps: setting a threshold of disk read / write volume corresponding to the first soft interrupt when the first kernel of the central processing unit processes the first soft interrupt task corresponding to the disk; if it is judged that the threshold of disk read / write volume is exceeded, ending the first soft interrupt task, executing a second soft interrupt task, and adding the first soft interrupt task which is not processed into the second kernel queue; the method further comprises: if it is judged that the threshold of disk read / write volume is not exceeded, judging whether the disk read / write volume queue of the first soft interrupt is processed, and if yes, ending the first soft interrupt task; the method further comprises: if the disk read / write volume queue of the first soft interrupt is not processed, judging whether the hardware queue of the disk is full, and if yes, ending the first soft interrupt task; the method further comprises: if the hardware queue of the disk is not full, judging whether the number of times of the first soft interrupt task exceeds a number threshold, and if yes, adding the first soft interrupt task which is not processed into the second kernel queue; the method further comprises: if the number of times of the first soft interrupt task does not exceed the number threshold, judging whether the execution time of the first soft interrupt task exceeds a time threshold, and if yes, adding the first soft interrupt task which is not processed into the second kernel queue.
2. The method of claim 1, wherein, The method further comprises the following steps before the first kernel of the central processing unit processes the first soft interrupt task corresponding to the disk: the first kernel of the central processing unit acquires an interrupt number corresponding to the disk controller; determining a central processing unit kernel list corresponding to the disk according to the interrupt number and an interrupt load balancing rule; selecting the first kernel from the central processing unit kernel list for sending an interrupt request.
3. The method of claim 2, wherein, After the first kernel is selected from the central processing unit kernel list, the upper half of the interrupt request is processed first, and after the upper half processing is completed, the lower half of the interrupt request is put into the first kernel queue; the lower half of the interrupt request is the first soft interrupt task.
4. A system for reducing the probability of system soft lock for performing the method for reducing the probability of system soft lock according to any one of claims 1 to 3, characterized in that The system comprises a threshold setting module and a first execution module; the threshold setting module is used for setting a threshold of disk read / write volume corresponding to the first soft interrupt when the first kernel of the central processing unit processes the first soft interrupt task corresponding to the disk; the first execution module is used for ending the first soft interrupt task, executing a second soft interrupt task, and adding the first soft interrupt task which is not processed into the second kernel queue if it is judged that the threshold of disk read / write volume is exceeded.
5. An apparatus, comprising: The method comprises the following steps: a memory for storing a computer program; a processor for executing the computer program to realize the method steps of any one of claims 1 to 3.
6. A readable storage medium, characterized by, The computer program is stored on the readable storage medium, and the computer program is executed by the processor to realize the method steps of any one of claims 1 to 3.
Citation Information
Patent Citations
Method for real-time operating system to avoid interrupt occupying excess CPU resources
CN101276295A
Interrupt control method and interrupt control device for SSD (solid state disk) control chip and SSD device
CN107273198A