Method, device and medium for locating memory anomaly in Linux system

By comparing the check value of the swap partition mirror during the wake-up sleep stage of the Linux system, re-reading and synchronizing the mirror data, the problem of difficult to locate memory exceptions in the S4 sleep mode of the Linux system in the prior art is solved, and faster and more accurate troubleshooting is achieved.

CN119226025BActive Publication Date: 2025-03-18KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411755891.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-18
Estimated Expiration
2044-12-03

AI Technical Summary

Technical Problem

The prior art is difficult to quickly and accurately locate memory exceptions that occur in Linux systems in S4 sleep mode, resulting in complex and time-consuming system troubleshooting, which may lead to loss of important data or system crashes.

Method used

During the system wake-up sleep phase, the second check value generated by the mirror of the swap partition is compared with the first check value generated when the system sleeps. If it is inconsistent, read the mirror data from the swap partition again, record the swap partition address of the read data, and change the reading method from asynchronous to synchronous, assign the mirror data to the memory page, and perform verification data comparisons to initially locate exceptions caused by memory instability.

Benefits of technology

By comparing the verification values ​​of the mirror data, we can initially determine the mirror recovery error caused by memory problems, which improves the system's troubleshooting efficiency and accuracy in sleep abnormalities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226025B_ABST
    Figure CN119226025B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method, device and medium for locating memory anomalies of a Linux system. The method comprises: when the system wakes up from a sleep stage, comparing a second check value generated according to a mirror image of a swap partition with a first check value generated when the system is in hibernation; when the first check value is inconsistent with the second check value, re-reading the mirror image data from the swap partition, and recording the swap partition address of the read data; changing the reading mode from an asynchronous mode to a synchronous mode, and assigning the read mirror image data to a first memory page; creating a new second memory page, reading the check data according to the swap partition address in a synchronous mode; and assigning the read data to the second memory page; comparing the check data of the assigned first memory page and the second memory page, and preliminarily locating the anomaly caused by memory instability when they are inconsistent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Linux system dormancy, and in particular to a method, device and medium for locating a Linux system memory anomaly. Background Art

[0002] With the development of computer systems, system stability and data security are becoming more and more important. S4 sleep mode is a low-power state defined in the ACPI specification. In this mode, the system can be completely powered off and the current system state can be saved to a non-volatile storage device.

[0003] In actual applications, many abnormal situations are inevitable in the S4 sleep mode. The sleep abnormalities may be caused by various reasons, such as hardware failure, driver failure, compression and decompression algorithm vulnerabilities or memory trampling, BIOS memory instability, etc.

[0004] It is a difficult task to quickly locate the cause of hibernation anomalies. Currently, it mainly relies on a simple verification mechanism, that is, when saving and reading images, CRC32 data consistency verification is selected for non-compressed images. However, when the data consistency check fails, the solution cannot effectively distinguish the true cause of the current verification failure anomaly. This limitation causes the system to be unable to detect hibernation anomalies caused by memory instability in a timely and accurate manner during the recovery process, thereby increasing the complexity and time-consuming of system troubleshooting. If the problem is not repaired in time, it may lead to the loss of important data or system crash. Summary of the invention

[0005] The embodiment of the present invention provides a method, device and medium for locating memory anomalies of a Linux system, so as to solve the technical problem of the complexity of locating sleep anomalies of a Linux system in the prior art.

[0006] In a first aspect, an embodiment of the present invention provides a method for locating a memory anomaly in a Linux system, comprising:

[0007] When the system wakes up from sleep, the second check value generated according to the image of the swap partition is compared with the first check value generated when the system is in sleep;

[0008] When the first check value is inconsistent with the second check value, re-reading the mirror data from the exchange partition, and recording the exchange partition address of the read data;

[0009] The reading mode is changed from asynchronous mode to synchronous mode, and the read mirror data is assigned to the first memory page;

[0010] Create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner; and assign the read data to the second memory page;

[0011] The check data of the assigned first memory page and the second memory page are compared, and when they are inconsistent, the abnormality caused by memory instability is preliminarily located.

[0012] In a second aspect, an embodiment of the present invention further provides a device for locating a memory anomaly in a Linux system, comprising:

[0013] A comparison module, used for comparing a second check value generated according to the image of the swap partition with a first check value generated when the system is in hibernation when the system wakes up from sleep;

[0014] A recording module, used for re-reading the mirror data from the exchange partition and recording the exchange partition address of the read data when the first check value is inconsistent with the second check value;

[0015] A first assignment module, used to change the reading mode from an asynchronous mode to a synchronous mode, and assign the read mirror data to a first memory page;

[0016] A second copy module is used to create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner, and assign the read data to the second memory page;

[0017] The preliminary positioning module is used to compare the verification data of the first memory page and the second memory page after the assignment, and when there is inconsistency, preliminarily locate the abnormality caused by memory instability.

[0018] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the method for locating a memory anomaly in a Linux system as provided in the above embodiment.

[0019] The method, device and medium for locating memory anomalies of a Linux system provided by an embodiment of the present invention compare the second check value generated according to the mirror image of the swap partition with the first check value generated when the system is in hibernation when the system wakes up from sleep; when the first check value is inconsistent with the second check value, re-read the mirror data from the swap partition and record the swap partition address of the read data; change the reading mode from asynchronous mode to synchronous mode, and assign the read mirror data to the first memory page; create a new second memory page, read the check data according to the swap partition address in a synchronous manner; and assign the read data to the second memory page; compare the check data of the assigned first memory page and the second memory page, and preliminarily locate the anomaly caused by memory instability when they are inconsistent. By reading the mirror data and comparing the mirror data, when the comparison is inconsistent, it can be preliminarily determined that the mirror recovery error is caused by a memory problem. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0021] Figure 1 It is a flowchart of a method for locating a memory anomaly in a Linux system provided in Embodiment 1 of the present invention;

[0022] Figure 2 It is a flowchart of a method for locating a memory anomaly in a Linux system provided by Embodiment 2 of the present invention;

[0023] Figure 3 1 is a flow chart of a method for locating a memory anomaly in a Linux system provided in Embodiment 3 of the present invention;

[0024] Figure 4 It is a structural diagram of a device for locating memory anomalies in a Linux system provided by a fourth embodiment of the present invention. DETAILED DESCRIPTION

[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0026] Embodiment 1

[0027] Figure 1 : is a flowchart of a method for locating a memory anomaly in a Linux system provided by an embodiment 1 of the present invention. This embodiment is applicable to the situation where a memory anomaly of a Linux system with an image loading anomaly is quickly located during the S4 wake-up phase. The method can be executed by a device for locating a memory anomaly in a Linux system, and specifically comprises the following steps:

[0028] Step 110, when the system wakes up from the sleep phase, compare the second check value generated according to the image of the swap partition with the first check value generated when the system is in sleep mode.

[0029] System sleep states include S1, S3, S4, etc. It is implemented through the Advanced Configuration and Power Interface (ACPI).

[0030] S4 stands for Suspend-to-disk, which means suspend to hard disk, also known as hibernation. Simply put, it saves the current memory image and stores it to the hard disk, and then all devices are powered off. When powered on again, the system will restore the image data saved in the hard disk to the memory, thus restoring the scene before hibernation.

[0031] For S4, it is equivalent to going through the system shutdown / startup process again. All devices will be powered off and reinitialized, but the previously saved data status will be restored from the image. From the above process, it can be seen that the premise for S4 to recover normally is that when waking up from the sleep phase, the image data read from the swap partition in the hard disk is consistent with the image data stored in the swap partition of the hard disk during the hibernation period.

[0032] Therefore, in this embodiment, it is necessary to compare the image data read from the swap partition in the hard disk during the wake-up sleep phase with the image data stored in the swap partition in the hard disk during the sleep phase. Further, to improve the comparison efficiency, the second check value of the image read from the swap partition in the hard disk, the first check value being consistent with the read image data, can be compared with the first check value generated corresponding to the data generated when the system is in sleep mode.

[0033] Step 120: When the first check value is inconsistent with the second check value, re-read the mirror data from the swap partition and record the swap partition address of the read data.

[0034] If the first check value and the second check value are different, it can be explained that an S4 recovery failure has occurred. However, there are many reasons for recovery failures, and it is difficult to locate the cause. In this embodiment, a new method is provided for locating the cause of the S4 wake-up recovery error caused by the Linux system memory anomaly.

[0035] Exemplarily, when an inconsistency is detected between the two, the mirror data is re-read from the swap partition of the hard disk using the memory. Optionally, since the read data cannot completely cover all the mirror data, the address of the swap partition of the read data needs to be recorded.

[0036] Step 130, changing the reading mode from the asynchronous mode to the synchronous mode, and assigning the read mirror data to the first memory page.

[0037] The read mirror data is written to the first allocated memory page. At the same time, the reading mode is changed from asynchronous mode to synchronous mode, so that reading errors can be avoided in time when reading again later, thereby affecting later judgments.

[0038] Step 140: create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner, and assign the read data to the second memory page.

[0039] Exemplarily, according to the swap partition address read above, the above data is read again as verification data, and the read data is assigned to the pre-allocated second memory page.

[0040] Step 150 , compare the check data of the assigned first memory page and the second memory page, and if they are inconsistent, preliminarily locate the abnormality caused by memory instability.

[0041] Since the first memory page and the second memory page read the data stored in the same address in the swap partition, under normal circumstances, the data in the two should be the same. If they are different, it means that there is a problem with the memory, which may cause the Linux system S4 sleep wake-up abnormality. Therefore, the abnormality caused by memory instability can be preliminarily located.

[0042] This embodiment compares the second check value generated according to the mirror of the swap partition with the first check value generated when the system is in hibernation when the system wakes up from the sleep stage; when the first check value is inconsistent with the second check value, re-read the mirror data from the swap partition and record the swap partition address of the read data; change the reading mode from asynchronous mode to synchronous mode, and assign the read mirror data to the first memory page; create a new second memory page, read the check data according to the swap partition address in a synchronous manner; and assign the read data to the second memory page; compare the check data of the assigned first memory page and the second memory page, and preliminarily locate the abnormality caused by memory instability when they are inconsistent. By reading the mirror data and comparing the mirror data, when the comparison is inconsistent, it can be preliminarily determined that the mirror recovery error is caused by memory problems.

[0043] In a preferred implementation of this embodiment, the method may further add the following steps: exit the current data loading function load_image_lzo; after being able to determine the initial location of the abnormality caused by memory instability, the data loading function may be exited without further reading the data in the swap partition. Furthermore, when the verification data of the first memory page and the second memory page after assignment are consistent, continue the current data loading function load_image_lzo. Since the data read in the aforementioned steps is part of the swap partition data, it is necessary to continue reading the data until all comparisons and verifications are completed, and then determine the initial location of the abnormality caused by memory instability.

[0044] In another preferred implementation of this embodiment, the method may further add the following steps: when the first check value is inconsistent with the second check value, determine that the data loading is abnormal, use the swsusp_free function to release the memory, clean up the data structure, and restore the current system state. Using the above method, when it is determined that the sleep wake-up is abnormal, the current system state can be quickly restored to prevent the Linux system from generating an abnormality when waking up.

[0045] Embodiment 2

[0046] Figure 2 It is a flow chart of the method for locating memory anomalies in a Linux system provided by Embodiment 2 of the present invention. This embodiment is optimized based on the above embodiment, and the method may further add the following steps: when the system is in hibernation or suspended, apply for a first structure for storing first compression verification data; apply for memory space for the first structure and initialize it; generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread; use the compression verification thread to perform compression data verification calculation on the data in the first waiting queue according to the signal of the first waiting queue, and use the second waiting queue to send a compression verification completion signal after the calculation; and save the stage verification data in the first structure.

[0047] See also Figure 2 , the method for locating memory anomalies in the Linux system includes:

[0048] Step 210: when the system is in hibernation or suspended state, apply for a first structure for storing first compression verification data; apply for memory space for the first structure and initialize it.

[0049] Exemplarily, the processor platform issues an S4 sleep request, and the S4 sleep mode includes a suspend stage. In this stage, the data preparation function save_image_lzo is used to implement mirror data storage.

[0050] In the save_image_lzo function, you can apply for a crc_cmp structure of type crc32_data to save the relevant information of the compression verification mechanism. And apply for memory space for the crc_cmp structure and initialize it.

[0051] Step 220: Generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread.

[0052] Prepare two waiting queues, one for the start signal crc_cmp->go of the compression verification thread, and the other for the end signal crc_cmp->done of the compression verification thread.

[0053] Step 230, using the compression verification thread to perform compression data verification calculation on the first waiting queue data according to the signal of the first waiting queue, and using the second waiting queue to send a compression verification calculation completion signal after the calculation; saving the stage verification data to the first structure.

[0054] Start a waiting thread, which can be named "crc_cmp" detection thread, waiting to execute the compressed numerical calculation task. The detection thread is implemented using the crc32_threadfn function commonly defined by the kernel. Exemplarily, the main process can use multiple threads. Optionally, three threads can be used according to the system situation. Each thread reads a certain length of image data from the snapshot. The image data in the snapshot is consistent with the data read from the snapshot in the uncompressed verification mechanism. The data is compressed and placed in the compression buffer. After the three threads are finished running, the first waiting queue can be used to send a start signal crc_cmp->go.

[0055] The crc_cmp thread receives the crc_cmp->go start signal and starts to perform verification calculations on the compressed buffer data. After the verification calculation is completed, the thread end signal crc_cmp->done is issued, indicating that the data carried by the current three threads have been processed. The above steps are repeated using three child threads, and the data in the snapshot is read again. Then, the start signal crc_cmp->go is issued again using the first waiting queue, and the verification calculation is performed again. The loop processing is completed until all compressed data processing is completed to obtain the first verification value. The verification calculation method is CRC32 verification.

[0056] Furthermore, the method can also add the following steps: create a first variable in the swsusp_header structure for storing the first check value; assign the first check value to the first variable. Create a cmp_crc32 variable of type u32 in the swsusp_header structure for storing the first check value V1 calculated in the suspension phase; assign the V1 value of the temporary variable cmp_crc32 to the cmp_crc32 variable in the swsusp_header structure, and the value of swsusp_header->cmp_crc32 is V1. Store it in the swap partition together with the Image data, the system goes into hibernation, and the processor platform is powered off.

[0057] The above method can be used to quickly form a phase image file, and the above steps can be repeated to form complete image data. The waiting queue is used to realize the communication between multiple sub-threads and the compression verification thread, so that the compression verification calculation can be completed in a fast cycle.

[0058] Step 240, when the system wakes up from the sleep phase, compare the second check value generated based on the mirror of the swap partition with the first check value generated when the system is in sleep mode. When the first check value is inconsistent with the second check value, re-read the mirror data from the swap partition and record the swap partition address of the read data.

[0059] Step 250, change the reading mode from asynchronous mode to synchronous mode, assign the read mirror data to the first memory page, create a second memory page, read the verification data according to the exchange partition address in a synchronous manner; and assign the read data to the second memory page.

[0060] Step 260, compare the check data of the first memory page and the second memory page after the assignment, and if they are inconsistent, preliminarily locate the abnormality caused by memory instability.

[0061] This embodiment adds the following steps: when the system is dormant or suspended, apply for a first structure to store the first compression verification data; apply for memory space for the first structure and initialize it; generate a first waiting queue for the start signal of the compression verification thread and a second waiting queue for the end signal of the compression verification thread; use the compression verification thread to perform compression data verification calculation on the first waiting queue data according to the signal of the first waiting queue, and use the second waiting queue to send a verification calculation completion signal after the calculation; create a new first variable in the exchange header, and fill the verification data into the first variable. The above method can be used to quickly and accurately calculate the first verification value, and store it in the corresponding data structure in the exchange partition for easy later reading.

[0062] Embodiment 3

[0063] Figure 3The present invention is a flowchart of a method for locating a memory anomaly in a Linux system provided by a third embodiment of the present invention. This embodiment is optimized based on the above embodiment, and the method may further add the following steps: when the system receives a wake-up signal, in the image data recovery memory function load_image_lzo, applying for a second structure, wherein a temporary variable for storing a second check value is provided in the second structure; applying for memory space for the second structure and initializing it; generating a third waiting queue for a start signal of a compression check thread and a fourth waiting queue for an end signal of a compression check thread; starting a main thread for performing compression check data calculation; starting a main thread for performing compression data calculation, wherein the main thread includes: a plurality of child threads; each child thread reads a preset length of image data from a swap partition, and after the reading is completed, fills the image data to be detected in the second structure and the length of the compressed image data actually read; performing compression check calculation on the data in the third waiting queue according to the signal of the third waiting queue, and sending a calculation completion signal using the third waiting queue after the calculation; and obtaining a second check value after all the image data are calculated.

[0064] See also Figure 3 , the method for locating memory anomalies in the Linux system includes:

[0065] Step 310, when the system is in sleep mode, apply for a first structure to store first compression verification data; apply for memory space for the first structure and initialize it, and generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread.

[0066] Step 320, using the compression verification thread to perform compression verification calculation on the first waiting queue data according to the signal of the first waiting queue, and using the second waiting queue to send a calculation completion signal after the calculation; after all the mirror data are calculated, a first verification value is obtained.

[0067] Step 330: In the image data recovery memory function load_image_lzo, a second structure is applied, a variable for storing a second check value is provided in the second structure, and memory space is applied for and initialized for the second structure.

[0068] In this embodiment, the second check value can be calculated in a manner similar to the above embodiment. Exemplarily, the image data is restored to the memory function load_image_lzo, and a crc_cmp structure of type crc32_data is applied to save the relevant information of the compression check mechanism and a variable cmp_crc32 of type u32 to record the compressed crc32 value. When the compression check calculation is turned on, memory space is applied for the crc_cmp structure and initialized.

[0069] Step 340, generating a third waiting queue for a start signal of a compression verification thread and a fourth waiting queue for an end signal of a compression verification thread; starting a main thread for performing compression verification data calculation; starting a main thread for performing compressed data reading, wherein the main thread comprises: a plurality of sub-threads; each sub-thread reads mirror data of a preset length from a swap partition, and after the reading is completed, fills the second structure with the data to be detected and the length of the compressed mirror data actually read.

[0070] Start a detection thread named "crc_cmp" to wait for the compression check value calculation task to be executed. The compression check thread is implemented using the crc32_threadfn function commonly defined by the kernel. Read a part of the compressed data from the swap partition and fill it into the data to be detected and the actual compressed length read in the current crc_cmp structure. The operation can be carried out in the following way: the main process prepares three threads, each thread reads a certain length of mirror data from the swap partition. The read mirror data can usually be 32 pages. When reading data from the swap partition, the disk bio algorithm is used to ensure the integrity and consistency of the data copied from the disk, and the data is placed in the compression buffer.

[0071] Step 350, perform compressed data verification calculation on the data in the third waiting queue according to the signal of the third waiting queue, and use the third waiting queue to send a calculation completion signal after the calculation, and wait until all the mirror data are calculated to obtain a second verification value.

[0072] After waiting for the three threads to finish running, a start signal crc_cmp->go is issued to wake up the compression verification thread, and continue to read in subsequent data until all the image compression data is processed, and the compression value V2 obtained in the wake-up phase is assigned to the cmp_crc32 temporary variable. Exemplary, it may include:

[0073] The main process can use multiple threads. Optionally, three threads can be used according to the system situation. Each thread reads a certain length of mirror data from the swap partition. After the three threads are finished running, the first waiting queue can be used to send a start signal crc_cmp->go; the crc_cmp thread receives the start signal and starts to verify the compressed data read from the swap partition. After the crc_cmp thread completes the calculation, it sends a thread end signal crc_cmp->done to the main thread, indicating that the data currently moved by the three threads have been processed; after the main process receives the crc_cmp->done signal, it repeats the above steps until the data in the swap partition is processed and the V2 value is obtained.

[0074] Step 360, when the system wakes up from the sleep phase, compare the second check value generated based on the mirror of the swap partition with the first check value generated when the system is in sleep mode. When the first check value is inconsistent with the second check value, re-read the mirror data from the swap partition and record the swap partition address of the read data.

[0075] Step 370, change the reading mode from asynchronous mode to synchronous mode, and assign the read mirror data to the first memory page; create a second memory page, read the verification data according to the exchange partition address in a synchronous manner; and assign the read data to the second memory page.

[0076] Step 380, compare the check data of the first memory page and the second memory page after the assignment, and if they are inconsistent, preliminarily locate the abnormality caused by memory instability.

[0077] This embodiment adds the following steps: when the system receives a wake-up signal, in the image data recovery memory function load_image_lzo, apply for a second structure, in which a temporary variable for storing a second check value is provided; apply for memory space for the second structure and initialize it; generate a third waiting queue for the start signal of the compression check thread and a fourth waiting queue for the end signal of the compression check thread; start the waiting main thread for performing the compression check data calculation; start the main thread for performing the compression data calculation, the main thread includes: multiple sub-threads; each sub-thread reads the image data of a preset length from the exchange partition, and after the reading is completed, fills the data to be detected in the second structure and the length of the compressed image data actually read; according to the signal of the third waiting queue, the data of the third waiting queue is compressed and checked, and after the calculation, the calculation completion signal is sent using the third waiting queue; after all the image data are calculated, the second check value is obtained. The above method can be used to quickly and accurately calculate the second check value.

[0078] In a preferred implementation of this embodiment, the method may further add the following steps: using a preset counter to record the number of sleep times; when the number is less than a preset number threshold, using the swsusp_read function to reload load_image_lzo until the data recorded by the counter reaches the preset number threshold. Since sleep anomalies may include hardware failure, driver failure, compression and decompression algorithm vulnerabilities, memory trampling, BIOS memory instability and other reasons. Therefore, the above method can only preliminarily locate the anomalies caused by BIOS memory instability. Therefore, multiple tests are required to accurately locate the anomalies caused by BIOS memory instability. For example, when the number threshold is set to 1000 times, the following phenomenon may be obtained:

[0079] 1. When all 1000 sleep tests are successful, V1=V2, the data compression verification mechanism passes, the compression verification values ​​in the suspend and resume stages remain consistent, and the test result shows that the BIOS memory is stable;

[0080] 2. When all 1000 sleep tests fail, V1=V2, the data compression check mechanism passes, and the compression check values ​​in the suspend and resume stages remain consistent. This exception is not a BIOS memory instability exception.

[0081] 3. When there are m sleep exceptions in 1000 sleep tests, the V1 and V2 values ​​are not equal, that is, the data compression check fails, and the compression check values ​​in the suspend and resume stages are inconsistent; the page1 value is inconsistent with the page2 value, that is, the data comparison and verification mechanism fails, and the data is read twice from the same swap partition address, and the values ​​obtained are inconsistent. The detection result is that the BIOS memory is unstable, so the BIOS needs to continuously optimize memory training to meet the memory stability requirements.

[0082] Embodiment 4

[0083] Figure 4 Schematic diagram of the structure of the device for locating memory anomalies in a Linux system provided by the third embodiment of the present invention, see Figure 4 , the device for locating memory anomalies in the Linux system comprises:

[0084] A comparison module 410, configured to compare a second check value generated according to the image of the swap partition with a first check value generated when the system is in hibernation when the system is awakened from sleep;

[0085] A recording module 420, configured to re-read the mirror data from the swap partition and record the swap partition address of the read data when the first check value is inconsistent with the second check value;

[0086] A first assignment module, 430, is used to change the reading mode from an asynchronous mode to a synchronous mode, and assign the read mirror data to the first memory page;

[0087] The second assignment module 440 is used to create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner, and assign the read data to the second memory page;

[0088] The preliminary positioning module 450 is used to compare the verification data of the first memory page and the second memory page after the assignment, and if there is inconsistency, preliminarily locate the abnormality caused by memory instability.

[0089] The present embodiment provides a device for locating memory anomalies in a Linux system. When the system wakes up from the sleep stage, the second check value generated according to the mirror of the swap partition is compared with the first check value generated when the system is in sleep mode; when the first check value is inconsistent with the second check value, the mirror data is read from the swap partition again, and the swap partition address of the read data is recorded; the reading mode is changed from asynchronous mode to synchronous mode, and the read mirror data is assigned to the first memory page; a new second memory page is created, and the check data is read according to the swap partition address in a synchronous manner; and the read data is assigned to the second memory page; the check data of the assigned first memory page and the second memory page are compared, and when they are inconsistent, the anomaly caused by memory instability is preliminarily located. By reading the mirror data and comparing the mirror data, when the comparison is inconsistent, it can be preliminarily determined that the mirror recovery error is caused by a memory problem.

[0090] Exit module, used to exit the current data loading function load_image_lzo;

[0091] The continuing loading module is used to continue the current data loading function load_image_lzo when the verification data of the first memory page and the second memory page after the assignment are consistent.

[0092] Based on the above embodiments, the device further includes:

[0093] A first application module, used for applying for a first structure for storing first compression verification data when the system is in hibernation or suspended;

[0094] A first initialization module, used to apply for memory space for the first structure and initialize it;

[0095] A first generating module, used to generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread;

[0096] A first compression verification calculation module, used to use a compression verification thread to perform compression verification calculation on the first waiting queue data according to the signal of the first waiting queue, and send a calculation completion signal using a second waiting queue after the calculation;

[0097] The stage verification value saving module is used to save the stage verification data into the first structure.

[0098] Based on the above embodiments, the device further includes:

[0099] The first check value is used as a module, and is used to use the check data as the first check value after all the compressed image data are checked;

[0100] The first storage module is used to store the first check value and the mirror data into the exchange partition.

[0101] Based on the above embodiments, the device further includes:

[0102] A second application module is used to apply for a second structure in the image data recovery memory function load_image_lzo when the system receives a wake-up signal, wherein the second structure is provided with a temporary variable for storing a second check value;

[0103] The second initialization module is used to apply for memory space for the second structure and initialize it;

[0104] A second generating module, used to generate a third waiting queue for a start signal of a compression verification thread and a fourth waiting queue for an end signal of a compression verification thread;

[0105] A second starting module is used to start a main thread for executing compressed data calculation, wherein the main thread includes: a plurality of sub-threads;

[0106] A second filling module is used to use each child thread to read the mirror data of a preset length from the swap partition, and after the reading is completed, fill the data to be detected in the second structure and the length of the compressed mirror data actually read;

[0107] A second compression check calculation module is used to perform compression check calculation on the data in the third waiting queue according to the signal of the third waiting queue, and send a compression completion signal using the third waiting queue after compression;

[0108] The second check value generating module is used to calculate the check value of all compressed data to obtain a second check value.

[0109] Based on the above embodiments, the device further includes:

[0110] The release module is used to determine that the data loading is abnormal, release the memory, clean up the data structure, and restore the current system state when the first check value is inconsistent with the second check value.

[0111] Based on the above embodiments, the device further includes:

[0112] A recording module, used for recording the number of sleep times using a preset counter;

[0113] The return module is used to use the swsusp_read function to reload load_image_lzo when the number of times is less than the preset number threshold, until the data recorded by the counter reaches the preset number threshold;

[0114] The abnormality determination module is used to determine the abnormality caused by memory instability when the data recorded by the counter reaches a preset number threshold.

[0115] The device for locating a memory anomaly in a Linux system provided by an embodiment of the present invention can execute the method for locating a memory anomaly in a Linux system provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

[0116] Embodiment 5

[0117] Embodiment 5 of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the method for locating a memory anomaly in a Linux system as described in any one of the above embodiments.

[0118] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-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 thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-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, device or device.

[0119] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. 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. Computer-readable signal media may also be any computer-readable medium other than a computer-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.

[0120] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

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

[0122] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for locating memory anomalies in a Linux system, characterized in that: include: When the system is in hibernation or suspended state, applying for a first structure to store first compression verification data; Allocate memory space for the first structure and initialize it; Generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread; Calculate compression verification data for the first waiting queue data according to the signal of the first waiting queue using the compression verification thread, and send a compression data verification completion signal using the second waiting queue after the calculation is completed; Save the stage verification data into the first structure; When the system wakes up from sleep, the second check value generated according to the image of the swap partition is compared with the first check value generated when the system is in sleep; When the first check value is inconsistent with the second check value, re-reading the mirror data from the exchange partition, and recording the exchange partition address of the read data; The reading mode is changed from asynchronous mode to synchronous mode, and the read mirror data is assigned to the first memory page; Create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner; and assign the read data to the second memory page; The check data of the assigned first memory page and the second memory page are compared, and when they are inconsistent, the abnormality caused by memory instability is preliminarily located.

2. The method according to claim 1, characterized in that The method further comprises: Exit the current data loading function load_image_lzo; When the check data of the first memory page and the second memory page after the assignment are consistent, the current data loading function load_image_lzo is continued.

3. The method according to claim 1, characterized in that The method further comprises: After all the compressed image data has been verified, the verification data is used as the first verification value; The first check value and the mirror data are stored in a swap partition.

4. The method according to claim 3, characterized in that: The storing the first check value and the mirror data into the exchange partition includes: Create a first variable in the swsusp_header structure for storing the first check value; Assign a first check value to a first variable.

5. The method according to claim 4, characterized in that The method further comprises: When the system receives the wake-up signal, in the image data recovery memory function load_image_lzo, a second structure is applied, wherein the second structure is provided with a temporary variable for storing a second check value; Allocate memory space for the second structure and initialize it; Generate a third waiting queue for a start signal of a compression verification thread and a fourth waiting queue for an end signal of a compression verification thread; Starting a main thread for executing compressed data calculation, the main thread comprising: a plurality of sub-threads; Using each child thread to read the mirror data of a preset length from the exchange partition, and after the reading is completed, filling the data to be detected in the second structure and the length of the compressed mirror data actually read; Performing compressed mirror data verification calculation on the data in the third waiting queue according to the signal of the third waiting queue, and sending a verification completion signal using the third waiting queue after verification; The check value calculation for all the compressed data is completed to obtain a second check value.

6. The method according to claim 3, characterized in that The method further comprises: When the first check value is inconsistent with the second check value, it is determined that the data loading is abnormal, and the swsusp_free function is used to release the memory, clean up the data structure, and restore the current system state.

7. The method according to claim 5, characterized in that The method further comprises: Use a preset counter to record the number of sleep times; When the number of times is less than a preset number threshold, use the swsusp_read function to reload load_image_lzo until the data recorded by the counter reaches the preset number threshold; When the data recorded by the counter reaches a preset number threshold, it is determined that the abnormality is caused by memory instability.

8. A device for locating memory anomalies in a Linux system, characterized in that: include: A first application module, used for applying for a first structure for storing first compression verification data when the system is in hibernation or suspended; A first initialization module, used to apply for memory space for the first structure and initialize it; A first generating module, used to generate a first waiting queue for a start signal of a compression verification thread and a second waiting queue for an end signal of a compression verification thread; A first compression verification calculation module, used to use a compression verification thread to perform compression verification calculation on the first waiting queue data according to the signal of the first waiting queue, and send a calculation completion signal using a second waiting queue after the calculation; A stage verification value saving module, used to save the stage verification data into the first structure; A comparison module, used for comparing a first check value generated according to the image of the swap partition with a second check value generated when the system is in hibernation when the system wakes up from sleep; A recording module, used for re-reading the mirror data from the exchange partition and recording the exchange partition address of the read data when the first check value is inconsistent with the second check value; A first assignment module, used to change the reading mode from an asynchronous mode to a synchronous mode, and assign the read mirror data to a first memory page; A second assignment module is used to create a new second memory page, read the verification data according to the exchange partition address in a synchronous manner, and assign the read data to the second memory page; The preliminary positioning module is used to compare the verification data of the first memory page and the second memory page after the assignment, and when there is inconsistency, preliminarily locate the abnormality caused by memory instability.

9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the method for locating a memory anomaly in a Linux system as described in any one of claims 1 to 7 when executed by a computer processor.

Citation Information

Patent Citations

  • Flash memory data protection method, device, electronic equipment and storage medium

    CN112347007A

  • Data verification method and device, storage medium and electronic equipment

    CN113972990A