CN113377492A - Memory management method and device, electronic equipment and computer readable storage medium - Google Patents

Memory management method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113377492A
CN113377492A CN202010163765.2A CN202010163765A CN113377492A CN 113377492 A CN113377492 A CN 113377492A CN 202010163765 A CN202010163765 A CN 202010163765A CN 113377492 A CN113377492 A CN 113377492A
Authority
CN
China
Prior art keywords
memory resource
memory
preset
virtual machine
locking
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010163765.2A
Other languages
Chinese (zh)
Other versions
CN113377492B (en
Inventor
李伟男
龙欣
郑晓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010163765.2A priority Critical patent/CN113377492B/en
Publication of CN113377492A publication Critical patent/CN113377492A/en
Application granted granted Critical
Publication of CN113377492B publication Critical patent/CN113377492B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention discloses a memory management method, a memory management device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: determining a first memory resource locked in advance and a second memory resource locked in delay; executing a look-ahead locking operation on the first memory resource in response to a preset virtual machine operation being triggered; and responding to the completion of the operation of the preset virtual machine, releasing the first memory resource, and executing a delayed locking operation on the second memory resource. According to the technical scheme, even if large-capacity memory resources are used, the starting time of the virtual machine cannot be obviously increased, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of guaranteeing the running quality of the virtual machine.

Description

Memory management method and device, electronic equipment and computer readable storage medium
Technical Field
The embodiment of the invention relates to the technical field of resource management, in particular to a memory management method, a memory management device, electronic equipment and a computer readable storage medium.
Background
With the development of virtualization technology, because KVM (kernel-based virtual machine) virtualization cloud services implemented based on VFIO (virtual function input/output service, a user state drive framework) can provide a stable and efficient pass-through virtualization solution for users, the performance of the virtualization cloud services can be close to the use experience of a physical machine, and thus the applications of the virtualization cloud services are more and more extensive. However, with the rise of cloud computing and artificial intelligence, the demand for storage and computing resources is increasing, and the configuration of memory capacity is increasing day by day. When the memory resources based on VFIO are used for management, all the memory resources need to be locked first in the starting process of the virtual machine, obviously, when the memory capacity is small, the memory locking process only needs a few milliseconds, the influence on a user can be ignored, but with the increase of the memory capacity, the influence of the memory locking on the starting time of the virtual machine is increasingly increased, for example, for 384GB virtual machine memory configuration, the locking of a single memory resource consumes about 90 seconds, which seriously affects the operating efficiency and quality of the virtual machine.
Disclosure of Invention
The embodiment of the invention provides a memory management method, a memory management device, electronic equipment and a computer readable storage medium.
In a first aspect, an embodiment of the present invention provides a memory management method, which is applicable to a virtual machine.
Specifically, the memory management method includes:
determining a first memory resource locked in advance and a second memory resource locked in delay;
executing a look-ahead locking operation on the first memory resource in response to a preset virtual machine operation being triggered;
and responding to the completion of the operation of the preset virtual machine, releasing the first memory resource, and executing a delayed locking operation on the second memory resource.
With reference to the first aspect, in a first implementation manner of the first aspect, a sum of the first memory resource and the second memory resource is a sum of resources of memory resources of the virtual machine, where the first memory resource is a necessary memory resource required when the virtual machine is started.
With reference to the first aspect and the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the performing a delayed locking operation on the second memory resource is implemented as:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; or, in response to the first memory resource being released, performing a fractional locking operation on the second memory resource, and when the locked portion meets a corresponding preset release condition, releasing the locked portion of the second memory resource until all the second memory resources are locked and released.
With reference to the first aspect, the first implementation manner of the first aspect, and the second implementation manner of the first aspect, in a third implementation manner of the first aspect, the executing an advance locking operation on the first memory resource in response to the preset virtual machine operation being triggered is implemented as:
responding to the triggering of the preset virtual machine operation, and acquiring a memory configuration table;
and setting the attribute of the first memory resource as available in the memory configuration table, setting the attribute of the second memory resource as reserved, and executing advanced locking operation on the first memory resource with the attribute as available.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, and the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the performing a delayed locking operation on the second memory resource is implemented as:
in response to the first memory resource being released, performing a locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the second memory resource as available, and releasing the second memory resource when the locked second memory resource meets a preset release condition; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the locked part as available, and releasing the locked part of the second memory resource when the locked part meets the corresponding preset release condition until the locking and releasing of all the second memory resources are completed.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, and the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect, in response to the preset virtual machine operation being triggered, the performing an advanced locking operation on the first memory resource is implemented as:
and responding to the triggering of the operation of the preset virtual machine, loading a preset driver so that the preset driver occupies the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, the fourth implementation manner of the first aspect, and the fifth implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the performing a delayed locking operation on the second memory resource is implemented as:
in response to the first memory resource being released, executing a release operation on a second memory resource occupied by the preset drive, so that the second memory resource which is released from being occupied is locked, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on the second memory resource occupied by the preset drive so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, the fourth implementation manner of the first aspect, the fifth implementation manner of the first aspect, and the sixth implementation manner of the first aspect, in a seventh implementation manner of the first aspect, the performing an advanced locking operation on the first memory resource in response to the preset virtual machine operation being triggered includes:
and responding to the triggering of the operation of the preset virtual machine, starting a preset system level application to enable the preset system level application to occupy the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource, wherein the priority of the preset system level application is higher than that of the relevant application when the virtual machine is started.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, the fourth implementation manner of the first aspect, the fifth implementation manner of the first aspect, the sixth implementation manner of the first aspect, and the seventh implementation manner of the first aspect, in an eighth implementation manner of the first aspect, the performing a delayed locking operation on the second memory resource is implemented as:
in response to the first memory resource being released, performing a release operation on a second memory resource occupied by the preset system-level application, so that the second memory resource which is released from being occupied is subjected to a locking operation, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on a second memory resource occupied by the preset system-level application so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
In a second aspect, an embodiment of the present disclosure provides a memory management apparatus, which is suitable for a virtual machine.
Specifically, the memory management device includes:
a determining module configured to determine an anticipatory locked first memory resource and a delayed locked second memory resource;
a first locking module configured to perform an anticipatory locking operation on the first memory resource in response to a preset virtual machine operation being triggered;
and the second locking module is configured to release the first memory resource and execute a delayed locking operation on the second memory resource in response to the completion of the preset virtual machine operation.
With reference to the second aspect, in a first implementation manner of the second aspect, a sum of the first memory resource and the second memory resource is a sum of resources of memory resources of the virtual machine, where the first memory resource is a necessary memory resource required when the virtual machine is started.
With reference to the second aspect and the first implementation manner of the second aspect, in a second implementation manner of the second aspect, the second locking module is configured to:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; or, in response to the first memory resource being released, performing a fractional locking operation on the second memory resource, and when the locked portion meets a corresponding preset release condition, releasing the locked portion of the second memory resource until all the second memory resources are locked and released.
With reference to the second aspect, the first implementation manner of the second aspect, and the second implementation manner of the second aspect, in a third implementation manner of the second aspect, the first locking module is configured to:
responding to the triggering of the preset virtual machine operation, and acquiring a memory configuration table;
and setting the attribute of the first memory resource as available in the memory configuration table, setting the attribute of the second memory resource as reserved, and executing advanced locking operation on the first memory resource with the attribute as available.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, and the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect, the second locking module is configured to:
in response to the first memory resource being released, performing a locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the second memory resource as available, and releasing the second memory resource when the locked second memory resource meets a preset release condition; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the locked part as available, and releasing the locked part of the second memory resource when the locked part meets the corresponding preset release condition until the locking and releasing of all the second memory resources are completed.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, and the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect, the first locking module is configured to:
and responding to the triggering of the operation of the preset virtual machine, loading a preset driver so that the preset driver occupies the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, the fourth implementation manner of the second aspect, and the fifth implementation manner of the second aspect, in a sixth implementation manner of the second aspect, the second locking module is configured to:
in response to the first memory resource being released, executing a release operation on a second memory resource occupied by the preset drive, so that the second memory resource which is released from being occupied is locked, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on the second memory resource occupied by the preset drive so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, the fourth implementation manner of the second aspect, the fifth implementation manner of the second aspect, and the sixth implementation manner of the second aspect, in a seventh implementation manner of the second aspect, the first locking module is configured to:
and responding to the triggering of the operation of the preset virtual machine, starting a preset system level application to enable the preset system level application to occupy the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource, wherein the priority of the preset system level application is higher than that of the relevant application when the virtual machine is started.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, the fourth implementation manner of the second aspect, the fifth implementation manner of the second aspect, the sixth implementation manner of the second aspect, and the seventh implementation manner of the second aspect, in an eighth implementation manner of the second aspect, the second locking module is configured to:
in response to the first memory resource being released, performing a release operation on a second memory resource occupied by the preset system-level application, so that the second memory resource which is released from being occupied is subjected to a locking operation, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on a second memory resource occupied by the preset system-level application so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a storage and a processor, where the storage is configured to store one or more computer instructions that support a memory management apparatus to execute the memory management method, and the processor is configured to execute the computer instructions stored in the storage. The memory management device may further include a communication interface for the memory management device to communicate with other devices or a communication network.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium for storing computer instructions for a memory management device, where the computer instructions include computer instructions for executing the memory management method to be a memory management device.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
according to the technical scheme, the memory resources of the virtual machine are divided into the first memory resource locked in advance and the second memory resource locked in a delayed mode, the first memory resource is locked in advance when the operation of the preset virtual machine is triggered, the first memory resource is released after the operation of the preset virtual machine is completed, and the delayed locking operation is executed on the second memory resource. According to the technical scheme, even if large-capacity memory resources are used, the starting time of the virtual machine cannot be obviously increased, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of guaranteeing the running quality of the virtual machine.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of embodiments of the invention.
Drawings
Other features, objects and advantages of embodiments of the invention will become more apparent from the following detailed description of non-limiting embodiments thereof, when taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 is a flow chart illustrating a memory management method according to an embodiment of the invention;
fig. 2A is a schematic view of an application scenario of a memory management method according to the prior art;
fig. 2B is a schematic view of an application scenario of a memory management method according to an embodiment of the disclosure;
fig. 3 is a block diagram illustrating a memory management device according to an embodiment of the present invention;
FIG. 4 shows a block diagram of an electronic device according to an embodiment of the invention;
fig. 5 is a schematic structural diagram of a computer system suitable for implementing a memory management method according to an embodiment of the present invention.
Detailed Description
Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. Also, for the sake of clarity, parts not relevant to the description of the exemplary embodiments are omitted in the drawings.
In the embodiments of the present invention, it is to be understood that terms such as "including" or "having", etc., are intended to indicate the presence of the features, numbers, steps, actions, components, parts, or combinations thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, actions, components, parts, or combinations thereof may be present or added.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict. Embodiments of the present invention will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
According to the technical scheme provided by the embodiment of the invention, the memory resources of the virtual machine are divided into the first memory resource which is locked in advance and the second memory resource which is locked in a delayed mode, the first memory resource is locked in advance when the operation of the preset virtual machine is triggered, the first memory resource is released after the operation of the preset virtual machine is finished, and the delayed locking operation is executed on the second memory resource. According to the technical scheme, even if large-capacity memory resources are used, the starting time of the virtual machine cannot be obviously increased, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of guaranteeing the running quality of the virtual machine.
Fig. 1 shows a flowchart of a memory management method according to an embodiment of the present invention, which is applicable to a virtual machine, and as shown in fig. 1, the memory management method includes the following steps S101 to S103:
in step S101, a first memory resource to be locked in advance and a second memory resource to be locked in delay are determined;
in step S102, in response to a preset virtual machine operation being triggered, performing a look-ahead locking operation on the first memory resource;
in step S103, in response to the completion of the operation of the preset virtual machine, the first memory resource is released, and a delayed locking operation is performed on the second memory resource.
As mentioned above, with the development of virtualization technology, because the KVM virtualization cloud service implemented based on the VFIO can provide a stable and efficient pass-through virtualization solution for the user, the performance of the KVM virtualization cloud service can be close to the use experience of a physical machine, and thus the application of the KVM virtualization cloud service is more and more extensive. However, with the rise of cloud computing and artificial intelligence, the demand for storage and computing resources is increasing, and the configuration of memory capacity is increasing day by day. When the memory resources based on VFIO are used for management, all the memory resources need to be locked first in the starting process of the virtual machine, obviously, when the memory capacity is small, the memory locking process only needs a few milliseconds, the influence on a user can be ignored, but with the increase of the memory capacity, the influence of the memory locking on the starting time of the virtual machine is increasingly increased, for example, for 384GB virtual machine memory configuration, the locking of a single memory resource consumes about 90 seconds, which seriously affects the operating efficiency and quality of the virtual machine.
Based on the above problems, it is considered that there is hysteresis in actual access to the memory resources by the end user during use, that is, the virtual machine is started from the boot to the system, then to the service or application start, and finally to the system load reaching a peak value, which is a relatively long time process. Therefore, in this embodiment, a staged memory management method is provided, in which a memory resource of a virtual machine is divided into a first memory resource locked in advance and a second memory resource locked in a delayed manner, the first memory resource is locked in advance when a preset virtual machine operation is triggered, the first memory resource is released after the preset virtual machine operation is completed, and the delayed locking operation is performed on the second memory resource. Therefore, the starting time of the virtual machine can be greatly shortened on the premise of ensuring that the normal use of a user is not influenced, the starting time of the virtual machine cannot be obviously increased even for large-capacity memory resources, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of ensuring the running quality of the virtual machine.
In an embodiment of the present invention, the first memory resource refers to a necessary memory resource required when the virtual machine is started, for example, a resource required in a system boot of the virtual machine, a configuration of a service or an application environment related to the virtual machine, a service related to the virtual machine, or an application initialization stage; and the second memory resource refers to the memory resource left after the first memory resource is removed. The sum of the first memory resource and the second memory resource is a resource sum of memory resources of the virtual machine, and the first memory resource and the second memory resource respectively account for a preset proportion of the memory resource sum of the virtual machine, for example, the first memory resource accounts for 20% of the memory resource sum of the virtual machine, and the second memory resource accounts for 80% of the memory resource sum of the virtual machine.
In an embodiment of the present invention, the preset virtual machine operation refers to a virtual machine starting operation capable of triggering locking of a memory resource, for example, the preset virtual machine operation may be a virtual machine starting operation, a virtual machine system initialization operation, a service/application/driver application operation on the memory resource, and the like.
In an embodiment of the present invention, the delayed locking refers to an operation of locking the second memory resource after a preset time after the first memory resource is locked in advance. That is, the first memory resource is locked first, the second memory resource is locked again, and the time between two locking operations, i.e. the length of the preset time, is related to the sum of the time for completing the operation of the preset virtual machine and the time for completing the release of the first memory resource.
That is, in this embodiment, after the preset virtual machine operation is triggered, the locking operation is not performed on all memory resources as in the prior art, but a first memory resource necessary when the virtual machine is started is locked first, and then after the preset virtual machine operation is completed, the first memory resource that is locked previously is released, so that the memory resource that has been already locked and released can be used normally, and then the locking operation is performed on the remaining second memory resource. Therefore, the starting time of the virtual machine with large-capacity memory resources can be greatly reduced, the normal use of the virtual machine after starting is ensured, and the influence of the locking process of the memory resources on the use of the user is greatly reduced. When the preset virtual machine operation is a virtual machine starting operation, based on the above technical solution, since the second memory resource is locked after the virtual machine is started, and only the necessary first memory resource is locked before, and the proportion of the first memory resource to the total memory resource of the virtual machine is usually smaller than the proportion of the second memory resource to the total memory resource of the virtual machine, the starting time of the virtual machine can be greatly shortened, for example, for the 384GB virtual machine memory configuration, the scheme in the prior art is adopted, and the locking of the memory resource will consume about 90 seconds of starting time, and by adopting the above technical solution of the present disclosure, 10% of the 384GB, that is, the memory resource of 38G is set as the first memory resource locking, and the remaining 90%, that is, the memory resource of 346G is locked before the virtual machine is started, the start-up time of the virtual machine can be shortened to 9 seconds, i.e. 81 seconds is saved.
In an embodiment of the present invention, the step of performing the delayed locking operation on the second memory resource in step S103 may be implemented as:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; or, in response to the first memory resource being released, performing a fractional locking operation on the second memory resource, and when the locked portion meets a corresponding preset release condition, releasing the locked portion of the second memory resource until all the second memory resources are locked and released.
In this embodiment, when the first memory resource is unlocked and released and the delayed locking operation is performed on the second memory resource, the second memory resource may be locked once and then released once, that is, in response to the first memory resource being released, the locking operation is performed on all the second memory resources, and when the second memory resource meets a preset release condition, the locked all the second memory resources are released once. The second memory resource may also be gradually and periodically locked and gradually released, that is, in response to the first memory resource being released, the second memory resource is partially locked, and when the locked portion meets the corresponding preset release condition, the locked portion of the second memory resource is released until all the second memory resources are locked and released. For example, if the second memory resource is divided into three parts to perform locking respectively, after the first memory resource is released, first performing locking on the part 1 of the second memory resource, where both the released first memory resource and the parts 2 and 3 of the second memory resource that are not locked can be used; after the part 1 of the second memory resource is unlocked and released, locking the part 2 of the second memory resource, wherein the released part 1 of the first memory resource and the second memory resource and the part 3 of the second memory resource which is not locked can be used; after the part 2 of the second memory resource is unlocked and released, locking the part 3 of the second memory resource, wherein the released first memory resource, the part 1 and the part 2 of the second memory resource can be used; after the part 3 of the second memory resource is unlocked and released, all the memory resources can be used at this time. The gradual and staged locking and the gradual and staged releasing of the second memory resource can further reduce the influence on the use of the memory resource and further improve the running quality of the virtual machine.
The preset release condition may be, for example, that a lock time expires, a previously locked memory resource is released, a preset virtual machine operation is triggered, and the like, and a person skilled in the art may set a specific release condition according to a need of an actual application, which is not specifically limited by the present disclosure.
In practical applications, the first memory resource and the second memory resource may be divided and the memory resources may be locked step by step in a plurality of manners, for example, a manner of managing a memory configuration table, a manner of loading a preset driver, a manner of starting a preset system-level application, and the like, and then the foregoing manners are explained and explained respectively.
In an embodiment of the present invention, the step S102, executed in response to the preset virtual machine operation being triggered, of executing an advance locking operation on the first memory resource, may be implemented as:
responding to the triggering of the preset virtual machine operation, and acquiring a memory configuration table;
and setting the attribute of the first memory resource as available in the memory configuration table, setting the attribute of the second memory resource as reserved, and executing advanced locking operation on the first memory resource with the attribute as available.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by managing the memory configuration table. Specifically, when the preset virtual machine operation is triggered, such as system initialization, a memory configuration table, such as an E820 table, is obtained; then, by modifying the memory configuration table, setting the attribute of the first memory resource with a predetermined proportion as available in the memory configuration table, that is, the memory resource with the available attribute can be normally locked and released according to the process of starting the virtual machine; and simultaneously reserving a part of memory resources, namely setting the attribute of the second memory resource with a predetermined proportion as reservation, wherein the reserved part of memory resources are unavailable at present, so that the locking cannot be carried out according to the process of starting the virtual machine, and thus, the operations of carrying out advanced locking on the first memory resource with the available attribute and carrying out delayed locking on the second memory resource with the reserved attribute are realized.
In this embodiment, the step of performing the delayed locking operation on the second memory resource in step S103 may be implemented as:
in response to the first memory resource being released, performing a locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the second memory resource as available, and releasing the second memory resource when the locked second memory resource meets a preset release condition; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing step-by-step locking operation on the second memory resource, informing the memory configuration table to set the attribute of the locked part as available, and releasing the locked part of the second memory resource when the locked part meets the corresponding preset release condition until the locking and releasing of all the second memory resources are completed.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of managing a memory configuration table, similar to the above description, there are two embodiments for the delayed locking operation performed on the second memory resource, i.e., performing locking operation and releasing operation on the second memory resource once, specifically, after the first memory resource is released, then performing locking operation on the second memory resource, and notifying the memory configuration table to modify the attribute of the second memory resource to be usable, and when the locked second memory resource meets a preset release condition, performing releasing operation on the second memory resource once. II, secondly: performing stepwise locking and stepwise releasing step by step on the second memory resource, specifically, after the first memory resource is released, performing fractional locking on the second memory resource, notifying the memory configuration table to modify the attribute of the locked portion to be usable, and when the locked portion meets the corresponding preset release condition, releasing the locked portion of the second memory resource until all the locking and releasing of the second memory resource are completed, for example, dividing the second memory resource into three portions to respectively perform locking, when the first memory resource is released, first performing locking on the portion 1 of the second memory resource, notifying the memory configuration table to modify the attribute of the portion 1 to be usable, and after the portion 1 of the second memory resource is unlocked and released, performing locking on the portion 2 of the second memory resource, and informing the memory configuration table to modify the attribute of the part 2 to be usable, similarly, after the part 2 of the second memory resource is unlocked and released, locking the part 3 of the second memory resource, and then informing the memory configuration table to modify the attribute of the part 3 to be usable.
In another embodiment of the present invention, the step S102, executed by the first memory resource, of executing an advance locking operation in response to the preset virtual machine operation being triggered, may be implemented as:
and responding to the triggering of the operation of the preset virtual machine, loading a preset driver so that the preset driver occupies the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by loading a preset driver. Specifically, when the operation of the preset virtual machine is triggered, for example, when a system is initialized, or before a user service, an application, or a driver applies for a memory resource, a preset driver is loaded in advance to preempt a predetermined proportion of the second memory resource, so that the virtual machine performs a preemptive locking operation on the remaining first memory resource, and the preempted second memory resource is reserved until the first memory resource is released. The preset drive may be, for example, a virtio-balloon drive.
In this embodiment, the step of performing the delayed locking operation on the second memory resource in step S103 may be implemented as:
in response to the first memory resource being released, executing a release operation on a second memory resource occupied by the preset drive, so that the second memory resource which is released from being occupied is locked, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on the second memory resource occupied by the preset drive so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of loading a preset driver, similar to the above description, there are two implementation manners for performing a delayed locking operation on the second memory resource, i.e., performing a one-time locking operation and a one-time releasing operation on the second memory resource, and specifically, after the first memory resource is released, performing a release occupation operation on all the second memory resources occupied by the preset driver, so that the second memory resources that are released from occupation can be locked and, when the second memory resources satisfy a preset release condition, all the second memory resources are released. II, secondly: performing stepwise locking and stepwise releasing step by step on the second memory resource, specifically, after the first memory resource is released, performing a partial occupation removing operation on the second memory resource occupied by the preset drive, so that an occupation removing part is subjected to a locking operation, and when the occupation removing part meets a corresponding preset releasing condition, releasing the occupation removing part until all the second memory resources are locked and released, for example, as an example above, dividing the second memory resource into three parts to respectively perform locking, when the first memory resource is released, first removing occupation on a part 1 of the second memory resource, performing locking on a part 1 removed from occupation, and after the part 1 of the second memory resource is unlocked and released, removing occupation on a part 2 of the second memory resource, and locking the unoccupied part 2, similarly, after the part 2 of the second memory resource is unlocked and released, then the part 3 of the second memory resource is unoccupied, and locking the unoccupied part 3.
In another embodiment of the present invention, the step S102, namely the step of executing the preemptive locking operation on the first memory resource in response to the preset virtual machine operation being triggered, may be implemented as:
and responding to the triggering of the operation of the preset virtual machine, starting a preset system level application to enable the preset system level application to occupy the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource, wherein the priority of the preset system level application is higher than that of the relevant application when the virtual machine is started.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by starting a preset system-level application. Specifically, when the operation of the preset virtual machine is triggered, for example, before a user service, an application, or a driver applies for a memory resource, a preset system-level application is started, so that the preset system-level application can occupy a predetermined proportion of the second memory resource in advance, and perform a preemptive locking operation on the remaining unoccupied first memory resource, it should be noted that the priority of the preset system-level application should be higher than the priority of the relevant application when the virtual machine is started, so as to achieve preemption of the memory resource.
In this embodiment, the step of performing the delayed locking operation on the second memory resource in step S103 may be implemented as:
in response to the first memory resource being released, performing a release operation on a second memory resource occupied by the preset system-level application, so that the second memory resource which is released from being occupied is subjected to a locking operation, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on a second memory resource occupied by the preset system-level application so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of starting a preset system-level application, similar to the above description, there are two implementation manners for performing a delayed locking operation on the second memory resource, that is, performing a one-time locking operation and a one-time releasing operation on the second memory resource, specifically, after the first memory resource is released, notifying the preset system-level application to perform an occupation removing operation on the occupied second memory resource, so that the occupied second memory resource is locked and the occupied second memory resource is released once when the second memory resource meets a preset releasing condition. II, secondly: performing stepwise locking and stepwise releasing of the second memory resource, specifically, after the first memory resource is released, notifying the preset system-level application to perform fractional deallocation on of the second memory resource, so that the deallocated portion is continuously locked, and when the deallocated portion meets a corresponding preset release condition, releasing the deallocated portion until all locking and releasing of the second memory resource are completed, for example, still taking the above example as an example, dividing the second memory resource into three portions to respectively perform locking, after the first memory resource is released, first notifying the preset system-level application to deallocate a portion 1 of the second memory resource, performing locking on the portion 1 of the deallocated portion, and after the portion 1 of the second memory resource is unlocked and released, and similarly, after the part 2 of the second memory resource is unlocked and released, the preset system-level application is notified to release the occupation of the part 3 of the second memory resource, and the part 3 of the second memory resource is locked.
Fig. 2A is a schematic view of an application scenario of a memory management method according to the prior art, and fig. 2B is a schematic view of an application scenario of a memory management method according to an embodiment of the present disclosure, in the application scenario, the operation of the preset virtual machine is a virtual machine system initialization operation, as shown in fig. 2A, in the prior art, after a virtual machine is started and enters a system initialization process, all memory resources need to be locked, after the system initialization is completed, the memory resources can be released, then initialization of user services/applications/drivers and operation of the user services/applications/drivers can be started, and for 384GB of virtual machine memory configuration, the locking of the memory resources will consume about 90 seconds of start time. As shown in fig. 2B, in the present disclosure, a 10% portion of the memory resources is used as the first memory resource that is locked in advance, and a 90% portion of the memory resources is used as the second memory resource that is locked in a delayed manner. When the virtual machine is started and enters a system initialization process, the first memory resource part is locked first, after the system initialization is completed, the first memory resource which is locked previously is released, the initialization and the operation of the user service/application/driver and the subsection delay locking of the second memory resource are started at the same time, along with the operation of the user service/application/driver, the actual occupation amount of the memory resources slowly reaches the peak value, and the locking of the second memory resource is also completed in the process. Therefore, the starting time of the virtual machine is greatly shortened under the condition that the normal use of a user is not influenced, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of ensuring the running quality of the virtual machine. For the memory configuration of the virtual machine of 384GB, by adopting the above technical solution of the present disclosure, 10% of the memory resources in 384GB, that is, 38G, are set as the first memory resources to be locked first, and the remaining 90% of the memory resources, that is, 346G, are locked after the virtual machine is started, so that the start time of the virtual machine can be shortened to 9 seconds, that is, the time of 81 seconds is saved.
The following are embodiments of the apparatus of the present invention that may be used to perform embodiments of the method of the present invention.
Fig. 3 is a block diagram illustrating a memory management apparatus according to an embodiment of the present invention, which may be implemented as part or all of an electronic device, and may be implemented as a virtual machine, through software, hardware, or a combination of the two. As shown in fig. 3, the memory management device includes:
a determining module 301 configured to determine a first memory resource locked in advance and a second memory resource locked in delay;
a first locking module 302 configured to perform an advance locking operation on the first memory resource in response to a preset virtual machine operation being triggered;
a second locking module 303, configured to release the first memory resource and perform a delayed locking operation on the second memory resource in response to the preset virtual machine operation being completed.
As mentioned above, with the development of virtualization technology, because the KVM virtualization cloud service implemented based on the VFIO can provide a stable and efficient pass-through virtualization solution for the user, the performance of the KVM virtualization cloud service can be close to the use experience of a physical machine, and thus the application of the KVM virtualization cloud service is more and more extensive. However, with the rise of cloud computing and artificial intelligence, the demand for storage and computing resources is increasing, and the configuration of memory capacity is increasing day by day. When the memory resources based on VFIO are used for management, all the memory resources need to be locked first in the starting process of the virtual machine, obviously, when the memory capacity is small, the memory locking process only needs a few milliseconds, the influence on a user can be ignored, but with the increase of the memory capacity, the influence of the memory locking on the starting time of the virtual machine is increasingly increased, for example, for 384GB virtual machine memory configuration, the locking of a single memory resource consumes about 90 seconds, which seriously affects the operating efficiency and quality of the virtual machine.
Based on the above problems, it is considered that there is hysteresis in actual access to the memory resources by the end user during use, that is, the virtual machine is started from the boot to the system, then to the service or application start, and finally to the system load reaching a peak value, which is a relatively long time process. Therefore, in this embodiment, a staged memory management device is provided, in which a memory resource of a virtual machine is divided into a first memory resource locked in advance and a second memory resource locked in a delayed manner, the first memory resource is locked in advance when a preset virtual machine operation is triggered, the first memory resource is released after the preset virtual machine operation is completed, and the delayed locking operation is performed on the second memory resource. Therefore, the starting time of the virtual machine can be greatly shortened on the premise of ensuring that the normal use of a user is not influenced, the starting time of the virtual machine cannot be obviously increased even for large-capacity memory resources, and the starting speed and the running efficiency of the virtual machine can be improved on the premise of ensuring the running quality of the virtual machine.
In an embodiment of the present invention, the first memory resource refers to a necessary memory resource required when the virtual machine is started, for example, a resource required in a system boot of the virtual machine, a configuration of a service or an application environment related to the virtual machine, a service related to the virtual machine, or an application initialization stage; and the second memory resource refers to the memory resource left after the first memory resource is removed. The sum of the first memory resource and the second memory resource is a resource sum of memory resources of the virtual machine, and the first memory resource and the second memory resource respectively account for a preset proportion of the memory resource sum of the virtual machine, for example, the first memory resource accounts for 20% of the memory resource sum of the virtual machine, and the second memory resource accounts for 80% of the memory resource sum of the virtual machine.
In an embodiment of the present invention, the preset virtual machine operation refers to a virtual machine starting operation capable of triggering locking of a memory resource, for example, the preset virtual machine operation may be a virtual machine starting operation, a virtual machine system initialization operation, a service/application/driver application operation on the memory resource, and the like.
In an embodiment of the present invention, the delayed locking refers to an operation of locking the second memory resource after a preset time after the first memory resource is locked in advance. That is, the first memory resource is locked first, the second memory resource is locked again, and the time between two locking operations, i.e. the length of the preset time, is related to the sum of the time for completing the operation of the preset virtual machine and the time for completing the release of the first memory resource.
That is, in this embodiment, after the preset virtual machine operation is triggered, the locking operation is not performed on all memory resources as in the prior art, but a first memory resource necessary when the virtual machine is started is locked first, and then after the preset virtual machine operation is completed, the first memory resource that is locked previously is released, so that the memory resource that has been already locked and released can be used normally, and then the locking operation is performed on the remaining second memory resource. Therefore, the starting time of the virtual machine with large-capacity memory resources can be greatly reduced, the normal use of the virtual machine after starting is ensured, and the influence of the locking process of the memory resources on the use of the user is greatly reduced. When the preset virtual machine operation is a virtual machine starting operation, based on the above technical solution, since the second memory resource is locked after the virtual machine is started, and only the necessary first memory resource is locked before, and the proportion of the first memory resource to the total memory resource of the virtual machine is usually smaller than the proportion of the second memory resource to the total memory resource of the virtual machine, the starting time of the virtual machine can be greatly shortened, for example, for the 384GB virtual machine memory configuration, the scheme in the prior art is adopted, and the locking of the memory resource will consume about 90 seconds of starting time, and by adopting the above technical solution of the present disclosure, 10% of the 384GB, that is, the memory resource of 38G is set as the first memory resource locking, and the remaining 90%, that is, the memory resource of 346G is locked before the virtual machine is started, the start-up time of the virtual machine can be shortened to 9 seconds, i.e. 81 seconds is saved.
In an embodiment of the present invention, the second locking module 303 may be configured to:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; or, in response to the first memory resource being released, performing a fractional locking operation on the second memory resource, and when the locked portion meets a corresponding preset release condition, releasing the locked portion of the second memory resource until all the second memory resources are locked and released.
In this embodiment, when the first memory resource is unlocked and released and the delayed locking operation is performed on the second memory resource, the second memory resource may be locked once and then released once, that is, in response to the first memory resource being released, the locking operation is performed on all the second memory resources, and when the second memory resource meets a preset release condition, the locked all the second memory resources are released once. The second memory resource may also be gradually and periodically locked and gradually released, that is, in response to the first memory resource being released, the second memory resource is partially locked, and when the locked portion meets the corresponding preset release condition, the locked portion of the second memory resource is released until all the second memory resources are locked and released. For example, if the second memory resource is divided into three parts to perform locking respectively, after the first memory resource is released, first performing locking on the part 1 of the second memory resource, where both the released first memory resource and the parts 2 and 3 of the second memory resource that are not locked can be used; after the part 1 of the second memory resource is unlocked and released, locking the part 2 of the second memory resource, wherein the released part 1 of the first memory resource and the second memory resource and the part 3 of the second memory resource which is not locked can be used; after the part 2 of the second memory resource is unlocked and released, locking the part 3 of the second memory resource, wherein the released first memory resource, the part 1 and the part 2 of the second memory resource can be used; after the part 3 of the second memory resource is unlocked and released, all the memory resources can be used at this time. The gradual and staged locking and the gradual and staged releasing of the second memory resource can further reduce the influence on the use of the memory resource and further improve the running quality of the virtual machine.
The preset release condition may be, for example, that a lock time expires, a previously locked memory resource is released, a preset virtual machine operation is triggered, and the like, and a person skilled in the art may set a specific release condition according to a need of an actual application, which is not specifically limited by the present disclosure.
In practical applications, the first memory resource and the second memory resource may be divided and the memory resources may be locked step by step in a plurality of manners, for example, a manner of managing a memory configuration table, a manner of loading a preset driver, a manner of starting a preset system-level application, and the like, and then the foregoing manners are explained and explained respectively.
In an embodiment of the present invention, the first locking module 302 may be configured to:
responding to the triggering of the preset virtual machine operation, and acquiring a memory configuration table;
and setting the attribute of the first memory resource as available in the memory configuration table, setting the attribute of the second memory resource as reserved, and executing advanced locking operation on the first memory resource with the attribute as available.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by managing the memory configuration table. Specifically, when the preset virtual machine operation is triggered, such as system initialization, a memory configuration table, such as an E820 table, is obtained; then, by modifying the memory configuration table, setting the attribute of the first memory resource with a predetermined proportion as available in the memory configuration table, that is, the memory resource with the available attribute can be normally locked and released according to the process of starting the virtual machine; and simultaneously reserving a part of memory resources, namely setting the attribute of the second memory resource with a predetermined proportion as reservation, wherein the reserved part of memory resources are unavailable at present, so that the locking cannot be carried out according to the process of starting the virtual machine, and thus, the operations of carrying out advanced locking on the first memory resource with the available attribute and carrying out delayed locking on the second memory resource with the reserved attribute are realized.
In this embodiment, the second locking module 303 may be configured to:
in response to the first memory resource being released, performing a locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the second memory resource as available, and releasing the second memory resource when the locked second memory resource meets a preset release condition; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing step-by-step locking operation on the second memory resource, informing the memory configuration table to set the attribute of the locked part as available, and releasing the locked part of the second memory resource when the locked part meets the corresponding preset release condition until the locking and releasing of all the second memory resources are completed.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of managing a memory configuration table, similar to the above description, there are two embodiments for the delayed locking operation performed on the second memory resource, i.e., performing locking operation and releasing operation on the second memory resource once, specifically, after the first memory resource is released, then performing locking operation on the second memory resource, and notifying the memory configuration table to modify the attribute of the second memory resource to be usable, and when the locked second memory resource meets a preset release condition, performing releasing operation on the second memory resource once. II, secondly: performing stepwise locking and stepwise releasing step by step on the second memory resource, specifically, after the first memory resource is released, performing fractional locking on the second memory resource, notifying the memory configuration table to modify the attribute of the locked portion to be usable, and when the locked portion meets the corresponding preset release condition, releasing the locked portion of the second memory resource until all the locking and releasing of the second memory resource are completed, for example, dividing the second memory resource into three portions to respectively perform locking, when the first memory resource is released, first performing locking on the portion 1 of the second memory resource, notifying the memory configuration table to modify the attribute of the portion 1 to be usable, and after the portion 1 of the second memory resource is unlocked and released, performing locking on the portion 2 of the second memory resource, and informing the memory configuration table to modify the attribute of the part 2 to be usable, similarly, after the part 2 of the second memory resource is unlocked and released, locking the part 3 of the second memory resource, and then informing the memory configuration table to modify the attribute of the part 3 to be usable.
In another embodiment of the present invention, the first locking module 302 may be configured to:
and responding to the triggering of the operation of the preset virtual machine, loading a preset driver so that the preset driver occupies the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by loading a preset driver. Specifically, when the operation of the preset virtual machine is triggered, for example, when a system is initialized, or before a user service, an application, or a driver applies for a memory resource, a preset driver is loaded in advance to preempt a predetermined proportion of the second memory resource, so that the virtual machine performs a preemptive locking operation on the remaining first memory resource, and the preempted second memory resource is reserved until the first memory resource is released. The preset drive may be, for example, a virtio-balloon drive.
In this embodiment, the second locking module 303 may be configured to:
in response to the first memory resource being released, executing a release operation on a second memory resource occupied by the preset drive, so that the second memory resource which is released from being occupied is locked, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on the second memory resource occupied by the preset drive so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of loading a preset driver, similar to the above description, there are two implementation manners for performing a delayed locking operation on the second memory resource, i.e., performing a one-time locking operation and a one-time releasing operation on the second memory resource, and specifically, after the first memory resource is released, performing a release occupation operation on all the second memory resources occupied by the preset driver, so that the second memory resources that are released from occupation can be locked and, when the second memory resources satisfy a preset release condition, all the second memory resources are released. II, secondly: performing stepwise locking and stepwise releasing step by step on the second memory resource, specifically, after the first memory resource is released, performing a partial occupation removing operation on the second memory resource occupied by the preset drive, so that an occupation removing part is subjected to a locking operation, and when the occupation removing part meets a corresponding preset releasing condition, releasing the occupation removing part until all the second memory resources are locked and released, for example, as an example above, dividing the second memory resource into three parts to respectively perform locking, when the first memory resource is released, first removing occupation on a part 1 of the second memory resource, performing locking on a part 1 removed from occupation, and after the part 1 of the second memory resource is unlocked and released, removing occupation on a part 2 of the second memory resource, and locking the unoccupied part 2, similarly, after the part 2 of the second memory resource is unlocked and released, then the part 3 of the second memory resource is unoccupied, and locking the unoccupied part 3.
In yet another embodiment of the present invention, the first locking module 302 may be configured to:
and responding to the triggering of the operation of the preset virtual machine, starting a preset system level application to enable the preset system level application to occupy the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource, wherein the priority of the preset system level application is higher than that of the relevant application when the virtual machine is started.
In this embodiment, the first memory resource and the second memory resource are divided and the memory resources are locked step by starting a preset system-level application. Specifically, when the operation of the preset virtual machine is triggered, for example, before a user service, an application, or a driver applies for a memory resource, a preset system-level application is started, so that the preset system-level application can occupy a predetermined proportion of the second memory resource in advance, and perform a preemptive locking operation on the remaining unoccupied first memory resource, it should be noted that the priority of the preset system-level application should be higher than the priority of the relevant application when the virtual machine is started, so as to achieve preemption of the memory resource.
In this embodiment, the second locking module 303 may be configured to:
in response to the first memory resource being released, performing a release operation on a second memory resource occupied by the preset system-level application, so that the second memory resource which is released from being occupied is subjected to a locking operation, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on a second memory resource occupied by the preset system-level application so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
When the first memory resource and the second memory resource are divided and the memory resources are locked step by step in a manner of starting a preset system-level application, similar to the above description, there are two implementation manners for performing a delayed locking operation on the second memory resource, that is, performing a one-time locking operation and a one-time releasing operation on the second memory resource, specifically, after the first memory resource is released, notifying the preset system-level application to perform an occupation removing operation on the occupied second memory resource, so that the occupied second memory resource is locked and the occupied second memory resource is released once when the second memory resource meets a preset releasing condition. II, secondly: performing stepwise locking and stepwise releasing of the second memory resource, specifically, after the first memory resource is released, notifying the preset system-level application to perform fractional deallocation on of the second memory resource, so that the deallocated portion is continuously locked, and when the deallocated portion meets a corresponding preset release condition, releasing the deallocated portion until all locking and releasing of the second memory resource are completed, for example, still taking the above example as an example, dividing the second memory resource into three portions to respectively perform locking, after the first memory resource is released, first notifying the preset system-level application to deallocate a portion 1 of the second memory resource, performing locking on the portion 1 of the deallocated portion, and after the portion 1 of the second memory resource is unlocked and released, and similarly, after the part 2 of the second memory resource is unlocked and released, the preset system-level application is notified to release the occupation of the part 3 of the second memory resource, and the part 3 of the second memory resource is locked.
Fig. 4 is a block diagram illustrating a structure of an electronic device according to an embodiment of the present invention, and as shown in fig. 4, the electronic device 400 includes a memory 401 and a processor 402; wherein the content of the first and second substances,
the memory 401 is used to store one or more computer instructions, which are executed by the processor 402 to implement any of the method steps described above.
Fig. 5 is a schematic structural diagram of a computer system suitable for implementing a memory management method according to an embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a processing unit 501 that can execute various processes in the above-described embodiments according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the system 500 are also stored. The processing unit 501, the ROM502, and the RAM503 are connected to each other by a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary. The processing unit 501 may be implemented as a CPU, a GPU, a TPU, an FPGA, an NPU, or other processing units.
In particular, the above described method may be implemented as a computer software program according to an embodiment of the present invention. For example, embodiments of the present invention include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the memory management method. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation of the units or modules themselves.
As another aspect, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium may be a computer-readable storage medium included in the apparatus in the foregoing embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the embodiments of the present invention.
The foregoing description is only exemplary of the preferred embodiments of the invention and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention according to the embodiments of the present invention is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept. For example, the above features and (but not limited to) the features with similar functions disclosed in the embodiments of the present invention are mutually replaced to form the technical solution.

Claims (13)

1. A memory management method is suitable for a virtual machine and comprises the following steps:
determining a first memory resource locked in advance and a second memory resource locked in delay;
executing a look-ahead locking operation on the first memory resource in response to a preset virtual machine operation being triggered;
and responding to the completion of the operation of the preset virtual machine, releasing the first memory resource, and executing a delayed locking operation on the second memory resource.
2. The method of claim 1, wherein a sum of the first memory resource and the second memory resource is a sum of memory resources of the virtual machine, wherein the first memory resource is a necessary memory resource required when the virtual machine is started.
3. The method of claim 1 or 2, the performing a delayed lock operation on the second memory resource implemented as:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection locking operation on the second memory resource, and when the locking part meets a corresponding preset releasing condition, releasing the locking part of the second memory resource until the locking and releasing of all the second memory resources are completed.
4. The method of claim 3, said performing an anticipatory lock operation on the first memory resource in response to the default virtual machine operation being triggered is implemented as:
responding to the triggering of the preset virtual machine operation, and acquiring a memory configuration table;
and setting the attribute of the first memory resource as available in the memory configuration table, setting the attribute of the second memory resource as reserved, and executing advanced locking operation on the first memory resource with the attribute as available.
5. The method of claim 4, the performing a delayed lock operation on the second memory resource implemented as:
in response to the first memory resource being released, performing a locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the second memory resource as available, and releasing the second memory resource when the locked second memory resource meets a preset release condition; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection locking operation on the second memory resource, notifying the memory configuration table to set the attribute of the locked part as available, and releasing the locked part of the second memory resource when the locked part meets the corresponding preset release condition until the locking and releasing of all the second memory resources are completed.
6. The method of claim 3, said performing an anticipatory lock operation on the first memory resource in response to the default virtual machine operation being triggered is implemented as:
and responding to the triggering of the operation of the preset virtual machine, loading a preset driver so that the preset driver occupies the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource.
7. The method of claim 6, the performing a delayed lock operation on the second memory resource implemented as:
in response to the first memory resource being released, executing a release operation on a second memory resource occupied by the preset drive, so that the second memory resource which is released from being occupied is locked, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on the second memory resource occupied by the preset drive so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
8. The method of claim 3, the performing an anticipatory lock operation on the first memory resource in response to the default virtual machine operation being triggered, comprising:
and responding to the triggering of the operation of the preset virtual machine, starting a preset system level application to enable the preset system level application to occupy the second memory resource in advance, and executing advanced locking operation on the remaining first memory resource, wherein the priority of the preset system level application is higher than that of the relevant application when the virtual machine is started.
9. The method of claim 8, the performing a delayed lock operation on the second memory resource implemented as:
in response to the first memory resource being released, performing a release operation on a second memory resource occupied by the preset system-level application, so that the second memory resource which is released from being occupied is subjected to a locking operation, and when the second memory resource meets a preset release condition, releasing the second memory resource; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection unoccupied operation on a second memory resource occupied by the preset system-level application so as to enable an unoccupied part to be locked, and releasing the unoccupied part when the unoccupied part meets corresponding preset release conditions until all the second memory resources are locked and released.
10. A memory management device is suitable for a virtual machine and comprises:
a determining module configured to determine an anticipatory locked first memory resource and a delayed locked second memory resource;
a first locking module configured to perform an anticipatory locking operation on the first memory resource in response to a preset virtual machine operation being triggered;
and the second locking module is configured to release the first memory resource and execute a delayed locking operation on the second memory resource in response to the completion of the preset virtual machine operation.
11. The apparatus of claim 10, the second locking module configured to:
executing locking operation on the second memory resource in response to the first memory resource being released, and releasing the second memory resource when a preset release condition is met; alternatively, the first and second electrodes may be,
and in response to the first memory resource being released, executing a subsection locking operation on the second memory resource, and when the locking part meets a corresponding preset releasing condition, releasing the locking part of the second memory resource until the locking and releasing of all the second memory resources are completed.
12. An electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of any of claims 1-9.
13. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, carry out the method steps of any of claims 1-9.
CN202010163765.2A 2020-03-10 2020-03-10 Memory management method and device, electronic equipment and computer readable storage medium Active CN113377492B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010163765.2A CN113377492B (en) 2020-03-10 2020-03-10 Memory management method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010163765.2A CN113377492B (en) 2020-03-10 2020-03-10 Memory management method and device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN113377492A true CN113377492A (en) 2021-09-10
CN113377492B CN113377492B (en) 2022-05-24

Family

ID=77568833

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010163765.2A Active CN113377492B (en) 2020-03-10 2020-03-10 Memory management method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113377492B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030028695A1 (en) * 2001-05-07 2003-02-06 International Business Machines Corporation Producer/consumer locking system for efficient replication of file data
US20130326509A1 (en) * 2012-05-30 2013-12-05 Red Hat Israel, Ltd. Robust non-shareable resource access under live virtual machine cloning
US20160055017A1 (en) * 2014-08-23 2016-02-25 Vmware, Inc. Application publishing using memory state sharing
CN106716348A (en) * 2014-09-08 2017-05-24 Arm 有限公司 Shared resources in a data processing appartus for executing a plurality of threads
CN107045468A (en) * 2017-02-09 2017-08-15 郑州云海信息技术有限公司 A kind of virtual machine cluster system method for obligating resource and device
CN108205472A (en) * 2017-08-15 2018-06-26 珠海市魅族科技有限公司 Memory release method, release device, computer installation and readable storage medium storing program for executing
CN108984270A (en) * 2018-07-18 2018-12-11 郑州云海信息技术有限公司 A kind of memory allocation method and device of virtual machine

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030028695A1 (en) * 2001-05-07 2003-02-06 International Business Machines Corporation Producer/consumer locking system for efficient replication of file data
US20130326509A1 (en) * 2012-05-30 2013-12-05 Red Hat Israel, Ltd. Robust non-shareable resource access under live virtual machine cloning
US20160055017A1 (en) * 2014-08-23 2016-02-25 Vmware, Inc. Application publishing using memory state sharing
CN106716348A (en) * 2014-09-08 2017-05-24 Arm 有限公司 Shared resources in a data processing appartus for executing a plurality of threads
CN107045468A (en) * 2017-02-09 2017-08-15 郑州云海信息技术有限公司 A kind of virtual machine cluster system method for obligating resource and device
CN108205472A (en) * 2017-08-15 2018-06-26 珠海市魅族科技有限公司 Memory release method, release device, computer installation and readable storage medium storing program for executing
CN108984270A (en) * 2018-07-18 2018-12-11 郑州云海信息技术有限公司 A kind of memory allocation method and device of virtual machine

Also Published As

Publication number Publication date
CN113377492B (en) 2022-05-24

Similar Documents

Publication Publication Date Title
CN110647394B (en) Resource allocation method, device and equipment
CN111966500B (en) Resource scheduling method and device, electronic equipment and storage medium
US9069465B2 (en) Computer system, management method of computer resource and program
JP5510556B2 (en) Method and system for managing virtual machine storage space and physical hosts
US9319281B2 (en) Resource management method, resource management device, and program product
US10284637B2 (en) Minimizing service restart by optimally resizing service pools
CN109240825B (en) Elastic task scheduling method, device, equipment and computer readable storage medium
US20170017511A1 (en) Method for memory management in virtual machines, and corresponding system and computer program product
JP2012221273A (en) Method, system and program for dynamically assigning resource
CN110597614B (en) Resource adjustment method and device
CN111798113A (en) Resource allocation method, device, storage medium and electronic equipment
JP2508589B2 (en) Server operation method
US11726816B2 (en) Scheduling workloads on a common set of resources by multiple schedulers operating independently
CN110162397B (en) Resource allocation method, device and system
CN115357310A (en) System starting method and device, electronic equipment and storage medium
CN111857951A (en) Containerized deployment platform and deployment method
CN115904761A (en) System on chip, vehicle and video processing unit virtualization method
CN113254223B (en) Resource allocation method and system after system restart and related components
CN112860387A (en) Distributed task scheduling method and device, computer equipment and storage medium
CN113377492B (en) Memory management method and device, electronic equipment and computer readable storage medium
US20220027264A1 (en) Concurrent memory management in a computing system
CN117112222A (en) Request processing method and device, electronic equipment and storage medium
CN116157778A (en) System and method for hybrid centralized and distributed scheduling on shared physical hosts
CN112445569B (en) Deployment method, device, electronic equipment and storage medium
CN113687908A (en) PMEM virtual machine creation method, device, equipment and readable storage medium

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40059853

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230517

Address after: Room 1-2-A06, Yungu Park, No. 1008 Dengcai Street, Sandun Town, Xihu District, Hangzhou City, Zhejiang Province

Patentee after: Aliyun Computing Co.,Ltd.

Address before: Box 847, four, Grand Cayman capital, Cayman Islands, UK

Patentee before: ALIBABA GROUP HOLDING Ltd.