CN111240870A - Memory management method and device of Linux operating system - Google Patents

Memory management method and device of Linux operating system Download PDF

Info

Publication number
CN111240870A
CN111240870A CN201911395970.5A CN201911395970A CN111240870A CN 111240870 A CN111240870 A CN 111240870A CN 201911395970 A CN201911395970 A CN 201911395970A CN 111240870 A CN111240870 A CN 111240870A
Authority
CN
China
Prior art keywords
memory page
monitoring
memory
page
queue
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
CN201911395970.5A
Other languages
Chinese (zh)
Other versions
CN111240870B (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.)
Ruijie Networks Co Ltd
Original Assignee
Ruijie Networks 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 Ruijie Networks Co Ltd filed Critical Ruijie Networks Co Ltd
Priority to CN201911395970.5A priority Critical patent/CN111240870B/en
Publication of CN111240870A publication Critical patent/CN111240870A/en
Application granted granted Critical
Publication of CN111240870B publication Critical patent/CN111240870B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/0751Error or fault detection not based on redundancy
    • 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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a memory management method and a device of a Linux system, wherein the method comprises the following steps: monitoring whether the release of a memory page occurs, wherein the memory page is a basic unit of a memory; when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue; modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state; and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state. The embodiment of the invention can solve the problem of difficult memory rewriting abnormal positioning in the prior art.

Description

Memory management method and device of Linux operating system
Technical Field
The present invention relates to the field of embedded system technology, and in particular, to a method and apparatus for managing a memory of a Linux operating system.
Background
The Linux operating system is divided into a user mode part and a kernel mode part. Common applications, such as web browsers, video players, text editors, etc., operate in a user mode; and the components such as the Linux core, the network protocol stack, the device driver and the like run in a kernel mode.
The user-mode program only shares the virtual memory space created for the user-mode program by the operating system, so that even if the memory is out of bounds and rewritten, the program can only make mistakes, and other application programs and kernel areas can not be damaged. The problem is relatively controllable and easy to locate.
However, all modules in the kernel mode share the same logical address space, and if one module is out of range or rewritten in memory access, the whole kernel may be crashed and information collection is difficult; meanwhile, the memory cross-border or rewrite problem usually belongs to errors of the class of use-after-free. The dynamic memory has the action requirements of malloc (application) and free (release), and if a program continues to access the corresponding memory in other program positions after the free is processed, the dynamic memory is called use-after-free, which is often caused by the fact that the logic of a complex program is not considered to be clear. The problem is not always reported immediately because the read and write of the memory which is possibly released will not cause system crash and is difficult to be perceived. However, program logic has presented problems, and it is the concealment of such problems that it is often difficult to effectively analyze the front if the first scene cannot be grasped.
When the memory is abnormal, the reason of system crash can be determined through oops information analysis, but the method can only analyze the direct reason causing the system crash, and when the memory is rewritten and the like with hiding abnormality, the system crash can not be directly caused, and the crash can be finally caused only through layer-by-layer transfer, so the method can not analyze the rewriting and the like with the hiding abnormality of the memory, and the analysis accuracy is poor.
In summary, a general method for efficiently locating the memory abnormality problem is lacking in the industry at present, and generally, a large amount of time and labor are consumed for analyzing the memory rewriting problem, so that the cost of product development is greatly increased, and the project is easily out of control.
Disclosure of Invention
The embodiment of the invention provides a memory management method and device of a Linux system, which are used for solving the problem of difficulty in memory rewriting abnormal positioning in the prior art.
The embodiment of the invention provides a memory management method of a Linux system, which is applied to the management of a kernel-mode memory and comprises the following steps:
monitoring whether the release of a memory page occurs, wherein the memory page is a basic unit of a memory;
when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue;
modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state;
and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state.
Preferably, the method further comprises:
when the monitoring queue reaches a preset maximum length or request information of insufficient memory of the idle queue is received, inserting a first memory page queued earliest in the monitoring queue back to the idle queue according to a first-in first-out principle;
and modifying a page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
Preferably, before inserting the newly released memory page into the preset monitoring queue, the method further includes:
inserting a preset magic word into the newly released memory page;
correspondingly, before the first memory page enqueued earliest in the monitoring queue is inserted back into the free queue, the method further includes:
detecting whether the magic word in the first memory page queued earliest in the monitoring queue is the same as a preset magic word;
if not, triggering an abnormal notification.
Preferably, the method further comprises:
inserting a second memory page corresponding to memory page information needing to be locked, which is input by a user, into a first area of the monitoring queue;
setting monitoring on time and monitoring off time of the first area;
and modifying a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring close time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring close time.
Preferably, the method further comprises:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
Wherein, when the memory page corresponding to the received memory access request is in the monitoring state, triggering an exception notification, including:
obtaining a page table entry of a memory page corresponding to the memory access request;
determining whether the page table entry represents that the memory page is in a monitoring state;
and if the memory page is in a monitoring state, triggering an exception notification.
The embodiment of the present invention further provides a memory management device for a Linux system, where the device is applied to management of kernel-state memories, and the device includes: the system comprises a monitoring unit, an inserting unit, a modifying unit and a managing unit; wherein the content of the first and second substances,
the monitoring unit is configured to monitor whether a release of a memory page occurs, where the memory page is a basic unit of a memory;
the inserting unit is configured to insert a newly released memory page into a preset monitoring queue when the newly released memory page is monitored;
the modifying unit is configured to modify a page table entry corresponding to the newly released memory page to indicate that the newly released memory page is in a monitoring state;
the management unit is configured to trigger an exception notification when the memory page corresponding to the received memory access request is in the monitoring state.
Preferably, the inserting unit is further configured to insert the first memory page queued earliest in the monitoring queue back to the idle queue according to a first-in first-out principle when the monitoring queue reaches a preset maximum length or request information that the memory in the idle queue is insufficient is received;
accordingly, the modifying unit is further configured to modify the page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
Preferably, before inserting the newly released memory page into the preset monitoring queue, the management unit is further configured to insert a preset magic word into the newly released memory page; before inserting the first memory page queued earliest in the monitoring queue back into the idle queue, the apparatus is further configured to detect whether a magic word in the first memory page queued earliest in the monitoring queue is the same as a preset magic word; if not, triggering an abnormal notification.
Preferably, the apparatus further comprises: a setting unit;
correspondingly, the inserting unit is further configured to insert a second memory page corresponding to the memory page information to be locked, which is input by the user, into the first area of the monitoring queue;
the setting unit is used for setting the monitoring on time and the monitoring off time of the first area;
the modifying unit is further configured to modify a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring stop time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring stop time.
Preferably, the management unit is further configured to:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
The management unit is specifically configured to obtain a page table entry of a memory page corresponding to the memory access request; determining whether the page table entry represents that the memory page is in a monitoring state; and if the memory page is in a monitoring state, triggering an exception notification.
The invention has the following beneficial effects:
according to the memory management method and device of the Linux system, whether the memory page is released or not is monitored, wherein the memory page is a basic unit of a memory; when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue; modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state; and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state. The embodiment of the invention can effectively find the errors of use-after-free (use-after-free) types by monitoring the memory pages just released, has the minimum revision amount of the native memory queue of the Linux system through the independent monitoring queue, reduces the complexity of realization, can better compatibly, quickly and effectively position the problems, reduces the manpower and time consumption for problem positioning, improves the analysis efficiency and the fault response speed, and ensures the project realization progress.
Drawings
FIG. 1 is a flowchart illustrating a memory management method of a Linux system according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a memory management device of the Linux system in an embodiment of the present invention.
Detailed Description
Aiming at the problem of memory rewriting positioning abnormity in the prior art, the memory management method of the Linux system provided by the embodiment of the invention can quickly position the memory rewriting abnormity problem by monitoring the memory page which is just released and notifying abnormity when the memory page in the monitoring queue is accessed. The method is applied to management of kernel mode memory, the specific flow is shown in fig. 1, and the execution steps are as follows:
step 101, monitoring whether the release of a memory page occurs, wherein the memory page is a basic unit of a memory;
here, the memory page is a basic unit of a memory, the minimum size of the memory page is 4KB, and the page table entries and the minimum memory page are in a one-to-one correspondence relationship, so in order to ensure that each memory page has a corresponding page table entry, in the embodiment of the present invention, when the system is initialized, the granularity of the memory page is forcibly controlled to 4 KB.
Step 102, when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue;
step 103, modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state;
the state of the memory page may be controlled by modifying an access control bit in the page table entry, for example, when the access control bit is 1, it is characterized that the memory page is in a monitoring state, and when the access control bit is 0, it is characterized that the memory page is in an accessible state.
And step 104, when the memory page corresponding to the received memory access request is in the monitoring state, triggering an exception notification.
In particular, the exception notification may be identified by a reserved bit of the page table entry as being caused by monitoring that the queue memory is accessed, and may specifically include location information of the initiator of the memory access request to locate to the problem point more quickly.
In the memory management method of the Linux system provided by the embodiment of the invention, whether the release of the memory page occurs or not is monitored, wherein the memory page is a basic unit of the memory; when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue; modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state; and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state. The embodiment of the invention can effectively find the errors of use-after-free (use-after-free) types by monitoring the memory pages just released, has the minimum revision amount of the native memory queue of the Linux system through the independent monitoring queue, reduces the complexity of realization, can better compatibly, quickly and effectively position the problems, reduces the manpower and time consumption for problem positioning, improves the analysis efficiency and the fault response speed, and ensures the project realization progress.
Preferably, before inserting the newly released memory page into the preset monitoring queue in step 102, the method may further include:
and inserting a preset magic word into the newly released memory page to monitor whether the content of the newly released memory page is rewritten. Here, the magic word is a preset field value, and all memory pages in the monitoring queue are filled with the magic word.
The method further comprises the following steps:
when the monitoring queue reaches a preset maximum length or request information of insufficient memory of the idle queue is received, inserting a first memory page queued earliest in the monitoring queue back to the idle queue according to a first-in first-out principle;
and modifying a page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
Correspondingly, before the first memory page enqueued earliest in the monitoring queue is inserted back into the free queue, the method further includes:
detecting whether the magic word in the first memory page queued earliest in the monitoring queue is the same as a preset magic word;
if the two Memory pages are different, triggering an exception notification, where if the magic word of the first Memory page is rewritten, it indicates that an exception other than Access occurs in the monitoring queue, for example, a Direct Memory Access (DMA) Unit accesses the Memory in the monitoring queue but is not found by a Memory Management Unit (MMU), and for example, a Double Data Rate (DDR) is unstable, which causes a change in the magic word; at this time, fault notification is also required to locate the fault point.
Preferably, the method further comprises:
inserting a second memory page corresponding to memory page information needing to be locked, which is input by a user, into a first area of the monitoring queue;
setting monitoring on time and monitoring off time of the first area;
and modifying a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring close time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring close time. For example, the monitoring on time of the first area is set to 7:00 to 19:00, monitoring the closing time from 19:00 to 7:00 the next day, then at 7:00 modifying a second page table entry corresponding to the second memory page to enable the second memory page to be in a monitoring state during the monitoring on time, and modifying the second page table entry corresponding to the second memory page at 19:00 a day to enable the second memory page to be in an accessible state during the monitoring off time.
Preferably, the method further comprises:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
Preferably, the triggering an exception notification when the memory page corresponding to the received memory access request is in the monitoring state includes:
obtaining a page table entry of a memory page corresponding to the memory access request;
determining whether the page table entry represents that the memory page is in a monitoring state;
and if the memory page is in a monitoring state, triggering an exception notification.
Based on the same inventive concept, an embodiment of the present invention provides a memory management device for a Linux system, which can be applied to management of kernel-mode memories, and has a structure as shown in fig. 2, where the memory management device includes: a monitoring unit 21, an insertion unit 22, a modification unit 23, and a management unit 24; wherein the content of the first and second substances,
the monitoring unit 21 is configured to monitor whether a memory page is released, where the memory page is a basic unit of a memory;
the inserting unit 22 is configured to insert a newly released memory page into a preset monitoring queue when the newly released memory page is monitored;
the modifying unit 23 is configured to modify a page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state;
the management unit 24 is configured to trigger an exception notification when the memory page corresponding to the received memory access request is in the monitoring state.
Further, the inserting unit 22 is further configured to insert the first memory page queued earliest in the monitoring queue back to the idle queue according to a first-in first-out principle when the monitoring queue reaches a preset maximum length or request information that the memory in the idle queue is insufficient is received;
accordingly, the modifying unit 23 is further configured to modify the page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
Before inserting a newly released memory page into a preset monitoring queue, the management unit 24 is further configured to insert a preset magic word into the newly released memory page; before inserting the first memory page queued earliest in the monitoring queue back into an idle queue, the apparatus is further configured to detect whether a magic word in the first memory page queued earliest in the monitoring queue is the same as a preset magic word; if not, triggering an abnormal notification.
Further, the apparatus further comprises: a setting unit;
correspondingly, the inserting unit 22 is further configured to insert a second memory page corresponding to the memory page information to be locked, which is input by the user, into the first area of the monitoring queue;
the setting unit is used for setting the monitoring on time and the monitoring off time of the first area;
the modifying unit 23 is further configured to modify a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring stop time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring stop time.
Further, the management unit 24 is further configured to:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
The management unit 24 is specifically configured to obtain a page table entry of a memory page corresponding to the memory access request; determining whether the page table entry represents that the memory page is in a monitoring state; and if the memory page is in a monitoring state, triggering an exception notification.
It should be understood that the implementation principle and process of the memory management device of the Linux system according to the embodiment of the present invention are similar to those in the embodiment shown in fig. 1 and described above, and are not described herein again.
According to the memory management method and device of the Linux system, whether the memory page is released or not is monitored, wherein the memory page is a basic unit of a memory; when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue; modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state; and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state. The embodiment of the invention can effectively find the errors of use-after-free (use-after-free) types by monitoring the memory pages just released, has the minimum revision amount of the native memory queue of the Linux system through the independent monitoring queue, reduces the complexity of realization, can better compatibly, quickly and effectively position the problems, reduces the manpower and time consumption for problem positioning, improves the analysis efficiency and the fault response speed, and ensures the project realization progress.
Those of ordinary skill in the art will understand that: the figures are merely schematic representations of one embodiment, and the blocks or flow diagrams in the figures are not necessarily required to practice the present invention.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for apparatus or system embodiments, since they are substantially similar to method embodiments, they are described in relative terms, as long as they are described in partial descriptions of method embodiments. The above-described embodiments of the apparatus and system are merely illustrative, and the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
In addition, in some of the flows described in the above embodiments and the drawings, a plurality of operations are included in a specific order, but it should be clearly understood that the operations may be executed out of the order presented herein or in parallel, and the sequence numbers of the operations, such as 201, 202, 203, etc., are merely used for distinguishing different operations, and the sequence numbers themselves do not represent any execution order. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first", "second", etc. in this document are used for distinguishing different messages, devices, modules, etc., and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While alternative embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following appended claims be interpreted as including alternative embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made in the embodiments of the present invention without departing from the spirit or scope of the embodiments of the invention. Thus, if such modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to encompass such modifications and variations.

Claims (12)

1. A memory management method of a Linux system is applied to management of kernel mode memory, and comprises the following steps:
monitoring whether the release of a memory page occurs, wherein the memory page is a basic unit of a memory;
when a newly released memory page is monitored, inserting the newly released memory page into a preset monitoring queue;
modifying the page table entry corresponding to the newly released memory page to represent that the newly released memory page is in a monitoring state;
and triggering an exception notification when the memory page corresponding to the received memory access request is in a monitoring state.
2. The method of claim 1, further comprising:
when the monitoring queue reaches a preset maximum length or request information of insufficient memory of the idle queue is received, inserting a first memory page queued earliest in the monitoring queue back to the idle queue according to a first-in first-out principle;
and modifying a page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
3. The method according to claim 2, wherein before the inserting the newly released memory page into the preset monitoring queue, the method further comprises:
inserting a preset magic word into the newly released memory page;
correspondingly, before the first memory page enqueued earliest in the monitoring queue is inserted back into the free queue, the method further includes:
detecting whether the magic word in the first memory page queued earliest in the monitoring queue is the same as a preset magic word;
if not, triggering an abnormal notification.
4. The method of claim 1, further comprising:
inserting a second memory page corresponding to memory page information needing to be locked, which is input by a user, into a first area of the monitoring queue;
setting monitoring on time and monitoring off time of the first area;
and modifying a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring close time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring close time.
5. The method of claim 4, further comprising:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
6. The method according to any one of claims 1 to 5, wherein the triggering an exception notification when the memory page corresponding to the received memory access request is in the monitoring state includes:
obtaining a page table entry of a memory page corresponding to the memory access request;
determining whether the page table entry represents that the memory page is in a monitoring state;
and if the memory page is in a monitoring state, triggering an exception notification.
7. A memory management device of Linux system is applied to management of kernel-mode memory, and comprises: the system comprises a monitoring unit, an inserting unit, a modifying unit and a managing unit; wherein the content of the first and second substances,
the monitoring unit is configured to monitor whether a release of a memory page occurs, where the memory page is a basic unit of a memory;
the inserting unit is configured to insert a newly released memory page into a preset monitoring queue when the newly released memory page is monitored;
the modifying unit is configured to modify a page table entry corresponding to the newly released memory page to indicate that the newly released memory page is in a monitoring state;
the management unit is configured to trigger an exception notification when the memory page corresponding to the received memory access request is in the monitoring state.
8. The apparatus according to claim 7, wherein the inserting unit is further configured to insert the first memory page queued earliest back into the idle queue according to a first-in first-out principle when the monitoring queue reaches a preset maximum length or receives a request message indicating that the memory in the idle queue is insufficient;
accordingly, the modifying unit is further configured to modify the page table entry corresponding to the first memory page to indicate that the first memory page is in an accessible state.
9. The apparatus according to claim 8, wherein before inserting a newly released memory page into a preset monitoring queue, the management unit is further configured to insert a preset magic word into the newly released memory page; before the first memory page which is queued earliest is inserted back into the idle queue, the method is further used for detecting whether the magic word in the first memory page which is queued earliest is the same as a preset magic word; if not, triggering an abnormal notification.
10. The apparatus of claim 7, further comprising: a setting unit;
correspondingly, the inserting unit is further configured to insert a second memory page corresponding to the memory page information to be locked, which is input by the user, into the first area of the monitoring queue;
the setting unit is used for setting the monitoring on time and the monitoring off time of the first area;
the modifying unit is further configured to modify a second page table entry corresponding to the second memory page according to the monitoring start time and the monitoring stop time, so that the second memory page is in a monitoring state at the monitoring start time and is in an accessible state at the monitoring stop time.
11. The apparatus of claim 10, wherein the management unit is further configured to:
when the second memory page is in a monitoring state and the memory page corresponding to the received memory access request is the second memory page, triggering an exception notification;
and when the second memory page is in an accessible state, directly accessing the second memory page when the memory page corresponding to the received memory access request is the second memory page.
12. The apparatus according to any one of claims 7 to 11, wherein the management unit is specifically configured to obtain a page table entry of a memory page corresponding to the memory access request; determining whether the page table entry represents that the memory page is in a monitoring state; and if the memory page is in a monitoring state, triggering an exception notification.
CN201911395970.5A 2019-12-30 2019-12-30 Memory management method and device of Linux operating system Active CN111240870B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911395970.5A CN111240870B (en) 2019-12-30 2019-12-30 Memory management method and device of Linux operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911395970.5A CN111240870B (en) 2019-12-30 2019-12-30 Memory management method and device of Linux operating system

Publications (2)

Publication Number Publication Date
CN111240870A true CN111240870A (en) 2020-06-05
CN111240870B CN111240870B (en) 2022-10-14

Family

ID=70877599

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911395970.5A Active CN111240870B (en) 2019-12-30 2019-12-30 Memory management method and device of Linux operating system

Country Status (1)

Country Link
CN (1) CN111240870B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101251822A (en) * 2008-03-11 2008-08-27 中兴通讯股份有限公司 Supervising method of internal memory being rewrited
CN101561775A (en) * 2009-05-12 2009-10-21 华为技术有限公司 Method and device for monitoring memory
US20160283302A1 (en) * 2015-03-27 2016-09-29 Justin E. Gottschlich Technologies for root cause identification of use-after-free memory corruption bugs
CN106294089A (en) * 2015-06-23 2017-01-04 阿里巴巴集团控股有限公司 The method and apparatus assisting the access monitoring to monitored memory headroom
CN107220182A (en) * 2017-06-20 2017-09-29 中国电子科技集团公司第五十四研究所 A kind of internal memory repeats release error-detecting method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101251822A (en) * 2008-03-11 2008-08-27 中兴通讯股份有限公司 Supervising method of internal memory being rewrited
CN101561775A (en) * 2009-05-12 2009-10-21 华为技术有限公司 Method and device for monitoring memory
US20160283302A1 (en) * 2015-03-27 2016-09-29 Justin E. Gottschlich Technologies for root cause identification of use-after-free memory corruption bugs
CN106294089A (en) * 2015-06-23 2017-01-04 阿里巴巴集团控股有限公司 The method and apparatus assisting the access monitoring to monitored memory headroom
CN107220182A (en) * 2017-06-20 2017-09-29 中国电子科技集团公司第五十四研究所 A kind of internal memory repeats release error-detecting method

Also Published As

Publication number Publication date
CN111240870B (en) 2022-10-14

Similar Documents

Publication Publication Date Title
US10282132B2 (en) Methods and systems for processing PRP/SGL entries
US9128615B2 (en) Storage systems that create snapshot queues
JP6293888B2 (en) Techniques for detecting race conditions
WO2013152660A1 (en) Operating system startup acceleration method and device, terminal and computer storage medium
CN111813713B (en) Data acceleration operation processing method and device and computer readable storage medium
CN106293781B (en) The method and apparatus of online upgrading machine virtual machine
CN107544755B (en) Data read-write control method and device
KR20170068373A (en) Electronic system with memory data protection mechanism and method of operation thereof
EP4220419A1 (en) Modifying nvme physical region page list pointers and data pointers to facilitate routing of pcie memory requests
US8296119B2 (en) Saving and restarting discrete event simulations
EP3274896B1 (en) Configuration of a memory controller for copy-on-write with a resource controller
US20100280817A1 (en) Direct pointer access and xip redirector for emulation of memory-mapped devices
US20180157605A1 (en) Configuration of a memory controller for copy-on-write
AU2019272434B2 (en) Processor feature ID response for virtualization
CN113076233B (en) IO performance detection method, device, equipment and storage medium
CN111240870B (en) Memory management method and device of Linux operating system
CN109408281A (en) Technology for headless server manageability and autonomous log recording
CN117234729A (en) Dynamic memory protection method, device, computer equipment and storage medium
WO2015165055A1 (en) Data storage method, memory controller and central processing unit
CN100342361C (en) Method and apparatus for fast reading and writing memory data
CN101751283A (en) Virtual machine monitor, virtual machine system and client operation system state acquiring method
CN114153560A (en) Virtual interrupt processing method, device, equipment and medium
CN106201344B (en) Information processing method and electronic equipment
CN112328423A (en) Processing method, device and storage medium for search service loophole
CN106815008B (en) System pause method, system recovery method and computer system using same

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