Memory overflow processing method and device, vehicle, equipment and medium

By transferring the processing rights of memory overflow to the user-state arbitration process and providing process control policy configuration, the possible system-level problems and personalized protection requirements of kernel-state processes in memory overflow processing are solved, and the robustness of the operating system is improved. flexibility.

CN119271443APending Publication Date: 2025-01-07GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411305998.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

When handling memory overflows in the prior art, kernel-state processes are prone to kernel errors (panics), resulting in system-level problems and instability, and lack of a personalized process protection mechanism.

Method used

The memory overflow processing rights are transferred from the kernel's memory overflow processing function to the user-state arbitration process running in the background, and the memory overflow processing is processed through the arbitration process, and process control policy configuration is provided, allowing users to personalize the protection of important processes.

Benefits of technology

It avoids system-level problems that occur in memory overflow processing by kernel-state processes, improves the robustness of the operating system, and provides a personalized process protection mechanism to adapt to the needs of different device terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271443A_ABST
    Figure CN119271443A_ABST
Patent Text Reader

Abstract

The invention relates to a memory overflow processing method and device, a vehicle, equipment and a medium. The method comprises the steps that whether memory overflow occurs or not is detected in a kernel mode; in response to the detected memory overflow, transferring the processing right of the memory overflow from a memory overflow processing function of the kernel to an arbitration process, so that the arbitration process performs memory overflow processing; the arbitration process is a user state process running in the background and has the authority of controlling other processes. The user mode process takes over the processing right of memory overflow, namely, the decision right of the kernel mode process for deciding to end which process is transferred to the user mode process, and the user mode process is isolated from the kernel mode process. The system level problem or system instability caused by kernel errors in the memory overflow processing process of the kernel mode process is avoided, and the robustness of an operating system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of operating systems and vehicles, and in particular to a method, device, vehicle, equipment and medium for processing memory overflow. Background Art

[0002] As the functions of smart devices increase and the amount of data increases, the running space and storage space required by applications on smart devices are also increasing. When running a large number of application processes in the operating system of a smart device, memory overflow (OOM, Out Of Memory) may occur. Memory overflow means that some application processes have unreclaimable memory or use too much memory. When other application processes apply for memory allocation, the system will first force the current process that occupies a large amount of memory to exit in order to reduce the system burden; or when the current application process applies for memory again, the system cannot allocate more memory and throws an exception, causing the current application process to exit. Summary of the invention

[0003] During the research and development, it was found that the relevant technologies have the following technical problems: the current solutions for memory overflow are basically to configure the scoring strategy or process priority of each application process by the kernel. When memory overflow occurs, the kernel state process selects a process with a higher or lower score, or a lower priority, to end (kill); however, in the above process, if a kernel error (panic) occurs in the above kernel state process, it will cause system-level problems, affecting the operation of the entire system.

[0004] In order to overcome the problems existing in the related art, the present disclosure provides a method, device, vehicle, equipment and medium for processing memory overflow.

[0005] According to the first aspect of the embodiment of the present disclosure, a method for processing memory overflow is provided. The method comprises: detecting whether memory overflow occurs in kernel state; in response to detecting memory overflow, transferring the processing right of memory overflow from the kernel's memory overflow processing function to an arbitration process, so that the arbitration process processes the memory overflow; wherein the arbitration process is a user state process running in the background and has the authority to control other processes.

[0006] In some embodiments, the above-mentioned transferring of the processing right of memory overflow from the memory overflow processing function to the arbitration process so that the above-mentioned arbitration process processes the memory overflow includes: the above-mentioned memory overflow processing function obtains the function switch status corresponding to the arbitration process; in response to the above-mentioned function switch status indicating that the function of the above-mentioned arbitration process is turned on, the above-mentioned memory overflow processing function sends a processing right transfer signal to the above-mentioned arbitration process; after receiving the above-mentioned processing right transfer signal, the above-mentioned arbitration process determines the target process according to the pre-configured process control strategy, and ends the above-mentioned target process to release corresponding resources.

[0007] In some embodiments, the processing right transfer signal is used to instruct the arbitration process to handle the memory overflow instead of continuing to execute the default processing logic of the memory overflow processing function.

[0008] In some embodiments, the method further includes: creating an interface object for kernel-mode and user-mode communication; the interface object includes: a first interface object for storing a function switch state corresponding to an arbitration process; a second interface object for storing a process identifier of the arbitration process; wherein the memory overflow processing function obtains the function switch state corresponding to the arbitration process, including: the memory overflow processing function obtains a pre-configured function switch state corresponding to the arbitration process from the first interface object; the memory overflow processing function sends a processing right transfer signal to the arbitration process, including: the memory overflow processing function obtains a pre-configured process identifier of the arbitration process from the second interface object; and according to the process identifier, the memory overflow processing function sends a processing right transfer signal to the arbitration process.

[0009] In some embodiments, the method further includes: loading a user-mode arbitration function configuration file; wherein the user-mode arbitration function configuration file includes: first configuration information for setting whether the function switch state corresponding to the arbitration process is turned on, second configuration information for setting the process identifier of the arbitration process, and third configuration information for setting the process control policy implemented after a memory overflow occurs; in the process of starting and initializing the arbitration process, parsing the user-mode arbitration function configuration file to obtain the first configuration information, the second configuration information, and the third configuration information, writing the first configuration information and the second configuration information into the interface object for communication between the kernel mode and the user mode, and configuring the process control policy of the arbitration process according to the third configuration information.

[0010] In some embodiments, the above method also includes at least one of the following: in response to the above function switch status indicating that the function of the above arbitration process is turned off, executing the default processing logic of the above memory overflow processing function; wherein the above default processing logic is the processing logic for memory overflow configured by the kernel; or, when the above arbitration process cannot obtain the target process according to the pre-configured process control policy, the above arbitration process sends a processing right return signal to the above memory overflow processing function; after receiving the above processing right return signal, the above memory overflow processing function executes the default processing logic of the above memory overflow processing function.

[0011] In some embodiments, the method further includes: upon detecting that the arbitration process is terminated due to a fault or anomaly, restarting the arbitration process at least once based on a restart mechanism; after the arbitration process is successfully restarted, the arbitration process continues to execute the previous processing task; after the arbitration process fails to restart based on the restart mechanism, the arbitration process sends a processing right return signal to the memory overflow processing function; after receiving the processing right return signal, the memory overflow processing function executes the default processing logic of the memory overflow processing function; or, after the arbitration process fails to restart based on the restart mechanism, the following information is prompted on the front-end display interface: the arbitration process is terminated and a memory overflow processing error is reported.

[0012] In some embodiments, the above method is applied to a Linux operating system; in the above Linux operating system, the above memory overflow processing function is modified, including: by assigning an end process selection object having the memory overflow processing right in the above memory overflow processing function to the process identifier of the above arbitration process, so as to transfer the memory overflow processing right from the kernel's memory overflow processing function to the above arbitration process, so that the above arbitration process performs memory overflow processing.

[0013] In some embodiments, the method further includes: defining a first global variable and a second global variable in a main file of the kernel source code of the Linux operating system, the first global variable indicating the function switch state corresponding to the arbitration process, and the second global variable indicating the process identifier of the arbitration process; creating a first interface object and a second interface object in a proc file of the Linux operating system, the first interface object being used to store the function switch state, and the second interface object being used to store the process identifier; wherein, when the function switch state indicates that the function of the arbitration process is turned on, performing the following steps: assigning the end process selection object having the memory overflow processing right in the memory overflow processing function to the process identifier of the arbitration process.

[0014] According to the second aspect of the embodiment of the present disclosure, a memory overflow processing device is provided. The above-mentioned device includes: a detection module and a processing right transfer module. The above-mentioned detection module is used to detect whether a memory overflow occurs in the kernel state. The above-mentioned processing right transfer module is used to transfer the processing right of the memory overflow from the kernel's memory overflow processing function to the arbitration process in response to the detection of the memory overflow, so that the above-mentioned arbitration process processes the memory overflow. Among them, the above-mentioned arbitration process is a user-mode process running in the background and has the authority to control other processes.

[0015] In some embodiments, the processing right transfer module includes: a state acquisition module, a signal sending module, a signal receiving module and a process control module. The state acquisition module is located in the memory overflow processing function, and is used to obtain the function switch state corresponding to the arbitration process in response to the detection of memory overflow. The signal sending module is located in the memory overflow processing function, and is used to send a processing right transfer signal to the arbitration process in response to the function switch state indicating that the function of the arbitration process is turned on. The signal receiving module is located in the arbitration process, and is used to receive the processing right transfer signal. The process control module is located in the arbitration process, and is used to determine the target process according to the pre-configured process control policy after receiving the processing right transfer signal, and end the target process to release the corresponding resources.

[0016] According to a third aspect of an embodiment of the present disclosure, a vehicle is provided, storing a set of instruction sets, wherein the instruction sets are executed by the vehicle to implement the memory overflow processing method provided by the first aspect of the present disclosure.

[0017] According to the fourth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing executable instructions of the above-mentioned processor; the above-mentioned processor is used to read the above-mentioned executable instructions from the above-mentioned memory, and execute the above-mentioned instructions to implement the memory overflow processing method provided by the first aspect of the present disclosure.

[0018] According to a fifth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the memory overflow processing method provided in the first aspect of the present disclosure are implemented.

[0019] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0020] When a memory overflow is detected, the processing right of the memory overflow (OOM) is transferred from the kernel's memory overflow processing function to the user-state process that runs in the background and has the authority to control other processes - the arbitration process, so that the above arbitration process handles the memory overflow; on the one hand, the user-state process takes over the processing right of the memory overflow, which is equivalent to transferring the decision-making right of the kernel-state process to decide which process to end (kill) to the user-state process, and the user-state process handles the memory overflow. Since the user-state process and the kernel-state process are isolated, system-level problems (generally difficult to recover) or system instability caused by kernel errors (panics) in the kernel-state process during the memory overflow processing can be avoided, which can improve the robustness of the operating system (the ability to withstand failures and interference). On the other hand, considering that the process scoring strategy configured by the kernel is unified and indiscriminate for all applications within the operating system, some users expect to be able to make personalized configurations on which processes to protect and which important processes cannot be terminated for different device ends. The above solution also provides a processing path that is parallel to the kernel's memory overflow processing, providing users with more choices. Users can protect important processes by personalizing the process control strategy of the arbitration process, and flexibly adapt to the personalized protection needs of the process when OOM occurs.

[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0023] Figure 1 The invention is a flowchart of a method for processing memory overflow according to an exemplary embodiment.

[0024] Figure 2 The figure is a schematic diagram of an implementation process of a method for processing memory overflow according to an exemplary embodiment.

[0025] Figure 3 is a detailed implementation flowchart of step S120 according to an exemplary embodiment.

[0026] Figure 4 is a detailed implementation flowchart of step S120 according to another exemplary embodiment.

[0027] Figure 5 is a detailed implementation flowchart of step S120 according to yet another exemplary embodiment.

[0028] Figure 6The figure is a flowchart of a method for processing memory overflow according to yet another exemplary embodiment.

[0029] Figure 7 is a flowchart of a method for processing memory overflow according to yet another exemplary embodiment.

[0030] Figure 8 The invention is a block diagram of a device for processing memory overflow according to an exemplary embodiment.

[0031] Fig. 9 is a block diagram of a vehicle according to an exemplary embodiment.

[0032] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0033] Exemplary embodiments will be described in detail below with reference to the accompanying drawings.

[0034] It should be pointed out that the relevant embodiments and drawings are only for describing exemplary embodiments provided by the present disclosure, rather than all embodiments of the present disclosure, and it should not be understood that the present disclosure is limited to the relevant exemplary embodiments.

[0035] 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 neither represent any specific technical meanings nor indicate the order or interdependence between them.

[0036] It should be noted that the modifications of the terms "one", "multiple", and "at least one" used in the present disclosure are illustrative rather than restrictive. Unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0037] It should be noted that the term "and / or" used in this disclosure is used to describe the association relationship between associated objects, and generally indicates that there are at least three association relationships. For example, A and / or B can at least indicate the existence of three association relationships: A exists alone, A and B exist at the same time, and B exists alone.

[0038] It should be noted that the various steps described in the method embodiments of the present disclosure may be performed in different orders 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 relevant embodiments.

[0039] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.

[0040] Technical terminology

[0041] Robustness of an operating system refers to the ability of an operating system to maintain normal operation in the face of unpredictable changes or interference. It mainly includes performance robustness and stability robustness. Performance robustness refers to the ability to ensure that the main performance indicators are within an acceptable range of variation in the face of changes or interference. Stability robustness refers to the ability to avoid adverse responses such as oscillation or instability in the face of changes or interference. This characteristic is of great significance for ensuring the long-term stable operation of the system.

[0042] Operating system: referred to as system, is a group of interrelated system software programs that manage and control the operation of electronic equipment, schedule and run hardware resources, software resources, and provide public services to organize user interactions.

[0043] Central Processing Unit (CPU): It is the computing and control core of electronic devices and the final execution unit for information processing and program running. The CPU contains computing logic components, register components, and control components, and has functions such as processing instructions, executing operations, controlling time, and processing data.

[0044] The CPU has two states: user state and kernel state. Programs that run the operating system in kernel state can be described as operating system programs. Programs that run applications in user state can be described as application programs.

[0045] The instructions that can be run in kernel mode and user mode are different. Kernel mode can run privileged instructions, while user mode can run non-privileged instructions. In user mode, programs can only access their own memory space and limited system resources, and cannot directly access the core functions and hardware devices of the operating system. This is a restriction set to ensure the stability and security of the system. Programs executed in user mode cannot perform some privileged operations, such as directly operating hardware devices and modifying operating system kernel data.

[0046] Kernel state process: refers to the system process running in kernel state.

[0047] User state process: refers to the process corresponding to the user program running in user state.

[0048] Exemplary Methods

[0049] Figure 1 The invention is a flowchart of a method for processing memory overflow according to an exemplary embodiment.

[0050] The memory overflow processing method provided in the embodiments of the present disclosure can be applied to devices that perform calculations based on an operating system. The above-mentioned devices include but are not limited to: vehicle-mounted equipment, flight equipment (such as drones, aircraft, airborne equipment, etc.), mobile devices (such as smart phones, smart robots, etc.), wearable devices (such as smart watches, smart bracelets, etc.), smart home devices (such as sweeping robots, indoor detection robots, chat robots, monitoring equipment, etc.), etc.

[0051] Reference Figure 1 As shown, the above processing method includes the following steps: S110 and S120.

[0052] In step S110, it is detected in kernel mode whether a memory overflow occurs.

[0053] The kernel allocates memory based on the needs of applications. Generally speaking, in reality, applications do not use all of the allocated memory or in rare scenarios, multiple applications consume all of the allocated memory. In most scenarios, there is a dynamic memory recovery and dynamic allocation process. Therefore, in order to improve operating performance, the kernel will use an over-allocation of memory (over-commit memory, the sum of memory allocated to multiple application threads is greater than the overall physical memory) to utilize unused memory or reclaimed memory to improve the overall memory usage efficiency of the system. After most applications have consumed all of their allocated memory, since pre-allocation is over-allocation, when the memory requirements of these applications exceed the capacity of physical memory, memory overflow occurs.

[0054] In some embodiments, in the above step S110, it is possible to determine whether a memory overflow occurs based on an existing function in the kernel, and when a memory overflow occurs, the above function generates an event prompt message accordingly. For example, it is possible to determine whether a memory overflow occurs based on a memory allocation function in the kernel, and when a memory overflow occurs, the memory allocation function generates an event prompt message indicating that memory allocation failed due to OOM, and based on this event prompt message, it can be determined that a memory overflow occurs.

[0055] In other embodiments, in the above step S110, a detection function can be constructed in kernel state, which can obtain the amount of memory actually used by each application process, and determine whether a memory overflow occurs based on the comparison result between the total amount of memory actually used by each application process and the total capacity of the physical memory.

[0056] In step S120, in response to detecting a memory overflow, the processing rights of the memory overflow are transferred from the kernel's memory overflow processing function to the arbitration process, so that the arbitration process handles the memory overflow; wherein the arbitration process is a user-mode process running in the background and has the authority to control other processes.

[0057] In the related art, an OOM-Score scoring mechanism and an OOM-Killer process termination mechanism are set in the kernel. The score or priority of each user-state process is determined based on preset scoring rules (for example, scoring each user-state process according to its resource consumption) or priority (for example, prioritizing each user-state process according to its resource consumption and business importance), and then the target user-state process whose score or priority meets the preset conditions (for example, the highest / lowest score and the lowest priority) is determined as the process to be terminated (killed), and memory space is released by terminating one or more target user-state processes to achieve memory recovery, and dynamic allocation continues in the future.

[0058] In some scoring rules of related technologies, some schemes give higher scores to user-mode processes that occupy more memory, so that when OOM occurs, the user-mode process with the highest final score is determined as the process to be terminated. Some schemes are to avoid terminating important user-mode processes that occupy a large amount of memory by manually setting the starting score of the user-mode process to be very low, so that the final score of the process to be protected is very low, and it will not be terminated in the end, thus achieving the purpose of protecting important processes. However, the scoring mechanism is still continued in this process. If there are multiple user-mode processes that need to be protected according to the needs of different businesses or different users, then the scores of these user-mode processes need to be manually adjusted, and there will be differences in this adjustment. Some users adjust more, and some users adjust less. As a result, there may still be differences in the scores of the user-mode processes to be protected, or they may be mistakenly killed after being scored according to the scoring rules.

[0059] In some priority sorting schemes of related technologies, most of them are based on the kernel to prioritize various user-mode processes, and at the same time, priority sorting rules are set according to the processes that the system wants to protect from being terminated, or the processes that are terminated without affecting the stability of system operation.

[0060] The overall idea of ​​the above-mentioned related technologies is still to directly control from the kernel level, and to perform scoring or priority sorting based on the kernel when OOM occurs, and determine the process to be terminated; for example, the memory overflow processing function in the kernel is used to select the user-mode process to be terminated and terminate the selected user-mode process. However, if a kernel error (panic) occurs in the kernel-mode process (for example, the memory overflow processing function or other related kernel processes or kernel threads, such as the kernel thread kswapd, which is used to perform page memory recovery tasks) during the above process, it will cause system-level problems, resulting in the operation of the entire system being affected. In addition, the process scoring strategy configured by the kernel is bottom-level and universal, and is unified and indiscriminate in the face of various applications in the operating system. As long as all devices using this operating system use the process scoring strategy corresponding to the same scoring mechanism, then for different device ends, some users expect to be able to perform personalized configuration for which processes to protect and which important processes cannot be terminated. The existing method is only to adjust the scores of these processes to be protected or important processes.

[0061] In view of this, in the embodiments of the present invention, by creating a user state process-an arbitration process that runs in the background and has the authority to control other processes, the processing right of the memory overflow processing function originally used for OOM processing in the kernel is transferred to this arbitration process, so that the arbitration process processes the memory overflow. On the one hand, the user state process takes over the processing right of the memory overflow OOM, which is equivalent to transferring the decision-making right of the kernel state process to decide which process to end (kill) to the user state process, and the user state process processes the memory overflow. Since the user state process and the kernel state process are isolated, the kernel state process is prevented from causing a kernel error (panic) during the memory overflow processing process. System On the other hand, considering that the process scoring strategy configured by the kernel is unified and indifferent for various applications in the operating system, some users expect to be able to perform personalized configuration on which processes to protect and which important processes cannot be terminated for different device ends. The above scheme also provides a processing path parallel to the kernel's memory overflow processing, which provides users with more choices. Users can protect important processes by personalizing the process control strategy of the arbitration process, and flexibly adapt to the personalized protection needs of the process when OOM occurs.

[0062] In the embodiments of the present disclosure, the arbitration process is a user-mode process that runs in the background and has control authority over other processes. For example, by setting root (exceeding the authority limit of general applications) authority for the arbitration process, it can control other user-mode processes, which may include but is not limited to: ending (killing) and restarting user-mode processes installed on the device, or controlling the installation, deletion, and uninstallation of some applications.

[0063] The other processes that can be controlled by the above arbitration process refer to user-state processes. Generally, one application corresponds to one user-state process. A user-state process can be implemented based on one or more threads during operation. The user-state process can create user-state threads through API (application programming interface) or create kernel-state threads through system calls.

[0064] Figure 2 The figure is a schematic diagram of an implementation process of a method for processing memory overflow according to an exemplary embodiment. Figure 3 is a detailed implementation flowchart of step S120 according to an exemplary embodiment.

[0065] In some embodiments, reference Figure 3 As shown, in the above step S120, the processing right of the memory overflow is transferred from the memory overflow processing function to the arbitration process, so that the above arbitration process performs the processing of the memory overflow, including the following steps: S310, S321 and S331.

[0066] In step S310, the memory overflow processing function obtains the function switch status corresponding to the arbitration process.

[0067] In step S321, in response to the function switch state indicating that the function of the arbitration process is turned on, the memory overflow processing function sends a processing right transfer signal to the arbitration process.

[0068] In step S331, after receiving the processing right transfer signal, the arbitration process determines the target process according to the pre-configured process control strategy and ends the target process to release corresponding resources.

[0069] The processing right transfer signal is used to instruct the arbitration process to process the memory overflow instead of continuing to execute the default processing logic of the memory overflow processing function.

[0070] In this embodiment, refer to Figure 2As shown, in the kernel state, memory overflow OOM is detected, triggering the kernel to call the memory overflow processing function to process OOM. Before the default processing logic of the memory overflow processing function is executed, a new judgment logic is added to determine whether to transfer the processing right and the transfer logic after the processing right transfer is determined, which specifically includes: obtaining the function switch status corresponding to the arbitration process; referring to Figure 2 As shown in the execution flow corresponding to sequence number ①, in response to the above function switch state indicating that the function of the above arbitration process is turned on, the above memory overflow processing function sends a processing right transfer signal to the above arbitration process; after receiving the above processing right transfer signal, the above arbitration process determines the target process according to the pre-configured process control strategy, and ends the above target process to release the corresponding resources. For example, taking the vehicle-mounted device as an example, Figure 2 4 user-mode processes are shown in the figure, namely user-mode process 1 (corresponding to application APP1), user-mode process 2 (corresponding to application APP2), user-mode process 3 (corresponding to application APP3) and user-mode process 4 (corresponding to application APP4). The pre-configured process control strategy indicates which user-mode processes are core processes or processes that need to be protected. Such processes will not be selected when terminating a process. For example, user-mode process 1 and user-mode process 2 are important processes or core processes related to safe driving of the vehicle and need to be protected. When OOM occurs, a process that occupies a large amount of memory is selected from the non-core processes: user-mode process 3 and user-mode process 4 as the target process to be terminated, for example, user-mode process 3 is determined as the target process to be terminated. The above user-mode process 3 is terminated through the control authority of the arbitration process itself, so that the memory resources occupied by it are released, part of the memory is recovered, and the system of the vehicle-mounted device is helped to run continuously and stably.

[0071] In some embodiments, reference Figure 2 As shown, the above method also includes: creating an interface object for kernel mode and user mode communication.

[0072] Taking the Linux operating system as an example, this interface object can be a virtual file system proc file, which actually corresponds to a shared memory area for communication between kernel state and user state. Kernel state processes and user state processes can communicate by accessing the above shared memory area.

[0073] In some embodiments, the interface object includes: a first interface object for storing the function switch state corresponding to the arbitration process; and a second interface object for storing the process identifier of the arbitration process. For example, taking the Linux operating system as an example, the first interface object for storing the function switch state corresponding to the arbitration process (exemplarily described as the userkiller process) is: proc1_oom_userkiller_status file, and the second interface object for storing the process identifier corresponding to the arbitration process is: proc2_oom_userkiller_pid file.

[0074] The memory overflow processing function obtains the function switch status corresponding to the arbitration process, including: the memory overflow processing function obtains the function switch status corresponding to the pre-configured arbitration process from the first interface object (for example, the proc1_oom_userkiller_status file).

[0075] The above-mentioned memory overflow processing function sends a processing right transfer signal to the above-mentioned arbitration process (for example, the userkiller process), including: the above-mentioned memory overflow processing function obtains the process identifier of the pre-configured arbitration process (for example, oom_userkiller_pid) from the above-mentioned second interface object (for example, the proc2_oom_userkiller_pid file); according to the above-mentioned process identifier, the above-mentioned memory overflow processing function sends a processing right transfer signal to the above-mentioned arbitration process.

[0076] Figure 4 is a detailed implementation flowchart of step S120 according to another exemplary embodiment.

[0077] In other embodiments, referring to Figure 2 The execution flow corresponding to sequence number ② and Figure 4 As shown in the solid line box, the above step S120 includes the following steps: S310 and S322. In some embodiments, for the case where the function switch state is adjusted, there may be logics that are executed by both branches at the same time, referring to Figure 4 The execution logic of step S321 shown in the dotted box and step S322 shown in the solid box.

[0078] In step S322, in response to the function switch state indicating that the function of the arbitration process is turned off, the default processing logic of the memory overflow processing function is executed.

[0079] The above default processing logic is the processing logic for memory overflow configured by the kernel. The specific default processing logic depends on the relevant configuration of the kernel and can follow the specific logic in the relevant technology or improved technology, which will not be described in detail here.

[0080] In the embodiment including steps {S110, S310, S321, S331}, or including steps {S110, S310, S322}, or including steps {S110, S310, S321, S331, S322}, by setting the switch function based on the function switch state corresponding to the arbitration process, it is compatible with the existing solution to provide another parallel OOM processing logic, and it is also helpful to improve the robustness of the system. After the switch is turned on, the arbitration process takes over the processing right, and the user state process-the arbitration process, which runs in the background and has the control authority over other processes, performs the corresponding processing for OOM; after the switch is turned off, the kernel state (for example, the memory overflow processing function in the kernel) performs the corresponding processing of OOM according to the default processing logic, thereby providing two processing paths for parallel optional execution for memory overflow, providing users with more choices. When the switch is turned on, users can protect important processes by personalizing the process control strategy of the arbitration process, and flexibly adapt to the personalized protection needs of the process when OOM occurs.

[0081] Figure 5 is a detailed implementation flowchart of step S120 according to yet another exemplary embodiment.

[0082] In other embodiments, reference Figure 5 As shown, the above step S120 includes the following steps: S310, S321, S331, S510 and S520. The above steps S510 and S520 are performed after step S330.

[0083] In step S510, when the arbitration process cannot obtain the target process according to the pre-configured process control policy, the arbitration process sends a processing right return signal to the memory overflow processing function.

[0084] In step S520, after receiving the processing right return signal, the memory overflow processing function executes the default processing logic of the memory overflow processing function.

[0085] In this embodiment, refer to Figure 2As shown in the execution flow corresponding to sequence number ①, the execution path corresponding to the dotted double arrow, and the execution flow corresponding to sequence number ②, when a memory overflow occurs, the OOM is first processed based on the arbitration process running in the background and having control authority over other processes. If the arbitration process cannot obtain the target process to be terminated according to the pre-configured process control policy (for example, some processes are beyond the control of the arbitration process or the appropriate target process cannot be matched according to the above process control policy in the current system operating environment), the processing right can be transferred back to the kernel state, and the memory overflow processing function in the kernel continues to perform OOM processing based on the default processing logic. This embodiment provides the following ideas: the arbitration process (i.e., the user-mode process) takes over the OOM processing right first for processing. If the arbitration process cannot obtain the target process to be terminated, the processing right is transferred back to the original memory overflow processing function, and the memory overflow processing function continues to perform OOM processing based on the default processing logic. Since the user-mode process is isolated from the kernel-mode process, system-level problems (generally difficult to recover) or system instability caused by kernel errors (panics) in the memory overflow processing process of the kernel-mode process are avoided, which can improve the robustness of the operating system (the ability to withstand failures and interference); at the same time, users can protect important processes by personalizing the process control strategy of the arbitration process, and flexibly adapt to the personalized protection requirements of the process when OOM occurs; a bottom-line strategy is also provided when the arbitration process cannot obtain the target process, and the process is transferred back to the kernel mode to continue OOM processing. In the face of various emergencies or extreme situations, timely response processing of memory recovery and dynamic allocation is ensured, stable operation of the system is ensured, and the robustness of the operating system is improved.

[0086] Figure 6 The figure is a flowchart of a method for processing memory overflow according to yet another exemplary embodiment.

[0087] In some embodiments, reference Figure 6 As shown, in addition to the above steps S110 and S120, the above method further includes the following steps: S610, S621; or steps corresponding to another branch: S610, S622, S632; or steps S610, S623 corresponding to another branch.

[0088] In step S610, when it is detected that the arbitration process is terminated due to a fault or anomaly, the arbitration process is restarted at least once based on a restart mechanism.

[0089] In step S621, after the arbitration process is successfully restarted, the arbitration process continues to execute the previous processing task.

[0090] In step S622, after the arbitration process fails to restart based on the restart mechanism, the arbitration process sends a processing right return signal to the memory overflow processing function.

[0091] In step S632, after receiving the processing right return signal, the memory overflow processing function executes the default processing logic of the memory overflow processing function.

[0092] In step S623, after the arbitration process fails to restart based on the restart mechanism, the following information is displayed on the front-end interface: the arbitration process is terminated and a memory overflow processing error is reported.

[0093] In this embodiment, the arbitration process can start the restart mechanism after a problem occurs in itself. Based on multiple restart attempts, the arbitration process can improve its timely response to OOM processing and ensure the stability of the system. In the case of restart failure, there are two processing logics. One is to transfer the processing right back to the kernel, and the memory overflow processing function in the kernel continues to process based on the default processing logic. The timely transfer of processing rights can ensure the continued processing of OOM; the other is to directly prompt the arbitration process termination and memory overflow processing error at the front end, and the user intervenes. After seeing the memory overflow processing error information, the user can directly end some user-mode processes to ensure that the system has enough memory space to ensure normal operation.

[0094] In the embodiment of the present disclosure, the function switch state corresponding to the above arbitration process specifically selects whether the switch is turned on or off, which is configured by the user in the configuration file according to needs and can be modified through the configuration file. In the subsequent description, the above configuration file is described as a user-mode arbitration function configuration file.

[0095] Figure 7 is a flowchart of a method for processing memory overflow according to yet another exemplary embodiment.

[0096] In some embodiments, reference Figure 7 As shown, the above method includes the following steps in addition to the above steps S110 and S120: S710 and S720. Steps S710 and S720 are performed before step S120.

[0097] In step S710, a user-mode arbitration function configuration file is loaded; wherein the user-mode arbitration function configuration file includes: first configuration information for setting whether the function switch state corresponding to the arbitration process is turned on, second configuration information for setting the process identifier of the arbitration process, and third configuration information for setting the process control strategy implemented after a memory overflow occurs.

[0098] In step S720, in the process of starting and initializing the arbitration process, the user-mode arbitration function configuration file is parsed to obtain the first configuration information, the second configuration information and the third configuration information, the first configuration information and the second configuration information are written into the interface object for communication between kernel mode and user mode, and the process control policy of the arbitration process is configured according to the third configuration information.

[0099] In some embodiments, the above method is applied to a Linux operating system; in the above Linux operating system, the above memory overflow processing function is modified, including: by assigning an end process selection object (for example, a select_bad_process function, or described as a select_victim_process function) with memory overflow processing rights in the above memory overflow processing function to the process identifier of the above arbitration process (for example, oom_userkiller_pid), so as to transfer the memory overflow processing rights from the kernel's memory overflow processing function to the above arbitration process, so that the above arbitration process performs memory overflow processing.

[0100] In some embodiments, the above method further comprises:

[0101] A first global variable and a second global variable are defined in a main file (for example, the main file oom_kill.c) of the kernel source code of the Linux operating system, wherein the first global variable (for example, the first global variable is oom_userkiller_status) indicates a function switch state corresponding to the arbitration process, and the second global variable (for example, the second global variable is oom_userkiller_pid) indicates a process identifier of the arbitration process;

[0102] Creating a first interface object and a second interface object in the proc file of the Linux operating system, wherein the first interface object is used to store the function switch state, and the second interface object is used to store the process identifier;

[0103] Among them, when the above-mentioned function switch status indicates that the function of the above-mentioned arbitration process is turned on (whether it is turned on is also determined by), the above-mentioned steps are executed: the end process selection object with the memory overflow processing right in the above-mentioned memory overflow processing function is assigned to the process identifier of the above-mentioned arbitration process.

[0104] Exemplary Devices

[0105] Figure 8 The invention is a block diagram of a device for processing memory overflow according to an exemplary embodiment.

[0106] Reference Figure 8As shown, the memory overflow processing device 800 includes: a detection module 810 and a processing right transfer module 820.

[0107] The detection module 810 is used to detect whether a memory overflow occurs in the kernel state.

[0108] The processing right transfer module 820 is used to transfer the processing right of the memory overflow from the kernel's memory overflow processing function to the arbitration process in response to detecting the memory overflow, so that the arbitration process handles the memory overflow. The arbitration process is a user-mode process running in the background and has the authority to control other processes.

[0109] In some embodiments, the processing right transfer module 810 includes: a state acquisition module 811 , a signal sending module 812 , a signal receiving module 813 and a process control module 814 .

[0110] The state acquisition module 811 is located in the memory overflow processing function and is used to acquire the function switch state corresponding to the arbitration process in response to detecting the memory overflow.

[0111] The signal sending module 812 is located in the memory overflow processing function, and is used to send a processing right transfer signal to the arbitration process in response to the function switch state indicating that the function of the arbitration process is turned on.

[0112] The signal receiving module 813 is located in the arbitration process and is used to receive the processing right transfer signal.

[0113] The process control module 814 is located in the arbitration process and is used to determine the target process according to the pre-configured process control strategy after receiving the processing right transfer signal, and terminate the target process to release corresponding resources.

[0114] For more details and beneficial effects of this embodiment, please refer to the relevant description of the first embodiment, which will not be repeated here.

[0115] Example Vehicles

[0116] Fig. 9 is a block diagram of a vehicle 900 according to an exemplary embodiment. The vehicle 900 may be a fuel vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle or other types of vehicles.

[0117] Reference Fig. 9As shown, the vehicle 900 may include multiple subsystems, for example, a drive system 910, a control system 920, a perception system 930, a communication system 940, an information display system 950, and a computing system 960. The vehicle 900 may also include more or fewer subsystems, and each subsystem may also include multiple components, which are not described one by one here.

[0118] The driving system 910 includes components that provide power movement for the vehicle 900, such as an engine, an energy source, a transmission device, etc.

[0119] The control system 920 includes components that provide control for the vehicle 900, such as vehicle control, cockpit equipment control, and driving assistance control.

[0120] The perception system 930 includes components that provide the vehicle 900 with surrounding environment perception, such as a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, a camera device, and the like.

[0121] The communication system 940 includes components that provide communication connections for the vehicle 900, such as mobile communication networks (such as 3G, 4G, 5G networks, etc.), WiFi, Bluetooth, and Internet of Vehicles.

[0122] The information display system 950 includes components that provide various information displays for the vehicle 900, such as vehicle information display, navigation information display, entertainment information display, etc.

[0123] The computing and processing system 960 includes components that provide data computing and processing capabilities for the vehicle 900. The computing and processing system 960 may include at least one processor 961 and a memory 962. The processor 961 may execute instructions stored in the memory 962.

[0124] The processor 961 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.

[0125] Memory 962 can be implemented by any type of volatile or nonvolatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0126] In the embodiment of the present disclosure, a set of instruction sets is stored in the memory 962, and the processor 961 can execute the instruction set to implement all or part of the steps of the memory overflow processing method described in any of the above exemplary embodiments.

[0127] Exemplary Electronic Devices

[0128] Fig.10 1 is a block diagram of an electronic device 1000 according to an exemplary embodiment. The electronic device 1000 may be a vehicle controller, a vehicle terminal, a vehicle computer or other types of electronic devices.

[0129] Reference Fig.10 As shown, the electronic device 1000 may include at least one processor 1010 and a memory 1020. The processor 1010 may execute instructions stored in the memory 1020. The processor 1010 is communicatively connected to the memory 1020 via a data bus. In addition to the memory 1020, the processor 1010 may also be communicatively connected to an input device 1030, an output device 1040, and a communication device 1050 via a data bus.

[0130] The processor 1010 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.

[0131] Memory 1020 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0132] In an embodiment of the present disclosure, executable instructions are stored in the memory 1020, and the processor 1010 can read the executable instructions from the memory 1020 and execute the instructions to implement all or part of the steps of the memory overflow processing method described in any of the above exemplary embodiments.

[0133] Exemplary computer-readable storage media

[0134] In addition to the above methods and devices, the exemplary embodiments of the present disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in any method in the above exemplary embodiments.

[0135] The computer program product may be written in any combination of one or more programming languages ​​to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and also conventional procedural programming languages, such as "C" language or similar programming languages ​​and scripting languages ​​(e.g., Python). The program code may be executed entirely on the user computing device, partially on the user computing device, as an independent software package, partially on the user computing device and partially on the remote computing device, or entirely on the remote computing device or server.

[0136] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of readable storage media include: a static random access memory (SRAM) with one or more wires electrically connected, 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 storage, a flash memory, a magnetic disk or an optical disk, or any suitable combination of the above.

[0137] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0138] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for processing memory overflow, characterized in that: include: Check whether memory overflow occurs in kernel state; In response to detecting a memory overflow, transferring the processing right of the memory overflow from the memory overflow processing function of the kernel to the arbitration process, so that the arbitration process performs the processing of the memory overflow; The arbitration process is a user-mode process running in the background and has the authority to control other processes.

2. The method according to claim 1, characterized in that The transferring of the memory overflow processing right from the memory overflow processing function to the arbitration process so that the arbitration process processes the memory overflow includes: The memory overflow processing function obtains the function switch status corresponding to the arbitration process; In response to the function switch state indicating that the function of the arbitration process is turned on, the memory overflow processing function sends a processing right transfer signal to the arbitration process; After receiving the processing right transfer signal, the arbitration process determines the target process according to the pre-configured process control strategy, and ends the target process to release corresponding resources.

3. The method according to claim 2, characterized in that The processing right transfer signal is used to instruct the arbitration process to handle the memory overflow instead of continuing to execute the default processing logic of the memory overflow processing function.

4. The method according to claim 1, characterized in that: Also includes: Creating an interface object for kernel-mode and user-mode communication; the interface object comprises: a first interface object for storing a function switch state corresponding to an arbitration process; A second interface object for storing a process identifier of an arbitration process; The memory overflow processing function obtains the function switch state corresponding to the arbitration process, including: the memory overflow processing function obtains the function switch state corresponding to the pre-configured arbitration process from the first interface object; The memory overflow processing function sends a processing right transfer signal to the arbitration process, including: the memory overflow processing function obtains the process identifier of the pre-configured arbitration process from the second interface object; according to the process identifier, the memory overflow processing function sends a processing right transfer signal to the arbitration process.

5. The method according to any one of claims 1 to 4, characterized in that Also includes: Loading a user-mode arbitration function configuration file; wherein the user-mode arbitration function configuration file includes: first configuration information for setting whether the function switch state corresponding to the arbitration process is turned on, second configuration information for setting the process identifier of the arbitration process, and third configuration information for setting the process control strategy implemented after a memory overflow occurs; In the process of starting and initializing the arbitration process, the user-state arbitration function configuration file is parsed to obtain the first configuration information, the second configuration information and the third configuration information, the first configuration information and the second configuration information are written into the interface object for communication between kernel state and user state, and the process control policy of the arbitration process is configured according to the third configuration information.

6. The method according to claim 1, characterized in that Also includes at least one of the following: In response to the function switch state indicating that the function of the arbitration process is turned off, the default processing logic of the memory overflow processing function is executed; wherein the default processing logic is the processing logic for memory overflow configured by the kernel; or, When the arbitration process cannot obtain the target process according to the pre-configured process control policy, the arbitration process sends a processing right return signal to the memory overflow processing function; after receiving the processing right return signal, the memory overflow processing function executes the default processing logic of the memory overflow processing function.

7. The method according to claim 1, characterized in that Also includes: When it is detected that the arbitration process is terminated due to a fault or anomaly, restarting the arbitration process at least once based on a restart mechanism; After the arbitration process is successfully restarted, the arbitration process continues to execute the previous processing task; After the arbitration process fails to restart based on the restart mechanism, the arbitration process sends a processing right return signal to the memory overflow processing function; after receiving the processing right return signal, the memory overflow processing function executes the default processing logic of the memory overflow processing function; or, After the arbitration process fails to restart based on the restart mechanism, the following information is prompted on the front-end display interface: the arbitration process is terminated and a memory overflow processing error is reported.

8. The method according to any one of claims 1 to 4, 6 or 7, characterized in that The method is applied to Linux operating system; In the Linux operating system, the memory overflow processing function is modified, including: by assigning the end process selection object with memory overflow processing rights in the memory overflow processing function to the process identifier of the arbitration process, so as to transfer the memory overflow processing rights from the kernel's memory overflow processing function to the arbitration process, so that the arbitration process performs memory overflow processing.

9. The method according to claim 8, characterized in that The method further comprises: A first global variable and a second global variable are defined in a main file of the kernel source code of the Linux operating system, wherein the first global variable indicates a function switch state corresponding to the arbitration process, and the second global variable indicates a process identifier of the arbitration process; Creating a first interface object and a second interface object in a proc file of the Linux operating system, wherein the first interface object is used to store the function switch state, and the second interface object is used to store the process identifier; Wherein, when the function switch state indicates that the function of the arbitration process is turned on, the following steps are performed: the end process selection object with the memory overflow processing right in the memory overflow processing function is assigned to the process identifier of the arbitration process.

10. A memory overflow processing device, characterized in that: include: The detection module is used to detect whether memory overflow occurs in kernel state; A processing right transfer module, for transferring the processing right of the memory overflow from the memory overflow processing function of the kernel to the arbitration process in response to detecting the memory overflow, so that the arbitration process performs the memory overflow processing; The arbitration process is a user-mode process running in the background and has the authority to control other processes.

11. The device according to claim 10, characterized in that The processing right transfer module includes: a state acquisition module, a signal sending module, a signal receiving module and a process control module; The state acquisition module is located in the memory overflow processing function and is used to obtain the function switch state corresponding to the arbitration process in response to detecting the memory overflow; The signal sending module is located in the memory overflow processing function, and is used to send a processing right transfer signal to the arbitration process in response to the function switch state indicating that the function of the arbitration process is turned on; The signal receiving module is located in the arbitration process and is used to receive the processing right transfer signal; The process control module is located in the arbitration process, and is used to determine the target process according to a pre-configured process control strategy after receiving the processing right transfer signal, and end the target process to release corresponding resources.

12. A vehicle, characterized in that: A set of instruction sets is stored, and the instruction sets are executed by the vehicle to implement the method described in any one of claims 1-9.

13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the method described in any one of claims 1-9.

14. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of any method described in claims 1-9 are implemented.