CN114691025A - Log recording method, device, equipment and storage medium - Google Patents

Log recording method, device, equipment and storage medium Download PDF

Info

Publication number
CN114691025A
CN114691025A CN202011641947.2A CN202011641947A CN114691025A CN 114691025 A CN114691025 A CN 114691025A CN 202011641947 A CN202011641947 A CN 202011641947A CN 114691025 A CN114691025 A CN 114691025A
Authority
CN
China
Prior art keywords
storage space
log
log information
information
space
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011641947.2A
Other languages
Chinese (zh)
Inventor
刘立超
袁俊卿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN202011641947.2A priority Critical patent/CN114691025A/en
Publication of CN114691025A publication Critical patent/CN114691025A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0683Plurality of storage devices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a log recording method, a device, equipment and a storage medium, wherein the method comprises the following steps: acquiring log information generated in the running process of a system kernel; recording the log information in a first storage space and/or a second storage space according to a preset log level, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory; according to a preset condition, synchronizing the log information which is recorded in the first storage space and is not stored in the second storage space into the second storage space. According to the embodiment of the invention, the logs generated in the running process of the system kernel are stored in the random access memory and the nonvolatile memory, and the contents stored in the nonvolatile memory cannot be lost due to power failure, so that the system restart logs are not lost.

Description

Log recording method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a log recording method, a log recording device, log recording equipment and a log recording storage medium.
Background
The system log is information for recording hardware, software and system problems in the system, and it can also monitor events occurring in the system, and an administrator can check the cause of the occurrence of errors by looking at the system log. By checking the recorded system log, an administrator can locate the reason of the system failure in time.
In the prior art, all logs generated during the operation of the system are recorded in a common Memory, for example, a Random Access Memory (RAM), and when a manager needs to query the logs, the manager can read the logs from the Memory according to a log storage path.
However, when the system needs to be restarted, the log stored in the ordinary memory is easily lost, so that the problem that the administrator cannot locate the system is caused.
Disclosure of Invention
Embodiments of the present invention provide a log recording method, apparatus, device, and storage medium, to solve the problem in the prior art that a log stored in a common memory is easily lost due to system power failure or restart, which results in that a manager cannot locate a system.
A first aspect of an embodiment of the present invention provides a log recording method, including:
acquiring log information generated in the running process of a system kernel;
recording the log information in a first storage space and/or a second storage space according to a preset log information level, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory;
according to a preset condition, synchronizing specific log information recorded in the first storage space into a second storage space, wherein the specific log information is information which is not stored in the second storage space.
Optionally, recording the log information in the first storage space and/or the second storage space according to a preset log information level includes:
for each log information, the following operations are performed:
if the log information level of the log information is an error level, recording the log information in the first storage space and the second storage space;
if the log information level of the log information is an alarm level, a debugging level or an information level, recording the log information in the first storage space, and marking a flag bit for the log information in the first storage space.
Optionally, before the specific log information recorded in the first storage space is synchronized to the second storage space according to the preset condition, the method further includes:
detecting whether a flag bit exists in the first storage space or not, and starting timing to obtain timing duration when the flag bit is detected;
the synchronizing the specific log information recorded in the first storage space to the second storage space according to the preset condition includes:
when the preset condition is met, writing specific log information in the first storage space into the second storage space according to a predetermined log write-back thread and a predetermined log write-back function;
wherein the preset conditions include any one or more of the following:
the timing time is greater than or equal to a preset time;
powering off a system kernel;
restarting the system;
a system program error.
Optionally, before recording the log information in the first storage space and/or the second storage space according to a preset log information level, the method further includes:
and writing reserved memory information in a device tree description file of a hardware system so as to divide a first storage space in the random access memory and a second storage space in the nonvolatile memory, wherein the reserved memory information comprises the position and the size of the first storage space needing to be divided in the RAM and the position and the size of the second storage space in the ROM of the nonvolatile memory.
Optionally, before recording the log information in the first storage space and/or the second storage space according to a preset log information level, the method further includes:
dividing a log management space and a log storage space in the first storage space and the second storage space respectively, wherein the log management space stores log management information which is used for representing the storage position of the log information in the log storage space;
the recording the log information in the first storage space and/or the second storage space includes:
analyzing the log management space to obtain log management information, wherein the log management information comprises log storage addresses and log line number information;
and writing the log information into the log storage space of the first storage space and/or the second storage space according to the log storage address and the log line number information.
Optionally, the method further includes:
and updating the log management information.
Optionally, before obtaining the log information generated in the running process of the system kernel, the method further includes:
and modifying a dump address of an operating system according to a Boot firmware modification instruction input by a user, so that the modified dump address corresponds to the first storage space and the second storage space, and the log information is controlled to be recorded in the first storage space and the second storage space.
A second aspect of an embodiment of the present invention provides a log recording apparatus, including:
the acquisition module is used for acquiring log information generated in the running process of a system kernel;
the recording module is used for recording the log information in a first storage space and/or a second storage space according to a preset log information level, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory;
and the synchronization module is used for synchronizing the specific log information recorded in the first storage space into the second storage space according to a preset condition, wherein the specific log information is information which is not stored in the second storage space.
A third aspect of an embodiment of the present invention provides a computer apparatus, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the logging method provided by the first aspect of the embodiment of the present invention.
A fourth aspect of the embodiments of the present invention provides a computer-readable storage medium, where a computer executing instruction is stored in the computer-readable storage medium, and when a processor executes the computer executing instruction, the method for recording logs provided in the first aspect of the embodiments of the present invention is implemented.
The embodiment of the invention provides a log recording method, a log recording device, log recording equipment and a log recording storage medium, wherein log information generated by a system kernel in the running process is stored in a first storage space and/or a second storage space according to the log level; and then according to a preset condition, synchronizing the log information which is recorded in the first storage space and is not stored in the second storage space into the second storage space. Because the first storage space is the space in the random access memory and the second storage space is the space in the nonvolatile memory, the log information is recorded into the nonvolatile memory according to the levels and different conditions, so that the log is not lost when the system is restarted or powered off, and managers can conveniently inquire the log information and position the system in time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a diagram illustrating an application scenario of a logging method according to an exemplary embodiment of the present invention;
FIG. 2 is a flowchart illustrating a logging method in accordance with an exemplary embodiment of the present invention;
FIG. 3 is a flowchart illustrating a logging method in accordance with another exemplary embodiment of the invention;
FIG. 4 is a schematic diagram illustrating a log storage page in accordance with an exemplary embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating a configuration of a logging apparatus in accordance with an exemplary embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device according to an exemplary embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In the prior art, an operating system generates various logs in the running process, the system logs are information for recording hardware, software and system problems in the system, the system logs can also monitor events occurring in the system, and an administrator can check the reason of error occurrence by looking at the system logs. By checking the recorded system log, an administrator can locate the reason of the system failure in time. All logs generated in the running process of the system are recorded in a common memory, such as a RAM, and when a manager needs to query the logs, the logs can be read in the memory according to a log storage path. However, when the system needs to be restarted or a sudden power failure occurs, the log stored in the ordinary memory is easily lost, so that the administrator cannot obtain the log information to locate the system.
Aiming at the defect, the technical scheme of the invention mainly comprises the following steps: the method comprises the steps of generating log information by a system kernel in the running process, respectively storing the log information in a first storage space and/or a second storage space according to log levels, wherein the first storage space is a space in a common Memory, the second storage space is a space in a Read-Only Memory (ROM), and the ROM is a storage medium for permanently storing data on a computer and other electronic equipment, and once the data are stored, the data cannot be changed or deleted, so that the logs in the common Memory and/or the ROM are recorded according to the log levels, and the logs in the ROM can be guaranteed not to be lost when the system is restarted or powered off. And according to the abnormal conditions frequently occurring in the running of some systems, the logs in the common memory are synchronized into the ROM, so that the logs are not lost when the abnormal conditions such as restarting or power failure occur to the system to a greater extent, and managers can conveniently obtain log information to position the system problems.
Fig. 1 is an application scenario diagram illustrating a logging method according to an exemplary embodiment of the present invention.
As shown in fig. 1, the architecture of the application scenario provided in this embodiment mainly includes: a Central Processing Unit (CPU) 101, a RAM102, and a ROM 103.
The method comprises the following steps that a processor CPU obtains log information generated by running of an operating system and then stores the log information into a random access memory (RAM102) and/or a nonvolatile memory (ROM 103); an operating system is stored and runs in ROM103 or other memory.
Fig. 2 is a flowchart illustrating a logging method according to an exemplary embodiment of the present invention, and an execution subject of the method provided in this embodiment may be a processor CPU in the embodiment illustrated in fig. 1.
As shown in fig. 2, the method provided by the present embodiment may include the following steps.
S201, obtaining log information generated in the running process of the system kernel.
Specifically, a system kernel generates a large number of log files in the running process, and the log files contain kernel log information in the system starting process, such as device information of the system; in addition, the log file also includes information of any errors and problems of the system recorded during system startup and operation.
S202, according to a preset log level, recording the log information in a first storage space and/or a second storage space, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory.
Specifically, after the log information is obtained, the log information is classified according to preset log levels, for example, the log levels include an alarm level WARN, an ERROR level ERROR, a DEBUG level DEBUG, and the like, and then the log information is recorded into a first storage space and/or a second storage space according to different levels, where the first storage space is a space in the RAM and the second storage space is a space in the ROM.
It should be noted that, because a system kernel may generate a large amount of log information during the starting or running process, and if all log information is directly stored in the ROM, a large amount of space may be occupied, therefore, the log information of a higher level (for example, an error level) is more important according to different levels of the log information actually generated during the running of the system in this step, and the loss of the log information of this level has a large influence on the system maintenance, and for other levels of information (for example, a debugging level and an information level) may be stored in the RAM first, and when the system is in an abnormal condition such as power failure, the log information of the debugging level, the information level, and the like is synchronized into the ROM, so that the log information of the debugging level, the information level, and the like is not lost, and if the system is not in an abnormal condition, the log information may not be synchronized into the ROM, which not only saves the ROM space, but also ensures that the log information is not lost due to the system abnormality.
S203, according to a preset condition, synchronizing the specific log information recorded in the first storage space into a second storage space, wherein the specific log information is information which is not stored in the second storage space.
Specifically, because the first storage space is a space in the random access memory, when the system is powered off or restarted in the operation process, the log information stored in the first storage space may be lost, and therefore, under some special conditions, the log information that is not stored in the second storage space in the first storage space needs to be synchronized to the second storage space, so that the log is ensured not to be lost to the maximum extent when the system is restarted or powered off.
In this embodiment, log information generated by a system kernel during operation is stored in the first storage space and/or the second storage space according to the log level, and since the first storage space is a space in a normal memory, the second storage space is a space in a non-volatile memory ROM, and the ROM is a storage medium for permanently storing data on a computer or other electronic devices, the data cannot be changed or deleted once stored, and thus, the log recorded in the normal memory and/or the ROM according to the log level can ensure that the log in the ROM is not lost when the system is restarted or powered off. And according to the conditions of some systems, such as restarting, power-off and the like, which often occur in the operation process, the logs in the common memory are synchronized into the ROM, so that the logs are not lost when the system is in abnormal conditions, such as restarting, power-off and the like, and management personnel can conveniently obtain log information to locate the system problems.
Fig. 3 is a flowchart illustrating a logging method according to another exemplary embodiment of the present invention, and the method provided in this embodiment further details the logging method based on the embodiment illustrated in fig. 2.
As shown in fig. 3, the method provided by the present embodiment may include the following steps.
S301, a first storage space and a second storage space are determined, wherein the first storage space is a space in a RAM, the second storage space is a space in the ROM, the first storage space and the second storage space both comprise a log management space and a log storage space, and log management information is stored in the log management space.
Specifically, as shown in fig. 1, the first storage space may be a reserved memory in the RAM, and the second storage space is a space in the ROM. In specific implementation, adding reserved memory information in information describing memory nodes contained in a device tree description file of a computer hardware system, namely respectively reserving a space in an RAM and a space in an ROM for recording log information; the reserved memory information comprises the position and the size of a first storage space needing to be divided in the RAM and the position and the size of a second storage space in the ROM. The ROM may be a nonvolatile memory such as RVRAM, FLASH, NAND, and the like, and is not particularly limited in this embodiment.
The device tree of the computer hardware system is a data structure for describing hardware resources such as a CPU (central processing unit), a memory and the like, and each hardware corresponds to one node in the device tree; thus, the relevant information of the RAM and the ROM can be described through the device tree. The whole Device Tree mainly comprises three parts, namely a Device Tree description file (DTS), a Device Tree Compiler (DTC) and a compiled Device Tree file (DTB); the device tree description file DTS is used for describing hardware resources of each hardware node in a device tree, the device tree description file DTS is located in an/arch/arm/boot/DTS directory of a system kernel, and a device tree compiling tool DTC is used for compiling the device tree description file DTS to generate a binary file DTB.
In this embodiment, by adding the reserved memory information to the subfile describing the RAM and the ROM included in the device tree description file of the computer system, the first storage space can be reserved in the RAM and the second storage space can be reserved in the ROM for storing the log information.
Further, a space is divided into a first storage space and a second storage space as a log management space. Specifically, when a device tree description file is modified to divide a first storage space and a second storage space in a RAM and a ROM respectively, an address division instruction is added, wherein the address division instruction comprises a start address and an end address to be divided, and the start address and the end address represent an address space range to be divided in a specified address range; by the address division instruction, a section of address space range is divided into the address ranges of the first storage space and the second storage space respectively as a log management space.
A space except the log management space in the first storage space is used as a log storage space of the first storage space, and a space except the log management space in the second storage space is used as a log storage space of the second storage space; the log management space is used for storing log management information, and the log management information is used for indicating the storage position of the log information in the log storage space, so that the size of the log management space can be determined according to the size of the log management information, for example, the size of the log management information can be 512K, and the size of the log management space is set to be 512K.
In the embodiment, the first storage space and the second storage space are divided into the log management space and the log storage space, and the log management information is stored through the log management space, so that the log information is prevented from being stored in the first storage space and the second storage space in a disordered manner, the log information in the first storage space and the log information in the second storage space are conveniently managed, and when the log information is read in the first storage space and the second storage space, the storage position of the log information can be quickly found through the log management information, so that the information acquisition efficiency is improved.
In one possible embodiment, the log storage space is described using the following structure:
Figure BDA0002880769530000081
Figure BDA0002880769530000091
in the above structure, the log data structure is declared first, each member variable is described by its own declaration, ending with a semicolon, and the semicolon after the curly brace indicates that the structure declaration ends. In the above structure, the log index data (i.e., the log storage address in this embodiment) is defined as 8 bytes, the log write line number line _ write is defined as 8 bytes, and the flag bit dirty is defined as boolean. Wherein the index is used to indicate the log storage location, such as which page in the log storage space the log is stored in, the line _ write is used to indicate which line the log is stored in, and the flag bit dirty is used to indicate whether the log information is written into each page in the log storage space.
Note that the descriptions of the information such as the index, the line _ write, and the flag bit dirty are all stored in the log management space.
S302, obtaining the log information generated in the running process of the system kernel, and judging the level of the log information.
Specifically, a system kernel generates a large number of log files during the running process, and the log files contain kernel log information during the starting process of the operating system, such as device information of the operating system. And any errors and problems with the operating system that are recorded during the start-up and operation of the operating system. After the log information is obtained, the log information is classified according to preset log levels, for example, the log levels include an alarm level WARN, an ERROR level ERROR, a debugging level DEBUG, an information level INFO, and the like.
It should be noted that the whole computer system includes two parts, namely a hardware system and a software system, the software system includes an operating system, and the system kernel is a core part of the operating system and is used for managing processes, memories, device drivers, files, a network system and the like of the operating system.
S303, if the log information level of the log information is an error level, recording the log information in the first storage space and the second storage space respectively; if the log information level of the log information is an alarm level, a debugging level or an information level, recording the log information in the first storage space, and marking a flag bit for the log information in the first storage space.
Specifically, for the ERROR level log, the ERROR level log is recorded into a first storage space (reserved memory) and a second storage space (ROM area) at the same time; for the journal information of WARNING, DEBUG and INFO levels, only the first storage space is recorded, and the journal information in the first storage space is marked with a flag bit (dirty) which indicates that the journal information is written in the first storage space.
In one possible embodiment, before logging the log information to the corresponding storage space, a detailed storage location of the log information in the storage space needs to be obtained, which includes: analyzing the log management space to obtain log management information, wherein the log management information comprises log storage addresses and log line number information; and writing the log information into the log storage space of the first storage space and/or the second storage space according to the log storage address and the log line number information.
Specifically, the storage space comprises a plurality of log storage pages, each log storage page comprises a plurality of log storage lines, and the log information is stored in a designated log storage line contained in the designated log storage page; in a system kernel starting stage, the log management spaces in the first storage space and the second storage space are analyzed, log index data is obtained, the index data indicates in which (log storage) page the log information is specifically stored, and then a log write line number line _ write (i.e. the log line number information or the log storage line information) is obtained to determine in which line of the log storage page the log information is specifically stored. And writing the log information generated by starting the system kernel into the correct position of the log storage space according to the log storage address and the log line number information.
For example, it is assumed that two log storage pages included in the log storage space in the second storage space divided in the ROM are as shown in fig. 4, and in the first log storage page, the log line number information 1, 2, 3, 4 … 10 lines, etc. are included, and each line corresponds to one piece of log information; similarly, the second log storage page also includes log line numbers of lines 1, 2, and 3 … 10, and when log information of an error level is generated by the system kernel startup, the log storage address is the first log storage page by analyzing the index and line _ write in the log management space in the second storage space, and the log information of the error level is stored in the third line of the first storage page when the log line number information is line 3.
Furthermore, when the log information is recorded, the log management information, namely the recording address and the log row number information of the next log in the log management space, is updated synchronously, so that the log generated by the next system kernel starting is recorded on the new address, and the log information recorded last time cannot be covered.
Illustratively, in the above example, after the log information of the error level is stored in the 3 rd line of the first storage page, the index in the log management information is updated to be the first storage page, and the line _ write is the 4 th line, and when the system generates the log information again, the log information is stored in a new position (the 4 th line), so as to avoid overwriting the log information recorded last time. When all 10 lines of the first storage page are full of log information, the index in the log management information is updated to the second storage page.
S304, detecting whether a flag bit dirty exists in the first storage space, and starting timing when the flag bit dirty is detected to obtain timing duration.
S305, when the preset condition is met, writing the log information in the first storage space into the second storage space according to a predetermined log write-back thread and a predetermined log write-back function; wherein the preset conditions include any one or more of the following: the timing time is greater than or equal to a preset time; powering off a system kernel; restarting the system; a system program error.
Specifically, a log write-back thread and a log write-back function (realized by a log recording mold) are arranged in a system kernel, and after the system kernel is started, the log write-back thread and the log write-back function run in a background; and when the first storage space dirty bit is detected, starting a timer to start timing, and when the timing duration is greater than or equal to the preset duration, synchronizing the log information in the first storage space (reserved memory) into a second storage space (ROM). For example, the preset duration may be set according to an actual situation, for example, set to 2 hours, and then synchronize the log information in the reserved memory into the ROM 2 hours after detecting the dirty bit. In addition, when any one or more of three flows of system kernel power-off, system restart or system program starting error flow modification occur, the CPU automatically synchronizes log information in the reserved memory into the ROM, and the log is ensured not to be lost to the maximum extent.
S306, according to a Boot firmware modification instruction input by a user, modifying a dump address of an operating system, so that the modified dump address corresponds to the first storage space and the second storage space, and controlling the log information to be recorded in the first storage space and the second storage space.
Specifically, when a Boot firmware modification interface receives a dump address modification instruction, a modified dump address is obtained; the log information generated by the operating system in the starting and running stages is recorded into the first storage space of the RAM and the second storage space of the ROM according to the modified dump address, so that the log information of the system kernel in the starting stage is ensured not to be lost.
In the embodiment, the cooperation of hardware such as a log recording module (namely, a log recording function, a log write-back thread and a log write-back function), a memory and the like and firmware is realized in the system kernel, so that the system kernel log is not lost during restarting; furthermore, log management information is updated in time while logs are recorded, and the log information generated by next kernel starting cannot cover the log information recorded last time, so that the kernel logs of multiple system operations are recorded, and the efficiency of positioning system problems is improved.
Fig. 5 is a schematic structural diagram of a logging apparatus according to an exemplary embodiment of the present invention.
As shown in fig. 5, the apparatus provided in this embodiment includes: an acquisition module 501, a recording module 502 and a synchronization module 503; the acquiring module 501 is configured to acquire log information generated in a system kernel operation process; a recording module 502, configured to record the log information in a first storage space and/or a second storage space according to a preset log level, where the first storage space is a space in a random access memory, and the second storage space is a space in a non-volatile memory; a synchronization module 503, configured to synchronize, according to a preset condition, specific log information recorded in the first storage space to the second storage space, where the specific log information is information that is not stored in the second storage space.
Further, the recording module is specifically configured to, for each piece of log information, perform the following operations: if the log information level of the log information is an error level, recording the log information in the first storage space and the second storage space; if the log information level of the log information is an alarm level, a debugging level or an information level, recording the log information in the first storage space, and marking a flag bit for the log information in the first storage space.
Further, the synchronization module is specifically configured to detect whether a flag bit exists in the first storage space before synchronizing the specific log information recorded in the first storage space into the second storage space, and start timing to obtain a timing duration when the flag bit is detected; when the preset condition is met, writing specific log information in the first storage space into the second storage space according to a predetermined log write-back thread and a predetermined log write-back function; wherein the preset conditions include any one or more of the following: the timing time is greater than or equal to a preset time; powering off a system kernel; restarting the system; a system program error.
Further, the apparatus provided in this embodiment further includes: a dividing module 504, configured to write reserved memory information in a device tree description file of a hardware system, so as to divide a first storage space in the random access memory and a second storage space in the non-volatile memory, where the reserved memory information includes a location and a size of the first storage space to be divided in the RAM, and a location and a size of the second storage space in the ROM of the non-volatile memory.
Further, the dividing module is further configured to: dividing a log management space and a log storage space in the first storage space and the second storage space respectively, wherein the log management space stores log management information which is used for representing the storage position of the log information in the log storage space; the recording module is specifically configured to: analyzing the log management space to obtain log management information, wherein the log management information comprises log storage addresses and log line number information; and writing the log information into the log storage space of the first storage space and/or the second storage space according to the log storage address and the log line number information.
Further, the apparatus provided in this embodiment further includes: and an updating module 505, configured to update the log management information.
Further, the recording module is further configured to: before obtaining log information generated in the running process of a system kernel, according to a Boot firmware modification instruction input by a user, modifying a dump address of an operating system, so that the modified dump address corresponds to the first storage space and the second storage space, and controlling the log information to be recorded in the first storage space and the second storage space.
For detailed functional description of each module in this embodiment, reference is made to the description of the embodiment of the method, and the detailed description is not provided herein.
Fig. 6 is a schematic hardware structure diagram of a computer device according to an embodiment of the present invention. As shown in fig. 6, the present embodiment provides a computer apparatus 600 including: at least one processor 601 and memory 602. The processor 601 and the memory 602 are connected by a bus 603.
In a specific implementation process, the at least one processor 601 executes the computer-executable instructions stored in the memory 602, so that the at least one processor 601 executes the logging method in the above method embodiment.
For the specific implementation process of the processor 601, reference may be made to the above method embodiments, which implement principles and technical effects similar to each other, and details are not described herein again.
In the embodiment shown in fig. 6, it should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
The memory may comprise high speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
Another embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the logging method in the above-mentioned method embodiment is implemented.
The computer-readable storage medium may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk. Readable storage media can be any available media that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the readable storage medium may also reside as discrete components in the apparatus.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method of logging, comprising:
acquiring log information generated in the running process of a system kernel;
recording the log information in a first storage space and/or a second storage space according to a preset log information level, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory;
according to a preset condition, synchronizing specific log information recorded in the first storage space into a second storage space, wherein the specific log information is information which is not stored in the second storage space.
2. The method of claim 1, wherein recording the log information in the first storage space and/or the second storage space according to a preset log information level comprises:
for each log information, the following operations are performed:
if the log information level of the log information is an error level, recording the log information in the first storage space and the second storage space;
if the log information level of the log information is an alarm level, a debugging level or an information level, recording the log information in the first storage space, and marking a flag bit for the log information in the first storage space.
3. The method according to claim 2, wherein before synchronizing the specific log information recorded in the first storage space into the second storage space according to a preset condition, the method further comprises:
detecting whether a flag bit exists in the first storage space or not, and starting timing to obtain timing duration when the flag bit is detected;
the synchronizing, according to a preset condition, the specific log information recorded in the first storage space into a second storage space includes:
when the preset condition is met, writing specific log information in the first storage space into the second storage space according to a predetermined log write-back thread and a predetermined log write-back function;
wherein the preset conditions include any one or more of:
the timing time is greater than or equal to a preset time;
powering off a system kernel;
restarting the system;
a system program error.
4. The method according to any one of claims 1-3, wherein before recording the log information in the first storage space and/or the second storage space according to a preset log information level, further comprising:
and writing reserved memory information in a device tree description file of a hardware system so as to divide a first storage space in the random access memory and a second storage space in the nonvolatile memory, wherein the reserved memory information comprises the position and the size of the first storage space needing to be divided in the RAM and the position and the size of the second storage space in the ROM of the nonvolatile memory.
5. The method according to any one of claims 1-4, wherein before recording the log information in the first storage space and/or the second storage space according to a preset log information level, the method further comprises:
dividing a log management space and a log storage space in the first storage space and the second storage space respectively, wherein the log management space stores log management information which is used for representing the storage position of the log information in the log storage space;
the recording the log information in the first storage space and/or the second storage space includes:
analyzing the log management space to obtain log management information, wherein the log management information comprises log storage addresses and log line number information;
and writing the log information into the log storage space of the first storage space and/or the second storage space according to the log storage address and the log line number information.
6. The method of claim 5, further comprising:
and updating the log management information.
7. The method according to any one of claims 1-6, wherein before the obtaining log information generated during the operation of the system kernel, the method further comprises:
and according to a Boot firmware modification instruction input by a user, modifying a dump address of an operating system so that the modified dump address corresponds to the first storage space and the second storage space, and controlling the log information to be recorded in the first storage space and the second storage space.
8. A logging apparatus, comprising:
the acquisition module is used for acquiring log information generated in the running process of a system kernel;
the recording module is used for recording the log information in a first storage space and/or a second storage space according to a preset log information level, wherein the first storage space is a space in a random access memory, and the second storage space is a space in a nonvolatile memory;
and the synchronization module is used for synchronizing the specific log information recorded in the first storage space into the second storage space according to a preset condition, wherein the specific log information is information which is not stored in the second storage space.
9. A computer device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing the memory-stored computer-executable instructions cause the at least one processor to perform the logging method of any of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer-executable instructions which, when executed by a processor, implement the logging method of any one of claims 1 to 7.
CN202011641947.2A 2020-12-31 2020-12-31 Log recording method, device, equipment and storage medium Pending CN114691025A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011641947.2A CN114691025A (en) 2020-12-31 2020-12-31 Log recording method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011641947.2A CN114691025A (en) 2020-12-31 2020-12-31 Log recording method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114691025A true CN114691025A (en) 2022-07-01

Family

ID=82136498

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011641947.2A Pending CN114691025A (en) 2020-12-31 2020-12-31 Log recording method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114691025A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116303314A (en) * 2022-12-16 2023-06-23 摩尔线程智能科技(北京)有限责任公司 Log storage method and device for GPU, electronic equipment and storage medium
CN116383012A (en) * 2023-05-26 2023-07-04 苏州浪潮智能科技有限公司 Method and device for acquiring boot log and method for transmitting boot log
CN116662284A (en) * 2022-09-07 2023-08-29 荣耀终端有限公司 Log management method, device, chip, electronic equipment and medium
CN117112520A (en) * 2023-04-10 2023-11-24 荣耀终端有限公司 Log processing method and electronic equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116662284A (en) * 2022-09-07 2023-08-29 荣耀终端有限公司 Log management method, device, chip, electronic equipment and medium
CN116303314A (en) * 2022-12-16 2023-06-23 摩尔线程智能科技(北京)有限责任公司 Log storage method and device for GPU, electronic equipment and storage medium
CN117112520A (en) * 2023-04-10 2023-11-24 荣耀终端有限公司 Log processing method and electronic equipment
CN116383012A (en) * 2023-05-26 2023-07-04 苏州浪潮智能科技有限公司 Method and device for acquiring boot log and method for transmitting boot log
CN116383012B (en) * 2023-05-26 2023-08-18 苏州浪潮智能科技有限公司 Method and device for acquiring boot log and method for transmitting boot log

Similar Documents

Publication Publication Date Title
CN114691025A (en) Log recording method, device, equipment and storage medium
US8341386B2 (en) Method for updating basic input/output system and method for repairing thereof
US20030236766A1 (en) Identifying occurrences of selected events in a system
CN108170495B (en) BIOS upgrading method, system, equipment and computer readable storage medium
US20110055278A1 (en) Setting Information Database Management
US9710340B2 (en) Replacement of a corrupt driver variable record
US8799716B2 (en) Heap dump occurrence detection
CN110781026A (en) Embedded equipment data storage and repair method and device and embedded equipment
EP3274839B1 (en) Technologies for root cause identification of use-after-free memory corruption bugs
CN115269544A (en) Database cluster upgrading method and device, electronic equipment and storage medium
US20030018865A1 (en) Disablement of a write filter stored on a write-protected partition
US9971670B2 (en) Detecting uninitialized memory references
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN113190256A (en) Upgrading method, device and equipment
US20080201572A1 (en) Method and system for uniformizing product data embedded in a computer platform
CN105279094A (en) NAND Flash operation processing method, NAND Flash operation processing device and logic device
CN109408265B (en) IOS abnormal operation protection method and device, terminal equipment and storage medium
CN109086162B (en) Memory diagnosis method and device
CN106528114A (en) Android firmware application, android firmware and firmware upgrading method
CN108197041B (en) Method, device and storage medium for determining parent process of child process
US10169195B2 (en) Detecting uninitialized memory references
CN113703823A (en) BMC (baseboard management controller) firmware upgrading method and device, electronic equipment and storage medium
CN117093402A (en) Recording method and device for PSU AC loss event after equipment power failure
JP4838226B2 (en) Network logging processing program, information processing system, and network logging information automatic saving method
US20240143474A1 (en) System and method for dynamic sensors support in ipmi stack

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination