CN117555718A - Linux operating system crash log dumping method based on swap exchange partition - Google Patents

Linux operating system crash log dumping method based on swap exchange partition Download PDF

Info

Publication number
CN117555718A
CN117555718A CN202410038679.7A CN202410038679A CN117555718A CN 117555718 A CN117555718 A CN 117555718A CN 202410038679 A CN202410038679 A CN 202410038679A CN 117555718 A CN117555718 A CN 117555718A
Authority
CN
China
Prior art keywords
log
swap
kernel
kmsg
crash log
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.)
Granted
Application number
CN202410038679.7A
Other languages
Chinese (zh)
Other versions
CN117555718B (en
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.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co 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 Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202410038679.7A priority Critical patent/CN117555718B/en
Publication of CN117555718A publication Critical patent/CN117555718A/en
Application granted granted Critical
Publication of CN117555718B publication Critical patent/CN117555718B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0778Dumping, i.e. gathering error/state information after a fault for later diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • 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/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
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to a method for dumping a crash log of a Linux operating system based on a swap partition, which comprises the steps of analyzing the swap partition registered by the operating system when the crash of the kernel of the operating system is detected, acquiring the information of the effective swap partition which can be used by the operating system, acquiring the real-time kernel crash log kmsg of the kernel, writing the kernel crash log kmsg into the swap partition based on the information of the swap partition, writing the information of the kernel crash log kmsg and a kernel crash log dump mark into a head information block of the swap partition, waiting for restarting the operating system, mounting the swap partition on the kernel after the operating system is restarted, reading the head information block of the swap partition, judging whether a kernel crash log dump mark exists, starting the operating system if the effective swap log kmsg does not exist, reading the kernel crash log kmsg and dumping the kernel crash log kmsg into a memory if the effective swap log dump mark does not exist, and starting the operating system.

Description

Linux operating system crash log dumping method based on swap exchange partition
Technical Field
The application relates to the field of kernel debugging of an operating system, in particular to a method for dumping a crash log of a Linux operating system based on a swap exchange partition.
Background
With the vigorous development of domestic CPU and domestic PC manufacturers, the development of an operating system based on linux has raised one-time leap development. With the wider and wider application of domestic PCs and operating systems, the system maintenance work based on linux brings serious examination, when the system is halted, technicians have to open a case like debugging embedded equipment, find a debugging serial port, grasp logs for the reproduction problem, the operation logic is very inconvenient and unfriendly, and a log preservation/dump scheme for the general domestic PC operating system is very needed.
In the current general linux log dump solution, a log dump solution based on a pstore is available, but the scheme is only realized based on mtd and ram, and is more suitable for an embedded operating system, and because the desktop operating system environment does not realize the hardware condition of the scheme, when the desktop operating system is halted, a debugging serial port is connected for log grabbing analysis, so that the analysis of the log grabbing is inconvenient in time, and the analysis problem of technicians is greatly influenced.
Disclosure of Invention
In order to solve the problems, the invention provides a method for dumping a crash log of a Linux operating system based on a swap exchange partition, which adopts the following technical scheme:
a method for dumping a crash log of a Linux operating system based on a swap exchange partition comprises the following steps:
when detecting that the kernel of the operating system crashes, analyzing a swap exchange partition registered by the operating system, and acquiring information of an effective swap exchange partition usable by the operating system;
obtaining a real-time kernel crash log kmsg of a kernel;
writing the kernel crash log kmsg into the swap exchange partition based on the information of the swap exchange partition, and writing the information of the kernel crash log kmsg into a header information block of the swap exchange partition;
waiting for the operating system to restart;
after restarting an operating system, the kernel mounts a swap exchange partition, reads a head information block of the swap exchange partition, and judges whether a kernel crash log dump mark exists or not;
if not, starting an operating system;
if the operation system exists, the kernel crash log kmsg is read, the kernel crash log kmsg is dumped into the memory, and the operation system is started.
In another possible implementation manner, writing the kernel crash log kmsg to the swap switch partition based on the swap switch partition information, and writing the information of the kernel crash log kmsg and the kernel crash log dump flag into a header information block of the swap switch partition includes:
step Sa1, applying for a cache memory page;
step Sa2, obtaining a swap_writer, wherein the swap_writer is an important handler for operating a swap exchange partition to read and write data pages;
step Sa3, initializing a bio request queue;
step Sa4, dividing kernel crash logs kmsg according to pages, and copying log data of one page of kernel crash logs kmsg into a cache memory page;
step Sa5, initiating a bio write request, and writing one page of cached log data into a swap exchange partition;
step Sa6, the step Sa4 and the step Sa5 are circularly executed until the log data of the last page is written into the swap exchange partition;
step Sa7, waiting for the completion of the bio write request;
step Sa8, ending the bio request queue;
step Sa9, calculating and counting the data information of the kernel crash log kmsg, and writing a kernel crash log dump mark SWAPSTORE character in a header information block of the swap exchange partition;
step Sa10, release the swap_writer, end.
In another possible implementation, reading the kernel crash log kmsg includes:
step Sb1, obtaining a swap_writer;
step Sb2, initiating a request for reading a head information block of the swap exchange partition through a bio, and analyzing important information of the kernel crash log kmsg, wherein the important information comprises the size of the kernel crash log kmsg, a CRC (cyclic redundancy check) value and a storage address of a first data page of log data in the swap exchange partition;
step Sb3, clearing a kernel crash log dump flag SWAPSTOR, initiating the operation of writing the swap exchange partition head information block through BIO, and backfilling the swap exchange partition head information block cleared of SWAPSTOR flag information;
step Sb4, applying for memory pages in a cache region based on the size of the kernel crash log kmsg;
step Sb5, initializing a bio request queue;
step Sb6, initiating a bio read request, and reading a data page of the kernel crash log kmsg from the swap exchange partition to a memory page of a cache region;
step Sb7, waiting for the bio to finish data reading;
step Sb8, the step Sb6 and the step Sb7 are circularly executed until all data pages in the swap exchange partition are read into memory pages of the cache area;
step Sb9, waiting for the completion of the bio read request and releasing a bio request queue;
and step Sb10, performing CRC (cyclic redundancy check) on the data in the memory page of the buffer area, releasing the swap_writer, and ending.
In another possible implementation, dumping the kernel crash log kmsg into the memory includes:
judging whether the kernel crash log kmsg is successfully read;
if the reading is successful, a log dump kthread corresponding to the kernel crash log kmsg is created;
sleeping for 500ms, and waiting for a file system mount log directory of an operating system;
judging whether the log catalog is successfully mounted or not;
if the file is mounted, creating a file in a log catalog, wherein the file name is formed by splicing the log type and the occurrence time of the kernel crash log kmsg;
writing the logs cached in the memory into files corresponding to the log file names;
the log dump kthread is ended.
In summary, the present application includes the following beneficial technical effects:
the method of the invention provides a log dump scheme suitable for a linux desktop operating system for the first time, and the scheme supplements a pstore log dump solution based on mtd and ram, which cannot be applied to a desktop hardware environment. This scheme is also distinguished from a scheme in which log files are written directly to the root file system after a crash. The problem that the system root file system partition file is not safe and reliable because the kernel is still started to read and write after being halted is avoided. And the embarrassing analysis problems of disassembly, serial port connection, recurrence and the like of technicians are avoided. A log dump scheme for assisting technicians in analyzing problems is provided for a desktop operating system based on linux.
Drawings
FIG. 1 is a flow chart of a method for dump crash log of a Linux operating system based on a swap partition in an embodiment of the present application.
FIG. 2 is a flow diagram of a method of writing kernel crash log kmsg to a swap partition in an embodiment of the present application.
FIG. 3 is a flow chart of a method of reading kernel crash log kmsg in an embodiment of the present application.
FIG. 4 is a flow chart of a method for dumping kernel crash log kmsg to memory in an embodiment of the application.
Detailed Description
The present application is described in further detail below in conjunction with figures 1-4.
Modifications of the embodiments which do not creatively contribute to the invention may be made by those skilled in the art after reading the present specification, but are protected by patent laws only within the scope of claims of the present application.
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In addition, the term "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In this context, unless otherwise specified, the term "/" generally indicates that the associated object is an "or" relationship.
Embodiments of the present application are described in further detail below with reference to the drawings attached hereto.
As shown in fig. 1, an embodiment of the present application provides a method for dump log of Linux operating system based on swap exchange partition, and the kernel using the method does not need to provide ram and mtd support, unlike the manner of directly writing log to file system, the method uses the disk swap exchange partition to perform log dump, and specifically includes:
and step S101, when detecting that the kernel of the operating system crashes, analyzing the swap exchange partition registered by the operating system, and acquiring information of the effective swap exchange partition usable by the operating system.
For the embodiment of the application, the swap switch partition is used for temporarily storing the kernel crash log kmsg, taking the kylin operating system as an example, analyzing the swap switch partition of the kylin operating system SP1, and the kylin operating system defaults to a 10G swap switch partition when being installed.
Step S102, obtaining a real-time kernel crash log kmsg of the kernel.
For the embodiment of the application, the kernel crash log kmsg contains kernel panic information of the first time, time-lapse information and the like. Specifically, the real-time kernel crash log kmsg of the obtained kernel can be obtained through a Linux kernel pstore mechanism, and the kernel crash log kmsg is generally 200kb-300kb different, can also be obtained through a prink subsystem of the kernel, can also be obtained through other custom modes, and is not limited herein.
And step S103, writing the kernel crash log kmsg into the swap exchange partition based on the information of the swap exchange partition, and writing the information of the kernel crash log kmsg and the kernel crash log dump mark into a header information block of the swap exchange partition.
For the embodiment of the application, specifically, the kernel crash log kmsg is divided into data pages with the size of a disk page, and the information of the kernel crash log kmsg and the kernel crash log dump mark are written into the head information block of the swap exchange partition after the last data page is written through writing the data area of the swap exchange partition page by page bio.
More specifically, writing the kernel crash log kmsg into the swap partition, which is to obtain partition format information of the swap partition, such as partition format, partition size, disk block/page size, etc., through an interface of the kernel, and then writing the obtained kernel crash log kmsg into the swap partition one page by one page according to the disk page size. After the kernel crash log kmsg is written into the last page, writing the retrieved information of the kernel crash log kmsg and a crash log dump flag into a header information block of the swap exchange partition, wherein the information of the kernel crash log kmsg comprises a log size, a crash occurrence time, a log source, a CRC check value of the log, an organization form of the block data of the kernel crash log kmsg in the swap exchange partition and an offset address of a first page of the kernel crash log kmsg in the swap exchange partition data, and in addition, the crash log dump flag is an important flag for judging whether the log dump exists in the swap exchange partition or not later, and after the header information block of the swap exchange partition is written into the swap exchange partition, the whole flow of writing the kernel crash log kmsg into the swap exchange partition is completed, as shown in fig. 2, and the specific steps are as follows:
step Sa1, applying for a cache memory page so as to cache the data which needs to be written into the swap exchange partition;
step Sa2, obtaining a swap_writer, wherein the swap_writer is an important handler for operating a swap switched partition to read and write a data page, and in the embodiment of the present application, obtaining a handler for a swap switched partition write operation through the get_swap_writer;
step Sa3, initializing a bio request queue, specifically, initializing a generic block layer bio read-write merge request queue dedicated for log dump, in this embodiment, initializing a queue swap_bio_plug dedicated for log dump read-write merge request by calling blk_start_plug of the generic block layer;
step Sa4, dividing kernel crash logs kmsg according to pages, and copying log data of one page of kernel crash logs kmsg into a cache memory page;
step Sa5, initiating a bio write request, and writing one page of cached log data into a swap exchange partition;
step Sa6, step Sa4 and step Sa5 are circularly executed until the last page of log data is written into the swap exchange partition, in the embodiment of the present application, the size of a disk page is 4kb, if the obtained kernel crash log kmsg has 200kb, 50 pages are written into the swap exchange partition;
step Sa7, waiting for the completion of the bio write request;
step Sa8, ending the bio request queue;
step Sa9, calculating and counting the data information of the kernel crash log kmsg, and writing a kernel crash log dump mark SWAPSTORE character in a header information block of the swap exchange partition;
step Sa10, release the swap_writer, end.
Step S104, waiting for the restarting of the operating system.
Step S105, after the operating system is restarted, the kernel mounts the swap exchange partition, reads the header information block of the swap exchange partition, judges whether a kernel crash log dump flag exists, namely reads the swap_header block information, and judges whether a kernel crash log dump flag SWAPSTORE field exists.
Step S106, if not, starting the operating system.
And step S107, if the kernel crash log kmsg exists, reading the kernel crash log kmsg and dumping the kernel crash log kmsg into a memory, and starting the operating system.
For the embodiment of the present application, reading the kernel crash log kmsg specifically includes, when a swapstop field flag exists, analyzing information of the kernel crash log kmsg in a header information block swap_header block, recording a size of the kernel crash log in the information, a CRC check value, and a storage address of a first data page of log data in a swap exchange partition (that is, an offset address of the first page of the crash log in the swap exchange partition data mentioned above), then initiating a read request for a general block layer bio disk data page according to the storage address of the first page of the log data recorded in the information, storing the information in the data page in a cache pool of a log size applied in advance in a memory, and after all the data pages are read, performing CRC check on the kernel crash log kmsg read into the memory. In addition, the SWAPSTORE flag in the swap_header block is cleared, and the next restart is prevented from repeatedly reading the kmsg log stored in the SWAP SWAP partition. The reading is completed. As shown in fig. 3, the specific steps are as follows:
step Sb1, obtaining a swap_writer;
step Sb2, initiating a request for reading a head information block of the swap exchange partition through a bio, and analyzing important information of the kernel crash log kmsg, wherein the important information comprises the size of the kernel crash log kmsg, a CRC (cyclic redundancy check) value and a storage address of a first data page of log data in the swap exchange partition;
step Sb3, clearing a kernel crash log dump flag SWAPSTOR, initiating the operation of writing a head information block of a swap exchange partition through BIO based on the storage address of a first data page of log data in the swap exchange partition, and backfilling the swap exchange partition head information block swap header, namely re-writing a swap exchange partition head information block without the kernel crash log dump flag SWAPSTOR, thereby achieving the effect of preventing the swap exchange partition cached from being repeatedly read in the next restarting;
step Sb4, applying for a memory page of a buffer area based on the size of the kernel crash log kmsg, wherein the size of the memory page of the buffer area is the size of the kernel crash log kmsg;
step Sb5, initializing a bio request queue;
step Sb6, initiating a bio read request, and reading a data page of the kernel crash log kmsg from the swap exchange partition to a memory page of a cache region;
step Sb7, waiting for the bio to finish data reading;
step Sb8, the step Sb6 and the step Sb7 are circularly executed until all data pages in the swap exchange partition are read into memory pages of the cache area;
step Sb9, waiting for the completion of the bio read request and releasing a bio request queue;
and step Sb10, performing CRC (cyclic redundancy check) on the data in the memory pages of the buffer area, releasing the swap_writer, and ending, wherein the step of releasing the SWAP reader is ended when the comparison is correct and the step of reporting the error and exiting when the comparison is failed by comparing the CRC value in the memory pages of the buffer area with the CRC value in the important information.
Therefore, the scheme of the invention can bypass the file system layer and directly initiate the data page read-write of the disk swap exchange partition on the general block layer.
After the kernel crash log kmsg in the swap partition is read to the memory page of the cache area, the kernel is dumped through the kernel thread, and specifically, the kernel thread of the kernel dump log of the swpstr_savelog_thread is launched first. The kernel thread waits for the correct mounting of the operating system/var/log/directory, then splices 11 points of log type kmsg and log occurrence time 20230921 days for 12 minutes and 12 seconds into log file name (kmsg-20230921111212. Log), and creates the log file name. Finally, the log of the 200kB kernel crash log kmsg cached in the memory is written into the file, so that the whole flow is finished, and as shown in fig. 4, the specific implementation steps are as follows:
judging whether the kernel crash log kmsg is successfully read;
if the reading is successful, a log dump kthread corresponding to the kernel crash log kmsg is created;
sleeping for 500ms, and waiting for a file system mount log directory of an operating system;
judging whether the log catalog is successfully mounted or not;
if the file is mounted, creating a file in a log catalog, wherein the file name is formed by splicing the log type and the occurrence time of the kernel crash log kmsg;
writing the logs cached in the memory into files corresponding to the log file names;
the log dump kthread is ended.
Further, in the embodiment of the present application, the kernel thread may analyze the event of the last occurrence of the crash of the kernel, wait for the system to complete starting, and write the crash log of the kernel into the log directory of the system according to the occurrence date.
In summary, the embodiment of the application realizes a shutdown log dump technology of a linux operating system based on a swap exchange partition, and the technology provides a log dump scheme suitable for a linux desktop operating system, which supplements a pstore log dump solution based on mtd and ram, which cannot be applied to a desktop hardware environment. This scheme is also distinguished from a scheme in which log files are written directly to the root file system after a crash. The design realizes the temporary storage of the kernel crash log by utilizing the exchange partition of the operating system, and sets the flag information. And searching the flag bit of the SWAP exchange partition and the storage information and data of the dump log when restarting for the second time, and dumping the log into a system log directory after the file system is successfully mounted, thereby completing the whole log dumping work.
The foregoing is only a partial embodiment of the present application and it should be noted that, for a person skilled in the art, several improvements and modifications can be made without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (4)

1. A method for dumping a crash log of a Linux operating system based on a swap exchange partition is characterized by comprising the following steps:
when detecting that the kernel of the operating system crashes, analyzing a swap exchange partition registered by the operating system, and acquiring information of an effective swap exchange partition usable by the operating system;
obtaining a real-time kernel crash log kmsg of a kernel;
writing the kernel crash log kmsg into the swap exchange partition based on the information of the swap exchange partition, and writing the information of the kernel crash log kmsg and a kernel crash log dump mark into a header information block of the swap exchange partition;
waiting for the operating system to restart;
after the operating system is restarted, the kernel mounts the swap exchange partition, reads the head information block of the swap exchange partition and judges whether a kernel crash log dump mark exists or not;
if not, starting the operating system;
if the operation system exists, the kernel crash log kmsg is read, the kernel crash log kmsg is dumped into a memory, and the operation system is started.
2. The method for dumping a crash log of a Linux operating system based on a swap switched partition according to claim 1, wherein writing the kernel crash log kmsg to the swap switched partition based on the swap switched partition information and writing the information of the kernel crash log kmsg and a kernel crash log dump flag into a header information block of the swap switched partition comprises:
step Sa1, applying for a cache memory page;
step Sa2, obtaining a swap_writer, wherein the swap_writer is an important handler for operating a swap exchange partition to read and write data pages;
step Sa3, initializing a bio request queue;
step Sa4, dividing the kernel crash log kmsg according to pages, and copying log data of one page of the kernel crash log kmsg into a cache memory page;
step Sa5, initiating a bio write request, and writing one page of cached log data into the swap exchange partition;
step Sa6, the step Sa4 and the step Sa5 are circularly executed until the log data of the last page is written into the swap exchange partition;
step Sa7, waiting for the completion of the bio write request;
step Sa8, ending the bio request queue;
step Sa9, calculating and counting the data information of the kernel crash log kmsg, and writing a kernel crash log dump mark SWAPSTORE character in a header information block of the swap exchange partition;
step Sa10, release the swap_writer, end.
3. The method for dumping a crash log of a Linux operating system based on a swap switched partition according to claim 1, wherein reading the kernel crash log kmsg comprises:
step Sb1, obtaining a swap_writer;
step Sb2, initiating a request for reading a head information block of the swap exchange partition through a bio, and analyzing important information of the kernel crash log kmsg, wherein the important information comprises the size of the kernel crash log kmsg, a CRC (cyclic redundancy check) value and a storage address of a first data page of log data in the swap exchange partition;
step Sb3, clearing a kernel crash log dump flag SWAPSTOR, initiating the operation of writing the swap exchange partition head information block through BIO, and backfilling the swap exchange partition head information block cleared of SWAPSTOR flag information;
step Sb4, applying for a memory page of a cache region based on the size of the kernel crash log kmsg;
step Sb5, initializing a bio request queue;
step Sb6, initiating a bio read request, and reading the data page of the kernel crash log kmsg from the swap exchange partition to the memory page of the cache region;
step Sb7, waiting for the bio to finish data reading;
step Sb8, circularly executing the step Sb6 and the step Sb7 until all data pages in the swap exchange partition are read into the memory pages of the cache area;
step Sb9, waiting for the completion of the bio read request and releasing a bio request queue;
and step Sb10, performing CRC (cyclic redundancy check) on the data in the memory page of the buffer area, releasing the swap_writer, and ending.
4. The method for dumping the crash log of the Linux operating system based on the swap switched partition according to claim 1, wherein dumping the kernel crash log kmsg into the memory comprises the following steps:
judging whether the kernel crash log kmsg is successfully read or not;
if the reading is successful, creating a log dump kthread corresponding to the kernel crash log kmsg;
sleeping for 500ms, and waiting for a file system mount log directory of an operating system;
judging whether the log catalog is successfully mounted or not;
if the kernel dead log kmsg is mounted, creating a file in a log catalog, wherein the file name is formed by splicing the log type and the occurrence time of the kernel dead log kmsg;
writing the logs cached in the memory into files corresponding to the log file names;
and ending the log dump kthread.
CN202410038679.7A 2024-01-11 2024-01-11 Linux operating system crash log dumping method based on swap exchange partition Active CN117555718B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410038679.7A CN117555718B (en) 2024-01-11 2024-01-11 Linux operating system crash log dumping method based on swap exchange partition

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410038679.7A CN117555718B (en) 2024-01-11 2024-01-11 Linux operating system crash log dumping method based on swap exchange partition

Publications (2)

Publication Number Publication Date
CN117555718A true CN117555718A (en) 2024-02-13
CN117555718B CN117555718B (en) 2024-04-09

Family

ID=89813231

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410038679.7A Active CN117555718B (en) 2024-01-11 2024-01-11 Linux operating system crash log dumping method based on swap exchange partition

Country Status (1)

Country Link
CN (1) CN117555718B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050071593A1 (en) * 2003-09-29 2005-03-31 Pradeep Vincent Efficient file system data journaling
CN103514260A (en) * 2013-08-13 2014-01-15 中国科学技术大学苏州研究院 Internal storage log file system and achieving method thereof
US20160283218A1 (en) * 2013-09-18 2016-09-29 G-Cloud Technology Ltd Method for distributing large-sized Linux software packages
CN112860195A (en) * 2021-03-26 2021-05-28 中国工商银行股份有限公司 Log storage method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050071593A1 (en) * 2003-09-29 2005-03-31 Pradeep Vincent Efficient file system data journaling
CN103514260A (en) * 2013-08-13 2014-01-15 中国科学技术大学苏州研究院 Internal storage log file system and achieving method thereof
US20160283218A1 (en) * 2013-09-18 2016-09-29 G-Cloud Technology Ltd Method for distributing large-sized Linux software packages
CN112860195A (en) * 2021-03-26 2021-05-28 中国工商银行股份有限公司 Log storage method and device

Also Published As

Publication number Publication date
CN117555718B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
TWI444825B (en) Memory storage device, memory controller thereof, and method for programming data thereof
US5960460A (en) Non-intrusive replication of hard disk
JPH11272427A (en) Method for saving data and outside storage device
US20070080205A1 (en) System and method for testing a card reader of a computer
JP2006519444A (en) Flash memory data management method
JPH06250906A (en) Backup/recovery system for data developed in main storage device
CN117555718B (en) Linux operating system crash log dumping method based on swap exchange partition
JPH0667812A (en) Patrol seaking system for high density magnetic disk device
US20070271311A1 (en) Disk array device and data management method for managing master data and replication data replicated from master data
US6229743B1 (en) Method of a reassign block processing time determination test for storage device
JP2002312416A (en) Logic verification device and method of memory control circuit
JP4471274B2 (en) How to boot OS from hard disk image file
CN112764954A (en) Startup diagnosis method for embedded device, and storage medium
JP2000035920A (en) Fault restoration method for system and storage medium storing program for fault restoration of system
JPH0793101A (en) Data backup device
JPH09330253A (en) Memory dump method and memory damp system applying the same
JPS603223B2 (en) Central processing unit error collection method
JPH08263389A (en) Data backup method
JPH07271518A (en) Magnetic disk device
JP3788602B2 (en) Computer installation system and installation method
CN118295602A (en) Storage management method and system based on NOR Flash
JP2000020249A (en) Data protecting method of disk device, disk device, and recording medium
JPH1139230A (en) Diagnostic method for floppy disk device and recording medium
JP3366922B2 (en) Operation input processing device and method
JPS62107331A (en) Error processing system for document file

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
GR01 Patent grant
GR01 Patent grant