Exchange space expelling method and device, electronic equipment and storage medium
By performing targeted memory page eviction based on process numbers in the swap space, the problems of system crashes and performance slowdowns caused by traditional methods are solved, achieving more efficient memory access and improving system performance.
Patent Information
- Application Number
- CN202410621870.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-10-01
AI Technical Summary
The traditional swap space eviction method will cause the system to crash when the physical memory is insufficient, and due to the slow speed of reading the swap space, it will slow down the execution speed of the application and affect the business performance.
Targeted clearing of memory pages in the swap space based on process numbers avoids closing the entire swap space, and directly evicts target memory pages from the swap space to the memory to improve system memory access efficiency.
Effectively prevent system crashes, improve system performance and memory access efficiency, and enhance business performance.
Smart Images

Figure CN118733248A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a swap space eviction method, device, electronic equipment and storage medium. Background Art
[0002] The system kernel divides memory into memory blocks and swap tools. When physical memory is insufficient, swap space is usually used to swap some infrequently used memory pages to swap space according to certain strategies. After physical memory is released, if the memory pages swapped to swap space have not been accessed, they will remain in the swap space. When these memory pages are accessed, they need to be swapped back from the swap space before they can be accessed normally. However, since the speed of reading swap space is affected by the random read speed of its backend storage medium, the read speed of swap space is greatly different from the direct access speed of memory, which has become an important reason for slowing down the execution speed of applications and seriously restricting business performance.
[0003] At present, the traditional swap space eviction method is to close the swap space by executing the SWAPOFF command, and evict all memory pages in the swap space back to the memory. The traditional swap space eviction method does not distinguish between processes, resulting in a time-consuming eviction process. In addition, due to the eviction operation mode, closing the swap space means that all swap spaces of all processes need to be evicted to the memory. When there is insufficient free memory, the system will crash and affect the stability of the system. At present, there is an urgent need for a swap space eviction method that can perform targeted eviction of the swap space while ensuring the execution speed of the application, thereby effectively improving business performance. Summary of the invention
[0004] The present invention provides a swap space eviction method, device, electronic device and storage medium, which can clear memory pages in the swap space in a targeted manner by process number without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency and enhancing the system performance.
[0005] According to one aspect of the present invention, a swap space eviction method is provided, which is applied to a swap space eviction device, wherein the method comprises:
[0006] Calling a preset kernel file interface according to the process number setting module to obtain the process number of the swap space to be released;
[0007] Determine the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module, and evict the target memory page from the swap space to the memory.
[0008] According to another aspect of the present invention, a swap space eviction device is provided, wherein the device comprises:
[0009] A process number setting module is used to call a preset kernel file interface to obtain the process number of the swap space to be released;
[0010] The swap space eviction module is used to determine the target memory page corresponding to the process number in the virtual memory area, and evict the target memory page from the swap space to the memory.
[0011] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0012] at least one processor; and
[0013] a memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the swap space eviction method described in any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the swap space eviction method described in any embodiment of the present invention when executed.
[0016] The technical solution of the embodiment of the present invention is to obtain the process number of the swap space to be released by calling a preset kernel file interface according to the process number setting module in the swap space eviction device, determine the target memory page corresponding to the process number in the virtual memory area of the swap space eviction module, and evict the target memory page from the swap space to the memory. The embodiment of the present invention performs targeted clearing of memory pages in the swap space according to the process number without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency, and enhancing the system performance.
[0017] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 is a flow chart of a swap space eviction method provided according to Embodiment 1 of the present invention;
[0020] Figure 2 is a flow chart of another swap space eviction method provided according to Embodiment 2 of the present invention;
[0021] Figure 3 is a flow chart of another swap space eviction method provided according to Embodiment 3 of the present invention;
[0022] Figure 4 is a flow chart of another swap space eviction method provided according to Embodiment 4 of the present invention;
[0023] Figure 5 is an example diagram of a swap space eviction method provided according to Embodiment 5 of the present invention;
[0024] Figure 6 is a structural schematic diagram of a swap space eviction device provided according to Embodiment 6 of the present invention;
[0025] Figure 7 The invention is a schematic diagram of the structure of an electronic device for implementing the swap space eviction method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1 The flowchart of a swap space eviction method provided according to the first embodiment of the present invention is applicable to the case of directional eviction of memory pages of a specified process in a swap space. The method can be executed by a swap space eviction device, which at least includes a number setting module and a swap space eviction module. The device can be implemented in the form of hardware and / or software, and the device can be configured in an electronic device. Figure 1 As shown, the method includes:
[0030] Step 110: According to the process number setting module, a preset kernel file interface is called to obtain the process number of the swap space to be released.
[0031] The process number setting module may be a module for configuring the process number, the process number setting module may be a system kernel module, the preset kernel file may be a calling interface for operating the kernel module, the preset kernel file interface may pass external information to the system kernel by calling the interface, and the preset kernel file interface may include but is not limited to a SYSFS interface or a PROCFS interface, etc. The swap space to be released may be a swap space that needs to be evicted, and the swap space to be released may be a swap space of a core business process or a swap space specified by a user.
[0032] In the embodiment of the present invention, the process number setting module can be specifically a system kernel module, and the process number setting module can be called in the system kernel space, so that the process number setting module can set the process number of the swap space to be released by calling the preset kernel file interface. The process number can be the unique identification information of the process, and different process numbers can be used to distinguish different processes.
[0033] Step 120: Determine the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module, and evict the target memory page from the swap space to the memory.
[0034] The swap space eviction module may be a system kernel module for eviction of the swap space, the swap space eviction module may be configured in the system kernel, the virtual memory area may be a virtual memory where the swap space is located, and the virtual memory area may be preconfigured. The target memory page may be a virtual memory space in the swap space that matches the process number, that is, the target memory page is a virtual memory space in the swap space that matches the process corresponding to the process number.
[0035] In the embodiment of the present invention, the swap space eviction module may be called to search the target memory page corresponding to the process number in the virtual memory area through the swap space eviction module, and evict the target memory page from the swap space to the memory.
[0036] In an embodiment of the present invention, a preset kernel file interface is called according to a process number setting module in a swap space eviction device to obtain the process number of the swap space to be released, a target memory page corresponding to the process number is determined in a virtual memory area of the swap space eviction module, and the target memory page is evicted from the swap space to the memory. In this embodiment of the present invention, memory pages are cleared in a targeted manner in the swap space according to the process number without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency, and enhancing the system performance.
[0037] Embodiment 2
[0038] Figure 2 is a flowchart of another swap space eviction method provided according to the second embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above invention. The process of setting the process number is described in detail. Figure 2 The method provided in the embodiment of the present invention specifically includes the following steps:
[0039] Step 210: Determine the process number of the swap space to be released according to the preset management requirement.
[0040] Among them, the preset management requirements may be the requirements for managing the swap space. The preset management requirements may be set based on business scenarios or system kernel performance requirements. The preset management requirements may include process attributes of the swap space to be released that needs to be evicted, for example, whether it belongs to a core process. The preset management requirements may also include the business type corresponding to the swap space to be released, for example, whether it belongs to an urgently needed business function.
[0041] In an embodiment of the present invention, a preset management requirement can be obtained based on a business scenario or a system kernel performance requirement, and one or more process numbers of the swap space to be released can be determined according to the preset management requirement. The preset management requirement can directly include the process number, or include the process attributes of the swap space to be released or the business type to which it belongs, and then determine one or more process numbers through the above-mentioned process attributes or business types.
[0042] Step 220: Control the process number setting module to call a preset kernel file interface to receive the process number.
[0043] In an embodiment of the present invention, the preset kernel file interface can be an interface exposed by the process number setting module for use by the external system. The determined process number can be transmitted to the process number setting module by calling the preset kernel file interface, so that the process number setting module can obtain the external input process number through the system kernel module.
[0044] Step 230: Determine the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module, and evict the target memory page from the swap space to the memory.
[0045] In an embodiment of the present invention, the process number of the swap space to be released is determined through preset management requirements, a preset kernel file interface is called in the process number setting module so that the process number setting module obtains the process number, a target memory page corresponding to the process number is determined in the virtual memory area of the swap space eviction module, and the target memory page is evicted from the swap space to the memory. In an embodiment of the present invention, memory pages are cleared in a targeted manner in the swap space through the process number without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency, and enhancing the system performance.
[0046] Furthermore, based on the above-mentioned embodiment of the invention, it also includes: obtaining preset management requirements provided by a system administrator or an external management system in the process number setting module.
[0047] In the embodiment of the present invention, the system administrator or external management system can preset management requirements, the process number setting module can directly obtain the preset management requirements, and the process number setting module itself determines the process number according to the preset management requirements.
[0048] Embodiment 3
[0049] Figure 3 is a flowchart of another swap space eviction method provided according to Embodiment 3 of the present invention. The embodiment of the present invention is a specific embodiment of the above-mentioned invention embodiment, and the process of obtaining the target memory page is described in detail. Figure 3The method provided in the embodiment of the present invention specifically includes the following steps:
[0050] Step 310: Call a preset kernel file interface according to the process number setting module to obtain the process number of the swap space to be released.
[0051] Step 320: Search the process descriptor corresponding to the process number in the swap space eviction module, and extract the region structure linked list of the virtual memory region from the process descriptor.
[0052] The process descriptor may be a data structure used to describe a process, and the process descriptor may at least include a region structure linked list identifying a virtual memory region, and each linked list item in the region structure linked list may store an address of a virtual memory region.
[0053] In the embodiment of the present invention, the process descriptor of the corresponding process can be searched according to the process number through the swap space eviction module, and the region structure linked list can be extracted from the process descriptor, and the region structure linked list can store the address of the virtual memory region.
[0054] Step 330: traverse the memory page belonging to the swap space in the region structure linked list as the target memory page.
[0055] In the embodiment of the present invention, the addresses stored in the region structure linked list may be accessed respectively to determine whether the swap space corresponding to the address belongs to a memory page. If so, the memory page is used as the target memory page.
[0056] Step 340: evict the target memory page from the swap space to the main memory.
[0057] The embodiment of the present invention calls a preset kernel file interface according to a process number setting module to obtain the process number of the swap space to be released, determines the process descriptor of the process number according to the swap space eviction module, extracts the region structure linked list corresponding to the virtual memory area in the process descriptor, traverses the region structure linked list to obtain the memory page belonging to the swap space as the target memory page, evicts the target memory page to the memory, thereby realizing the targeted clearing of the memory page of the swap space, and the eviction process does not need to close the entire swap space, which can prevent the system from freezing due to insufficient free memory, improve the system memory access efficiency, and enhance the system performance.
[0058] In some inventive embodiments, traversing the memory pages belonging to the swap space as target memory pages in the region structure linked list includes:
[0059] Traverse all page table addresses in the regional structure linked list; determine in turn whether the page table entry corresponding to the page table address is the swap space; if so, use the memory page corresponding to the page table entry as the target memory page, if not, continue to determine the next page table entry.
[0060] The page table address may be an access address of a virtual memory area stored in the area structure linked list, the page table entry may be attribute information of the virtual memory area, and the page table entry at least includes indication information indicating whether it belongs to a swap space.
[0061] In an embodiment of the present invention, the region structure linked list can be traversed, and the page table addresses in the region structure linked list can be read in sequence. The corresponding page table item can be accessed through the page table address, and the attributes of the page table item can be extracted to determine whether the memory page corresponding to the page table item is a swap space. When the page table item has identification information of the swap space, the memory page corresponding to the page table item can be used as the target memory page. Otherwise, the reading of the current page table item is terminated, and the next page table item in the region structure linked list is judged. After all the page table items corresponding to the page table addresses in the region structure linked list are traversed, it can be determined that the target memory page corresponding to the process number is obtained.
[0062] Embodiment 4
[0063] Figure 4 is a flowchart of another swap space eviction method provided according to Embodiment 4 of the present invention. The embodiment of the present invention is a specific embodiment of the above-mentioned invention embodiment, and describes the eviction process of the target memory page. Figure 4 The method provided in the embodiment of the present invention specifically includes the following steps:
[0064] Step 410: The module calls a preset kernel file interface according to the process number setting to obtain the process number of the swap space to be released.
[0065] Step 420: Determine the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module.
[0066] Step 430: The swap space eviction module calls a preset swapin_readahead function to read the target memory page from the swap space into the memory.
[0067] The preset swapin_readahead function may be a system kernel function preconfigured in the swap space eviction module. The preset swapin_readahead function is similar to an input / output pre-reading mechanism and may read the current and subsequent pages.
[0068] In an embodiment of the present invention, the page table address of the target memory page is used as an input parameter of a preset swapin_readahead function in the swap space eviction module, and the target memory page can be read from the swap space to the memory by calling the preset swapin_read ahead function.
[0069] Step 440: activate the target memory page of the memory according to the swap space eviction module, and release the swap space corresponding to the target memory page.
[0070] Specifically, after the target memory page is read into the memory through the swap space eviction module, the target memory page in the memory can be activated so that the target memory page can be accessed in the memory, and the swap space corresponding to the target memory page can be released.
[0071] The embodiment of the present invention obtains the process number of the swap space to be released by calling a preset kernel file interface according to the process number setting module in the swap space eviction device, determines the target memory page corresponding to the process number in the virtual memory area of the swap space eviction module, calls the preset swapin_readahead function in the swap space eviction module to read the target memory page from the swap space into the memory, calls the swap space eviction module to activate the target memory page of the memory, and releases the swap space corresponding to the target memory page. The embodiment of the present invention performs targeted clearing of memory pages in the swap space according to the process number without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency, and enhancing the system performance.
[0072] Further, based on the above-mentioned embodiment of the invention, the swap space eviction device also includes a function loading module, and accordingly, the method also includes: loading the process number setting module and the swap space eviction module into the operating system as a kernel function module according to the function loading module.
[0073] In the embodiment of the present invention, the function loading module may load the process number setting module and the swap space eviction module into the system kernel of the operating system, so that the process number setting module and the swap space eviction module serve as kernel function modules.
[0074] Embodiment 5
[0075] Figure 5 This is an example diagram of a swap space eviction method provided according to Embodiment 5 of the present invention. The embodiment of the present invention can realize the eviction of the swap space of a specified process to the memory. In the embodiment of the present invention, the process ID to be released is set through the file system interface, and the swap space used by the process corresponding to the process ID is expelled back to the memory, so that the entire process resides in the memory and can be quickly accessed. Figure 5The device provided by the embodiment of the present invention may include a function loading module M101, which can load a process ID setting module M102 and a swap space eviction module M103 into the operating system in the form of a kernel module. The process ID setting module M102 can provide a SYSFS interface or a PROCFS interface, which can be used to receive a set process ID, and the process ID can be specifically the process ID of the swap space to be released. The swap space eviction module M103 can obtain the process task_struct structure according to the process ID, thereby obtaining the virtual memory area vm_area_struct linked list, obtain all page table addresses in the virtual address space by traversing the vm_area_struct linked list, and determine whether the corresponding virtual address space is a swap space according to the page table entry corresponding to the page table address. If so, it is read from the swap space into the memory page through the swapin_readahead function, and the memory page corresponding to the swap space is activated, and the swap space is released. Specifically, the swap space eviction method provided by the embodiment of the present invention may include the following steps:
[0076] Step S101: The process ID setting module M102 and the swap space eviction module M103 are loaded into the operating system through the function loading module M101. After loading, the process ID setting module M102 is called to expose the process ID setting interface for use by the external system, thereby obtaining the process ID set by the external system or the system administrator;
[0077] Step S102: the system administrator or other management system sets the process ID that needs to be evicted from the swap space through the process ID setting interface provided by the process ID setting module M102, and passes the process ID to the swap space eviction module M103, which executes the specific operation of eviction of the swap space to the memory.
[0078] The embodiment of the present invention sets the process ID through an interface, releases the swap space of the specified process through the process ID, and expels the specified memory from the swap space to the main memory by encoding the virtual space of the process. The embodiment of the present invention can expel the swap space of the core business process back to the main memory in advance to prevent the corresponding swap space from being accessed, thereby greatly avoiding the degradation of system performance caused by swap space access and effectively improving business performance.
[0079] Embodiment 6
[0080] Figure 6 Schematic diagram of the structure of a swap space eviction device provided according to Embodiment 6 of the present invention. Figure 6 As shown, the device comprises:
[0081] The process number setting module 510 is used to call a preset kernel file interface to obtain the process number of the swap space to be released.
[0082] The swap space eviction module 520 is used to determine the target memory page corresponding to the process number in the virtual memory area, and evict the target memory page from the swap space to the memory.
[0083] In the embodiment of the present invention, a process number setting module calls a preset kernel file interface according to the process number setting module to obtain the process number of the swap space to be released, and the swap space eviction module determines the target memory page corresponding to the process number in the virtual memory area, and evicts the target memory page from the swap space to the memory. In the embodiment of the present invention, the memory page is cleared in a targeted manner in the swap space according to the process number, without closing the entire swap space, thereby preventing the system from freezing due to insufficient free memory, improving the system memory access efficiency, and enhancing the system performance.
[0084] In some inventive embodiments, the process number setting module 510 includes:
[0085] The number obtaining unit is used to determine the process number of the swap space to be released according to a preset management requirement.
[0086] The number setting unit is used to control the process number setting module to call the preset kernel file interface to receive the process number.
[0087] In some inventive embodiments, the swap space eviction module 520 includes: a page determination unit, specifically used to: search for the process descriptor corresponding to the process number in the swap space eviction module, and extract the region structure linked list of the virtual memory area from the process descriptor; traverse the memory page belonging to the swap space in the region structure linked list as the target memory page.
[0088] In some inventive embodiments, the swap space eviction module 520 traverses the memory page belonging to the swap space in the region structure linked list as the target memory page specifically including: traversing all page table addresses in the region structure linked list;
[0089] Determine in sequence whether the page table entry corresponding to the page table address is the swap space;
[0090] If yes, the memory page corresponding to the page table entry is used as the target memory page; if no, continue to determine the next page table entry.
[0091] In some inventive embodiments, the swap space eviction module 520 further includes: an eviction execution unit, configured to call a preset swapin_readahead function in the swap space eviction module to read the target memory page from the swap space into the memory;
[0092] The target memory page of the memory is activated according to the swap space eviction module, and the swap space corresponding to the target memory page is released.
[0093] In some embodiments of the invention, it also includes: a function loading module, which is specifically used to load the process number setting module and the swap space eviction module into the operating system as a kernel function module.
[0094] In some embodiments of the invention, the process number setting module 510 further includes: a requirement acquisition unit, configured to acquire the preset management requirement provided by the system administrator or an external management system.
[0095] The swap space eviction device provided in the embodiment of the present invention can execute the swap space eviction method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0096] Embodiment 7
[0097] Figure 7 It is a structural schematic diagram of an electronic device that implements the exchange space eviction method of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0098] like Figure 7As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0099] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0100] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the swap space eviction method.
[0101] In some embodiments, the swap space eviction method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the swap space eviction method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the method in any other suitable manner (e.g., by means of firmware).
[0102] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0103] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0104] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0105] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0106] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0107] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0108] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0109] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A swap space eviction method, characterized in that: Applied to a swap space eviction device, the device at least includes a process number setting module and a swap space eviction module, and the method includes: Calling a preset kernel file interface according to the process number setting module to obtain the process number of the swap space to be released; Determine the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module, and evict the target memory page from the swap space to the memory.
2. The method according to claim 1, characterized in that: The step of calling a preset kernel file interface according to the process number setting module to obtain the process number of the swap space to be released includes: Determine the process number of the swap space to be released according to preset management requirements; The process number setting module is controlled to call the preset kernel file interface to receive the process number.
3. The method according to claim 1, characterized in that: The step of determining the target memory page corresponding to the process number in the virtual memory area according to the swap space eviction module includes: Searching the process descriptor corresponding to the process number in the swap space eviction module, and extracting the region structure linked list of the virtual memory region from the process descriptor; The memory pages belonging to the swap space are traversed in the regional structure linked list as the target memory pages.
4. The method according to claim 3, characterized in that: The traversing the memory page belonging to the swap space in the regional structure linked list as the target memory page comprises: Traversing all page table addresses in the regional structure linked list; Determine in sequence whether the page table entry corresponding to the page table address is the swap space; If yes, the memory page corresponding to the page table entry is used as the target memory page; if no, continue to determine the next page table entry.
5. The method according to claim 1, characterized in that: The step of expelling the target memory page from the swap space to the memory includes: Calling a preset swapin_readahead function in the swap space eviction module to read the target memory page from the swap space into the memory; The target memory page of the memory is activated according to the swap space eviction module, and the swap space corresponding to the target memory page is released.
6. The method according to any one of claims 1 to 5, characterized in that: The device further includes a function loading module, and the method further includes: According to the function loading module, the process number setting module and the swap space eviction module are loaded into the operating system as a kernel function module.
7. The method according to claim 2, characterized in that: Also includes: The preset management requirement provided by the system administrator or the external management system is obtained in the process number setting module.
8. A swap space expulsion device, characterized in that: The device comprises: A process number setting module is used to call a preset kernel file interface to obtain the process number of the swap space to be released; The swap space eviction module is used to determine the target memory page corresponding to the process number in the virtual memory area, and evict the target memory page from the swap space to the memory.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the swap space eviction method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the swap space eviction method according to any one of claims 1 to 7 when executed.
