CN115576864A - Processing method of virtual memory space of file and computing equipment - Google Patents

Processing method of virtual memory space of file and computing equipment Download PDF

Info

Publication number
CN115576864A
CN115576864A CN202211212377.4A CN202211212377A CN115576864A CN 115576864 A CN115576864 A CN 115576864A CN 202211212377 A CN202211212377 A CN 202211212377A CN 115576864 A CN115576864 A CN 115576864A
Authority
CN
China
Prior art keywords
interval tree
file
interval
tree
processed
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
CN202211212377.4A
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.)
Uniontech Software Technology Co Ltd
Original Assignee
Uniontech Software Technology 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 Uniontech Software Technology Co Ltd filed Critical Uniontech Software Technology Co Ltd
Priority to CN202211212377.4A priority Critical patent/CN115576864A/en
Publication of CN115576864A publication Critical patent/CN115576864A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/65Details of virtual memory and virtual address translation
    • G06F2212/657Virtual address space management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a processing method and computing equipment for a virtual memory space of a file, and relates to the field of computers. The address space of the file stores an interval tree array consisting of a plurality of interval trees for managing all VMAs of the file, a read lock and a write lock of the interval tree array, and a read lock and a write lock of each interval tree. The method comprises the following steps: receiving a target request for executing VMA operation processing on the address space of the file; and acquiring the interval tree to be processed based on the target request. And if the target request is a write request, acquiring a read lock of the interval tree array and a write lock of the interval tree to be processed, and executing write processing on the interval tree to be processed. And if the target request is a read request, acquiring a read lock of the interval tree array and a read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed. The interval tree and the interval tree lock of the VMA of the management file are refined, so that a plurality of interval trees of the VMA of the management file can be processed at the same time, and the performance of multiple concurrent processes is improved.

Description

Processing method of virtual memory space of file and computing equipment
Technical Field
The present invention relates to the field of computers, and in particular, to a method and a computing device for processing a virtual memory space of a file.
Background
In order to allow multiple processes to access physical memory simultaneously, the operating system adds a new abstraction between the application and physical memory: and (5) virtual memory. Each process has a unified continuous virtual address space, and only can access the virtual address space during operation. When a process accesses its virtual Memory, a Memory Management Unit (MMU) is responsible for translating a virtual address into a physical address, and an operating system is responsible for setting the mapping between the virtual address and the physical address, so that multiple processes can share one physical Memory. In addition, the operating system only maps the virtual address actually used by the process to the physical address, so that the utilization rate of the physical memory is improved.
It can be seen that after the virtual memory is added between the application program and the physical memory, when the process reads and writes the file, the file in the memory is mapped to the virtual address space actually used by the process. The process manages its own Virtual address space through a Virtual memory space (VMA), where the VMA refers to a continuous Virtual space (that is, the Virtual address space of the process includes multiple VMAs), and thus, the process reads and writes files, and substantially maps the read and written file portions to its own VMA.
That is, if any file is read or written by a process, a mapping relationship between the file and the VMA of the process is established. Currently, the VMA mapping relationship of a file to each process is managed by an address space (address _ space) of the file, specifically, by one interval tree in the address _ space. And, the address _ space of the file stores a read-write lock for keeping the interval tree mutually exclusive access, so as to ensure that only one process can write the interval tree at the same time, such as deleting or adding a VMA.
Obviously, even if VMA operations are performed on different sections of the interval tree at the same time, the method of managing all VMAs (all VMAs mapped to the file) based on one file by one interval tree cannot be implemented, and the multi-concurrency performance of the process is reduced.
Disclosure of Invention
To this end, the present invention provides a method, a computing device and a readable storage medium for processing a virtual memory space of a file in an attempt to solve or at least alleviate the above-existing problems.
According to an aspect of the present invention, there is provided a method for processing a virtual memory space of a file, in which an address space of the file stores an interval tree array, a read lock and a write lock of the interval tree array, and a read lock and a write lock of each interval tree in the interval tree array, the interval tree array being composed of a plurality of interval trees for managing all virtual memory spaces VMAs of the file, the method including: receiving a target request for executing VMA operation processing on the address space of the file, wherein the target request comprises a read request or a write request; acquiring a to-be-processed interval tree to be processed based on the target request; if the target request is a write request, acquiring a read lock of the interval tree array and a write lock of the interval tree to be processed, and executing write processing on the interval tree to be processed; and if the target request is a read request, acquiring a read lock of the interval tree array and a read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, the method further includes: determining two endpoint values of each interval tree in the interval tree array; and storing the two endpoint values of each interval tree into the address space of the file.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, determining two endpoint values of each interval tree in an interval tree array includes: determining the size of a file part managed by one interval tree according to the size of the file and the number of the interval trees in the interval tree array; and determining a first endpoint value and a second endpoint value of each interval tree according to the determined size of the file part managed by one interval tree, wherein the first endpoint value of each interval tree is the offset of the starting position of the file part managed by each interval tree relative to the starting position of the file, and the second endpoint value of each interval tree is the offset of the ending position of the file part managed by each interval tree relative to the starting position of the file.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, determining a size of a file portion managed by an interval tree according to the size of the file and the number of interval trees in an interval tree array includes: calculating the size of the file part which can be managed by one interval tree according to the size of the file and the number of the interval trees in the interval tree array; judging whether the calculated size of the file part which can be managed by one interval tree is larger than or equal to a preset size or not; if so, determining the calculated size of the file part which can be managed by the interval tree as the size of the file part managed by the interval tree.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, wherein: when the target request is a request for adding a VMA or deleting a VMA to the address space of the file, determining the target request as a write request; when the target request is a request to perform a search for the address space of the file for the VMA, the target request is determined to be a read request.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, each interval tree corresponds to an index value, and obtaining a to-be-processed interval tree to be processed includes: when the target request is a request for adding VMA or deleting VMA to the address space of the file, acquiring a first index value of an interval tree to be processed based on the minimum offset of the file part mapped by the VMA to be added or deleted; and taking the interval tree corresponding to the first index value as a to-be-processed interval tree.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, the performing a write process on the interval tree to be processed includes: when the target request is a request for adding VMA to the address space of the file, adding the VMA to be added to the interval tree to be processed as a node, and detecting whether the maximum offset of the mapped file part of the added VMA is larger than the second endpoint value of the interval tree to be processed; if so, the second endpoint value of the pending interval tree is updated to the maximum offset of the mapped file portion of the added VMA.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, the performing a write process on the interval tree to be processed includes: and when the target request is a request for executing VMA deletion on the address space of the file, removing the VMA to be deleted from the interval tree to be processed.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, obtaining a to-be-processed interval tree to be processed includes: when the target request is a request for searching the VMA in the address space of the file, acquiring a second index value of the interval tree to be processed based on the searched offset; and taking the interval tree corresponding to the second index value and the candidate interval tree of which the second endpoint value is greater than the searched offset as the interval tree to be processed, wherein the candidate interval tree is the interval tree corresponding to each index value smaller than the second index value.
Optionally, in the method for processing a virtual memory space of a file according to the present invention, performing read processing on a to-be-processed interval tree includes: and searching the VMA comprising the searched offset in the interval tree to be processed.
According to yet another aspect of the invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing a method of processing a virtual memory space of a file according to the present invention.
According to yet another aspect of the present invention, there is provided a readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform a method of processing a virtual memory space of a file according to the present invention.
According to the processing method of the virtual memory space of the file, the address space of the file stores a section tree array consisting of a plurality of section trees for managing all VMAs of the file, a read lock and a write lock of the section tree array, and a read lock and a write lock of each section tree in the section tree array. Based on the method, after a target request for executing VMA operation processing on the address space of the file is received, the to-be-processed interval tree to be processed is obtained. And if the target request is a write request, acquiring a read lock of the interval tree array and a write lock of the interval tree to be processed, and executing write processing on the interval tree to be processed. And if the target request is a read request, acquiring a read lock of the interval tree array and a read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed.
Therefore, the interval tree and the interval tree lock of the VMA of the management file are refined, when the VMA is executed on the address space of the file, only the lock of the interval tree to which the operated VMA belongs is needed to be obtained, and therefore a plurality of interval trees of the VMA of the management file can be processed at the same time, and the performance of multiple concurrent processes can be improved.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a block diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 is a flow diagram illustrating a method 200 for processing a virtual memory space of a file according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The invention provides a processing method of a virtual memory space of a file suitable for being executed in a computing device, which refines the granularity of an interval tree of a VMA (virtual machine architecture) for managing the file and correspondingly adopts a fine-grained interval tree lock. Therefore, the VMAs of different sections of the file can be operated and processed at the same time, and the performance of multi-process concurrency can be improved.
Fig. 1 illustrates a block diagram of the physical components (i.e., hardware) of a computing device 100. In a basic configuration, computing device 100 includes at least one processing unit 102 and system memory 104. According to one aspect, the processing unit 102 may be implemented as a processor depending on the configuration and type of computing device. The system memory 104 includes, but is not limited to, volatile storage (e.g., random access memory), non-volatile storage (e.g., read-only memory), flash memory, or any combination of such memories. According to one aspect, operating system 105 and program modules 106 are included in system memory 104, and virtual memory space processing module 120 is included in program modules 106, virtual memory space processing module 120 being configured to perform method 200 of processing the virtual memory space of a file of the present invention.
According to one aspect, the operating system 105 is, for example, adapted to control the operation of the computing device 100. Further, the examples are practiced in conjunction with a graphics library, other operating systems, or any other application program, and are not limited to any particular application or system. This basic configuration is illustrated in fig. 1 by those components within dashed line 108. According to one aspect, the computing device 100 has additional features or functionality. For example, according to one aspect, computing device 100 includes additional data storage devices (removable and/or non-removable) such as, for example, magnetic disks, optical disks, or tape. Such additional storage is illustrated in FIG. 1 by removable storage device 109 and non-removable storage device 110.
As stated hereinabove, according to one aspect, program modules are stored in the system memory 104. According to one aspect, the program modules may include one or more applications, the invention not being limited to the type of application, for example, the applications may include: email and contacts applications, word processing applications, spreadsheet applications, database applications, slide show applications, drawing or computer-aided applications, web browser applications, and the like.
According to one aspect, examples may be practiced in a circuit comprising discrete electronic elements, a packaged or integrated electronic chip containing logic gates, a circuit utilizing a microprocessor, or on a single chip containing electronic elements or microprocessors. For example, an example may be practiced via a system on a chip (SOC) in which each or many of the components shown in fig. 1 may be integrated on a single integrated circuit. According to one aspect, such SOC devices may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all integrated (or "burned") onto a chip substrate as a single integrated circuit. When operating via an SOC, the functions described herein may be operated via application-specific logic integrated with other components of the computing device 100 on a single integrated circuit (chip). Embodiments of the invention may also be practiced using other technologies capable of performing logical operations (e.g., AND, OR, AND NOT), including but NOT limited to mechanical, optical, fluidic, AND quantum technologies. In addition, embodiments of the invention may be practiced within a general purpose computer or in any other circuit or system.
According to one aspect, computing device 100 may also have one or more input devices 112, such as a keyboard, mouse, pen, voice input device, touch input device, or the like. Output device(s) 114 such as a display, speakers, printer, etc. may also be included. The foregoing devices are examples and other devices may also be used. Computing device 100 may include one or more communication connections 116 that allow communications with other computing devices 118. Examples of suitable communication connections 116 include, but are not limited to: RF transmitter, receiver and/or transceiver circuitry; universal Serial Bus (USB), parallel, and/or serial ports.
The term computer readable media as used herein includes computer storage media. Computer storage media may include volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, or program modules. System memory 104, removable storage 109, and non-removable storage 110 are all examples of computer storage media (i.e., memory storage). Computer storage media may include Random Access Memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other article of manufacture that may be used to store information and that may be accessed by the computer device 100. In accordance with one aspect, any such computer storage media may be part of computing device 100. Computer storage media does not include a carrier wave or other propagated data signal.
According to one aspect, communication media is embodied by computer readable instructions, data structures, program modules, or other data in a modulated data signal (e.g., a carrier wave or other transport mechanism) and includes any information delivery media. According to one aspect, the term "modulated data signal" describes a signal that has one or more feature sets or that has been altered in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, radio Frequency (RF), infrared, and other wireless media.
FIG. 2 illustrates a flow diagram of a method 200 for processing a virtual memory space of a file, the method 200 being suitable for execution in a computing device (e.g., the computing device 100 shown in FIG. 1), according to one embodiment of the invention. The operating system of the computing device may be a Linux operating system, or may be other operating systems, such as Unix, windows, and the like, which is not limited in this invention.
The interval tree of the VMA of the management file is refined, and all the VMA of the management file are managed by adopting a plurality of interval trees. In other words, all VMAs of a file are managed using one span tree array. Based on this, the present invention stores in the address space of the file an interval tree array composed of a plurality of interval trees for managing all VMAs of the file, read locks and write locks of the interval tree array, and read locks and write locks of each interval tree in the interval tree array.
Specifically, according to an embodiment of the present invention, an interval tree array i _ mmap _ array is added to address _ space of a file. The interval tree ARRAY i _ MMAP _ ARRAY includes AS _ MMAP _ ARRAY _ SIZE interval tree AS _ MMAP _ rb members, and a preset SIZE (range) of the interval tree AS _ MMAP _ rb member management file part is MMAP _ tree _ SIZE. And, the read lock and write lock of the interval tree array i _ mmap _ array, such as the read-write lock i _ mmap _ rwsem, are stored in the interval tree array i _ mmap _ array for protecting the interval tree array. The read and write locks of the interval tree as _ mmap _ rb, such as read/write lock as _ mmap _ rwsem, are stored in each interval tree as _ mmap _ rb member to protect the interval tree. In some embodiments, the interval tree as _ mmap _ rb members also have stored therein their root node mmap _ rb _ root.
Regarding the interval tree array i _ mmap _ array, generally, when a process loads an executable file through an exec function family, or a dynamic library loader maps a shared library file to a virtual address space of the process, or the process maps a file to a virtual address space of the process through mmap, the process is initialized, which is substantially to determine a range of each interval tree management file portion. Specifically, two endpoint values of each interval tree in the interval tree array are determined, and the two endpoint values of each interval tree are stored in the address space of the file. Wherein preferably both end point values of each interval tree are stored in the respective interval tree member.
According to one embodiment of the invention, the two endpoint values of each interval tree in the interval tree array may be determined as follows.
First, the size of the file part managed by one interval tree is determined according to the size of the file and the number of interval trees in the interval tree array. Specifically, the size of the file part which can be managed by one interval tree is calculated according to the size of the file and the number of the interval trees in the interval tree array. Further, the ratio tmp _ tree _ SIZE of the file SIZE and the number AS _ MMAP _ ARRAY _ SIZE of the interval trees is calculated, and the ratio tmp _ tree _ SIZE is used AS the SIZE of the file portion that can be managed by one interval tree. In some embodiments, to prevent the interval tree from being thinned too small, after the size tmp _ tree _ size of the file portion that can be managed by an interval tree is calculated, the size tmp _ tree _ size is compared with the preset size mmap _ tree _ size, or whether the size tmp _ tree _ size is greater than or equal to the preset size mmap _ tree _ size is determined. If so, determining the size tmp _ tree _ size of the file part capable of being managed by one interval tree as the size of the file part managed by one interval tree, otherwise, determining the preset size mmap _ tree _ size as the size of the file part managed by one interval tree.
Then, according to the size of the file part managed by the determined interval tree, a first endpoint value and a second endpoint value of each interval tree are determined. The first end value of each interval tree is an offset of a start position of a file part managed by each interval tree with respect to a start position of the file, and the second end value of each interval tree is an offset of an end position of a file part managed by each interval tree with respect to a start position of the file. That is, the first endpoint value of an interval tree is the offset min _ offset of the start data of the part of the file content managed (corresponding) by the interval tree relative to the start data of the whole file, and the second endpoint value is the offset max _ offset of the end data of the part of the file content managed by the interval tree relative to the start data of the whole file. It should be noted that the interval tree array in the address space of the file is fixed after initialization, and is generally modified only when the address space is destroyed. If the size of the file is increased and exceeds the range which can be expressed by the array, the last interval tree in the interval tree array can be used for managing all the pages which exceed the range.
Next, a method of processing the virtual memory space of the file will be described in detail in a case where all VMAs of the file are managed by a plurality of interval trees. As shown in FIG. 2, a method 200 for processing a virtual memory space of a file according to the present invention begins at 210. In 210, a target request to perform VMA operation processing on the address space of a file is received.
Wherein the target request comprises a read request or a write request. Specifically, the target request may be a request to perform an add VMA to the address space of the file, a request to perform a delete VMA to the address space of the file, or a request to perform a search for VMAs to the address space of the file. For example, if part or all of the content of the file 1 is mapped to the virtual address space of the process a, when the process a exits or calls the exec function family to load a new executable file, the unmap file 1 needs to be mapped in the virtual address space of the process a, and the VMA of the process a needs to be deleted from the interval tree of all VMAs in the management file 1, and at this time, a request for deleting the VMA of the process a from the address space of the file 1 is received. For the service scenario that needs to add VMA to the address space of the file or search for VMA, no one will be illustrated here.
After receiving the target request, entering 220, and acquiring the to-be-processed interval tree to be processed based on the target request. When the target request is a request for adding a VMA or deleting a VMA to the address space of the file, the target request is determined to be a write request. When the target request is a request to perform a search for the address space of the file for the VMA, the target request is determined to be a read request.
In addition, according to an embodiment of the present invention, an index value may be set for each interval tree in the interval tree array, so that each interval tree corresponds to an index value. In this way, in some embodiments, the interval tree to be processed can be obtained through the index value corresponding to each interval tree.
Specifically, when the target request is a request for adding a VMA to the address space of the file or a request for deleting a VMA from the address space of the file, the to-be-processed interval tree to be processed may be acquired as follows.
First, a first index value of the interval tree to be processed is acquired based on a minimum offset of a file portion mapped by the VMA to be added or deleted (i.e., an offset of a start position of the file portion mapped by the VMA to be added or deleted with respect to a start position of the entire file). Further, the first index value of the interval tree to be processed is acquired based on the minimum offset of the file portion of the VMA map to be added or deleted and the size of the file portion managed by one interval tree. Specifically, in some embodiments, the rounded-up value of the quotient of the minimum offset of the file portion mapped by the VMA to be added or deleted and the size of the file portion managed by one span tree may be used as the first index value of the span tree to be processed. Of course, the first index value may be obtained in other manners, and the present invention is not limited thereto. And then, taking the interval tree corresponding to the first index value as a to-be-processed interval tree.
For ease of understanding, an example is given below. The interval tree array i _ mmap _ array comprises 3 interval tree members as _ mmap _ rb, the index value of the first interval tree member as _ mmap _ rb is 1, the index value of the second interval tree member as _ mmap _ rb is 2, the index value of the third interval tree member as _ mmap _ rb is 3, the size of a file part managed by one interval tree is 10, and the minimum offset of the file part mapped by the VMA to be added is 13. Obviously, the rounded-up value of the quotient of the minimum offset 13 of the file portion of the VMA map to be added and the size 10 of the file portion managed by one interval tree is 2, so that the interval tree to be processed is the second interval tree. It should be noted that this is merely an example, and the to-be-processed interval tree may also be obtained in other manners, which is not limited to this invention.
When the target request is a request for searching for a VMA in the address space of the file, the to-be-processed interval tree to be processed may be acquired as follows.
First, a second index value of the section tree to be processed is acquired based on a searched offset amount, which is an offset amount of the file data to be searched with respect to the start data of the entire file. Further, a second index value of the interval tree to be processed is acquired based on the searched offset and the size of the file portion managed by one interval tree. Of course, the second index value of the section tree to be processed may be specifically set to the rounded-up value of the quotient of the searched offset and the size of the file portion managed by one section tree. Then, the interval tree corresponding to the second index value and the candidate interval tree with the second endpoint value larger than the searched offset are used as the interval tree to be processed, and the candidate interval tree is the interval tree corresponding to each index value smaller than the second index value.
It is noted that, when a VMA is added to a range tree, a case may occur in which a second endpoint value of the range tree is greater than the second endpoint value at the time of initialization (which will be described in detail later), that is, the maximum offset of the added VMA exceeds the range managed by the range tree. Therefore, in the present embodiment, when the target request is a request for searching for the VMA, in addition to the interval tree corresponding to the second index value as the to-be-processed interval tree, an interval tree in which the second endpoint value is larger than the searched offset amount among the interval trees corresponding to the index values smaller than the second index value is also used as the to-be-processed interval tree. That is, the present invention performs the special process of the boundary check when processing the request for searching the VMA, which is more accurate.
Thus, a to-be-processed interval tree is obtained, and then the to-be-processed interval tree is processed, which is specifically as follows.
If the target request is a write request, the process proceeds to 230 after the to-be-processed interval tree is acquired, the read lock of the interval tree array and the write lock of the to-be-processed interval tree are acquired, and write processing is performed on the to-be-processed interval tree. The reading lock of the interval tree array is obtained to prevent the address space of the file from being destroyed (the reading lock of the interval tree array can be held by a plurality of threads simultaneously) in the process of executing the writing processing on the interval tree to be processed, and the writing lock of the interval tree to be processed is obtained to ensure that only one thread can execute the writing processing on the interval tree to be processed at the same time, namely, the exclusive access of the interval tree is kept.
The following describes a procedure for performing write processing on the span tree to be processed. When the target request is a request for deleting the VMA in the address space of the file, removing the VMA to be deleted from the interval tree to be processed.
When the target request is a request for adding a VMA to the address space of the file, adding the VMA to be added as a node to the interval tree to be processed, and detecting whether the maximum offset of the file part mapped by the added VMA (i.e., the offset of the end position of the file part mapped by the added VMA with respect to the start position of the entire file) is greater than the second end value of the interval tree to be processed. If so, the second endpoint value of the pending interval tree is updated to the maximum offset of the mapped file portion of the added VMA. Otherwise, keeping the second endpoint value of the interval tree to be processed unchanged, namely not processing the endpoint of the interval tree to be processed.
After the write process is performed on the to-be-processed interval tree, according to an embodiment of the present invention, the write lock of the to-be-processed interval tree and the read lock of the interval tree array are released. That is, after a VMA is added to or deleted from the to-be-processed interval tree, the write lock of the to-be-processed interval tree and the read lock of the interval tree array are also released.
And if the target request is a read request, entering 240 after the interval tree to be processed is obtained, obtaining the read lock of the interval tree array and the read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed. Specifically, when the target request is a request for searching for a VMA in the pending interval tree, then a VMA including the searched offset is searched for in the pending interval tree. According to one embodiment of the present invention, after the search (i.e., search) in any pending interval tree is completed, the read lock of the interval tree is released. In some embodiments, after a VMA is found in a span tree to be processed, it is also deleted from the span tree, which may subsequently obtain a write lock for the span tree, then delete the found VMA directly from the span tree, and finally release the write lock in the span tree. In addition, after all the acquired to-be-processed interval trees are processed, the read lock of the interval tree array can be released.
Therefore, the interval tree and the interval tree lock of the VMA for managing the file are refined, so that when the address space of the file is subjected to VMA adding or VMA deleting processing, only the write lock of the interval tree to which the operated VMA belongs is required to be acquired, and the VMA adding or VMA deleting processing can be performed on a plurality of interval trees of the VMA for managing the file at the same time, so that the performance of multiple concurrent processes can be improved. In addition, when searching for the VMA in the address space of the file, the method only needs to search in the acquired plurality of interval trees to be processed, obviously, the search range can be reduced, and the search speed can be improved.
In some embodiments, a red-black tree of VMAs of a file can be owned by each process, or a radix tree can be tried by using free lock technology, and all VMAs mapped to a physical page are linked together to find all VMAs sharing the physical page.
According to the processing method of the virtual memory space of the file, the address space of the file stores a section tree array consisting of a plurality of section trees for managing all VMAs of the file, a read lock and a write lock of the section tree array, and a read lock and a write lock of each section tree in the section tree array. Based on the method, after a target request for executing VMA operation processing on the address space of the file is received, the to-be-processed interval tree to be processed is obtained. And if the target request is a write request, acquiring a read lock of the interval tree array and a write lock of the interval tree to be processed, and executing write processing on the interval tree to be processed. And if the target request is a read request, acquiring a read lock of the interval tree array and a read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed.
Therefore, the interval tree and the interval tree lock of all the VMAs of the management file are refined, so that when the VMA processing is executed on the address space of the file, only the lock of the interval tree to which the operated VMA belongs is required to be obtained, and the VMA processing can be carried out on different interval trees of the VMA of the management file at the same time, thereby improving the performance of multiple concurrent processes. Moreover, the invention reduces the file range protected by one lock, thus reducing the time length of waiting for the lock of each process even if a plurality of processes need to operate a certain interval tree simultaneously.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the processing method of the virtual memory space of the file according to the instructions in the program codes stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
It should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (12)

1. A processing method of a virtual memory space of a file, wherein an interval tree array, a read lock and a write lock of the interval tree array, and a read lock and a write lock of each interval tree in the interval tree array are stored in an address space of the file, the interval tree array is composed of a plurality of interval trees for managing all virtual memory spaces VMA of the file, and the method comprises the following steps:
receiving a target request for executing VMA operation processing on the address space of the file, wherein the target request comprises a read request or a write request;
acquiring a to-be-processed interval tree to be processed based on the target request;
if the target request is a write request, acquiring a read lock of the interval tree array and a write lock of the interval tree to be processed, and executing write processing on the interval tree to be processed;
and if the target request is a read request, acquiring the read lock of the interval tree array and the read lock of the interval tree to be processed, and executing read processing on the interval tree to be processed.
2. The method of claim 1, further comprising:
determining two endpoint values of each interval tree in the interval tree array; and
and storing two endpoint values of each interval tree into the address space of the file.
3. The method of claim 2, wherein the determining two endpoint values for each interval tree in the array of interval trees comprises:
determining the size of the file part managed by one interval tree according to the size of the file and the number of the interval trees in the interval tree array;
and determining a first end value and a second end value of each interval tree according to the determined size of the file part managed by one interval tree, wherein the first end value of each interval tree is the offset of the starting position of the file part managed by each interval tree relative to the starting position of the file, and the second end value of each interval tree is the offset of the ending position of the file part managed by each interval tree relative to the starting position of the file.
4. The method of claim 3, wherein said determining a size of a portion of a file managed by an interval tree based on a size of the file and a number of interval trees in the array of interval trees comprises:
calculating the size of the file part which can be managed by one interval tree according to the size of the file and the number of the interval trees in the interval tree array;
judging whether the calculated size of the file part which can be managed by one interval tree is larger than or equal to a preset size or not;
if so, determining the calculated size of the file part which can be managed by the interval tree as the size of the file part managed by the interval tree.
5. The method of claim 3 or 4, wherein:
when the target request is a request for adding VMA or deleting VMA to the address space of the file, determining the target request as a write request;
and when the target request is a request for searching the address space of the file by VMA, determining that the target request is a read request.
6. The method of claim 5, wherein each interval tree corresponds to an index value, and obtaining the interval tree to be processed comprises:
when the target request is a request for adding VMA or deleting VMA to the address space of the file, acquiring a first index value of an interval tree to be processed based on the minimum offset of a file part mapped by the VMA to be added or deleted;
and taking the interval tree corresponding to the first index value as the interval tree to be processed.
7. The method of claim 6, wherein performing a write process on the pending interval tree comprises:
when the target request is a request for adding VMA to the address space of the file, adding the VMA to be added to the interval tree to be processed as a node, and detecting whether the maximum offset of the mapped file part of the added VMA is larger than the second endpoint value of the interval tree to be processed;
if so, updating the second endpoint value of the pending interval tree to the maximum offset of the mapped file portion of the added VMA.
8. The method of claim 6 or 7, wherein performing a write process on the inter-span tree to be processed comprises:
and when the target request is a request for deleting the VMA in the address space of the file, removing the VMA to be deleted from the interval tree to be processed.
9. The method of claim 6, wherein obtaining the interval tree to be processed comprises:
when the target request is a request for searching VMA (virtual machine architecture) for the address space of the file, acquiring a second index value of the interval tree to be processed based on the searched offset;
and taking the interval tree corresponding to the second index value and a candidate interval tree of which the second endpoint value is greater than the searched offset as the interval tree to be processed, wherein the candidate interval tree is an interval tree corresponding to each index value smaller than the second index value.
10. The method of claim 9, wherein performing a read process on the pending interval tree comprises:
and searching the VMA comprising the searched offset in the interval tree to be processed.
11. A computing device, comprising:
at least one processor; and
a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-10.
12. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-10.
CN202211212377.4A 2022-09-28 2022-09-28 Processing method of virtual memory space of file and computing equipment Pending CN115576864A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211212377.4A CN115576864A (en) 2022-09-28 2022-09-28 Processing method of virtual memory space of file and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211212377.4A CN115576864A (en) 2022-09-28 2022-09-28 Processing method of virtual memory space of file and computing equipment

Publications (1)

Publication Number Publication Date
CN115576864A true CN115576864A (en) 2023-01-06

Family

ID=84582443

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211212377.4A Pending CN115576864A (en) 2022-09-28 2022-09-28 Processing method of virtual memory space of file and computing equipment

Country Status (1)

Country Link
CN (1) CN115576864A (en)

Similar Documents

Publication Publication Date Title
CN109426619B (en) Method for accessing flash memory module, related flash memory controller and electronic device
US7650458B2 (en) Flash memory driver
US7809918B1 (en) Method, apparatus, and computer-readable medium for providing physical memory management functions
CN111090663B (en) Transaction concurrency control method, device, terminal equipment and medium
US9697111B2 (en) Method of managing dynamic memory reallocation and device performing the method
US11556466B2 (en) Logical-to-physical data structures
JP7058132B2 (en) Systems and methods for maximized deduplication memory
US20110320689A1 (en) Data Storage Devices and Data Management Methods for Processing Mapping Tables
US11307784B2 (en) Method and apparatus for storing memory attributes
CN109213423B (en) Address barrier-based lock-free processing of concurrent IO commands
CN114327917A (en) Memory management method, computing device and readable storage medium
WO2016119597A1 (en) Page querying method and data processing node in oltp cluster database
US10387302B2 (en) Managing database index by leveraging key-value solid state device
CN114880289A (en) File grouping display method and computing device
US10901914B2 (en) Method for writing multiple copies into storage device, and storage device
US10642531B2 (en) Atomic write method for multi-transaction
US20060184759A1 (en) Permanent pool memory management method and system
CN110489425B (en) Data access method, device, equipment and storage medium
CN115576864A (en) Processing method of virtual memory space of file and computing equipment
CN115269199A (en) Data processing method and device, electronic equipment and computer readable storage medium
US11579801B2 (en) Write ordering in SSDs
CN108959517B (en) File management method and device and electronic equipment
CN109213424B (en) Lock-free processing method for concurrent IO command
Feltham et al. Linear hashing implementations for flash memory
US12008261B2 (en) Method and device for accessing memory

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