Log processing method, electronic device, storage device, and storage medium
By transmitting target timestamps between electronic devices and storage devices and matching them with runtime logs, the problem of limited information acquisition by logic analyzers is solved, enabling rapid and accurate location of anomalies on the eMMC platform and device side, simplifying operation and reducing the risk of device damage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHONGSHAN JIANGBOLONG ELECTRONICS CO LTD
- Filing Date
- 2024-12-05
- Publication Date
- 2026-06-12
AI Technical Summary
Existing technologies, when dealing with performance optimization, kernel exception log analysis, and system lag issues on the eMMC platform and device side, provide limited information for logic analyzers, making it impossible to achieve fast and accurate location, and the operation is complex and carries the risk of damaging the device.
By transmitting target timestamps between electronic devices and storage devices, recording and matching operation logs, the log correspondence between electronic devices and storage devices is achieved, and the timestamps are used for rapid analysis and location of anomalies.
It enables rapid and accurate analysis and localization of electronic device performance optimization, kernel log anomalies, and lag issues without the need for a logic analyzer, simplifying operations and reducing the risk of device damage.
Smart Images

Figure CN122195802A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage devices, and in particular to a log processing method, an electronic device, a storage device, and a storage medium. BACKGROUND
[0002] In the rapid debugging process of a storage device and a platform host, especially when problems such as performance optimization related to an eMMC platform end and an eMMC device end, kernel exception log analysis, system freezing, and startup interface stagnation (logo stuck) are processed, related technologies usually capture and analyze a command sequence sent by the eMMC device end through a logic analyzer. However, the information obtained on the logic analyzer is limited, and the problems cannot be quickly analyzed and accurately located. SUMMARY
[0003] Therefore, it is necessary to provide a log processing method, an electronic device, a storage device, and a storage medium to solve the problem that problems cannot be quickly analyzed and accurately located.
[0004] In a first aspect, an embodiment of the present application provides a log processing method applied to an electronic device, the electronic device being connected to a storage device, and the method comprising: transmitting a target timestamp to the storage device, the target timestamp comprising a time corresponding to a first running log of the electronic device; recording, by the storage device, a second running log of the storage device according to the target timestamp, wherein the second running log comprises a time corresponding to the second running log; sending a log reading request to the storage device, wherein the log reading request is used to read the second running log recorded by the storage device; and saving the second running log recorded by the storage device.
[0005] In a possible implementation manner, the method further comprises: matching the first running log and the second running log to obtain a matched log pair; and analyzing the matched log pair to determine an exception cause.
[0006] In a possible implementation manner, the first running log comprises K log events and log records corresponding to the log events, K being an integer greater than or equal to 1; and the matching of the first running log and the second running log to obtain a matched log pair comprises: determining, for each log event, a start time and an end time of the log record corresponding to the log event; and matching the first running log and the second running log according to the time corresponding to the second running log, the start time, and the end time to obtain a matched log pair.
[0007] In one possible implementation, the time corresponding to the first running log includes the time of the electronic device's running state, which may include one or more of the following: kernel running time, system running time, and current system time; transmitting the target timestamp to the storage device includes: transmitting the target timestamp to the storage device when the storage device is detected to be in an initialization state, the electronic device is in an idle state for a preset time, or the electronic device detects abnormal information, wherein the initialization state may include any of the following: storage device power-on reset, storage device hardware reset, storage device wake-up from hibernation state.
[0008] Secondly, embodiments of this application provide a log processing method applied to a storage device connected to an electronic device. The method includes: obtaining a target timestamp transmitted by the electronic device, the target timestamp including the time corresponding to a first operating log of the electronic device; recording a second operating log according to the target timestamp, wherein the second operating log includes the time corresponding to the second operating log; receiving a log read request sent by the electronic device, wherein the log read request is used to read the second operating log recorded by the storage device; and in response to the log read request, transmitting the second operating log to the electronic device.
[0009] In one possible implementation, the method further includes: using the target timestamp as the start time of a timer; when a second running log needs to be recorded, obtaining the corresponding elapsed time from the timer, wherein the elapsed time is used to indicate the elapsed duration from the start time to the time when the second running log needs to be recorded; and obtaining the time corresponding to the second running log based on the start time and the elapsed time.
[0010] In one possible implementation, the time corresponding to the second operation log includes the time of the storage device's operating state, which may include one or more of the following: kernel running time, system running time, and current system time; the second operation log includes one or more of the following: the time during which no command request was received from the electronic device within a first preset time period, the amount of data written and read by the electronic device within a second preset time period, the preset state of the storage device within a third preset time period, and the preset behavior of the storage device within a third preset time period.
[0011] Thirdly, embodiments of this application provide an electronic device, the electronic device including a processor and a memory, the memory for storing a computer program, and the processor for executing the computer program in the memory, causing the electronic device to perform the log processing method as described in any of the preceding claims.
[0012] Fourthly, embodiments of this application provide a storage device, the electronic device including a controller and a memory, the memory for storing a computer program, and the controller for executing the computer program in the memory, causing the electronic device to perform the log processing method as described in any of the preceding claims.
[0013] Fifthly, embodiments of this application provide a computer-readable storage medium including computer instructions that, when executed on a device, cause the device to perform the log processing method as described in any of the preceding claims.
[0014] The log processing method, electronic device, storage device, and storage medium provided in this application embodiment can quickly correlate the operation logs of the electronic device with the operation logs of the storage device without the need for a logic analyzer, and achieve rapid analysis and location of problems. It can quickly and accurately analyze and locate problems such as performance optimization of electronic devices, kernel log anomalies, lag, and logo freezes. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0016] Figure 1 This is a schematic diagram of the structure of a log processing system provided in an embodiment of this application.
[0017] Figure 2 This is a flowchart illustrating a log processing method applied to a log processing system, as provided in an embodiment of this application.
[0018] Figure 3 This is a flowchart illustrating a log processing method for an electronic device, as provided in an embodiment of this application.
[0019] Figure 4 A flowchart illustrating another log processing method for electronic devices provided in an embodiment of this application.
[0020] Figure 5 This is a flowchart illustrating a log processing method applied to a storage device, as provided in an embodiment of this application.
[0021] Figure 6 A flowchart illustrating another log processing method applied to a storage device, as provided in an embodiment of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0023] It should be noted that in this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or sequence.
[0024] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being better or more advantageous than other embodiments or designs. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0025] When dealing with complex issues such as performance optimization between storage devices and electronic devices, kernel exception log analysis, system lag, and boot logo issues, the current debugging and diagnostic process involves first analyzing the electronic device's logs, then capturing the storage device's logs using a logic analyzer, and finally combining the logs from both devices to arrive at a final conclusion. Taking an embedded multi-media card (eMMC) device as an example (eMMC device side includes the eMMC chip), and an eMMC platform as the electronic device side), when addressing performance optimization, kernel exception log analysis, lag, and boot logo issues related to the eMMC platform and device, the process begins by analyzing the eMMC platform's trace command information, top command information, kernel logs, and system logs for preliminary problem diagnosis. Next, a logic analyzer is used to capture the eMMC command sequence, and finally, the logs from both the eMMC platform and device sides are combined to arrive at the final conclusion.
[0026] However, the inventors discovered the following drawbacks in implementing the embodiments of this application: 1. The information obtained from the logic analyzer is limited, mainly confined to the command sequence of the eMMC, and cannot obtain abnormal state records inside the eMMC chip. This means that if the problem lies within the eMMC chip, the logic analyzer may not provide enough information for accurate diagnosis. 2. The logs on the logic analyzer lack timestamps corresponding to the logs of the electronic device (eMMC platform side), making it more difficult to correlate the behavior of the eMMC device with other activities of the electronic device, thus affecting the accuracy of problem localization. 3. On commercially available electronic devices, there are usually no reserved pin headers for connecting to the logic analyzer. In order to capture logs, technicians may need to bring out the pin headers through soldering or other means. However, this operation carries the risk of damaging the electronic device and storage device, increasing the complexity and uncertainty of the operation. 4. For some problems with low probability of anomalies, since it is impossible to guarantee that every electronic device can be connected to the logic analyzer during batch testing, it is difficult to ensure that the problem can be discovered and located in a timely manner.
[0027] In view of this, embodiments of this application provide a log processing method, an electronic device, a storage device, and a storage medium that can solve the above problems. Without a logic analyzer, the operation logs of the electronic device can be quickly matched with the operation logs of the storage device, enabling rapid and accurate analysis and location of issues such as performance optimization, kernel log anomalies, lag, and logo freezes in the electronic device, thus achieving rapid analysis and location of problems.
[0028] Please see Figure 1 The following is an exemplary description of the log processing system 100 provided in an embodiment of this application.
[0029] The log processing system 100 includes an electronic device 10 and a storage device 20. The electronic device 10 can establish a communication connection with the storage device 20 through an interface, which may include, but is not limited to, interfaces for Secure Digital (SD) cards and Multi Media Cards (MMC).
[0030] Electronic device 10 includes, but is not limited to, a processor 11, a memory 12, and a computer program 13 stored in the memory 12 and executable on the processor 11. The processor 11, running the computer program 13, can perform log processing methods, for example, implementing... Figure 2 The steps S101 and S103 shown, and Figure 3 , Figure 4 The steps are shown.
[0031] The electronic device 10 can be a mobile phone, tablet computer, laptop computer, home appliance, etc., and this application does not impose any restrictions on the specific type of the electronic device 10. The electronic device 10 can be a device running Android, iOS, Windows, or other operating systems. This application embodiment does not specifically limit the type of electronic device 10 that executes the log processing method provided in this application embodiment or the operating system that the electronic device 10 runs.
[0032] Storage device 20 includes, but is not limited to, a controller 21, a memory 22, and a computer program 23 stored in the memory 22 and executable on the processor 11. The controller 21, running the computer program 23, can perform log processing methods, for example, implementing... Figure 2 The steps S102 and S104 shown, and Figure 5 , Figure 6 The steps are shown.
[0033] In this embodiment, the storage device 20 also includes a time management tool (not shown). The time management tool can be used to manage and record time. The time management tool may include, but is not limited to, timers and time-counting devices. A timer is a hardware or software component used to measure time intervals or implement timing functions, while a timer is a hardware or software component used to measure the elapsed time.
[0034] In some embodiments, storage device 20 may be an eMMC chip. An eMMC chip is a storage device that integrates a controller 21 and NAND flash memory, and communicates with the processor 11 of electronic device 10 through a specific interface (such as an SD / MMC interface).
[0035] In some embodiments, the storage device 20 may be a Secure Digital Card (SD), Universal Flash Storage (UFS), Multi Media Card (MMC), Micro Secure Digital Card (MicroSD), or Solid State Disk (SSD).
[0036] In some embodiments, memory 23 may include memory (not shown) and non-volatile memory (not shown). Logs recorded by storage device 20 may be stored in memory buffer and then written to non-volatile memory, such as NAND Flash.
[0037] In some embodiments, the log processing method provided in this application can be burned into the electronic device 10 and the storage device 20 in firmware form, so that the electronic device 10 executes the log processing method provided in this application, for example, implementing... Figure 2 The steps S101 and S103 shown, and Figure 3 , Figure 4 The steps shown indicate that the storage device 10 executes the log processing method provided in the embodiments of this application, for example, implementing... Figure 2 The steps S102 and S104 shown, and Figure 5 , Figure 6 The steps are shown.
[0038] Those skilled in the art will understand that the schematic diagram is merely an example of the log processing system 100, electronic device 10, and storage device 20, and does not constitute a limitation on the log processing system 100, electronic device 10, and storage device 20. It may include more or fewer components than shown, or combine certain components, or use different components.
[0039] Please see Figure 2 This document provides an exemplary embodiment of a log processing method, which can be applied to a log processing system and is executed jointly by an electronic device and a storage device. The log processing method may include the following steps; the order of these steps in the flowchart may be changed, and some may be omitted, depending on different requirements.
[0040] Step S201: The electronic device transmits the target timestamp to the storage device.
[0041] The target timestamp includes the time corresponding to the first operational log of the electronic device. The first operational log includes all operational logs of the electronic device. It can cover the operational status and activity records of all critical components on the electronic device (such as the processor and memory), and these logs are crucial for understanding the overall health of the electronic device, monitoring its performance, and promptly identifying and resolving problems.
[0042] The target timestamp includes the timestamps corresponding to all the electronic device's runtime logs, such as kernel runtime, system runtime, and current system time. In the electronic device's runtime logs, each log entry is accompanied by a precise timestamp, which comprehensively reflects the various time information corresponding to the log entry.
[0043] Kernel runtime refers to the length of time the operating system kernel spends executing on the Central Processing Unit (CPU). This runtime reflects system load, kernel scheduling efficiency, and overall system performance. In the logs, kernel runtime can be associated with specific kernel activities (such as interrupt handling and process scheduling).
[0044] System runtime refers to the total time elapsed from system startup to the current moment. This time span can include all system activities, such as kernel operation, user process execution, and system idle time. System runtime is a key indicator for evaluating system stability and performance.
[0045] The current system time refers to the current date and time of the system. This time information provides a clear time reference framework, helping technical personnel to better understand the events and activities recorded in the logs.
[0046] In this embodiment, the electronic device can transmit a target timestamp to the storage device based on a communication connection with the storage device. For example, the electronic device can send the target timestamp to the storage device via the CMD49 command.
[0047] In some embodiments, an electronic device may transmit a target timestamp to a storage device in the following timestamp scenarios: Scenario 1: Storage device power-on reset.
[0048] For example, when a storage device undergoes a power-on reset (POR), it starts operating from its initial state and is ready to receive commands from electronic devices. After the storage device undergoes a power-on reset, the electronic devices can send a target timestamp to the storage device via the CMD49 command, and the target timestamp may include any one or more of the following information: kernel runtime, system runtime, and the current system time.
[0049] Scenario 2: Storage device hardware reset.
[0050] Hardware reset forces the storage device into an initial state by using an external signal (such as the RESET pin).
[0051] For example, after the storage device hardware is reset, the electronic device can send a target timestamp to the storage device via the CMD49 command, and the target timestamp may include any one or more of the following information: Kernel runtime, system runtime, and current system time.
[0052] Scenario 3: The storage device wakes up from hibernation.
[0053] Storage devices support hibernation mode to reduce power consumption. When a storage device wakes up from hibernation mode, it needs to be reinitialized and ready to accept commands.
[0054] For example, after the storage device wakes up from hibernation mode and completes initialization, the electronic device can send a target timestamp to the storage device via the CMD49 command, and the target timestamp may include any one or more of the following information: Kernel runtime, system runtime, and current system time.
[0055] Scenario 4: Electronic devices are idle for a preset time threshold.
[0056] For example, when an electronic device is in an idle state and this idle state reaches a preset time threshold, the electronic device sends a target timestamp to the storage device via a CMD49 command, and the target timestamp may include, but is not limited to, the kernel runtime, the system runtime, and the current system time.
[0057] Scenario 5: The electronic device detects abnormal information.
[0058] For example, when an electronic device detects abnormal information (such as hardware failure, software error, etc.), the electronic device sends a target timestamp to the storage device via the CMD49 command, and the target timestamp may include, but is not limited to, the kernel runtime, the system runtime, and the current system time.
[0059] Step S202: The storage device records the second running log according to the target timestamp.
[0060] During the operation of a storage device, it continuously generates various log entries, such as status information, error messages, and performance data. The second operational log can include all log entries generated during the storage device's operation.
[0061] The contents of the second runtime log may include, but are not limited to, any one or more of the following: 1. The time during which no command request is received from the electronic device within the first preset time period.
[0062] For example, the second operation log includes: the idle time of the electronic device within a first preset time period, that is, the time during which the storage device does not send command requests. This part of the log records the time period during which the electronic device does not send command requests to the storage device within the first preset time period. This helps to analyze the load of the electronic device and the percentage of idle time the storage device spends waiting for platform commands.
[0063] 2. The amount of data written and read by the electronic device within the second preset time period.
[0064] For example, the second operation log includes the amount of data written by the electronic device to the storage device and the amount of data read from the storage device during a second preset time period. This helps to evaluate the read and write performance of the storage device and the electronic device's demand for storage resources.
[0065] 3. The preset state of the storage device and / or the preset behavior of the storage device within the third preset time period.
[0066] For example, the second operation log includes: preset states and / or preset behaviors encountered by the storage device during operation within a third preset time period, including but not limited to: (1) New bad blocks in NAND Flash: Record information on newly added bad blocks in NAND Flash to help with subsequent data management and bad block processing.
[0067] (2) NAND Flash reread: Records NAND Flash data reread operations caused by ECC errors or other reasons.
[0068] (3) NAND Flash ECC is too high: NAND Flash read and write operations with ECC error rate exceeding the preset threshold.
[0069] (4) Read protection operation: Records read protection operations performed to protect data integrity.
[0070] (5) Pre-replacement operation: Records the pre-replacement operation performed to prevent data loss.
[0071] (6) GC (garbage collection) operations: Records garbage collection operations performed to release invalid data blocks.
[0072] (7) Read / write / erase latency exceeds threshold: Records cases where read / write / erase operation latency exceeds a preset threshold.
[0073] The first, second, and third preset time periods can be set according to actual conditions. For example, they can be preset durations before logging, such as 5 seconds or 1 minute. The durations of the first, second, and third preset time periods can be the same or different.
[0074] 4. The time corresponding to the second running log.
[0075] The time corresponding to the second runtime log includes the time of the storage device's running status, which may include, but is not limited to, one or more of the following: kernel running time, system running time, and current system time. The time corresponding to this part of the log includes the kernel start time, system start time, and current system start time, kernel end time, system end time, and current system end time, etc.
[0076] In this embodiment, the electronic device sends a target timestamp to the storage device. The target timestamp contains the times corresponding to all the electronic device's operation logs, such as kernel runtime, system runtime, and current system time. The storage device records internal logs containing kernel runtime, system runtime, and current system time, etc., to correlate the electronic device's logs with the storage device's logs when analyzing anomalies later.
[0077] In some embodiments, the storage device uses the target timestamp as the start time of the timer. When it is necessary to record the second running log, it obtains the corresponding elapsed time from the timer, wherein the elapsed time is used to indicate the elapsed time from the start time to when the second running log needs to be recorded. The time corresponding to the second running log is obtained based on the start time and the elapsed time.
[0078] Specifically, after receiving a target timestamp sent by an electronic device, the storage device uses the target timestamp as the start time and sets a timer inside the storage device to start counting from the start time and record the runtime of the storage device.
[0079] For example, taking a target timestamp transmitted from an electronic device to a storage device, which includes the kernel runtime and the current system time, where the kernel runtime is 1 hour, 3 minutes, 50 seconds, and 400 ms and the current system time is November 19, 2024, 2:27:35 PM as an example, at time T1, the storage device uses the received target timestamp as its starting time and starts a timer to record the storage device's runtime relative to the starting time. At time T2, when the storage device needs to record a log (the second runtime log), it obtains the corresponding elapsed time from the timer. The elapsed time recorded by the timer is the duration from time T1 to time T2, such as 600 ms. The storage device obtains the second running log time as 1 hour 03 minutes 50 seconds 400 ms and an elapsed time of 600 ms, which includes 1 hour 03 minutes 50 seconds 400 ms + 600 ms = 1 hour 03 minutes 51 seconds 0 ms. The storage device also obtains the second running log time as 2024 November 19, 14:27:35 0 ms and an elapsed time of 600 ms, which includes 2024 November 19, 14:27:35 600 ms + 600 ms = 2024 November 19, 14:27:35 600 ms. Therefore, the time recorded by the storage device (the second running log) includes 1 hour 03 minutes 51 seconds 0 ms and 2024 November 19, 14:27:35 600 ms.
[0080] In some embodiments, when preset write conditions are met, the storage device writes a second runtime log stored in a memory buffer to a non-volatile memory, such as NAND Flash.
[0081] Among them, the preset write conditions may include, but are not limited to: (1) the storage device is in an idle state, that is, the electronic device does not send a command request to the storage device, and the idle time of the storage device in an idle state reaches a preset time threshold. (2) the usage rate of the memory buffer used for log recording inside the storage device reaches a preset storage threshold.
[0082] The preset time threshold and preset storage threshold can be set according to the actual situation, and this application does not make specific limitations on them.
[0083] Step S203: The electronic device sends a log read request to the storage device.
[0084] The log read request is used to read the second runtime log recorded by the storage device, which may include all logs recorded in memory and non-volatile memory.
[0085] In step S204, the storage device responds to the log read request by transmitting a second operating log to the electronic device.
[0086] For example, electronic devices and storage devices agree to use CMD56 with special command parameters to read the second runtime log of the storage device.
[0087] In this embodiment, when dealing with electronic device performance optimization, kernel exception log analysis, and issues such as stuttering and logo freezes, the electronic device pulls down its runtime log. Then, the electronic device reads the storage device's runtime log using a private command and matches the log contents from both ends based on the target timestamp of the data transfer. This allows analysts to quickly determine whether the exception was caused by a storage device malfunction or the electronic device by examining the logs at the points in time where the exception occurred.
[0088] The following describes the log processing method provided in the embodiments of this application, using an electronic device as the execution subject.
[0089] Please see Figure 3 This application provides an exemplary log processing method that can be applied to and executed by an electronic device. The log processing method may include the following steps; the order of these steps in the flowchart may be changed or some may be omitted depending on different requirements.
[0090] In step S301, the electronic device transmits a target timestamp to the storage device. The target timestamp includes the time corresponding to the first operating log of the electronic device. The storage device records a second operating log based on the target timestamp, wherein the second operating log includes the time corresponding to the second operating log.
[0091] The relevant content of the target timestamp, the first running log, and the second running log can be referred to in step S201, and will not be repeated here.
[0092] In some embodiments, the time corresponding to the first running log includes the time of the electronic device's running state, which may include, but is not limited to, one or more of the following: kernel running time, system running time, and current system time.
[0093] In some embodiments, when the electronic device detects that the storage device is in an initialization state, the electronic device is in an idle state for a preset time, or the electronic device detects abnormal information, it transmits a target timestamp to the storage device. The initialization state may include any one of the following: the storage device is powered on and reset, the storage device is hardware reset, or the storage device is woken up from a hibernation state.
[0094] For example, the electronic device includes a timestamp sending module, which sends the target timestamp to the storage device via the CMD49 command in the timestamp scenario described above.
[0095] In step S302, the electronic device sends a log read request to the storage device, wherein the log read request is used to read the second operation log recorded by the storage device.
[0096] The relevant content of step S302 can be referred to step S203, and will not be repeated here.
[0097] For example, the electronic device includes a device log reading module. The device log reading module reads the second operating log of the storage device using CMD56 with special command parameters.
[0098] Step S303: The electronic device saves the second operation log recorded by the storage device.
[0099] In step S304, the electronic device matches the first operation log with the second operation log to obtain a matched log pair.
[0100] Electronic devices can match the first and second operation logs based on a target timestamp to obtain a matching log pair. For example, the target timestamp can horizontally correlate the log contents of the first and second operation logs in segments.
[0101] In some embodiments, the first running log includes K log events and log records corresponding to the log events, where K is an integer greater than or equal to 1. Step S304 may specifically include: for each log event, determining the start time and end time of the log record corresponding to the log event, and matching the first running log and the second running log according to the time, start time and end time corresponding to the second running log to obtain a matched log pair.
[0102] For example, the log events in the first running log are arranged in chronological order, and each log event has a clearly defined start and end time. The electronic device parses the first running log to obtain the start and end times of each log event, as well as the log content. The electronic device parses the second running log to obtain the time (i.e., the time calculated based on the target timestamp) and log content corresponding to each log entry in the second running log. Each log event in the first running log is traversed, and log entries within the time range in the second running log are checked. Matching log pairs are stored in a new data structure to obtain the matching log pairs.
[0103] For example, the electronic device includes a log matching module. The log matching module is used to match a first running log with a second running log to obtain a matched log pair.
[0104] Step S305: The electronic device analyzes the matched log pairs to determine the cause of the anomaly.
[0105] The following example uses electronic devices as eMMC platforms and storage devices as eMMC devices (eMMC chips).
[0106] For example, if you encounter a low performance issue on an eMMC platform, you can first check the memory status, swap partition usage, and CPU status. CPU status may include, but is not limited to: user space CPU utilization, kernel space CPU utilization, idle CPU percentage, and the percentage of CPU used for I / O wait. Then, check the eMMC device logs for the corresponding system time period to confirm the percentage of idle time and the rate of data processing during non-idle hours. If the eMMC platform has high I / O wait and the corresponding eMMC device log shows a low rate of data processing during non-idle hours, this quickly confirms that the low platform performance is caused by the eMMC device.
[0107] For example, if the eMMC platform application log indicates a file read failure, you can check the log of the eMMC device with the corresponding timestamp to confirm whether there is a NAND flash record indicating a decoding failure. The eMMC device may have entered read protection due to low voltage or excessive temperature. If the eMMC device log records that it entered read protection due to low voltage, it can be confirmed that the eMMC read failure was caused by an unstable power supply environment.
[0108] For example, the electronic device includes an anomaly analysis module. The anomaly analysis module is used to analyze matched log pairs to determine the cause of the anomaly.
[0109] In this embodiment, the electronic device sends a target timestamp to the storage device via a command in the aforementioned timestamp scenario. The target timestamp includes the times corresponding to all the electronic device's operation logs, such as kernel runtime, system runtime, and the current system time. The storage device records its internal logs based on the target timestamp transmitted by the electronic device, including kernel runtime, system runtime, and the current system time, etc., to correlate the electronic device's logs with the storage device's logs during subsequent analysis of anomalies. The storage device needs to save all key information that could cause electronic device anomalies in its logs. This way, when an electronic device malfunctions, searching the corresponding storage device logs allows for quick confirmation of whether the electronic device's anomaly is related to the storage device.
[0110] Please see Figure 4 This paper exemplifies another log processing method provided by an embodiment of the present application. This log processing method can be applied to an electronic device and executed by the electronic device. The electronic device is an eMMC platform and the storage device is an eMMC device. The log processing method may include the following steps. Depending on different needs, the order of the steps in the flowchart may be changed, and some may be omitted.
[0111] Step S401: The eMMC platform starts up and runs.
[0112] For example, the eMMC platform is powered on, establishing a communication link between the eMMC device and the eMMC platform. The eMMC platform runs a corresponding computer program to execute the log processing method provided in this application embodiment.
[0113] Step S402: The eMMC platform determines whether the eMMC device power-on reset is complete.
[0114] For example, the status of the reset pin is detected or a reset completion signal is received from the eMMC device to determine whether the power-on reset of the eMMC device has ended.
[0115] If not, proceed to step S403; if yes, proceed to step S407.
[0116] Step S403: The eMMC platform determines whether the eMMC device hardware reset is complete.
[0117] For example, a specific hardware reset signal is detected or a reset completion notification is waited for from the eMMC device to determine whether the eMMC device hardware reset has ended.
[0118] If not, proceed to step S404; if yes, proceed to step S407.
[0119] Step S404: The eMMC platform determines whether the eMMC device has finished its sleep-wake cycle.
[0120] For example, check the eMMC device status register or receive a wake-up notification from the eMMC device.
[0121] If not, proceed to step S405; if yes, proceed to step S407.
[0122] Step S405: The eMMC platform determines whether it is in an idle state and whether it has been in an idle state for a preset time.
[0123] For example, the idle status of the eMMC platform is monitored, and the cumulative value of the idle time is calculated. When the idle time reaches a preset time, step S407 is executed.
[0124] If the eMMC platform is determined to be in an idle state, or if the eMMC platform is in an idle state but the idle time has not reached the preset time, then step S406 is executed.
[0125] Step S406: The eMMC platform determines whether abnormal information has been detected.
[0126] The eMMC platform determines whether abnormal information of an abnormal state has been detected. The abnormal state can be set according to the actual situation, such as detecting hardware failure, software error, etc.
[0127] If not, proceed to step S402; if yes, proceed to step S407.
[0128] The execution order of steps S402 to S406 is not specifically limited. They can be executed simultaneously or not simultaneously. Step S406 can be executed first and then step S405, step S405 can be executed first and then step S404, step S404 can be executed first and then step S403, or step S403 can be executed first and then step S402. This application does not make specific limitations in this regard.
[0129] In step S407, the eMMC platform sends the target timestamp to the storage device.
[0130] The relevant content of step S407 can be referred to step S201 or step S301, and will not be repeated here.
[0131] In step S408, the eMMC platform determines whether it is necessary to read the second runtime log of the storage device.
[0132] The eMMC platform can determine whether it is necessary to read the second runtime log of the storage device based on actual needs or system configuration. For example, when dealing with complex issues such as performance optimization between storage devices and electronic devices, kernel exception log analysis, system lag, and boot logo issues, it may be necessary to read the second runtime log of the storage device.
[0133] If yes, proceed to step S409; otherwise, proceed to step S402.
[0134] Step S409: The eMMC platform reads and saves the second operation log of the storage device.
[0135] The relevant content of step S409 can be referred to in steps S203 or S302 to S303, and will not be repeated here.
[0136] In this embodiment, when handling platform performance optimization issues, kernel exception log analysis, and anomalies such as lag and logo freezes, the eMMC platform and eMMC device pull up the eMMC platform's runtime log. Then, the eMMC platform reads the eMMC device's runtime log using a private command and matches the log contents of both ends based on their timestamps. This allows analysts to quickly determine whether the anomaly was caused by an eMMC device malfunction or the eMMC platform by examining the logs at the time of the anomaly. This addresses the problem of lacking detailed eMMC device runtime logs for rapid analysis and localization when handling platform performance optimization issues, kernel exception log analysis, and anomalies such as lag and logo freezes.
[0137] The following describes the log processing method provided in the embodiments of this application, with storage devices as the execution subject.
[0138] Please see Figure 5 This application provides an exemplary log processing method that can be applied to and executed by a storage device. The log processing method may include the following steps; the order of these steps in the flowchart may be changed, and some may be omitted, depending on different requirements.
[0139] Step S501: The storage device obtains the target timestamp transmitted by the electronic device. The target timestamp includes the time corresponding to the first running log of the electronic device.
[0140] The target timestamp and the first running log are referenced above and will not be repeated here.
[0141] Step S502: The storage device records a second operation log based on the target timestamp, wherein the second operation log includes the time corresponding to the second operation log.
[0142] In some embodiments, the storage device uses the target timestamp as the start time of the timer. When it is necessary to record the second running log, it obtains the corresponding elapsed time from the timer, wherein the elapsed time is used to indicate the elapsed time from the start time to when the second running log needs to be recorded. The time corresponding to the second running log is obtained based on the start time and the elapsed time.
[0143] In some embodiments, the time corresponding to the second operation log includes the time of the storage device's operating state, which may include, but is not limited to, one or more of the following: kernel running time, system running time, and current system time. The second operation log includes one or more of the following: the time during which no command request was received from the electronic device within a first preset time period, the amount of data written and read by the electronic device within a second preset time period, the preset state of the storage device within a third preset time period, and the preset behavior of the storage device within a third preset time period.
[0144] For example, the storage device includes a device logging module. During the operation of the storage device, various log contents are continuously generated. The device logging module stores the log contents generated by the device and records the time of the operation log according to the target timestamp.
[0145] In step S503, the storage device receives a log read request sent by the electronic device, wherein the log read request is used to read the second running log recorded by the storage device.
[0146] In step S504, the storage device responds to the log read request by transmitting a second running log to the electronic device.
[0147] Please see Figure 6 This paper exemplifies another log processing method provided by an embodiment of the present application. This log processing method can be applied to a storage device and executed by the storage device. The electronic device is referred to as an eMMC platform and the storage device is an eMMC device. The log processing method may include the following steps. Depending on different needs, the order of the steps in the flowchart may be changed, and some may be omitted.
[0148] Step S601: The eMMC device starts up and runs.
[0149] After being powered on, eMMC devices can perform initialization operations, including checking hardware status, loading firmware, and configuring necessary register parameters. Once initialization is complete, the eMMC device enters standby mode, waiting for instructions or requests from other electronic devices.
[0150] In step S602, the eMMC device determines whether it has received the target timestamp sent by the electronic device.
[0151] The electronic device may send a target timestamp to the eMMC device via a specific communication protocol (such as SPI, SD, etc.). The eMMC device needs to listen to the communication interface to check whether the target timestamp has been received. If the target timestamp has been received, step S603 is executed; otherwise, step S604 is executed.
[0152] In step S603, the eMMC device records the target timestamp and starts the timer to begin timing.
[0153] eMMC devices can store the received target timestamp in memory, such as internal registers or RAM. Simultaneously, the eMMC device starts a timer (either a hardware or software timer) to begin counting from the target timestamp, which is used for subsequent timestamp updates in the log.
[0154] In step S604, the eMMC device determines whether the memory used to store logs has reached a preset storage threshold.
[0155] The eMMC device has an internal memory area for storing logs. The eMMC device can periodically check the usage of this memory area to determine whether a preset storage threshold has been reached. If the preset storage threshold has been reached, step S606 is executed; otherwise, step S605 is executed.
[0156] Step S605: Is the eMMC device in an idle state and has the idle state time met the set time?
[0157] The eMMC device checks whether it is currently in an idle state, meaning there are no tasks or operations being executed, such as not receiving command requests from electronic devices. Simultaneously, the eMMC device also determines whether it has been in an idle state for a set period of time. If both conditions are met, step S606 is executed; otherwise, step S608 is executed.
[0158] The time limit is usually set to ensure that there is enough time to write log data to non-volatile memory when the eMMC device is idle, so as to avoid affecting performance when the eMMC device is busy.
[0159] Step S606: The eMMC device updates the log based on the timer.
[0160] When an eMMC device needs to record log data, it updates the log timestamp based on the current timer. Then, the eMMC device writes the updated timestamp along with the relevant log data to the log record, resulting in a second runtime log. This second runtime log is first written to a log buffer in memory, and subsequently written to non-volatile memory.
[0161] In step S607, the eMMC device writes the log from memory to non-volatile memory.
[0162] When the log buffer in memory reaches the preset storage threshold or the eMMC device is idle for a set period of time, the eMMC device will write the log data from memory to non-volatile storage, such as NAND Flash. This ensures that the log data can still be retained after power failure or device restart.
[0163] In step S608, the eMMC device determines whether it has received a log read request.
[0164] eMMC devices listen to the communication interface to check if they receive log read requests from electronic devices.
[0165] If yes, proceed to step S609; otherwise, proceed to step S602.
[0166] In step S609, the eMMC device integrates the logs stored in memory and non-volatile memory and sends them to the electronic device.
[0167] When an eMMC device receives a log read request, it can retrieve the corresponding log data from memory and non-volatile storage based on the filtering criteria in the request. The eMMC device then integrates the retrieved log data and sends it to the electronic device via the communication interface according to the requested format or protocol.
[0168] This application also provides a computer-readable storage medium including computer instructions that, when executed on a device, cause the device to perform the log processing method described in any of the preceding claims. For example, when the computer instructions are executed on an electronic device, they perform... Figure 2 The steps S101 and S103 shown, and Figure 3 , Figure 4 The steps are shown. When computer instructions are executed on the storage device, the following steps are performed: Figure 2 The steps S102 and S104 shown, and Figure 5 , Figure 6 The steps are shown.
[0169] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in the apparatus claims may also be implemented by the same unit or device in software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.
[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. A log processing method, applied to electronic devices, characterized in that, The electronic device is connected to the storage device, and the method includes: The target timestamp is transmitted to the storage device, the target timestamp including the time corresponding to the first operation log of the electronic device; the storage device records the second operation log of the storage device according to the target timestamp, wherein the second operation log includes the time corresponding to the second operation log; Send a log read request to the storage device, wherein the log read request is used to read the second running log recorded by the storage device; Save the second operation log recorded by the storage device.
2. The log processing method as described in claim 1, characterized in that, The method further includes: The first running log is matched with the second running log to obtain a matched log pair; Analyze the matched log pairs to determine the cause of the anomaly.
3. The log processing method as described in claim 2, characterized in that, The first running log includes K log events and the log records corresponding to the log events, where K is an integer greater than or equal to 1; The step of matching the first running log with the second running log to obtain a matched log pair includes: For each log event, determine the start and end times of the log record corresponding to the log event; The first and second running logs are matched based on the time corresponding to the second running log, the start time, and the end time to obtain a matched log pair.
4. The log processing method according to any one of claims 1 to 3, characterized in that, The time corresponding to the first running log includes the time of the electronic device's running state, which may include one or more of the following: kernel running time, system running time, and current system time; The transmission of the target timestamp to the storage device includes: When the storage device is detected to be in an initialization state, the electronic device is in an idle state for a preset time, or the electronic device detects abnormal information, a target timestamp is transmitted to the storage device. The initialization state may include any of the following: storage device power-on reset, storage device hardware reset, or storage device wake-up from hibernation state.
5. A log processing method applied to a storage device, characterized in that, The storage device is connected to an electronic device, and the method includes: Obtain the target timestamp transmitted by the electronic device, wherein the target timestamp includes the time corresponding to the first operating log of the electronic device; A second operation log is recorded according to the target timestamp, wherein the second operation log includes the time corresponding to the second operation log; Receive a log read request sent by the electronic device, wherein the log read request is used to read the second operation log recorded by the storage device; In response to the log read request, the second operation log is transmitted to the electronic device.
6. The log processing method as described in claim 5, characterized in that, The method further includes: Use the target timestamp as the start time of the timer; When it is necessary to record the second operation log, the corresponding elapsed time is obtained from the timer, wherein the elapsed time is used to indicate the elapsed time from the start time to the time when the second operation log needs to be recorded. The time corresponding to the second running log is obtained based on the start time and the elapsed time.
7. The log processing method as described in claim 6, characterized in that, The time corresponding to the second running log includes the time of the storage device's running status, which may include one or more of the following: kernel running time, system running time, and current system time; The second operation log includes one or more of the following: the time during which no command request was received from the electronic device within a first preset time period, the amount of data written and read by the electronic device within a second preset time period, the preset state of the storage device within a third preset time period, and the preset behavior of the storage device within a third preset time period.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory being used to store a computer program, and the processor being used to execute the computer program in the memory, causing the electronic device to perform the log processing method according to any one of claims 1 to 4.
9. A storage device, characterized in that, The electronic device includes a controller and a memory, the memory being used to store a computer program, and the controller being used to execute the computer program in the memory, causing the electronic device to perform the log processing method according to any one of claims 5 to 7.
10. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on the device, cause the device to perform the log processing method as described in any one of claims 1 to 4 or 5 to 7.