A method and computing device for analyzing deadlock faults.

By registering callback functions in the watchdog service, lock information can be automatically obtained, solving the problem of low efficiency in manual analysis by operations engineers, improving the efficiency and accuracy of lock information acquisition, and enhancing security and reliability.

CN119669018BActive Publication Date: 2026-11-17XFUSION DIGITAL TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411737750.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2026-11-17
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

In existing technologies, the efficiency and accuracy of operations and maintenance engineers manually analyzing memory image files to obtain lock information are low, and there are also security and reliability issues.

Method used

Register callback functions in the watchdog service to automatically obtain lock information, including lock data structure information, CPU request order and call stack information, and save it to the log file to achieve architectural decoupling.

Benefits of technology

It improves the efficiency and accuracy of lock information acquisition, reduces resource consumption, enhances security and reliability, and avoids impacting operating system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669018B_ABST
    Figure CN119669018B_ABST
Patent Text Reader

Abstract

This application provides a method and computing device for analyzing deadlock faults. The method includes: the computing device running a watchdog service; when a fault is detected in the operating system, calling a callback function to obtain lock information; the computing device saving the lock information to a log file to analyze the deadlock fault based on the lock information in the log file. Alternatively, the computing device queries a memory image file to obtain and display the lock information. The memory image file is obtained from a kernel crash dump service, which saves and processes the memory data at the time of the operating system fault when a fault is detected. The lock information includes: lock data structure information, the request order of at least one CPU for using the lock, and the call stack information corresponding to at least one CPU. The method of this application improves the efficiency and accuracy of lock information acquisition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computing device technology, and in particular to a method for analyzing deadlock faults and a computing device. Background Technology

[0002] In related technologies, the watchdog service can trigger a kernel crash dump service (kdump service) when an operating system failure is detected, saving the memory data at the time of the operating system failure as a memory image file (vmcore file). Operations engineers then need to manually analyze the memory image file using analysis programs (such as crash tools) to obtain lock information.

[0003] In related technologies, operations engineers need to manually use analysis programs to obtain lock information based on massive memory image files, which may result in low efficiency and accuracy. Summary of the Invention

[0004] This application provides a deadlock fault analysis method and computing device, which improves the efficiency and accuracy of lock information acquisition.

[0005] In a first aspect, embodiments of this application provide a method for analyzing deadlock faults, including:

[0006] The watchdog service runs and, when an operating system failure is detected, calls a callback function to obtain lock information. The lock information includes: the lock's data structure information, the order in which at least one CPU requested to use the lock, and the call stack information corresponding to at least one CPU.

[0007] Lock information is saved to a log file so that deadlock failures can be analyzed based on the lock information in the log file.

[0008] In this scheme, the computing device can run a watchdog service to monitor the operating system for faults. When a fault is detected in the operating system, a callback function is invoked to acquire lock information. On one hand, compared to related technologies where maintenance engineers need to manually obtain lock information using analysis programs based on massive memory image files, which may result in low efficiency and accuracy, the method in this embodiment registers a callback function on the watchdog service's call chain. This allows the callback function to be executed in response to watchdog service calls to acquire lock information when the operating system malfunctions, improving the efficiency and accuracy of lock information acquisition. On the other hand, the callback function in this embodiment acquires lock information based on watchdog service calls when the operating system malfunctions. When the operating system is functioning normally, no lock information acquisition is required, reducing operating system resource overhead and avoiding impact on operating system performance. Furthermore, the callback function in this embodiment can be a separate module. When lock information needs to be acquired using the callback function, it is registered on the watchdog service's notification chain, achieving architectural decoupling and ensuring the portability of the callback function. On the other hand, compared to related technologies that require the use of a kernel crash dump service (kdump service) with poor reliability to generate memory image files, and require the use of analysis programs (such as crash tools) to obtain and analyze memory image files that may contain sensitive information, resulting in poor security and reliability, the method of this application embodiment can use callback functions registered on the notification chain of the watchdog service to automatically obtain lock information, thereby improving the efficiency and security of lock information acquisition.

[0009] In one implementation, obtaining lock information includes:

[0010] Read the target register to obtain the lock address; the target register is the register that stores the lock address.

[0011] Based on the lock address, obtain the lock's data structure information;

[0012] The order of requests is determined based on the lock's data structure information;

[0013] Based on the order of requests, obtain the call stack information corresponding to at least one CPU.

[0014] In this scheme, the computing device can run a callback function to read the target register (the register storing the lock address), obtain the lock address, and retrieve the lock's data structure information based on the lock address. The computing device can then run the callback function to determine the request order based on the lock's data structure information and, according to the request order, obtain the call stack information corresponding to at least one CPU. This method enables the callback function to obtain lock information, improving the efficiency and accuracy of lock information retrieval.

[0015] In one implementation, the method further includes the following before acquiring the lock information:

[0016] Obtain the call stack information corresponding to the target CPU; wherein, the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails;

[0017] It is determined that the call information of at least one function contains the call information of a target function; the target function is the call function used to acquire the lock.

[0018] In this scheme, the computing device can determine that the lock information acquisition condition is met if the target function's call information is present in at least one function's call information. In other words, it can determine that the operating system malfunction is caused by a lock. The computing device can then acquire the lock information if the lock information acquisition condition is met. By setting the lock information acquisition condition as described above, the utilization rate of lock information can be improved.

[0019] In one implementation, the request order is determined based on the lock's data structure information, including:

[0020] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0021] Determine if the first CPU holds the lock;

[0022] If so, then the application order should only include the identifier of the first CPU;

[0023] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0024] In this scheme, the computing device can determine that only the first CPU (the last CPU to request the lock) is requesting the lock if it holds the lock; that is, the request order is determined solely by the identifier of the first CPU. If the first CPU does not hold the lock, the computing device can determine that other CPUs are requesting the lock, and can perform at least one CPU lookup process to obtain the request order. This method accurately identifies the identifier of each CPU in the request order, improving the accuracy of determining the request order.

[0025] In one implementation, at least one CPU lookup operation is performed, including:

[0026] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0027] Determine if the (i+1)th CPU holds the lock;

[0028] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0029] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0030] In this scheme, based on the address information of the data structure corresponding to the (i+1)th CPU, the computing device can perform a lookup process using the address information of the data structure corresponding to the i-th CPU to obtain the (i+1)th CPU. If the (i+1)th CPU holds the lock, the computing device can determine that the (i+1)th CPU's lock request order is before that of the i-th CPU and end the CPU lookup operation; if the (i+1)th CPU does not hold the lock, the computing device can determine that the (i+1)th CPU's lock request order is before that of the i-th CPU. Through this method, accurate lookup of each CPU requesting a lock is achieved, thus improving the accuracy of determining the request order.

[0031] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the method also includes:

[0032] A deadlock is identified when the lock status indicates that the lock is held, and the waiting-to-hold status indicates that there is a CPU requesting to use the lock but not holding it.

[0033] In this scheme, the computing device can determine that a deadlock fault exists when the lock status indicates that the lock is held and the waiting-to-hold status indicates that there is a CPU requesting use but not holding the lock. This method improves the accuracy of determining whether a deadlock fault exists in the operating system. In other words, it improves the accuracy of determining the type of operating system fault (deadlock fault).

[0034] In one implementation, the method also includes:

[0035] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0036] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0037] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0038] In this scheme, the computing device can determine, based on lock information, whether the process corresponding to the second CPU is abnormal, or whether the function call relationship of the process corresponding to the second CPU is abnormal, or whether the function call relationship of the process corresponding to at least one CPU is abnormal. This improves the accuracy of deadlock fault analysis.

[0039] Secondly, embodiments of this application provide a method for analyzing deadlock faults, including:

[0040] The memory image file is queried to obtain lock information. The memory image file is a kernel crash dump service that saves and processes the memory data at the time of the operating system failure when a failure is detected. The lock information includes: the lock data structure information, the request order of at least one CPU to use the lock, and the call stack information of at least one CPU.

[0041] Display lock information to analyze deadlock faults based on the lock information.

[0042] In this scheme, the computing device can obtain lock information by querying the memory image file. On the one hand, compared to related technologies where maintenance engineers need to manually use analysis programs and multiple commands to obtain lock information based on a large amount of data in the memory image file, which may result in low efficiency and accuracy, the method of this application embodiment can directly and automatically query the memory image file to obtain lock information, thereby improving the efficiency, accuracy, and security of determining lock information.

[0043] In one implementation, the memory image file is queried to obtain lock information, including:

[0044] Query the memory image file to determine the target register in the target CPU; the target CPU is the CPU running when the operating system fails; the target register is the register that stores the lock address.

[0045] Read the target register to obtain the lock address;

[0046] Based on the lock address, obtain the lock's data structure information;

[0047] The order of requests is determined based on the lock's data structure information;

[0048] Based on the order of application, query the memory image file to obtain the call stack information corresponding to at least one CPU.

[0049] In this scheme, the computing device can determine the target register by querying the memory image file. The computing device can read the target register, obtain the lock address, and retrieve the lock's data structure information based on the lock address. The computing device can then determine the request order based on the lock's data structure information and, according to the request order, query the memory image file to obtain the call stack information corresponding to at least one CPU. This method achieves an ordered search of the memory image file, enabling rapid retrieval of lock information and improving the efficiency and accuracy of lock information acquisition.

[0050] In one implementation, the method further includes the following before acquiring the lock information:

[0051] Obtain the call stack information corresponding to the target CPU; wherein, the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails;

[0052] It is determined that the call information of at least one function contains the call information of a target function; the target function is the call function used to acquire the lock.

[0053] In this scheme, the computing device can determine that the lock information acquisition condition is met if the target function's call information is present in at least one function's call information. In other words, it can determine that the operating system malfunction is caused by a lock. The computing device can then acquire the lock information if the lock information acquisition condition is met. By setting the lock information acquisition condition as described above, the utilization rate of lock information can be improved.

[0054] In one implementation, the request order is determined based on the lock's data structure information, including:

[0055] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0056] Determine if the first CPU holds the lock;

[0057] If so, then the application order should only include the identifier of the first CPU;

[0058] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0059] In this scheme, the computing device can determine that only the first CPU (the last CPU to request the lock) is requesting the lock if it holds the lock; that is, the request order is determined solely by the identifier of the first CPU. If the first CPU does not hold the lock, the computing device can determine that other CPUs are requesting the lock, and can perform at least one CPU lookup process to obtain the request order. This method accurately identifies the identifier of each CPU in the request order, improving the accuracy of determining the request order.

[0060] In one implementation, at least one CPU lookup operation is performed, including:

[0061] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0062] Determine if the (i+1)th CPU holds the lock;

[0063] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0064] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0065] In this scheme, based on the address information of the data structure corresponding to the (i+1)th CPU, the computing device can perform a lookup process using the address information of the data structure corresponding to the i-th CPU to obtain the (i+1)th CPU. If the (i+1)th CPU holds the lock, the computing device can determine that the (i+1)th CPU's lock request order is before that of the i-th CPU and end the CPU lookup operation; if the (i+1)th CPU does not hold the lock, the computing device can determine that the (i+1)th CPU's lock request order is before that of the i-th CPU. Through this method, accurate lookup of each CPU requesting a lock is achieved, thus improving the accuracy of determining the request order.

[0066] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the method also includes:

[0067] A deadlock is identified when the lock status indicates that the lock is held, and the waiting-to-hold status indicates that there is a CPU requesting to use the lock but not holding it.

[0068] In this scheme, the computing device can determine that a deadlock fault exists when the lock status indicates that the lock is held and the waiting-to-hold status indicates that there is a CPU requesting use but not holding the lock. This method improves the accuracy of determining whether a deadlock fault exists in the operating system. In other words, it improves the accuracy of determining the type of operating system fault (deadlock fault).

[0069] In one implementation, the method also includes:

[0070] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0071] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0072] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0073] In this scheme, the computing device can determine, based on lock information, whether the process corresponding to the second CPU is abnormal, or whether the function call relationship of the process corresponding to the second CPU is abnormal, or whether the function call relationship of the process corresponding to at least one CPU is abnormal. This improves the accuracy of deadlock fault analysis.

[0074] Thirdly, embodiments of this application provide a deadlock fault analysis apparatus, comprising:

[0075] The watchdog service is used to retrieve lock information by calling a callback function when a fault is detected in the operating system. The lock information includes: the lock's data structure information, the order in which at least one CPU requested to use the lock, and the call stack information corresponding to at least one CPU.

[0076] The callback function is used to save lock information to a log file so that deadlock failures can be analyzed based on the lock information in the log file.

[0077] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0078] In one implementation, the callback function includes:

[0079] The lock data structure analysis module is used to read the target register and obtain the lock address; the target register is the register that stores the lock address.

[0080] The lock data structure analysis module is used to obtain the lock's data structure information based on the lock address.

[0081] The lock queue analysis module is used to determine the request order based on the lock's data structure information;

[0082] The CPU call stack recording module is used to obtain call stack information corresponding to at least one CPU according to the request order.

[0083] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0084] One implementation also includes:

[0085] The scenario analysis module is used to obtain the call stack information corresponding to the target CPU; the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails.

[0086] The scenario analysis module is also used to determine that at least one function's call information contains the call information of a target function; the target function is the call function used to acquire the lock.

[0087] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0088] In one implementation, the lock queue analysis module is specifically used for:

[0089] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0090] Determine if the first CPU holds the lock;

[0091] If so, then the application order should only include the identifier of the first CPU;

[0092] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0093] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0094] In one implementation, the lock queue analysis module is specifically used for:

[0095] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0096] Determine if the (i+1)th CPU holds the lock;

[0097] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0098] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0099] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0100] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the callback function also includes:

[0101] The fault analysis module is used to determine if a deadlock fault exists when the lock status indicates that the lock is held and the waiting-to-hold status indicates that there is a CPU requesting to use the lock but not holding it.

[0102] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0103] In one implementation, the fault analysis module is also used for:

[0104] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0105] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0106] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0107] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0108] Fourthly, embodiments of this application provide a lock analysis plugin for:

[0109] The memory image file is queried to obtain lock information. The memory image file is a kernel crash dump service that saves and processes the memory data at the time of the operating system failure when a failure is detected. The lock information includes: the lock data structure information, the request order of at least one CPU to use the lock, and the call stack information of at least one CPU.

[0110] Display lock information to analyze deadlock faults based on the lock information.

[0111] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0112] In one implementation, the lock analysis plugin includes:

[0113] The lock data structure analysis module is used to query the memory image file and determine the target register in the target CPU; the target CPU is the CPU running when the operating system fails; the target register is the register that stores the lock address.

[0114] The lock data structure analysis module is used to read the target register and obtain the lock address;

[0115] The lock data structure analysis module is used to obtain the lock's data structure information based on the lock address.

[0116] The lock queue analysis module is used to determine the request order based on the lock's data structure information;

[0117] The CPU call stack recording module is used to query the memory image file according to the request order and obtain the call stack information corresponding to at least one CPU.

[0118] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0119] One implementation also includes:

[0120] The scenario analysis module is used to obtain the call stack information corresponding to the target CPU; the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails.

[0121] The scenario analysis module is also used to determine that at least one function's call information contains the call information of a target function; the target function is the call function used to acquire the lock.

[0122] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0123] In one implementation, the lock queue analysis module is specifically used for:

[0124] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0125] Determine if the first CPU holds the lock;

[0126] If so, then the application order should only include the identifier of the first CPU;

[0127] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0128] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0129] In one implementation, the lock queue analysis module is specifically used for:

[0130] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0131] Determine if the (i+1)th CPU holds the lock;

[0132] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0133] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0134] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0135] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the lock analysis plugin also includes:

[0136] The fault analysis module is used to determine if a deadlock fault exists when the lock status indicates that the lock is held and the waiting-to-hold status indicates that there is a CPU requesting to use the lock but not holding it.

[0137] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0138] In one implementation, the fault analysis module is also used for:

[0139] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0140] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0141] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0142] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0143] Fifthly, embodiments of this application provide a computing device, including:

[0144] The processor, and the memory that is in communication with the processor;

[0145] Memory is used to store instructions that the computer executes;

[0146] The processor is used to execute computer-executable instructions stored in memory to implement the method of the first aspect or the second aspect.

[0147] The computing device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0148] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method of the first aspect.

[0149] When the computer-executable instructions in the computer-readable storage medium provided in this application are executed by a processor, the technical solutions shown in the above method embodiments can be implemented. The implementation principle and beneficial effects are similar, and will not be repeated here.

[0150] Fifthly, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement the method of the first aspect.

[0151] When the computer program in the computer program product provided in this application is executed by a processor, it can implement the technical solution shown in the above method embodiments. The implementation principle and beneficial effects are similar, and will not be repeated here. Attached Figure Description

[0152] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0153] Figure 1a This application provides a schematic diagram of the architecture of a computing device.

[0154] Figure 1b A schematic diagram of a software architecture provided for an embodiment of this application;

[0155] Figure 2a A flowchart illustrating an embodiment of a deadlock fault analysis method provided in this application;

[0156] Figure 2b A schematic diagram of a scenario for obtaining lock information provided in an embodiment of this application;

[0157] Figure 2c This is a schematic diagram of the data structure information of a lock provided in an embodiment of this application;

[0158] Figure 2d A schematic diagram illustrating the principle of a search operation provided in an embodiment of this application;

[0159] Figure 3a A flowchart illustrating a second embodiment of a deadlock fault analysis method provided in this application;

[0160] Figure 3b A second schematic diagram illustrating a scenario for obtaining lock information, provided as an embodiment of this application;

[0161] Figure 3c This is a schematic diagram illustrating the interaction between the analysis program and the lock analysis plugin;

[0162] Figure 3d A diagram illustrating the built-in commands of the analysis program;

[0163] Figure 4 A schematic diagram of the structure of a deadlock fault analysis device provided in an embodiment of this application;

[0164] Figure 5 This is a schematic diagram of the lock analysis plugin provided in the embodiments of this application;

[0165] Figure 6 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation

[0166] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments made by those skilled in the art under the guidance of these embodiments are within the scope of protection of this application.

[0167] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0168] Definitions:

[0169] Deadlock: A state in an operating system where a process can no longer continue running. In one implementation, deadlock can occur in a concurrent environment with multiple processes when two or more processes become mutually waiting due to competition for resources.

[0170] A kernel panic occurs when a serious error occurs within the operating system, requiring it to stop running immediately. This is usually caused by kernel bugs, device malfunctions, or other reasons. If a kernel panic occurs, the operating system will be unable to function properly and will need to be restarted.

[0171] Crash tool: An open-source command-line tool used to analyze memory data when an operating system crashes.

[0172] Notification Chain: A notification chain is a data structure, typically a list or linked list, used to store function pointers to a set of callback functions. When a specific event occurs, the notification chain calls the callback functions sequentially through their function pointers.

[0173] To facilitate understanding, let's first combine... Figure 1a An architecture of a computing device related to an embodiment of this application will be described.

[0174] Figure 1a This is a schematic diagram of the architecture of a computing device provided in an embodiment of this application.

[0175] like Figure 1a As shown, the computing device 10 may include a processor 101, memory 102, and hard disk 103. The memory 102 and hard disk 103 may be electrically connected to the processor 101. It should be noted that an operating system may run on the processor 101.

[0176] The processor 101 can be a central processing unit (CPU) or other components with processing capabilities. The CPU, as the core of the computing device 10 for computation and control, is the final execution unit for information processing and program execution. The CPU is a very large-scale integrated circuit, composed of an arithmetic logic unit (ALU), a control unit, registers, etc., and its main task is to process and handle various types of data.

[0177] Memory 102, also known as internal memory or main memory, is installed in the memory slots on the motherboard of a computing device. Memory can be used to store data processed by the processor. For example, memory can be Random Access Memory (RAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Dual Inline Memory Modules (DIMM), Persistent Memory (PMEM), or Double Data Rate (DDR), etc.

[0178] The hard disk 103 is the main storage device of the computing device 10, and can be a solid-state drive or a mechanical hard disk.

[0179] It should also be noted that the computing device 10 can be a terminal (mobile phone, computer, etc.) or a server.

[0180] Figure 1b This is a schematic diagram of a software architecture provided for an embodiment of this application. For example... Figure 1b As shown in the diagram, there are two levels: kernel mode and user mode. Kernel mode and user mode are two operating states of the operating system, and their main difference lies in their access permissions.

[0181] Kernel mode, also known as privileged mode, refers to the execution mode with the highest privileges in a computing device. Kernel mode is mainly used to handle system-level tasks, such as device drivers and file management.

[0182] like Figure 1b As shown, the kernel mode includes a watchdog service 20 and a lock information analyzer 30. Additionally, the kernel mode may also include a kernel crash dump service 40 and a memory image file 50. The watchdog service 20, upon detecting an operating system failure, can invoke the lock information analyzer 30 to acquire lock information and save it to a log file (stored on hard disk 103). The lock information includes: lock data structure information, the lock request order of at least one CPU, and the call stack information corresponding to at least one CPU.

[0183] User mode, also known as non-privileged mode, refers to a lower-privilege execution mode in a computing device, typically used by applications. User mode is primarily used for executing applications. Due to the lower privileges associated with user mode, applications running in user mode can only execute certain specific instructions and access limited data to prevent malicious applications from harming the computing device.

[0184] like Figure 1b As shown, the user space includes a lock analysis plugin 60. This plugin 60 can query the memory image file 50 to obtain and display lock information. The memory image file 50 is obtained by the kernel crash dump service 40, which saves memory data at the time of the operating system failure when a failure is detected. It should be noted that the lock information includes: lock data structure information, the request order of at least one CPU for the lock, and the call stack information corresponding to at least one CPU. It should also be noted that the kernel crash dump service 40 is triggered by the watchdog service 20 when an operating system failure is detected.

[0185] This application proposes a method for analyzing deadlock faults. The computing device can run a watchdog service, and upon detecting a fault in the operating system, obtain lock information through a callback function and save the lock information to a log file; alternatively, the computing device can query a memory image file to obtain lock information and display it. The lock information includes: lock data structure information, the request order of at least one CPU to use the lock, and the call stack information corresponding to at least one CPU.

[0186] The following provides a detailed description of the deadlock fault analysis method according to embodiments of this application. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0187] Figure 2a This is a flowchart illustrating an embodiment of a deadlock fault analysis method provided in this application. See also... Figure 2a The method specifically includes the following steps:

[0188] S201: Run the watchdog service. When a fault is detected in the operating system, call the callback function to obtain lock information.

[0189] Figure 2b This is a schematic diagram of a scenario for obtaining lock information provided in an embodiment of this application.

[0190] In this embodiment, an operating system runs on the computing device.

[0191] like Figure 1bAs shown, both the watchdog service and the lock information analysis program reside in kernel mode.

[0192] During the operating system startup phase, the lock information analyzer can be started as a boot service. In one implementation, the lock information analyzer is a service managed by systemd (the first program started by the kernel). During the systemd initialization phase of the operating system startup, systemd sends a startup command to the lock information analyzer. The lock information analyzer can then start in response to the startup command.

[0193] After startup, the lock information analyzer can be registered as a callback function on the watchdog service's notification chain. In essence, this means adding the lock analyzer's function pointer to the watchdog service's notification chain.

[0194] The computing device can run a watchdog service. If a failure is detected in the operating system, the watchdog can obtain lock information by calling a lock information analyzer (callback function) registered on the notification chain.

[0195] It should be noted that lock information refers to the lock information of the computing device. In one implementation, the lock can be a spinlock.

[0196] The lock information includes: the lock's data structure information, the request order of at least one central processing unit (CPU) to use the lock, and the call stack information corresponding to at least one CPU.

[0197] In one implementation, the computing device can run a watchdog service that, upon detecting a failure in the operating system, calls a callback function to acquire lock information. In other words, the computing device can run the callback function to directly acquire lock information.

[0198] In one implementation, the computing device can run a watchdog service. Upon detecting a fault in the operating system, it acquires the lock information via a callback function, provided that the conditions for acquiring the lock information are met. In other words, the computing device can run a callback function to acquire the lock information if the conditions for acquiring the lock information are determined to be met.

[0199] The following section explains the process by which the computing device executes a callback function to acquire lock information when the conditions for acquiring lock information are met.

[0200] In one implementation:

[0201] The computing device can run a callback function to obtain the call stack information corresponding to the target CPU. This call stack information includes call information for at least one function; the target CPU is the CPU running when the operating system malfunctions. In other words, the call stack information corresponding to the target CPU is the call stack information of the CPU running when the operating system malfunctions. It should be noted that the call stack information corresponding to the running CPU refers to the call stack information of the process corresponding to that running CPU.

[0202] The computing device can run a callback function to determine whether a call to a target function exists in the call information of at least one function. The target function is the function used to acquire the lock. For example, the calling function could be `native_queued_spin_lock_slowpath`.

[0203] The computing device can run a callback function. If it determines that the call information of the target function exists in the call information of at least one function, it can determine that the conditions for obtaining lock information are met. In other words, it can determine that the operating system failure is caused by a lock.

[0204] The computing device can run callback functions and terminate the call if it determines that the call information for at least one function does not contain any call information for the target function. In other words, the watchdog service can continue to call other callback functions registered on the call notification chain.

[0205] By setting the conditions for obtaining lock information as described above, the utilization rate of lock information can be improved.

[0206] The following section explains the process by which the computing device executes a callback function to obtain lock information.

[0207] In one implementation:

[0208] The computing device can run a callback function to read the target register and obtain the lock address. For example, in the case of an x86_64 processor architecture, the target register can be the R0 register; in the case of an arm64 processor architecture, the target register can be the x3 register. It should be noted that, in one implementation, the computing device can run a callback function to determine the target register based on a pre-acquired identifier and read the target register to obtain the lock address.

[0209] The computing device can run a callback function to obtain the lock's data structure information based on the lock address. In one implementation, the lock address is a virtual address, and the computing device can run a callback function to determine the physical address based on the lock address. The computing device can also run a callback function to obtain the lock's data structure information based on the physical address.

[0210] The computing device can run a callback function to determine the request order based on the lock's data structure information. This request order includes the identifier of at least one CPU.

[0211] The computing device can run a callback function to obtain the call stack information for at least one CPU, based on the request order. In one implementation, for any CPU identifier in the request order, the computing device can run a callback function to obtain the call stack information corresponding to that CPU. It should be noted that the call stack information corresponding to a CPU refers to the call stack information of the process corresponding to that CPU.

[0212] The following describes the process by which the computing device runs a callback function to obtain the call stack information corresponding to at least one CPU according to the request order.

[0213] In one implementation,

[0214] The computing device executes a callback function, which can trigger the kernel to broadcast an interrupt to each CPU in the request sequence. Upon receiving the interrupt, the CPU can call the interrupt callback function to print the call stack information corresponding to that CPU (storing the call stack information in the kernel buffer). In one implementation, the interrupt can be a non-maskable interrupt (NMI). In another implementation, the interrupt can be an inter-processor interrupt (IPI).

[0215] The following section explains the process by which the computing device executes a callback function to determine the request order based on the lock's data structure information.

[0216] In one implementation:

[0217] Figure 2c This is a schematic diagram of the data structure information of a lock provided in an embodiment of this application.

[0218] like Figure 2c As shown, the lock's data structure information records the following information:

[0219] Lock state; it should be noted that the lock state indicates whether the lock is held. In one implementation, a lock state of 0 indicates that the lock is not held; a lock state of 1 indicates that the lock is held.

[0220] The pending state (pengding bit state) indicates whether a CPU is requesting to use the CPU without holding the lock. In one implementation, a pending state of 0 indicates that no CPU is requesting to use the CPU without holding the lock; a pending state of 1 indicates that a CPU is requesting to use the CPU without holding the lock.

[0221] Lock index; it should be noted that the lock index is used to indicate the lock-related data structure (struct qnode) in the qnodes data structure corresponding to the first CPU. For example, a lock index of 0 indicates that the lock-related data structure (struct qnode) in the qnodes data structure corresponding to the first CPU is the first of a plurality of data structures; a lock index of 1 indicates that the lock-related data structure (struct qnode) in the qnodes data structure corresponding to the first CPU is the second of a plurality of data structures.

[0222] The identifier of the first CPU. For example, the identifier of the first CPU can be the number of the first CPU. It should be noted that the first CPU is the last CPU to request the use of the lock.

[0223] The lock-based data structure information records the identifier of the first CPU. The computing device can run a callback function to determine the first CPU from the data structure information.

[0224] The computing device can run a callback function to determine whether the first CPU holds the lock.

[0225] In one implementation, the computing device can run a callback function to determine the waiting-to-hold status from the data structure information. The computing device can then run the callback function to determine whether the waiting-to-hold status indicates that there is no CPU requesting use and not holding the lock. If so, the computing device can run the callback function to determine that the first CPU holds the lock; otherwise, the computing device can run the callback function to determine that the first CPU does not hold the lock.

[0226] In one implementation, the data structure corresponding to the CPU records indication information used to indicate whether the lock is held. The computing device can run a callback function to determine the qnodes data structure corresponding to the first CPU based on the first CPU's identifier. The computing device can also run the callback function to determine a data structure within the qnodes data structure based on the lock index. The computing device can then run the callback function to determine whether the indication information recorded in that data structure indicates lock holding; if yes, the computing device can run the callback function to determine that the first CPU holds the lock; otherwise, the computing device can run the callback function to determine that the first CPU does not hold the lock.

[0227] The computing device can run a callback function to determine the request order, including the identifier of the first CPU, if it is determined that the first CPU holds the lock.

[0228] The computing device can run a callback function to perform at least one CPU lookup operation if it is determined that the first CPU does not hold the lock, and determine the request order based on the first CPU and the CPU found.

[0229] The following section explains the process of running a callback function on the computing device, performing at least one CPU lookup operation, and determining the request order based on the first CPU and the found CPU.

[0230] In one implementation,

[0231] The computing device can run a callback function to search through the data structures corresponding to all CPUs based on the address information of the data structure corresponding to the i-th CPU, thus obtaining the (i+1)-th CPU. It should be noted that the (i+1)-th CPU is the CPU that requested the lock before the i-th CPU. The data structure corresponding to the (i+1)-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0232] The computing device can run a callback function to determine whether the (i+1)th CPU holds the lock.

[0233] The computing device can run a callback function, which, if it is determined that the (i+1)th CPU holds the lock, determines that the (i+1)th CPU requests the lock before the i-th CPU, and then ends the lookup operation.

[0234] The computing device can run a callback function to determine the order in which the (i+1)th CPU requests the lock before the i-th CPU, if it is determined that the (i+1)th CPU does not hold the lock.

[0235] It should be noted that i takes the values ​​1, 2, ... in sequence until the application order is obtained.

[0236] Additionally, it should be noted that i represents the last CPU in the application (queue) sequence.

[0237] When i is 1, the i-th CPU is the CPU with the first request number in the order of request. In other words, the i-th CPU is the last CPU to request the lock - the first CPU.

[0238] The following section explains the search principle.

[0239] Figure 2d This is a schematic diagram illustrating the principle of a search operation provided in an embodiment of this application.

[0240] like Figure 2d As shown, the qnodes data structure corresponding to the (i+1)th CPU includes multiple data structures (struct qnode). Each data structure includes the address information and indication information of the data structure (struct qnode) corresponding to the i-th CPU (the CPU following the (i+1)-th CPU that requests the lock).

[0241] The indication information is used to indicate whether the (i+1)th CPU holds the lock. In one implementation, the indication information (lock value) is 0, indicating that the (i+1)th CPU does not hold the lock; the indication information (lock value) is 1, indicating that the (i+1)th CPU holds the lock.

[0242] The computing device can run a callback function to search through the data structures corresponding to all CPUs based on the address information of the data structure corresponding to the i-th CPU, thus obtaining the (i+1)-th CPU. The data structure corresponding to the (i+1)-th CPU includes the address information of the data structure corresponding to the i-th CPU. In one implementation, for any data structure corresponding to any CPU, the computing device can run a callback function to search through that data structure based on the address information of the data structure corresponding to the i-th CPU, determining whether the data structure contains the address information of the data structure corresponding to the i-th CPU; if so, the CPU is identified as the (i+1)-th CPU, and the address information of that data structure is determined.

[0243] The computing device can run a callback function to determine whether the indication information recorded in the data structure corresponding to the (i+1)th CPU indicates that the lock is held. If yes, the computing device can run the callback function to determine that the (i+1)th CPU holds the lock; if no, the computing device can run the callback function to determine that the (i+1)th CPU does not hold the lock.

[0244] Additionally, it should be noted that during the process of finding the preceding CPU based on the address information of the data structure corresponding to the first CPU, the computing device can run a callback function to determine the qnodes data structure corresponding to the first CPU based on the first CPU's identifier. The computing device can also run the callback function to determine a data structure within the qnodes data structure based on the lock index. Furthermore, the computing device can run the callback function to determine the address information of that data structure as the address information of the data structure corresponding to the first CPU. Finally, the computing device can run the callback function to find the preceding CPU based on the address information of the data structure corresponding to the first CPU.

[0245] S202: Save the lock information to the log file to analyze deadlock faults based on the lock information in the log file.

[0246] In this embodiment, the computing device can save lock information to a log file to analyze deadlock faults based on the lock information in the log file.

[0247] In one implementation, the computing device can run a callback function to save the lock information to a kernel buffer. The computing device can then run an operating system to save the lock information from the kernel buffer to a log file (which is stored on disk).

[0248] The computing device can analyze deadlock faults based on the lock information in the log file.

[0249] In one implementation, the computing device can control the display interface of the computing device to display lock information.

[0250] The beneficial effects of this embodiment are as follows: In this embodiment, the computing device can run a watchdog service to monitor the operating system for faults. When a fault is detected in the operating system, a callback function is invoked to obtain lock information. Firstly, compared to related technologies where maintenance engineers need to manually obtain lock information using analysis programs based on massive memory image files, which may result in low efficiency and accuracy, the method in this embodiment registers a callback function on the watchdog service's call chain. This allows the callback function to be run in response to the watchdog service's call to obtain lock information when the operating system malfunctions, improving the efficiency and accuracy of lock information acquisition. Secondly, the callback function in this embodiment obtains lock information based on the watchdog service call when the operating system malfunctions. When the operating system is not malfunctioning, there is no need to obtain lock information, reducing operating system resource overhead and avoiding impact on operating system performance. Thirdly, in this embodiment, the callback function can be a separate module. When lock information needs to be obtained using the callback function, it is registered on the watchdog service's notification chain, achieving architectural decoupling and ensuring the portability of the callback function. On the other hand, compared to related technologies that require the use of a kernel crash dump service (kdump service) with poor reliability to generate memory image files, and require the use of analysis programs (such as crash tools) to obtain and analyze memory image files that may contain sensitive information, resulting in poor security and reliability, the method of this application embodiment can use callback functions registered on the notification chain of the watchdog service to automatically obtain lock information, thereby improving the efficiency and security of lock information acquisition.

[0251] Figure 3aThis is a flowchart illustrating a second embodiment of a deadlock fault analysis method provided in this application. See also... Figure 3a The method specifically includes the following steps:

[0252] S301: Query the memory image file to obtain lock information.

[0253] In this embodiment, the computing device runs a kernel crash dump service (kdump service), which can save the memory data at the time of the operating system failure when a failure is detected, and obtain a memory image file (vmcore file).

[0254] The memory image file may include the target CPU's identifier and complete CPU call stack information. It should be noted that the target CPU is the CPU running when the operating system malfunctions.

[0255] The computing device can query the memory image file to obtain lock information. In one implementation, the computing device can run a lock analysis plugin to query the memory image file and obtain lock information. It should be noted that in one implementation... Figure 3b This is a second schematic diagram illustrating a scenario for obtaining lock information, provided in an embodiment of this application. Figure 3c This is a schematic diagram illustrating the interaction between the analysis program and the lock analysis plugin. For example... Figure 3b and Figure 3c As shown, the computing device can load a lock analysis plugin through an analysis program upon receiving an extend command. In one implementation, Figure 3d A diagram illustrating the built-in commands of the analysis program, such as Figure 3d As shown, during the process of loading the lock analysis plugin through the analysis program, the computing device can register the corresponding analysis commands (such as the `lock` command) of the lock analysis plugin into the built-in commands of the analysis program. When the computing device runs the analysis program, it can call the lock analysis plugin when obtaining analysis commands, so as to query the memory image file and obtain lock information through the lock analysis plugin.

[0256] In one implementation,

[0257] The computing device can obtain the call stack information corresponding to the target CPU. This call stack information includes call information for at least one function. It should be noted that, in one implementation, the memory image file stores the identifier of the target CPU and all call stack information corresponding to that CPU. The computing device can query the memory image file to determine the target CPU and then query the memory image file to obtain the call stack information corresponding to that target CPU.

[0258] The computing device can query a memory image file and acquire lock information if it determines that the call information of a target function exists in the call information of at least one function. The target function is the function that calls the lock.

[0259] The following section explains the process by which a computing device queries a memory image file to obtain lock information.

[0260] In one implementation,

[0261] The computing device can query a memory image file to determine the target register in the target CPU. The target CPU is the CPU running when the operating system malfunctions. The target register is the register that stores the lock address.

[0262] The computing device can read the target register and obtain the lock address.

[0263] The computing device can obtain the data structure information of the lock based on the lock address.

[0264] The computing device can determine the request order based on the lock's data structure information.

[0265] The memory image file contains call stack information for multiple CPUs. The computing device can query the memory image file according to the request order to obtain the call stack information for at least one CPU.

[0266] The following section explains the process by which the computing device determines the order of requests based on the data structure information of the lock.

[0267] In one implementation,

[0268] The computing device can identify the first CPU from the data structure information; the first CPU is the last CPU to request the use of the lock.

[0269] The computing device can determine whether the first CPU holds the lock.

[0270] If so, the computing device can determine that the application order includes the identifier of the first CPU.

[0271] If not, the computing device may perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0272] The process of performing at least one lookup operation on a computing device is described below.

[0273] In one implementation,

[0274] The computing device can use the address information of the data structure corresponding to the i-th CPU to search through the data structures corresponding to all CPUs and obtain the (i+1)-th CPU. Here, the (i+1)-th CPU is the CPU that requested the lock before the i-th CPU; the data structure corresponding to the (i+1)-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0275] The computing device can determine whether the (i+1)th CPU holds the lock;

[0276] If so, the computing device can determine that the (i+1)th CPU requests the lock before the i-th CPU and end the search operation.

[0277] If not, the computing device can determine that the (i+1)th CPU requests the lock before the i-th CPU.

[0278] It should be noted that i takes the values ​​1, 2, ... in sequence until the application order is obtained.

[0279] S302: Display lock information to analyze deadlock faults based on the lock information.

[0280] In this embodiment, the computing device can display the lock information after obtaining it, so as to analyze the deadlock fault based on the lock information.

[0281] In other words, the computing device can control the display interface of the computing device to display the lock information.

[0282] The beneficial effects of this embodiment are as follows: In this embodiment, the computing device can obtain lock information by querying the memory image file. On the one hand, compared to related technologies where maintenance engineers need to manually use analysis programs and multiple commands to obtain lock information based on a large amount of data in the memory image file, which may result in low efficiency and accuracy, the method of this embodiment can directly and automatically query the memory image file to obtain lock information, thereby improving the efficiency, accuracy, and security of determining lock information.

[0283] The following describes, through method embodiment three, the process by which a computing device analyzes deadlock faults based on lock information.

[0284] In this embodiment, the computing device can analyze deadlock faults based on lock information.

[0285] It should be noted that, in one implementation, the computing device can run a callback function (such as a fault analysis module within the callback function) to analyze deadlock faults based on lock information. In another implementation, the computing device can run a lock analysis plugin (such as a fault analysis module within the lock analysis plugin) to analyze deadlock faults based on lock information.

[0286] In one implementation:

[0287] The data structure information of a lock includes the lock state and the waiting-to-hold state. Additionally, the data result information of a lock may also include the lock index and the identifier of the first CPU.

[0288] The computing device can determine that a deadlock fault exists when the lock status indicates that the lock is held and the waiting hold status indicates that there is a CPU requesting to use the lock but not holding it.

[0289] In one implementation:

[0290] The computing device can determine the second CPU based on the order of requests. The second CPU is the CPU that first requested to use the lock. It should be noted that since the first CPU to request the lock is the CPU that holds the lock, the second CPU is also the CPU that holds the lock.

[0291] The computing device can determine the process corresponding to the second CPU based on the second CPU. It should be noted that the process corresponding to the second CPU is the process that runs on the second CPU when the operating system of the computing device malfunctions.

[0292] The computing device can determine that the process corresponding to the second CPU is experiencing an anomaly. Alternatively, in one implementation, the computing device can perform recovery processing by terminating the process if an anomaly is detected. In another implementation, the computing device can perform recovery processing by reinitializing the lock if an anomaly is detected.

[0293] In one implementation:

[0294] The computing device can determine the call stack information corresponding to the second CPU based on the call stack information corresponding to at least one CPU. The second CPU is the first CPU to request the lock. It should be noted that since the first CPU to request the lock is the CPU that holds the lock, the second CPU is also the CPU that holds the lock.

[0295] The computing device can determine the function call relationships of the processes corresponding to the second CPU based on the call stack information corresponding to the second CPU.

[0296] The computing device can determine the function call relationships of the process corresponding to the second CPU, which indicates an anomaly.

[0297] The following describes the process by which the computing device determines the function call relationships of the processes corresponding to the second CPU based on the call stack information corresponding to the second CPU.

[0298] When a CPU runs a process, it maintains a call stack (a data structure) corresponding to that process. The call stack uses stack frames (the basic unit of the call stack) to store function call information. One stack frame stores the call information for one function. All the information stored in the call stack is the call stack information; that is, the call stack information includes the call information for at least one function.

[0299] Taking the first function as an example, when the first function in a process is called, the CPU can create a stack frame corresponding to the first function and record the call information of the first function into the stack frame. This call information includes the function name, function parameters, return address (the location where the function was called), and local variables. When the first function calls the second function, the CPU can create a stack frame corresponding to the second function and record the call information of the second function into the stack frame.

[0300] Computing devices can determine function call relationships based on call stack information. In one implementation, the call stack consists of multiple stack frames stacked sequentially. The top stack frame corresponds to the currently executing function, and the stack frames below it correspond to the functions that called that function. Computing devices can determine the function call relationships of a process by traversing the stack frames of the call stack.

[0301] In one implementation:

[0302] The computing device can determine the function call relationships of processes corresponding to at least one CPU based on the call stack information corresponding to at least one CPU.

[0303] The computing device can determine the function call relationships of at least one CPU-based process, indicating an anomaly.

[0304] The beneficial effects of this embodiment are as follows: After obtaining lock information, the computing device can analyze deadlock faults based on the lock information to obtain various information for determining the cause of operating system failures. Compared to related technologies, which require maintenance engineers to manually use analysis programs based on massive memory image files to obtain lock information and then analyze deadlock faults based on the lock information and the massive memory image files, potentially resulting in low efficiency and accuracy, the method of this embodiment can automatically analyze deadlock faults based on lock information, improving analysis efficiency and accuracy.

[0305] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0306] Figure 4This is a schematic diagram of a deadlock fault analysis device provided in an embodiment of this application. Figure 4 As shown, the deadlock fault analysis device 70 includes a watchdog service 20 and a callback function (lock information analysis program) 30. Among them,

[0307] The watchdog service 20 is used to call a callback function to obtain lock information when a fault is detected in the operating system. The lock information includes: the lock's data structure information, the order in which at least one central processing unit (CPU) requests to use the lock, and the call stack information corresponding to at least one CPU.

[0308] Callback function 30 is used to save lock information to a log file so that deadlock faults can be analyzed based on the lock information in the log file.

[0309] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0310] In one implementation, callback function 30 includes:

[0311] The lock data structure analysis module 31 is used to read the target register and obtain the lock address; the target register is a register that stores the lock address.

[0312] The lock data structure analysis module 31 is used to obtain the lock data structure information based on the lock address;

[0313] The lock queue analysis module 32 is used to determine the request order based on the lock's data structure information;

[0314] The CPU call stack recording module 33 is used to obtain call stack information corresponding to at least one CPU according to the request order.

[0315] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0316] One implementation also includes:

[0317] The scenario analysis module 34 is used to obtain the call stack information corresponding to the target CPU; wherein, the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails.

[0318] The scenario analysis module 34 is also used to determine that at least one function's call information contains the call information of a target function; the target function is the call function used to acquire the lock.

[0319] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0320] In one implementation, the lock queue analysis module 32 is specifically used for:

[0321] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0322] Determine if the first CPU holds the lock;

[0323] If so, then the application order should only include the identifier of the first CPU;

[0324] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0325] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0326] In one implementation, the lock queue analysis module 32 is specifically used for:

[0327] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0328] Determine if the (i+1)th CPU holds the lock;

[0329] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0330] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0331] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0332] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the callback function also includes:

[0333] The fault analysis module 35 is used to determine the existence of a deadlock fault when the lock status indicates that the lock is occupied and the waiting occupation status indicates that there is a CPU that requests to use the lock but does not own the lock.

[0334] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0335] In one implementation, the fault analysis module 35 is further used for:

[0336] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0337] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0338] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0339] The deadlock fault analysis device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0340] Figure 5 This is a schematic diagram of the lock analysis plugin provided in an embodiment of this application.

[0341] like Figure 5 As shown, lock analysis plugin 60 is used for:

[0342] The memory image file is queried to obtain lock information. The memory image file is a kernel crash dump service that saves and processes the memory data at the time of the operating system failure when a failure is detected. The lock information includes: the lock data structure information, the request order of at least one CPU to use the lock, and the call stack information of at least one CPU.

[0343] Display lock information to analyze deadlock faults based on the lock information.

[0344] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0345] In one implementation, the lock analysis plugin 60 includes:

[0346] The lock data structure analysis module 61 is used to query the memory image file and determine the target register in the target CPU; the target CPU is the CPU running when the operating system fails; the target register is the register that stores the lock address.

[0347] Lock data structure analysis module 61 is used to read the target register and obtain the lock address;

[0348] The lock data structure analysis module 61 is used to obtain the lock data structure information based on the lock address;

[0349] The lock queue analysis module 62 is used to determine the request order based on the lock's data structure information;

[0350] The CPU call stack recording module 63 is used to query the memory image file according to the request order and obtain the call stack information corresponding to at least one CPU.

[0351] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0352] One implementation also includes:

[0353] The scenario analysis module 64 is used to obtain the call stack information corresponding to the target CPU; wherein, the call stack information corresponding to the target CPU includes the call information of at least one function; the target CPU is the CPU running when the operating system fails.

[0354] The scenario analysis module 64 is also used to determine that at least one function's call information contains the call information of a target function; the target function is the call function used to acquire the lock.

[0355] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0356] In one implementation, the lock queue analysis module 62 is specifically used for:

[0357] In the data structure information, the first CPU is identified; the first CPU is the last CPU to request the use of the lock.

[0358] Determine if the first CPU holds the lock;

[0359] If so, then the application order should only include the identifier of the first CPU;

[0360] If not, perform at least one CPU lookup operation and determine the request order based on the first CPU and the CPU obtained from the lookup operation.

[0361] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0362] In one implementation, the lock queue analysis module 62 is specifically used for:

[0363] Based on the address information of the data structure corresponding to the i-th CPU, the i+1-th CPU is obtained; the i+1-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the i+1-th CPU includes the address information of the data structure corresponding to the i-th CPU.

[0364] Determine if the (i+1)th CPU holds the lock;

[0365] If so, then determine that the order in which the (i+1)th CPU requests the lock is before that of the ith CPU, and end the CPU lookup operation;

[0366] If not, then the order in which the (i+1)th CPU requests the lock is before that of the i-th CPU.

[0367] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0368] In one implementation, the lock's data structure information includes the lock state and the waiting-to-hold state; the lock analysis plugin also includes:

[0369] The fault analysis module 65 is used to determine the existence of a deadlock fault when the lock status indicates that the lock is occupied and the waiting status indicates that there is a CPU that requests to use the lock but does not own the lock.

[0370] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0371] In one implementation, the fault analysis module 65 is further used for:

[0372] Based on the order of requests, determine the second CPU, then determine the process corresponding to the second CPU, and confirm that the process corresponding to the second CPU is abnormal. The second CPU is the first CPU to request the lock; or,

[0373] Based on the call stack information corresponding to at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or,

[0374] Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

[0375] The lock analysis plugin provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0376] Figure 6 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Figure 6 As shown, the computing device 80 includes a processor 81 and a memory 82; wherein the processor 81 is coupled to the memory 82, and the memory 82 is used to store computer instructions; the processor 81 is used to execute the computer instructions to cause the computing device 80 to perform the technical solutions in the aforementioned method embodiments.

[0377] Optionally, the memory 82 can be either standalone or integrated with the processor 81. Optionally, when the memory 82 is a device independent of the processor 81, the first computing device 80 may further include a bus 83 for connecting the aforementioned devices.

[0378] The processor is used to execute the technical solutions in the aforementioned method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.

[0379] This application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the technical solutions provided in the aforementioned method embodiments.

[0380] This application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solutions provided in the aforementioned method embodiments.

[0381] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as volatile memory and non-volatile memory.

[0382] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method of analyzing a deadlock fault, characterized by, include: Run the watchdog service, and when an operating system failure is detected, call the callback function to obtain lock information; The lock information includes: lock data structure information, the request order of at least one central processing unit (CPU) requesting to use the lock, and call stack information corresponding to at least one CPU; wherein, obtaining the call stack information corresponding to at least one CPU includes: triggering the kernel to send an interrupt to the CPU corresponding to each CPU identifier in the request order via broadcast; after receiving the interrupt, the CPU calls the interrupt callback function and prints the call stack information corresponding to the CPU; The lock information is saved to a log file so that deadlock faults can be analyzed based on the lock information in the log file. Determining the request order based on the lock's data structure information includes: In the data structure information, a first CPU is identified; the first CPU is the last CPU to request the use of the lock; it is determined whether the first CPU holds the lock; if yes, it is determined that the request order only includes the identifier of the first CPU; if no, at least one CPU lookup operation is performed, and the request order is determined based on the first CPU and the CPU obtained from the lookup operation. The process of performing at least one CPU lookup operation includes: The (i+1)th CPU is obtained based on the address information of the data structure corresponding to the i-th CPU; the (i+1)-th CPU is the CPU that requested to use the lock before the i-th CPU; the data structure corresponding to the (i+1)-th CPU includes the address information of the data structure corresponding to the i-th CPU. Determine whether the (i+1)th CPU holds the lock; If so, then it is determined that the (i+1)th CPU requested to use the lock before the i-th CPU, and the CPU lookup operation is terminated; If not, then the order in which the (i+1)th CPU requests to use the lock is determined to be before that of the i-th CPU; i takes values ​​sequentially until the application order is obtained.

2. The method of claim 1, wherein, The acquisition of lock information includes: Read the target register to obtain the lock address; the target register is the register that stores the lock address; Based on the lock address, obtain the lock's data structure information; The request order is determined based on the data structure information of the lock; According to the application order, obtain the call stack information corresponding to the at least one CPU.

3. The method according to claim 1, characterized in that, Before obtaining the lock information, the method further includes: Obtain the call stack information corresponding to the target CPU; wherein, the call stack information corresponding to the target CPU includes call information of at least one function; the target CPU is the CPU running when the operating system malfunctions; It is determined that the call information of the at least one function contains the call information of a target function; the target function is a call function used to acquire a lock.

4. The method according to any one of claims 1-3, characterized in that, The data structure information of the lock includes the lock state and the waiting-to-acquire state; the method further includes: A deadlock fault is determined when the lock state indicates that the lock is held, and the waiting-to-hold state indicates that there is a CPU requesting to use the lock but not holding it.

5. The method according to any one of claims 1-3, characterized in that, The method further includes: Based on the application order, a second CPU is determined, and based on the second CPU, the process corresponding to the second CPU is determined. It is also determined that the process corresponding to the second CPU is abnormal, and the second CPU is the first CPU to request the use of the lock; or, Based on the call stack information corresponding to the at least one CPU, determine the call stack information corresponding to the second CPU, and based on the call stack information corresponding to the second CPU, determine the function call relationship of the process corresponding to the second CPU, and determine that the function call relationship of the process corresponding to the second CPU is abnormal; or, Based on the call stack information corresponding to at least one CPU, determine the function call relationship of the process corresponding to at least one CPU, and determine that the function call relationship of the process corresponding to at least one CPU is abnormal.

6. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, implements the method of any one of claims 1-5.

7. A computing device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory is used to store computer-executed instructions; The processor is configured to execute computer execution instructions stored in the memory to implement the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • System and method for processing abnormal information based on kernel module

    CN107908537A