Operating system scheduling delay diagnosis method and device, electronic equipment and storage medium
By storing thread wake-up timestamps in the Linux kernel stack space and combining them with user-space programs and kernel modules, the universality problem of Linux kernel scheduling delay diagnosis is solved, and fast and accurate scheduling delay localization is achieved.
Patent Information
- Application Number
- CN202211193934.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-09-28
AI Technical Summary
Existing technologies for diagnosing Linux kernel scheduling delays lack universality and scalability, making them difficult to apply effectively across different kernel versions.
By storing the timestamp of the thread's wake-up time in the kernel's stack space, and combining it with the user-mode program and the kernel module, the scheduling delay time is calculated, and the delay information is stored in the kernel cache for access by the user-mode program.
It improves the universality and scalability of scheduling delay diagnosis, lowers the threshold for users to conduct self-diagnosis, has little impact on system performance, and can quickly locate abnormal threads.
Smart Images

Figure CN115525347B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, in particular to an operating system scheduling delay diagnosis method and device, electronic equipment and storage medium. BACKGROUND
[0002] In the prior art, Linux real-time plays a very important role in Linux, and different application scenarios have different requirements for real-time. At present, the common problem of Linux is that it is difficult to diagnose the scheduling delay of the Linux kernel.
[0003] In the prior art, the delay diagnosis is implemented through the reserved field of the thread structure or the newly added field, but the above processing method lacks universality for all versions of the kernel.
[0004] Therefore, there is an urgent need for a Linux kernel scheduling delay diagnosis method with universality and expansibility to solve the problem of difficulty in diagnosing the scheduling delay of the Linux kernel in the prior art. SUMMARY
[0005] The purpose of the present disclosure is to provide an operating system scheduling delay diagnosis method and device, electronic equipment and storage medium, aiming to solve the above problems in the prior art.
[0006] According to a first aspect of an embodiment of the present disclosure, an operating system scheduling delay diagnosis method is provided, comprising: in response to a diagnosis instruction of a user state program, activating a scheduling delay diagnosis function of a kernel module, obtaining a wake-up time timestamp of a first thread and storing it in a stack space, when the first thread is scheduled, calculating a scheduling delay time according to the wake-up time timestamp and the obtained scheduling time timestamp, and storing the scheduling delay time of the first thread and the corresponding delay information into a kernel cache area; in response to a data acquisition instruction of the user state program, sending the delay information saved in the kernel cache area to a storage space specified by the user state program.
[0007] According to a second aspect of an embodiment of the present disclosure, an operating system scheduling delay diagnosis device is provided, comprising: a user state program module for sending a diagnosis instruction and a data acquisition instruction, and obtaining delay information saved in a kernel cache area; a kernel module for activating a scheduling delay diagnosis function of the kernel module in response to a diagnosis instruction of a user state program, obtaining a wake-up time timestamp of a first thread and storing it in a stack space, when the first thread is scheduled, calculating a scheduling delay time according to the wake-up time timestamp and the obtained scheduling time timestamp, and storing the scheduling delay time of the first thread and the corresponding delay information into a kernel cache area; in response to a data acquisition instruction of the user state program, sending the delay information saved in the kernel cache area to the user state program.
[0008] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the operating system scheduling delay diagnosis method provided in the first aspect of the present disclosure.
[0009] According to a fourth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, which stores computer program instructions, the program instructions being executed by a processor to implement the steps of the operating system scheduling delay diagnosis method provided in the first aspect of the present disclosure.
[0010] The technical solutions provided by the embodiments of the present disclosure can include the following beneficial effects:
[0011] By using the stack space of the kernel to store the wake-up time stamp of the thread, the applicability and expansibility are improved, and the user state program and the kernel module are integrated, thereby reducing the threshold of user self-diagnosis. The technical solutions of the embodiments of the present disclosure have little effect on the performance of the system and occupy few resources, and can quickly locate the abnormal thread.
[0012] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0013] The accompanying drawings, which are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0014] Figure 1 is a flowchart of an operating system scheduling delay diagnosis method according to an exemplary embodiment;
[0015] Figure 2 is an exemplary processing flowchart of an operating system scheduling delay diagnosis method according to an exemplary embodiment;
[0016] Figure 3 is a block diagram of an operating system scheduling delay diagnosis apparatus according to an exemplary embodiment;
[0017] Figure 4 is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0018] The exemplary embodiments will be described in detail below with reference to the accompanying drawings.
[0019] It should be noted that the related embodiments and drawings are only for describing the exemplary embodiments provided by the present disclosure, and are not all embodiments of the present disclosure, and the present disclosure should not be understood as being limited by the related exemplary embodiments.
[0020] It should be noted that the terms "first", "second", etc. used in the present disclosure are only used to distinguish different steps, devices or modules, etc. The related terms do not represent any specific technical meaning, nor do they represent the order or interdependence between them.
[0021] It should be noted that the terms "one", "multiple", "at least one" used in the present disclosure are illustrative and not restrictive. Unless otherwise explicitly stated in the context, it should be understood as "one or more".
[0022] It should be noted that the term "and / or" used in the present disclosure is used to describe the association between the associated objects, which generally represents at least three kinds of association relationships. For example, A and / or B can at least represent the following three association relationships: A exists alone, A and B exist together, and B exists alone.
[0023] It should be noted that the steps described in the method embodiments of the present disclosure can be executed in different order and / or in parallel. Unless otherwise specified, the scope of the present disclosure is not limited by the order of description of the steps in the related embodiments.
[0024] It should be noted that all actions of obtaining signals, information or data in the present disclosure are carried out in accordance with the corresponding data protection regulations and policies of the country where the device is located, and with the authorization given by the owner of the corresponding device.
[0025] Technical term explanation
[0026] 1. Scheduling delay: refers to the time from when a task has the conditions to run (i.e. enters the runqueue of the CPU) to when it is actually executed (obtains the execution right of the CPU).
[0027] 2. Real-time: refers to the fact that the operating system must react to external events within a limited time. The range of the limited time needs to be determined according to actual needs. For example, the limited time for a chemical reaction control system may be long, while the limited time for a car control system may be short.
[0028] 3. Operating system: a set of interrelated system software programs that govern and control computer operations, utilize and run hardware, software resources, and provide common services to organize user interactions.
[0029] Exemplary method one
[0030] Figure 1 This is a flowchart illustrating an operating system scheduling delay diagnosis method according to an exemplary embodiment, such as... Figure 1 As shown, the operating system scheduling delay diagnosis method is used in Linux kernel scheduling delay diagnosis and includes the following steps:
[0031] In step S110, in response to the diagnostic instruction of the user-mode program, the scheduling delay diagnostic function of the kernel module is activated, the wake-up time timestamp of the first thread is obtained and stored in the stack space, and when the first thread is scheduled, the scheduling delay time is calculated based on the wake-up time timestamp and the obtained scheduling time timestamp, and the scheduling delay time and corresponding delay information of the first thread are stored in the kernel cache.
[0032] Specifically, after activating the scheduling delay diagnosis function of the kernel module, the stack space is used to store the timestamp of the first thread being awakened. Subsequently, when the first thread is scheduled, the scheduling delay time needs to be calculated based on the wake-up timestamp and the scheduling timestamp. Furthermore, a custom kernel cache is used to store the scheduling delay time and corresponding delay information of the first thread.
[0033] In step S120, in response to the data acquisition instruction of the user-mode program, the delay information stored in the kernel cache is sent to the storage space specified by the user-mode program.
[0034] It should be noted that in the above process, after receiving the data acquisition instruction from the user-mode program, the latency information obtained in step S110 and stored in the custom kernel cache needs to be sent to the user-mode program's storage space. It should be noted that this storage space is the storage space specified by the user-mode program.
[0035] By using the embodiments of this disclosure, the kernel's stack space is used to store the timestamp of the thread being awakened, which improves the applicability and scalability. Furthermore, it integrates user-mode programs and kernel modules, lowering the threshold for user self-diagnosis. The technical solution of the embodiments of this disclosure has little impact on the system's performance and consumes few resources.
[0036] Exemplary Method Two
[0037] like Figure 1 As shown, the operating system scheduling delay diagnosis method is used in Linux kernel scheduling delay diagnosis and includes the following steps:
[0038] In step S110, in response to the diagnosis instruction of the user mode program, the scheduling delay diagnosis function of the kernel module is activated, the wake-up time timestamp of the first thread is acquired and stored in the stack space, when the first thread is scheduled, the scheduling delay time is calculated according to the wake-up time timestamp and the acquired scheduled time timestamp, and the scheduling delay time of the first thread and the corresponding delay information are stored into the kernel buffer area; wherein the delay information specifically includes at least one of the following: thread information, control group (Cgroups) information, kernel state call stack information, user state call stack information, and thread call chain information. Thus, rich delay information is obtained. Cgroups is the abbreviation of control groups, which is a function of the Linux kernel, used to limit, control and separate the resources (such as CPU, memory, disk input and output, etc.) of a process group.
[0039] Step S110 specifically includes:
[0040] In response to the first thread being woken up, the wake-up time timestamp of the first thread is recorded through the stack space;
[0041] In response to the first thread being scheduled, the difference between the scheduled time timestamp and the wake-up time timestamp is calculated, and the scheduling delay time of the first thread is obtained according to the difference and stored into the kernel buffer area. By calculating the difference between the scheduled time timestamp and the wake-up time timestamp, the scheduling delay time of the first thread can be accurately obtained.
[0042] In the embodiments of the present disclosure, in order to facilitate the user to quickly locate the thread of interest, in the embodiments of the present disclosure, the user mode program can also be used to acquire the specified thread and the scheduling delay time threshold value set in advance. That is, in actual application, the thread can be filtered through the thread or the PID (the unique ID of the thread in the operating system), COMM (the Chinese name of the thread), and TGID (the PID of the thread group master thread), and only the business thread of interest of the business can be concerned. Of course, according to actual needs, the thread can also not be specified, and all threads can be concerned. In addition, according to the different real-time response requirements of the business, the scheduling delay time threshold value of the nanosecond or microsecond level can be specified to help the business thread to discover the abnormal business process that does not meet the expectation. In this case, the processing of step S110 specifically includes:
[0043] In response to the first thread being the specified thread set in advance, the wake-up time timestamp of the specified thread is acquired and stored in the stack space, when the first thread is scheduled, the scheduling delay time is calculated according to the wake-up time timestamp and the acquired scheduled time timestamp, and the scheduling delay time of the specified thread is stored into the kernel buffer area;
[0044] In response to the scheduling delay time of the specified thread being greater than or equal to the scheduling delay time threshold, an operation of acquiring the delay information of the specified thread and storing the delay information into the kernel buffer area is performed.
[0045] Through the above processing, the threads not concerned by the user can be quickly filtered out, so that the delay information of the threads really concerned by the user is pushed to the user. In addition, the scheduling delay time threshold can also be set according to the personalized needs of the user.
[0046] As can be seen from the above processing, step S110 needs to be processed in the following three steps:
[0047] 1. When the first thread is woken up, the stack space of the first thread is borrowed to record the time t1 (corresponding to the above-mentioned woken-up time stamp) at which the first thread enters the running queue;
[0048] 2. When the first thread is scheduled, the current time (corresponding to the above-mentioned scheduled time stamp) t2-t1, the scheduling delay time delta=t2-t1 of the first thread is obtained;
[0049] 3. For the first thread whose delta exceeds the threshold, the thread information, stack information, delayed scheduling thread information, stack information, etc. of the thread currently running on the CPU are put into the custom memory buffer area.
[0050] In actual application, in step S110, in response to the diagnostic instruction of the user mode program, the diagnostic kernel module chushi-tools install needs to be loaded; the scheduling delay diagnostic function chushi-tools syssched-delay--activate="threshold=20" needs to be activated; the stack space is borrowed to store the storage space of the thread scheduling delay storage field; when the thread is woken up, the time stamp of the woken-up time of the thread is recorded; when the thread is scheduled, the scheduling delay time delta_ms of the thread is obtained through the difference between the scheduled time stamp current_time_ms and the woken-up time stamp; if the delay time delta_ms is greater than the pre-set scheduling delay time threshold, the thread information, Cgroups information, kernel state call stack, user state call stack and thread call chain information of the current thread are acquired into the custom buffer area.
[0051] In step S120, in response to the data acquisition instruction of the user mode program, the delay information saved in the kernel buffer area is sent to the storage space specified by the user mode program. In the embodiment of the present disclosure, the delay information specifically includes at least one of the following: thread information, Cgroups information, kernel mode call stack information, user mode call stack information, and thread call chain information. Through these information, the specific flow of the business code exception can be fully mastered, and the user can directly find the business exception point. Among them, through the Cgroups information, the business thread situation in the specified container can be focused on, and in the container scene, the abnormal thread corresponding container and business can be quickly located, helping the user to quickly find the problem point.
[0052] In the embodiment of the present disclosure, the user mode program acquires the delay information in the kernel buffer area, and then can perform format analysis and format output on the delay information, view the diagnosis result, and generate a flame graph.
[0053] By using the stack space of the kernel to store the wake-up time stamp of the thread, the applicability and expansibility are improved, and the user mode program and the kernel module are integrated, so that the threshold of user self-diagnosis is reduced. The technical scheme of the embodiment of the present disclosure has little effect on the performance of the system and occupies few resources, and the abnormal thread can be quickly located by setting the specified thread and the scheduling delay time threshold.
[0054] Example method three
[0055] Figure 2 An example processing flowchart of an operating system scheduling delay diagnosis method is shown according to an example embodiment, as shown in Figure 2 The specific operations include the following operations:
[0056] I. Filtering configuration and threshold setting of the user mode program.
[0057] The kernel module supports the acquisition of the scheduling delay time of all threads at the us level, so as to avoid interference information. Through the user mode program, the system call of interest can be set, so that the kernel state (i.e. the kernel module) only focuses on the system call of interest of the user, for example, the thread group ID filtering condition, the thread PID filtering condition, and the thread name filtering condition are used to filter the system call of interest. Of course, the scheduling delay time threshold is also specified, and only the delay event outside the user's expectation is concerned.
[0058] II. Data acquisition of the kernel module, and the specific steps are as follows:
[0059] 1. When the thread is woken up and put into the CPU running queue, the thread entry time is recorded through the self-defined thread extension field.
[0060] 2、When the thread is selected by the CPU and starts to run, the scheduling delay time of the thread can be obtained through the difference delta_us between the scheduled time stamp and the woken-up time stamp; and according to the setting of the user state program, the condition filtering of the specified thread and the scheduling delay time threshold is performed, and only the thread scheduling situation configured by the user is concerned;
[0061] When the scheduling delay time delta_us is greater than the set threshold threshold time, the scheduling information and running information related to the thread are collected, for example, the thread PID, the thread kernel state stack information, the thread user state stack information, the thread call chain information, the thread Cgroups information, the thread enqueuing information, and the thread scheduling delay duration, etc.
[0062] III. On-demand information acquisition and on-demand data formatting.
[0063] The user state program can access the scheduling delay time obtained by the kernel module at any time, the user state program can output the abnormal information of the thread on demand, and can also generate a specific flame chart.
[0064] As can be seen from the above technical solution, the scheduling delay of the thread is determined by recording the time of the thread on the CPU scheduling queue, but the kernel thread structure body does not have a redundant field to record the time stamp of the thread, therefore, the scheduling delay time of the thread is stored by borrowing the kernel stack space in the embodiment of the disclosure, that is, the call chain of the current thread and the program call chain of the delayed scheduling thread are obtained by customizing the presentation mode of the stack, the link stack of the influencer and the influenced can be intuitively presented, and the influenced and the influencing reason can be quickly and accurately determined; the user state can generate a log file or a flame chart through a command field to help analyze the scheduling delay problem, the flame chart and the log can help the customer to intuitively find the abnormal business process and intuitively find the problem point, and help to optimize and diagnose the scheduling delay problem. When the business thread rt is jittered and the scheduling delay is adopted, the technical solution of the embodiment of the disclosure can provide a diagnosis basis for the related technical personnel in this case, and facilitate the technical personnel to repair the problem.
[0065] Exemplary apparatus
[0066] Figure 3 is a block diagram of an operating system scheduling delay diagnosis apparatus according to an exemplary embodiment. Referring to Figure 3 The apparatus 300 includes a user state program module 310 and a kernel module 320.
[0067] The user state program module 310 is configured to send a diagnosis instruction and a data acquisition instruction, and acquire the delay information saved in the kernel buffer area; the user state program module 310 is further configured to acquire the specified thread and the scheduling delay time threshold set in advance.
[0068] The kernel module 320 is configured to activate the scheduling delay diagnosis function of the kernel module in response to the diagnosis instruction of the user program, acquire the wake-up time timestamp of the first thread and store the wake-up time timestamp in the stack space, calculate the scheduling delay time according to the wake-up time timestamp and the acquired scheduling time timestamp when the first thread is scheduled, and store the scheduling delay time of the first thread and the corresponding delay information in the kernel buffer area; and send the delay information stored in the kernel buffer area to the user program in response to the data acquisition instruction of the user program.
[0069] The kernel module 320 is specifically configured to:
[0070] In response to the first thread being woken up, the wake-up time timestamp of the first thread is recorded in the stack space;
[0071] In response to the first thread being scheduled, the difference between the scheduling time timestamp and the wake-up time timestamp is calculated, the scheduling delay time of the first thread is obtained according to the difference, and the scheduling delay time is stored in the kernel buffer area.
[0072] When the user program module 310 acquires the pre-set specified thread and the scheduling delay time threshold, the kernel module 320 is specifically configured to: in response to the first thread being the pre-set specified thread, acquire the wake-up time timestamp of the specified thread and store the wake-up time timestamp in the stack space; and when the first thread is scheduled, calculate the scheduling delay time according to the wake-up time timestamp and the acquired scheduling time timestamp, and store the scheduling delay time of the specified thread in the kernel buffer area. In response to the scheduling delay time of the specified thread being greater than or equal to the scheduling delay time threshold, the operation of acquiring the delay information of the specified thread and storing the delay information in the kernel buffer area is performed.
[0073] It should be noted that the delay information specifically includes at least one of the following: thread information, control group information, kernel state call stack information, user state call stack information, and thread call chain information.
[0074] The example device is a device embodiment corresponding to the above example method, and the specific operations of each module can be understood with reference to the description of the method embodiment, which will not be described here.
[0075] An example electronic device
[0076] Figure 4 is a block diagram of an electronic device 400 according to an example embodiment. The electronic device 400 can be a vehicle controller, a vehicle terminal, a vehicle computer, or other types of electronic devices.
[0077] Referring to Figure 4The electronic device 400 can include at least one processor 410 and a memory 420. The processor 410 can execute instructions stored in the memory 420. The processor 410 is communicatively connected to the memory 420 through a data bus. In addition to the memory 420, the processor 410 can be communicatively connected to an input device 430, an output device 440, and a communication device 450 through the data bus.
[0078] The processor 410 can be any conventional processor, such as commercially available CPUs. The processor can also include a Graphic Process Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.
[0079] The memory 420 can be implemented by any type of volatile or nonvolatile memory device or a combination thereof, such as a Static Random Access Memory (SRAM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), an Erasable Programmable Read-Only Memory (EPROM), a Programmable Read-Only Memory (PROM), a Read-Only Memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.
[0080] In the embodiments of the present disclosure, the memory 420 stores executable instructions. The processor 410 can read the executable instructions from the memory 420 and execute the instructions to implement all or part of the steps of the operating system scheduling delay diagnosis method described in any of the above example embodiments.
[0081] Example computer-readable storage medium
[0082] In addition to the above method and device, the example embodiments of the present disclosure can also be a computer program product or a computer-readable storage medium storing the computer program product. The computer program product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in any of the above example embodiments.
[0083] The computer program product can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages, and scripting languages (e.g., Python). The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. The embodiments of the application are not limited by the programming languages used to write the program code.
[0084] The computer readable storage medium can be a combination of one or more computer readable media. The computer readable media can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can include, for example, but is not limited to, static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), flash memory, magnetic storage, optical disk, or any suitable combination thereof.
[0085] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. Variations and modifications of the embodiments disclosed herein can be made based on the description set forth herein, without departing from the scope and spirit of the disclosure. The application is intended to cover any variations, uses or adaptations of the disclosure including such departures from the present disclosure as come within known or customary practice in the art to which the disclosure pertains. The specification and examples are to be regarded as exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.
[0086] It should be understood that the present disclosure is not limited to the precise structures herein described and illustrated and that various modifications and changes can be made without departing from the scope of the present disclosure. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. An operating system scheduling latency diagnosis method, characterized by, The method comprises: in response to a diagnosis instruction of a user state program, activating a scheduling delay diagnosis function of a kernel module, obtaining a wake-up time timestamp of a first thread and storing it in a stack space, when the first thread is scheduled, calculating a scheduling delay time according to the wake-up time timestamp and an obtained scheduling time timestamp, and storing the scheduling delay time of the first thread and corresponding delay information into a kernel buffer area; and the stack space stores the call chain of the current thread and the program call chain information of the delayed scheduling thread through a stack, intuitively presenting the link stack of the influencer and the influenced, and determining the influenced and the influencing reason; in response to a data acquisition instruction of the user state program, sending the delay information saved in the kernel buffer area to a storage space specified by the user state program.
2. The method of claim 1, wherein, The method further comprises: obtaining a wake-up time timestamp of a first thread and storing it in a stack space, when the first thread is scheduled, calculating a scheduling delay time according to the wake-up time timestamp and an obtained scheduling time timestamp, and storing the scheduling delay time of the first thread into a kernel buffer area. in response to the first thread being woken up, recording the wake-up time timestamp of the first thread through the stack space; 3. The method of claim 1, wherein, in response to the first thread being scheduled, calculating the difference between the scheduling time timestamp and the wake-up time timestamp, and obtaining the scheduling delay time of the first thread according to the difference and storing it into the kernel buffer area. The method further comprises:
4. The method of claim 3, wherein, obtaining a pre-set specified thread and a scheduling delay time threshold value through a user state program. The method further comprises:
5. The method of claim 3, wherein, in response to the first thread being woken up, recording the wake-up time timestamp of the first thread through the stack space; in response to the first thread being scheduled, calculating the difference between the scheduling time timestamp and the wake-up time timestamp, and obtaining the scheduling delay time of the first thread according to the difference and storing it into the kernel buffer area. The method further comprises:
6. The method of claim 1, wherein, filtering threads through the PID of the thread, the Chinese name COMM of the thread, and the PID of the main thread of the thread group; 7. An operating system scheduling delay diagnosis apparatus characterized by comprising: in response to the scheduling delay time of the specified thread being greater than or equal to the scheduling delay time threshold value, performing the operation of obtaining the delay information of the specified thread and storing it into the kernel buffer area. The delay information specifically comprises at least one of the following: thread information, control group information, kernel state call stack information, user state call stack information, and thread call chain information. The method comprises: a user state program module for sending a diagnosis instruction and a data acquisition instruction, and obtaining delay information saved in a kernel buffer area; A kernel module is configured to activate a scheduling delay diagnosis function of the kernel module in response to a diagnosis instruction of a user mode program, acquire a woken time timestamp of a first thread and store the woken time timestamp in a stack space, calculate a scheduling delay time according to the woken time timestamp and an acquired scheduled time timestamp when the first thread is scheduled, and store the scheduling delay time of the first thread and corresponding delay information in a kernel buffer area. The kernel module is further configured to send the delay information stored in the kernel buffer area to the user mode program in response to a data acquisition instruction of the user mode program.
8. The apparatus of claim 7, wherein, The kernel module is specifically configured to: record a woken time timestamp of the first thread in the stack space in response to the first thread being woken up; calculate a difference between a scheduled time timestamp and the woken time timestamp, obtain the scheduling delay time of the first thread according to the difference, and store the scheduling delay time in the kernel buffer area in response to the first thread being scheduled.
9. The apparatus of claim 7, wherein, The user mode program module is further configured to acquire a preset specified thread and a scheduling delay time threshold.
10. The apparatus of claim 9, wherein, The kernel module is specifically configured to: acquire the woken time timestamp of the specified thread and store the woken time timestamp in the stack space in response to the first thread being the preset specified thread, calculate the scheduling delay time according to the woken time timestamp and an acquired scheduled time timestamp when the first thread is scheduled, and store the scheduling delay time of the specified thread in the kernel buffer area.
11. The apparatus of claim 9, wherein, The kernel module is specifically configured to: acquire the delay information of the specified thread and store the delay information in the kernel buffer area in response to the scheduling delay time of the specified thread being greater than or equal to the scheduling delay time threshold.
12. The apparatus of claim 7, wherein, The delay information specifically includes at least one of thread information, control group information, kernel mode call stack information, user mode call stack information, and thread call chain information.
13. An electronic device, comprising: The computer program is stored in the memory and executable on the processor, and the computer program is executed by the processor to implement the steps of the operating system scheduling delay diagnosis method. The computer readable storage medium stores an implementation program of information transmission, and the program is executed by the processor to implement the steps of the operating system scheduling delay diagnosis method.
14. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
Overtime detection method, device and equipment and storage medium
CN111176869A