Process processing method, electronic equipment and storage medium

By registering hook functions in the operating system to obtain process interrupt information and automatically perform exception handling operations based on the interrupt duration and frequency, the problem of untimely resolution of process exceptions is solved, and the stability and performance of the operating system are improved.

CN119690728APending Publication Date: 2025-03-25HENAN KUNLUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411847936.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the operating system, process exception resolution is not timely, resulting in the impact of the operating system's stability and performance.

Method used

By registering a hook function on the interrupt handling function, the process's interrupt information is obtained, and the exception handling operation is automatically performed to resolve potential exceptions based on the interrupt duration and frequency.

Benefits of technology

Real-time detection and automatic processing of process exceptions are realized, the stability and performance of the operating system are improved, and the overall performance of the operating system is reduced or crashed due to problems with a single process or interruption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690728A_ABST
    Figure CN119690728A_ABST
Patent Text Reader

Abstract

The invention discloses a process processing method, electronic equipment and a storage medium, and belongs to the technical field of operating systems, in the method, through a first hook function registered to an interrupt processing function, process interrupt information of a plurality of processes running based on a processing unit is obtained, and according to the process interrupt information, the process interrupt processing function is executed; and determining the interruption duration of the interrupted first process, and if the interruption duration exceeds a first threshold value, executing the configured first exception handling operation. Thus, when the interruption duration of the interrupted process exceeds the first threshold value, the first exception handling operation is automatically executed to handle the exception, potential exceptions can be found and handled without waiting for the process to throw the exception, the potential exceptions can be found, and the exception handling efficiency is high. Besides, as long as the process is interrupted, the first hook function can acquire the process interruption information, the process interruption information cannot be omitted, the acquisition granularity of the process interruption information is relatively fine, and potential exceptions can be comprehensively discovered and timely processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of operating systems, and in particular to a process processing method, an electronic device, and a storage medium. Background Art

[0002] In an operating system, a processing unit usually runs multiple processes. The running status of the processes can reflect the running status of the operating system. Therefore, it is necessary to monitor the running status of the processes.

[0003] In the related art, in order to operate and maintain the operating system, the exceptions that occur in the process are monitored and the exception information when the process is abnormal is recorded. Then, the operation and maintenance personnel manually solve the exceptions based on the recorded exception information, and the exceptions are not solved in time. Summary of the invention

[0004] The embodiments of the present application provide a process processing method, an electronic device, and a storage medium, which are used to solve the problem of untimely resolution of process anomalies in the related art.

[0005] In a first aspect, an embodiment of the present application provides a process processing method, including:

[0006] Obtaining process interrupt information of a process running on the processing unit through a first hook function registered on the interrupt processing function, wherein the process interrupt information includes at least one of an interrupt start time, an interrupt number, a process identifier of the interrupted process, a position where the code is executed, and an interrupt end time;

[0007] Determining, according to the process interruption information, an interruption duration of a first process, where the first process is an interrupted process;

[0008] If the interruption duration of the first process exceeds a first threshold, a configured first exception handling operation is executed.

[0009] In some embodiments, the method further comprises:

[0010] Determining an interruption frequency of the processing unit according to the process interruption information;

[0011] If the interrupt frequency of the processing unit exceeds a second threshold, the interrupt frequency of the processing unit is reduced.

[0012] In some embodiments, reducing the interrupt frequency of the processing unit includes:

[0013] Multiple interruptions are merged into one interruption, and tasks corresponding to the multiple interruptions are merged into the task corresponding to the one interruption.

[0014] In some embodiments, the method further comprises:

[0015] Acquiring process switching information of a process running on the processing unit through a second hook function registered to the process switching function;

[0016] Determine, according to the process switching information acquired in the current period, the running time of the second process, where the second process is the process to be switched;

[0017] If the running time of the second process exceeds a third threshold, the configured second exception handling operation is executed.

[0018] In some embodiments, the second process is the same process as the first process, and the second process undergoes multiple process switches, and the method further includes:

[0019] Determining, according to the process switching information of the second process, the running time of the second process before each switching;

[0020] If the running time of the second process before each switching exceeds a fourth threshold, the single runnable time of the second process is extended, and the fourth threshold is positively correlated with the single runnable time of the second process.

[0021] In some embodiments, the second process and the first process are the same process, and after determining the running time of the second process, the method further includes:

[0022] The running time of the second process is corrected according to the process interruption information of the second process in the period.

[0023] In some embodiments, the method further comprises:

[0024] storing process switching information and process interruption information of the process run by the processing unit in a memory corresponding to the processing unit;

[0025] In response to a trajectory query request for a specified object, querying process switching information and process interruption information of the specified object from the memory, wherein the specified object is the processing unit or a specified process;

[0026] Generate the trajectory information of the specified object according to the queried process switching information and process interruption information;

[0027] The trajectory information of the designated object is outputted through the virtual file system.

[0028] In some embodiments, there are multiple processing units, and the method further includes:

[0029] determining, according to the process switching information of the second process, a processing unit that runs the second process each time;

[0030] If the processing units that run the second process each time belong to different clusters, the scheduling strategy of the second process is adjusted to: scheduling according to the rule of scheduling to the processing units in the same cluster.

[0031] In some embodiments, the plurality of processes are processes of an operating system.

[0032] In a second aspect, an embodiment of the present application provides a process processing device, including:

[0033] an acquisition module, configured to acquire process interruption information of a process running on the processing unit through a first hook function registered on the interruption processing function, wherein the process interruption information includes at least one of an interruption start time, an interruption number, a process identifier of the interrupted process, a position where the code is executed, and an interruption end time;

[0034] A determination module, configured to determine an interruption duration of a first process according to the process interruption information, wherein the first process is an interrupted process;

[0035] The processing module is used to execute a configured first exception handling operation if the interruption duration of the first process exceeds a first threshold.

[0036] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:

[0037] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the above process processing method.

[0038] In a fourth aspect, an embodiment of the present application provides a storage medium. When a computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the above-mentioned process processing method.

[0039] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the above-mentioned process processing method when executed by a processor.

[0040] In the embodiment of the present application, the process interruption information of multiple processes running on the processing unit is obtained by registering the first hook function on the interruption processing function, and the interruption duration of the interrupted first process is determined according to the process interruption information. If the interruption duration exceeds the first threshold, the configured first exception handling operation is executed. In this way, when the interruption duration of the interrupted process exceeds the first threshold, the first exception handling operation is automatically executed to handle the exception, and the potential exception can be discovered and processed without waiting for the process to throw an exception. Not only can the potential exception be discovered, but the exception handling efficiency is also relatively high. In addition, as long as the process is interrupted, the first hook function can obtain the process interruption information, and the process interruption information will not be missed. The acquisition granularity of the process interruption information is relatively fine, which is also conducive to comprehensive discovery and timely processing of potential exceptions. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 A scene graph provided for an embodiment of the present application;

[0043] Figure 2 A flowchart of a process processing method provided in an embodiment of the present application;

[0044] Figure 3 A flowchart of another process processing method provided in an embodiment of the present application;

[0045] Figure 4 A schematic diagram of an interruption frequency provided in an embodiment of the present application;

[0046] Figure 5 A flowchart of another process processing method provided in an embodiment of the present application;

[0047] Figure 6 A schematic diagram of a scheduling trajectory of a second process provided in an embodiment of the present application;

[0048] Figure 7 A flowchart of another process processing method provided in an embodiment of the present application;

[0049] Figure 8 A schematic diagram of the module composition of a process processing method provided in an embodiment of the present application;

[0050] Fig. 9 A storage schematic diagram provided for an embodiment of the present application;

[0051] Fig.10 A schematic diagram of the structure of a process processing device provided in an embodiment of the present application;

[0052] Fig.11 A schematic diagram of the hardware structure of an electronic device for implementing a process processing method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to solve the problem of untimely resolution of process anomalies in the related art, an embodiment of the present application provides a process processing method, an electronic device, and a storage medium.

[0054] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0055] In order to facilitate the understanding of this application, the technical terms involved in this application are:

[0056] Process scheduling is an important function of operating systems such as the Linux operating system. It is used to determine which process can obtain the right to use a processing unit such as a central processing unit (CPU), and the length of time each process can use the CPU. Common process scheduling algorithms include polling scheduling, priority scheduling, and multi-level feedback queue scheduling.

[0057] Context switching refers to the process of CPU switching from one process to another. During this process, relevant information of the outgoing process such as the switching time, process ID, and the executed code location can be saved, and relevant information of the incoming process such as the ID, the CPU scheduled to, and the code location where execution starts can be saved.

[0058] Hooks allow additional code to be inserted during program execution to change or extend the behavior of a program. In this application, by registering a hook function to a corresponding function, context switch information of a process (i.e., process switch information) and context switch information of an interrupt (i.e., process interrupt information) can be obtained.

[0059] The proc file system is a virtual file system provided by the Linux operating system and other Unix-like operating systems. It is used to access the status information of the kernel and running processes.

[0060] Non-Volatile Memory (NVM) is a type of memory that can retain data even after power failure.

[0061] See also Figure 1 , Figure 1A scenario diagram provided for an embodiment of the present application includes a server 10, in which an operating system such as a Linux operating system or other Unix-like operating system may be installed. When the operating system is running, multiple processes will be started: process 1, process 2...process n. The running conditions of these multiple processes can reflect whether the operating system is running normally. To this end, a monitoring tool (a product manifestation of the method steps in the embodiment of the present application) can be installed in the server, and the running conditions of these multiple processes can be monitored by the monitoring tool, and potential anomalies can be found and processed to improve the stability of the operating system.

[0062] See also Figure 2 , Figure 2 A flowchart of a process processing method provided in an embodiment of the present application, the execution subject of the method may be Figure 1 The server 10 in the embodiment includes the following steps.

[0063] In step 201, by registering the first hook function on the interrupt handling function, the process interrupt information of the process running based on the processing unit is obtained, and the process interrupt information includes at least one of the interrupt start time, the interrupt number, the process ID of the interrupted process, the location where the code is executed, and the interrupt end time.

[0064] Among them, the processing unit can be a physical CPU or a logical CPU, the processes running based on the processing unit can be one, two or more, and the processes running based on the processing unit can all be processes of the operating system or some of them can be processes of the operating system, such as the Linux operating system or other Unix-like operating systems.

[0065] Tracepoint is a static debugging and performance analysis tool that allows developers to insert hook points at specific locations in the code to capture and record relevant information at runtime. Kernel developers declare some hook points in the kernel code and trigger a trace by calling the trace_xxx function. This hook point is a tracepoint.

[0066] Taking the interrupt entry hook point interrupt handling entry (irq_handler_entry) as an example, when using it, you can first call the trace-probe-register tracepoint_probe_register (__tracepoint_irq_handler_entry, fun_irq_handler_entry_probe, NULL) to register the probe function for the irq_handler_entry tracepoint; in the kernel code handle_interrupt_event_percpu (handle_irq_event_percpu) function (responsible for calling all interrupt handlers associated with a specific interrupt), the position before the interrupt handler function call pre-declares the trace point function trace_irq_handler_entry (irq, action). When this function is executed, the registered probe function will be called. Inside the probe function, according to the input parameter irq and action action, the event information (such as the interrupt start time, interrupt number, the process ID of the interrupted process, the location where the code is executed, the interrupt end time, etc.) is saved in the ring buffer (Ring_Buffer), thereby realizing the tracking of the interrupt event.

[0067] In step 202, the interruption duration of the first process is determined according to the process interruption information, and the first process is the interrupted process.

[0068] For the process interruption information corresponding to the first process, the time difference between the interruption end time and the interruption start time in the process interruption information is the interruption duration of the first process.

[0069] In step 203, if the interruption duration of the first process exceeds a first threshold, a configured first exception handling operation is executed.

[0070] Among them, the first exception handling operation may include an alarm, an exit interruption, a call stack recording, etc. The alarm may include the first process interruption duration exceeding XX milliseconds, the exit interruption may include the automatic execution of the interruption exit command, and the call stack recording may include the calling of the kernel dump_stack interface to print the call stack. The specific first exception handling operation may be selected according to the actual business scenario, and will not be described in detail here.

[0071] In the embodiment of the present application, the first hook function monitors the duration of process interruption and automatically handles the exception after the interruption times out, which can effectively prevent a process of the operating system from excessively occupying hardware resources, thereby improving the overall performance of the operating system.

[0072] See also Figure 3 , Figure 3 A flowchart of another process processing method provided in an embodiment of the present application, the method includes the following steps.

[0073] In step 301, by registering the first hook function on the interrupt handling function, the process interrupt information of the process running based on the processing unit is obtained, and the process interrupt information includes at least one of the interrupt start time, the interrupt number, the process ID of the interrupted process, the location where the code is executed, and the interrupt end time.

[0074] The implementation of this step can refer to step 201 and will not be described in detail here.

[0075] In step 302, the interruption duration of the first process is determined according to the process interruption information, and the first process is the interrupted process.

[0076] The implementation of this step can refer to step 202, which will not be described in detail here.

[0077] In step 303, if the interruption duration of the first process exceeds a first threshold, a configured first exception handling operation is executed.

[0078] The implementation of this step can refer to step 203, which will not be described in detail here.

[0079] In step 304, the interruption frequency of the processing unit is determined according to the process interruption information.

[0080] In actual applications, each interruption of the processing unit will generate a process interruption message. Therefore, there are several process interruption messages M within the time T, and the interruption frequency of the processing unit is M / T.

[0081] In step 305, if the interrupt frequency of the processing unit exceeds the second threshold, the interrupt frequency of the processing unit is reduced.

[0082] In specific implementation, multiple interruptions of the processing unit may be merged into one interruption, and the tasks originally corresponding to the multiple interruptions may be merged into the task corresponding to this interruption for processing, so as to reduce the overhead required for interrupt processing.

[0083] Assuming that the interrupt frequency of the processing unit is once every 1ms, the processing unit will be interrupted 1000 times in 1 second. Each interruption has a task to be processed, so 1000 context switches will be generated. If it is adjusted to interrupt once every 2ms, there will only be 500 interrupts in 1 second, and the tasks processed by 2 interrupts will be processed in the task of 1 interrupt. This can reduce the overhead of interrupt context switches by 500 times per second.

[0084] See also Figure 4 , Figure 4A schematic diagram of an interrupt frequency provided for an embodiment of the present application, wherein the original interrupt frequency is 9 interrupts per unit period, each interruption processes one task, and a total of 9 tasks are processed. The current interrupt frequency is 3 interrupts per unit period, and each interruption processes 3 tasks. The original 9 tasks are evenly divided into the tasks corresponding to the 3 interruptions and processed together.

[0085] In actual applications, permissions can also be opened to allow users to set the interruption frequency according to the business busyness. For example, when the business is not busy, the interruption frequency can be set higher to handle the business in time. When the business is busy, the interruption frequency can be set lower to save interruption expenses and use more resources for business processing.

[0086] In an embodiment of the present application, automatically handling exceptions after an interrupt times out can effectively prevent a process of the operating system from excessively occupying hardware resources and improve the overall performance of the operating system. Adjusting the interrupt frequency can make the interrupt consumption of the operating system more compatible with the business busyness, which can also improve the overall performance of the operating system.

[0087] It should be noted that in the above process, steps 302-303 and steps 304-305 can be executed in parallel or in series, and there is no strict order relationship between steps 302-303 and steps 304-305 when they are executed in series.

[0088] See also Figure 5 , Figure 5 A flowchart of another process processing method provided in an embodiment of the present application, the method includes the following steps.

[0089] In step 501, by registering the first hook function on the interrupt handling function, the process interrupt information of the process running based on the processing unit is obtained, and the process interrupt information includes at least one of the interrupt start time, the interrupt number, the process ID of the interrupted process, the location where the code is executed, and the interrupt end time.

[0090] The implementation of this step can refer to step 201 and will not be described in detail here.

[0091] In step 502, the interruption duration of the first process is determined according to the process interruption information, and the first process is the interrupted process.

[0092] The implementation of this step can refer to step 202, which will not be described in detail here.

[0093] In step 503, if the interruption duration of the first process exceeds a first threshold, a configured first exception handling operation is executed.

[0094] The implementation of this step can refer to step 203, which will not be described in detail here.

[0095] In step 504, the interruption frequency of the processing unit is determined according to the process interruption information.

[0096] The implementation of this step can refer to step 304, which will not be described in detail here.

[0097] In step 505, if the interrupt frequency of the processing unit exceeds the second threshold, the interrupt frequency of the processing unit is reduced.

[0098] The implementation of this step can refer to step 305, which will not be described in detail here.

[0099] In step 506, the process switching information of the process running on the processing unit is obtained through the second hook function registered to the process switching function.

[0100] In actual applications, after the second hook function is registered with the process switching function, whenever the process switching function is executed, that is, the process switching is performed, the second hook function can obtain a process switching information. The process switching information includes the switching time, the process ID of the switched-out process, the location where the code is executed, the process ID of the switched-in process, the CPU scheduled, the starting location of the code execution, and other information.

[0101] In step 507, the running time of the second process is determined according to the process switching information acquired in the current cycle, and the second process is the process to be switched.

[0102] That is, the running time of the second process can be determined periodically based on the obtained process switching information. Taking the process switching information obtained in a cycle as an example, the running time of the second process refers to the execution time of the second process from the start time to the end time of this cycle. During this process, the second process may not be interrupted, or may be interrupted once, twice, or more times.

[0103] In step 508, if the running time of the second process exceeds the third threshold, the configured second exception handling operation is executed.

[0104] Among them, the second exception handling operation includes alarm, process termination, call stack recording, operating system reset, etc. The alarm is such as the running time of the second process exceeds XX milliseconds, the process termination is such as automatically executing the process termination command, the call stack recording is such as calling the kernel dump_stack interface to print the call stack, and the operating system reset is such as calling panic to reset the operating system. The specific second exception handling operation to be performed can be selected according to the actual business scenario, and will not be repeated here.

[0105] In this way, automatically handling exceptions after the running time is timed out can also effectively prevent a process of the operating system from excessively occupying hardware resources, thereby improving the overall performance of the operating system.

[0106] In step 509, the process switching information and the process interruption information are stored in the memory corresponding to the processing unit.

[0107] Generally, each time a process switching message or a process interrupt message is obtained, the message can be stored in the memory corresponding to the processing unit, such as the kernel memory. In this way, the information in the memory is stored in the order of generation time, which is more readable and convenient for subsequent trajectory analysis. In addition, the kernel memory is a non-volatile memory, which can also ensure the storage reliability of process switching information and process interrupt information.

[0108] In step 510, in response to a trace query request for a specified object, process switching information and process interruption information of the specified object are queried from the memory, the specified object is a processing unit or a specified process, and the trace query request is received through a virtual file system.

[0109] The specified processes include the first process, the second process, and other processes.

[0110] In step 511, the trajectory information of the designated object is generated according to the queried process switching information and process interruption information.

[0111] In specific implementation, the switching events and interrupt events of the specified object can be arranged in order from early to late, so as to obtain the trajectory information of the specified object. For example, the trajectory information of a process includes: CPU0—>CPU1—>Interrupt 0—>CPU2—>Interrupt 1—>CPU0—>CPU3, a total of 7 trajectory points, and each trajectory point can also include more information such as time, call stack, etc. This information can be set according to actual needs and will not be repeated here.

[0112] In step 512, the trajectory information of the designated object is output through the virtual file system.

[0113] In this way, relevant personnel can obtain the trajectory of specified objects through the virtual file system and understand the operation status of specified objects, so as to better operate and maintain the operating system.

[0114] In some embodiments, there are multiple processing units, and the second process is run based on the multiple processing units, that is, the second process is scheduled back and forth between the multiple processing units. In this case, the processing unit that runs the second process each time can be determined based on the process switching information of the second process. If the processing units that run the second process each time belong to different clusters, the scheduling strategy of the second process can be adjusted to: schedule according to the rules for scheduling to the processing units on the same cluster. Since the processing units on the same cluster can share memory, the data reading speed is faster and less prone to errors, so this can improve the data reading speed of the second process and reduce read and write errors.

[0115] The above situation is illustrated below with examples.

[0116] Assume that there are 4 processing units: CPU0~CPU3, each of which corresponds to a work queue, and CPU0 and CPU1 belong to the same cluster and share the L2 cache, while CPU2 and CPU3 belong to another cluster and share another L2 cache.

[0117] See also Figure 6 , Figure 6 A schematic diagram of the scheduling trajectory of a second process provided for an embodiment of the present application, wherein the original trajectory of the second process is: scheduled to CPU0 -> scheduled to CPU1 -> scheduled to CPU2 -> scheduled to CPU1 -> scheduled to CPU2 -> scheduled to CPU0, that is, the second process is scheduled to drift back and forth among CPU0, CPU1, and CPU2.

[0118] Since CPU0 and CPU1 belong to the same cluster and can share L2 cache, but CPU2 belongs to another cluster and cannot share L2 cache with CPU0 and CPU1, when the second process is executed on CPU2, it cannot share L2 cache and needs to read data from memory again, which is slower than directly accessing cache. To this end, the scheduling rule of the second process can be modified to: put it on CPU0 and CPU1 for execution. Subsequently, the second process can only be scheduled back and forth between CPU0 and CPU1, thereby avoiding the performance loss of cache invalidation when the second process is scheduled on CPU2.

[0119] In the embodiment of the present application, by setting the alarm threshold and the exception handling strategy, the real-time detection and automatic handling of abnormal processes can be realized, which greatly improves the efficiency of exception handling. Moreover, by timely handling the abnormal situation, the probability of the overall performance degradation or crash of the operating system due to a single process or interrupt problem can be reduced, thereby enhancing the stability of the operating system. In addition, by displaying the recorded information through the proc file system, a convenient and fast query method is provided for the operation and maintenance engineers, which can greatly improve the operation and maintenance efficiency.

[0120] In actual applications, a process may experience a switching event and an interruption event at the same time during operation. That is to say, in some embodiments, the second process and the first process are the same process. The following takes the second process and the first process as an example to introduce the solution of the embodiment of the present application. Figure 7 , Figure 7 A flowchart of another process processing method provided in an embodiment of the present application, the method includes the following steps.

[0121] In step 701, by registering the first hook function on the interrupt handling function, the process interrupt information of the process running based on the processing unit is obtained, and the process interrupt information includes at least one of the interrupt start time, the interrupt number, the process ID of the interrupted process, the location where the code is executed, and the interrupt end time.

[0122] There may be one, two or more processing units.

[0123] In step 702, the process switching information of the process running on the processing unit is obtained through the second hook function registered to the process switching function.

[0124] In step 703, the running time of the first process is determined according to the process switching information of the first process acquired in the current cycle.

[0125] In step 704, the running time of the first process is corrected according to the process interruption information of the first process in the corresponding period.

[0126] For example, the corrected running time of the first process=the running time of the first process-(the total interruption time of the first process in the corresponding period).

[0127] Among them, if the first process is interrupted only once in the corresponding period, the total interruption duration of the first process is equal to the interruption duration of this interruption; if the first process is interrupted more than once in the corresponding period, the total interruption duration of the first process is equal to the sum of the interruption durations.

[0128] In this way, a more accurate running time of the first process in the corresponding period can be obtained, which is conducive to improving the accuracy of subsequent abnormality judgment.

[0129] In step 705, if the corrected running time of the first process exceeds the third threshold, the configured second exception handling operation is executed.

[0130] In step 706, the running time of the first process before each switching is determined according to the process switching information of the first process.

[0131] In step 707, the running time of the first process before each switching out is corrected according to the process interruption information of the first process.

[0132] For example, the running time of the first process before each cut-out after correction=the running time of the first process before each cut-out-the total interruption time of the first process from the last cut-in before the current cut-out to the current cut-out.

[0133] In this way, a more accurate running time of the first process before each switching can be obtained, which is conducive to improving the accuracy of subsequent single running time adjustment, wherein the single running time represents the longest time that the process is allocated to run on the processing unit.

[0134] In step 708, if the running time of the first process before each switching out after correction exceeds the fourth threshold, the single runnable time of the first process is extended, and the fourth threshold is positively correlated with the single runnable time of the first process.

[0135] The fourth threshold may be a preset ratio of a single operational time period, such as 80%.

[0136] In actual applications, if the running time of the first process before each cutout is relatively long (i.e., exceeds the fourth threshold), it means that the first process is likely to passively abandon the execution of the processing unit, that is, the single runnable time allocated to the first process is insufficient. To this end, the single runnable time of the first process can be increased to reduce the performance consumption in the scheduling process of the first process.

[0137] For example, due to the kernel scheduling rules of the Linux operating system, the first process could only execute for 1ms before being scheduled out (i.e., cut out). Now, by modifying the process parameters such as increasing the weight of the first process, the single running time of the first process is extended to 3ms, reducing the process switching by 2 times, so the process switching overhead can be reduced.

[0138] It should be noted that, in the above process, there is no strict sequence relationship between steps 703-705 and steps 706-708, and there is no strict sequence relationship between steps 701 and 701.

[0139] See also Figure 8 , Figure 8 The module composition diagram of a process processing method provided by the embodiment of the present application includes a tracking configuration module, a context switching tracking module, an information storage module, an exception handling module, a query display module and an optimization module. These modules are introduced below.

[0140] 1. Tracking configuration module, used to configure the relevant thresholds and exception handling operations of the process, as well as the relevant thresholds and exception handling operations of the interrupt.

[0141] 1) Configure interrupt-related thresholds and exception handling operations:

[0142] a. Interruption duration threshold (i.e., first threshold): a reference value used to measure whether an interruption has timed out. Generally, the interruption duration of a process will not be too long. If an interruption duration is too long, it may also indicate that the software process design is defective or abnormal.

[0143] b. Interrupt frequency threshold (ie, second threshold): a reference value used to measure whether the interrupt frequency is too high.

[0144] c. Exception handling strategy (i.e., the first exception handling operation): that is, after the interruption duration of a process exceeds the corresponding threshold, the executable operations include alarm, exit interruption, recording call stack, etc.

[0145] 2) Configure the relevant thresholds and exception handling operations of the process:

[0146] a. The threshold of the process running time in a single cycle (i.e., the third threshold): a reference value used to measure whether a process occupies the CPU for a long time. Generally, the execution time of a process in a single cycle is short. If a process is executed on the CPU for a long time in a single cycle and is not dispatched out of the CPU, it means that the software process design is defective or abnormal.

[0147] b. Exception handling strategy (i.e., the second exception handling operation): refers to the operation that can be performed after the running time of the process in a single cycle exceeds the corresponding threshold, such as alarm, process termination, call stack recording, operating system reset, etc.

[0148] 2. Context switch tracking module, used to track the context switch of processes and interrupts. In actual applications, when the operating system starts, the kernel module can be loaded through the systemd service, and the first hook function (also called interrupt tracking hook) can be registered in the kernel interrupt system, and the second hook function (also called process tracking hook) can be registered in the kernel scheduling system. Subsequently, when an interrupt occurs in any CPU, the first hook function will be triggered to execute, a process interrupt information will be obtained, and the process interrupt information will be stored in the information storage module; when a process switch occurs in any CPU, the second hook function will be triggered to execute, a process switch information will be obtained, and the process switch information will be stored in the information storage module.

[0149] 3. Information storage module, used to store and manage the process switching information and process interruption information obtained from the context switch tracking module. This information will be stored in the kernel memory, see Fig. 9 , Fig. 9 A storage diagram is provided for an embodiment of the present application, wherein the kernel memory is RAM or non-volatile memory, which is used to store the process switching information and process interruption information of CPU0~CPUn. The process switching information and process interruption information of each CPU are stored in partitions in the kernel memory and can be exported to the log partition of the operating system.

[0150] 4. An exception handling module is used to perform a first exception handling operation such as an alarm, exit interruption, and record a call stack after the interruption duration of any process exceeds a first threshold; and to perform a second exception handling operation such as an alarm (such as the process execution exceeds xx ms), terminate the process, record the call stack (i.e., call the kernel dump_stack interface to print the call stack), and reset the operating system (such as calling panic to reset the operating system) after the running time of the process in a single cycle exceeds a third threshold.

[0151] 5. A query and display module is used to display the recorded process switching information or process interruption information through the proc file system, and to display the trajectory information of a specified object such as a specified CPU or a specified process through the proc file system. The trajectory information of the specified object is generated based on the process switching information and process interruption information of the specified object, providing a convenient and fast information query function for operation and maintenance engineers.

[0152] 6. Optimization module, used to optimize the interruption frequency based on the process interruption information and optimize the process scheduling strategy based on the process switching information.

[0153] 1) Optimize interrupt frequency based on process interrupt information.

[0154] The interrupt frequency of the CPU is determined based on the process interrupt information of each CPU. If it is determined that the interrupt frequency of the CPU exceeds the second threshold, the interrupt frequency of the CPU can be reduced. In this way, the interrupt frequency of the CPU can be automatically adjusted to better match the actual business needs.

[0155] 2) Optimize process scheduling strategy based on process switching information.

[0156] a. According to the process switching information of each process, determine the running time of the process before each switch. If the running time of the process before each switch exceeds the preset proportion of the single running time of the process, the single running time can be extended to reduce the number of times the process is scheduled and reduce the scheduling overhead.

[0157] b. According to the process switching information of each process, determine the CPU to which the process is scheduled each time. If the CPUs to which the process is scheduled each time do not belong to the same cluster, the process will be subsequently scheduled according to the rules for scheduling to the CPUs in the same cluster. Since CPUs in the same cluster share the L2 cache, the probability of process read errors can be reduced.

[0158] In specific implementation, the administrator can configure the above-mentioned interrupt-related thresholds and exception handling operations, as well as the process-related thresholds and exception handling operations in the configuration file in advance. Subsequently, when the operating system starts, the kernel module can be loaded through the systemd service, and the process tracking hook and the interrupt tracking hook can be registered. When the operating system process is scheduled or switched, the process tracking hook can obtain the process switching information, call the interface of the information storage module, and store the process switching information in the memory block corresponding to the current CPU. When the operating system process is interrupted, the process interrupt hook can obtain the process interrupt information, call the interface of the information storage module, and store the process interrupt information in the memory block corresponding to the current CPU. The process switching information and process interrupt information stored in the memory block constitute the process tracking information. Operation and maintenance engineers can view the process tracking information in the memory block through the proc file system, and can also export the process tracking log from the memory block.

[0159] Based on the same technical concept, the embodiment of the present application also provides a process processing device. The principle of solving the problem by the process processing device is similar to that of the above-mentioned process processing method. Therefore, the implementation of the process processing device can refer to the implementation of the process processing method, and the repeated parts will not be repeated.

[0160] Fig.10 A schematic diagram of the structure of a process processing device provided in an embodiment of the present application includes:

[0161] The acquisition module 1001 is used to acquire process interruption information of a process running on the processing unit through a first hook function registered on the interruption processing function, wherein the process interruption information includes at least one of an interruption start time, an interruption number, a process identifier of the interrupted process, a position where the code is executed, and an interruption end time;

[0162] A determination module 1002, configured to determine an interruption duration of a first process according to the process interruption information, wherein the first process is an interrupted process;

[0163] The processing module 1003 is used to execute a configured first exception handling operation if the interruption duration of the first process exceeds a first threshold.

[0164] In some embodiments, an optimization module 1004 is further included for:

[0165] Determining an interruption frequency of the processing unit according to the process interruption information;

[0166] If the interrupt frequency of the processing unit exceeds a second threshold, the interrupt frequency of the processing unit is reduced.

[0167] In some embodiments, the optimization module 1004 is specifically configured to:

[0168] Multiple interruptions are merged into one interruption, and tasks corresponding to the multiple interruptions are merged into the task corresponding to the one interruption.

[0169] In some embodiments, the acquisition module 1001 is further used to acquire the process switching information of the process running on the processing unit through a second hook function registered to the process switching function;

[0170] The determination module 1002 is further configured to determine the running time of the second process according to the process switching information acquired in the current cycle, where the second process is the process to be switched;

[0171] The processing module 1003 is further configured to execute a configured second exception handling operation if the running time of the second process exceeds a third threshold.

[0172] In some embodiments, the second process is the same process as the first process, and the second process undergoes multiple process switches. The optimization module 1004 is further configured to:

[0173] Determining, according to the process switching information of the second process, the running time of the second process before each switching;

[0174] If the running time of the second process before each switching exceeds a fourth threshold, the single runnable time of the second process is extended, and the fourth threshold is positively correlated with the single runnable time of the second process.

[0175] In some embodiments, the second process and the first process are the same process, and the determination module 1002 is further configured to:

[0176] After determining the running time of the second process, the running time of the second process is corrected according to the process interruption information of the second process in the period.

[0177] In some embodiments, it also includes:

[0178] The storage module 1005 is used to store the process switching information and process interruption information of the process run by the processing unit in the memory corresponding to the processing unit;

[0179] A query module 1006 is used to query the process switching information and process interruption information of the specified object from the memory in response to a trajectory query request for the specified object, wherein the specified object is the processing unit or the specified process; and generate the trajectory information of the specified object according to the queried process switching information and process interruption information;

[0180] The trajectory information of the designated object is outputted through the virtual file system.

[0181] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated in a processor, or may exist physically separately, or two or more modules may be integrated in one module. The coupling between the modules may be achieved through some interfaces, which are usually electrical communication interfaces, but it is not excluded that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0182] After introducing the process processing method and device according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0183] Refer to the following Fig.11 The electronic device 130 implemented according to this embodiment of the present application is described. Fig.11 The electronic device 130 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0184] like Fig.11 As shown, the electronic device 130 is in the form of a general electronic device. The components of the electronic device 130 may include but are not limited to: the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).

[0185] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0186] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .

[0187] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0188] The electronic device 130 may also communicate with one or more external devices 134 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 130, and / or communicate with any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules for the electronic device 130 via a bus 133. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0189] In an exemplary embodiment, a storage medium is also provided, and when a computer program in the storage medium is executed by a processor of an electronic device, the electronic device can perform the above-mentioned process processing method. Optionally, the storage medium can be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0190] In an exemplary embodiment, the electronic device of the present application may include at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor may execute the steps of any process processing method provided in the embodiments of the present application.

[0191] In an exemplary embodiment, a computer program product is also provided. When the computer program product is executed by an electronic device, the electronic device can implement any exemplary method provided in the present application.

[0192] Furthermore, the computer program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0193] The program product for process processing in the embodiment of the present application may adopt a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0194] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0195] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0196] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network such as a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0197] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0198] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0199] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0200] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0201] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0202] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0203] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0204] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application also includes these modifications and variations.

Claims

1. A process processing method, characterized in that: include: Obtaining process interrupt information of a process running on the processing unit through a first hook function registered to the interrupt processing function, wherein the process interrupt information includes at least one of an interrupt start time, an interrupt number, a process identifier of the interrupted process, a code execution location, and an interrupt end time; Determining, according to the process interruption information, an interruption duration of a first process, where the first process is an interrupted process; If the interruption duration of the first process exceeds a first threshold, a first exception handling operation is performed.

2. The method according to claim 1, characterized in that The method further comprises: Determining an interruption frequency of the processing unit according to the process interruption information; If the interrupt frequency of the processing unit exceeds a second threshold, the interrupt frequency of the processing unit is reduced.

3. The method according to claim 2, characterized in that Reducing the interrupt frequency of the processing unit, comprising: Multiple interruptions are merged into one interruption, and tasks corresponding to the multiple interruptions are merged into the task corresponding to the one interruption.

4. The method according to claim 1, characterized in that The method further comprises: Acquiring process switching information of a process running on the processing unit through a second hook function registered to the process switching function; Determine, according to the process switching information acquired in the current period, the running time of the second process, where the second process is the process to be switched; If the running time of the second process exceeds a third threshold, the configured second exception handling operation is executed.

5. The method according to claim 4, characterized in that The second process is the same process as the first process, and the second process undergoes multiple process switches. The method further includes: Determining, according to the process switching information of the second process, the running time of the second process before each switching; If the running time of the second process before each switching exceeds a fourth threshold, the single runnable time of the second process is extended, and the fourth threshold is positively correlated with the single runnable time of the second process.

6. The method according to claim 4 or 5, characterized in that The second process is the same process as the first process, and after determining the running time of the second process, the method further includes: The running time of the second process is corrected according to the process interruption information of the second process in the period.

7. The method according to claim 4, characterized in that The method further comprises: storing process switching information and process interruption information of the process run by the processing unit in a memory corresponding to the processing unit; In response to a trajectory query request for a specified object, querying process switching information and process interruption information of the specified object from the memory, wherein the specified object is the processing unit or a specified process; Generate the trajectory information of the specified object according to the queried process switching information and process interruption information; The trajectory information of the designated object is outputted through the virtual file system.

8. An electronic device, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor, wherein: The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 7.

9. A storage medium, characterized in that: When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the method as claimed in any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when executed by a processor.