Method for updating cold and hot information, storage medium, and program product

CN115509679BActive Publication Date: 2026-08-11ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-11
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

然而,预留内存时不断被虚拟机使用的,即预留内存的冷热信息是不断更新的,更新过程同样需要持有冷热操作锁来保护冷热集合数据,若需要扫描的内存范围较大,会导致长期持有冷热操作锁

Benefits of technology

[0010]根据本申请实施例提供的方案,通过确定第一进程的内存操作针对的预留内存的物理地址,其中,所述内存操作的执行会导致所述预留内存的使用情况的变化,并导致冷热信息集合发生变更,所述冷热信息集合用于记录预留内存的冷热信息;并根据所述预留内存的物理地址,确定所述预留内存对应的冷热节点,所述冷热节点中包括冷热信息集合;若所述冷热节点的冷热操作锁被第二进程持有,则根据所述第一进程的内存操作对应的冷热信息更新操作,生成所述冷热信息更新操作对应的操作缓存对象,并将所述操作缓存对象无锁入队至缓存队列;由此,可以在第一进程不持有冷热节点的冷热操作锁时,根据冷热信息更新操作生成操作缓存对象,当所述第二进程释放所述冷热节点的冷热操作锁后,从所述缓存队列无锁出队操作缓存对象,并根据所述操作缓存对象执行对应的冷热信息更新操作,以实现冷热信息的异步更新,由此,通过增加缓存队列避免了第一进程和第二进程的锁竞争,并通过无锁入队和无锁出队,保证缓存队列不会引入新的锁竞争。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115509679B_ABST
    Figure CN115509679B_ABST
Patent Text Reader

Abstract

This application provides a method, storage medium, and program product for updating hot and cold information. The method for updating hot and cold information includes: determining the physical address of reserved memory targeted by a memory operation of a first process, wherein the execution of the memory operation causes a change in the usage of the reserved memory and a change in the set of hot and cold information; determining the hot and cold nodes corresponding to the reserved memory based on the physical address of the reserved memory, wherein the hot and cold nodes include a set of hot and cold information, which is used to record the hot and cold information of the reserved memory; if the hot and cold operation lock of the hot and cold node is held by a second process, generating an operation cache object corresponding to the hot and cold information update operation corresponding to the memory operation of the first process, and enqueuing the operation cache object into a cache queue without locking; when the second process releases the hot and cold operation lock of the hot and cold node, dequeuing the operation cache object from the cache queue without locking, and executing the corresponding hot and cold information update operation based on the operation cache object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, storage medium, and program product for updating hot and cold information. Background Technology

[0002] In the host machine memory allocation architecture of a virtualization scenario, a large portion of the host machine's memory is reserved for allocation to virtual machines. This reserved memory is unavailable to the host machine kernel, and the host machine kernel cannot directly determine the access status of this memory.

[0003] To obtain information on the access frequency and other characteristics of the reserved memory, it is necessary to periodically scan the reserved memory for access patterns.

[0004] Therefore, it is necessary to use a hot / cold operation lock to determine whether the reserved memory falls within the memory range to be scanned before proceeding with the scan. However, reserved memory is constantly used by the virtual machine, meaning its hot / cold information is continuously updated. This update process also requires holding a hot / cold operation lock to protect the hot / cold data set. If the memory range to be scanned is large, this can lead to holding the hot / cold operation lock for an extended period. If other virtual machine operation commands occur simultaneously, and these commands require updating the hot / cold operation set, these operations will be blocked. These operations often require rapid responses; otherwise, host machine operations may be stuck, resulting in a virtual freeze.

[0005] In view of this, the technical problem that the existing technology urgently needs to solve is how to provide an alternative solution for updating hot and cold information. Summary of the Invention

[0006] In view of this, embodiments of this application provide a method for updating hot and cold information to at least partially solve the above-mentioned problems.

[0007] According to a first aspect of the embodiments of this application, a method for updating hot and cold information is provided, comprising: determining the physical address of reserved memory targeted by a memory operation of a first process, wherein the execution of the memory operation causes a change in the usage of the reserved memory and causes a change in a set of hot and cold information, the set of hot and cold information being used to record the hot and cold information of the reserved memory; determining a hot and cold node corresponding to the reserved memory based on the physical address of the reserved memory, the hot and cold node including the set of hot and cold information; if the hot and cold operation lock of the hot and cold node is held by a second process, generating an operation cache object corresponding to the hot and cold information update operation corresponding to the memory operation of the first process, and enqueuing the operation cache object into a cache queue without lock; when the second process releases the hot and cold operation lock of the hot and cold node, dequeuing the operation cache object from the cache queue without lock, and performing a corresponding hot and cold information update operation based on the operation cache object.

[0008] According to a second aspect of the embodiments of this application, a computer storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the method described above.

[0009] According to a third aspect of the embodiments of this application, a computer program product is provided, including computer instructions that instruct a computing device to perform an operation corresponding to the method described above.

[0010] According to the solution provided in the embodiments of this application, the physical address of the reserved memory targeted by the memory operation of the first process is determined. The execution of the memory operation causes a change in the usage of the reserved memory and a change in the hot / cold information set, which records the hot / cold information of the reserved memory. Based on the physical address of the reserved memory, the hot / cold nodes corresponding to the reserved memory are determined, and the hot / cold nodes include the hot / cold information set. If the hot / cold operation lock of the hot / cold node is held by the second process, then a hot / cold information update operation is generated based on the hot / cold information update operation corresponding to the memory operation of the first process. The corresponding operation cache object is created and enqueued to the cache queue without lock. Thus, when the first process does not hold the cold and hot operation lock of the cold and hot node, the operation cache object is generated according to the cold and hot information update operation. When the second process releases the cold and hot operation lock of the cold and hot node, the operation cache object is dequeued from the cache queue without lock and the corresponding cold and hot information update operation is executed according to the operation cache object to realize the asynchronous update of cold and hot information. Thus, by adding the cache queue, lock contention between the first process and the second process is avoided, and by enqueuing and dequeuing without lock, it is ensured that the cache queue will not introduce new lock contention. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.

[0012] Figure 1 This application provides a schematic diagram of the structure of a host machine according to an embodiment of the present application.

[0013] Figure 2 A flowchart illustrating a method for updating hot and cold information provided in an embodiment of this application;

[0014] Figure 3 This application provides a schematic diagram of the structure of a host machine according to an embodiment of the present application.

[0015] Figure 4 A flowchart illustrating a method for updating hot and cold information provided in an embodiment of this application;

[0016] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0017] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.

[0018] To illustrate the solution provided in this embodiment in more detail, the usage scenarios in this application will be described below as examples.

[0019] Figure 1 The diagram shows the structure of a host machine. As shown, a host machine can run multiple virtual machines VM1, VM2, ... VMn, and multiple applications can run in each virtual machine.

[0020] The host machine's memory can be divided into two categories based on the user: memory used by the host itself and reserved memory for virtual machines. To ensure the normal operation of virtual machines, the host machine typically allocates a preset amount of reserved memory from its main memory. This reserved memory is exclusively for the use of virtual machines and cannot be used by the host itself. When a new virtual machine is created on the host machine, a portion of the reserved memory can be allocated for the newly created virtual machine.

[0021] During the process of running a virtual machine on the host machine, it is necessary to continuously allocate reserved memory for new virtual machine processes, and release or update the reserved memory corresponding to the virtual machine processes. For this purpose, the host machine needs to know the hot and cold information of the reserved memory in a timely manner.

[0022] However, the host machine cannot use reserved memory. Therefore, the applicant provides a hot / cold memory management structure, which can include multiple nodes to record the hot / cold information of reserved memory. However, to obtain timely information on the hot / cold status of reserved memory, it is necessary to scan the reserved memory and update it in the hot / cold memory management structure.

[0023] However, to ensure accurate scanning and updates, the scanning process requires holding cold and hot operation locks; similarly, the process of allocating or releasing reserved memory for virtual machines also requires timely synchronization of the reserved memory's cold and hot information to the cold and hot memory management structure, which also requires holding cold and hot operation locks. This can lead to lock conflicts during the scanning process and the allocation or release of reserved memory for virtual machines. If the cold and hot operation locks are held for a long time during the scanning process, it may cause the tasks of allocating or releasing reserved memory for virtual machines to be blocked for an extended period. These blocked tasks will directly affect the user experience and may even cause the host machine to appear to freeze.

[0024] Therefore, this application provides a method for updating hot and cold information, which can update hot and cold information while minimizing lock conflicts.

[0025] Figure 2 This is a flowchart illustrating a method for updating hot and cold information according to an embodiment of this application. The steps provided in this embodiment can be executed by the host machine shown in the figure above, as shown in the figure, and include:

[0026] S201. Determine the physical address of the reserved memory targeted by the memory operation of the first process.

[0027] The execution of the memory operation will cause changes in the usage of the reserved memory and result in a change in the hot and cold information set, which is used to record the hot and cold information of the reserved memory.

[0028] Reserved memory is memory that can be allocated to virtual machines, which are services or processes deployed on the host machine through virtualization technology.

[0029] In this embodiment, the physical memory in the host machine can be divided into two categories: one part is the memory used by the host machine, and the other part is reserved memory for virtual machines. The host machine can determine the memory addresses it can use and designate the memory outside of its own usable memory as reserved memory.

[0030] In this embodiment, the hot / cold status of reserved memory indicates the access status of reserved memory. Data written to reserved memory can be understood as high access frequency, and vice versa. Generally, the host machine allocates reserved memory at a certain granularity, for example, slicing reserved memory into 2MB granularities and allocating reserved memory to virtual machines in multiples of 2MB. In this embodiment, hot / cold information can also be determined at the same granularity.

[0031] The memory operations of the first process can specifically include memory release operations, memory allocation requests, etc. The execution of memory operations will cause changes in the usage of reserved memory. For example, some reserved memory may be released, meaning there is no corresponding virtual machine process, or some previously unallocated reserved memory may be allocated to virtual machine processes. Changes in the usage of reserved memory will further cause changes in the set of hot and cold information used to record the hot and cold information of reserved memory.

[0032] S202. Based on the physical address of the reserved memory, determine the hot and cold nodes corresponding to the reserved memory, wherein the hot and cold nodes include a set of hot and cold information.

[0033] Specifically, see Figure 3 The diagram illustrates the structure of a host machine. Multiple virtual machines (VM1, VM2, etc.) can be deployed on the host machine, and the host kernel can maintain a hot and cold memory management structure. This structure includes hot and cold aging information for determining the reserved memory allocated to virtual machines. Specifically, the hot and cold memory management structure can include multiple hot and cold nodes and various control fields for the overall aging function.

[0034] The aging function's various control fields can include, for example, fields controlling whether the entire hot and cold scanning function is enabled, statistical information, and a cache pool for frequently used structures that are repeatedly allocated and released; each node can include multiple hot and cold aging data sets. After each update to the data in a node, the various control fields of the aging function can be updated.

[0035] A single hot / cold node can correspond to one or more virtual machines, and a single virtual machine can correspond to one or more hot / cold nodes. This embodiment does not impose any limitations on this. Generally, the program holds hot / cold operation locks for hot / cold nodes. If a memory operation targets a physical address of reserved memory that belongs to multiple hot / cold nodes, then the solution provided in this embodiment will be executed for all multiple hot / cold nodes.

[0036] See Figure 3 Taking node0 and node1 as examples, each node can include multiple sets of hot and cold information. The sets of hot and cold information can be divided into four categories: inactive (cold), active (hot), paused (temporarily not participating in scanning), or pinned (permanently not participating in scanning), corresponding to four states of memory. Of course, this embodiment only uses these four states as examples and is not intended to limit this application.

[0037] Each set of hot and cold information can include multiple hot and cold items, which can be sorted by time, so that the set of hot and cold information accumulated over time can characterize the aging of memory.

[0038] Each hot / cold item can include the physical address (idx) of the allocated reserved memory and the size of the allocated reserved memory, as well as next to indicate the next hot / cold item and the PID of the virtual machine process to which the allocated reserved memory belongs.

[0039] S203. If the cold and hot operation lock of the cold and hot node is held by the second process, then according to the cold and hot information update operation corresponding to the memory operation of the first process, an operation cache object corresponding to the cold and hot information update operation is generated, and the operation cache object is enqueued into the cache queue without lock.

[0040] In this embodiment, the second process can have a smaller impact on the user's experience, while the first process can have a greater impact. Specifically, the first process is a foreground process, and the second process is a background process.

[0041] It should be noted that there can be multiple first processes, meaning that multiple virtual machine processes may be performing memory operations simultaneously. Therefore, there may be multiple operation cache objects that need to be enqueued into the cache queue at the same time. To avoid the introduction of a cache queue leading to new lock contention, this embodiment adopts a lock-free enqueue and lock-free dequeue structure for the cache queue.

[0042] In this embodiment, before step S203, the method may further include performing memory operations of the first process.

[0043] If the cold / hot operation lock for the aforementioned cold / hot nodes is held by the second process, it indicates that the first operation does not hold the cold / hot operation lock. In this case, the cold / hot information update operation corresponding to the memory operation can be identified and recorded, but the corresponding cold / hot information update operation is not executed. The recorded cold / hot information update operation corresponding to the memory operation can be used to generate an operation cache object, and the operation cache object can be enqueued to the cache queue without lock. For specific methods of lock-free enqueuing, please refer to relevant technologies, which will not be elaborated here.

[0044] In addition, if the first process can successfully hold the cold and hot operation lock, it can directly execute the cold and hot information update operation corresponding to the memory operation.

[0045] S204. After the second process releases the cold and hot operation lock of the cold and hot node, it dequeues the operation cache object from the cache queue without lock and performs the corresponding cold and hot information update operation according to the operation cache object.

[0046] In this embodiment, the lock-free dequeue method can be referred to relevant technologies, and will not be described in detail here.

[0047] After the cached object is dequeued from the cache queue without lock, the relevant content of the operation can be updated according to the hot and cold information recorded in the cached object. The hot and cold information update operation can continue to be executed through the first process, the second process, or a third process other than the first and second processes. For specific execution methods, please refer to relevant technologies, which will not be elaborated here.

[0048] The solution provided in this embodiment determines the physical address of the reserved memory targeted by the memory operation of the first process, wherein the execution of the memory operation causes a change in the hot / cold status of the reserved memory; and determines the hot / cold nodes corresponding to the reserved memory based on the physical address of the reserved memory, wherein the hot / cold nodes include a hot / cold information set, which is used to record the hot / cold information of the reserved memory; if the hot / cold operation lock of the hot / cold node is held by the second process, then an operation cache corresponding to the hot / cold information update operation corresponding to the memory operation of the first process is generated. The operation cache object is enqueued without lock into the cache queue. Thus, when the first process does not hold the cold and hot operation lock of the cold and hot node, the operation cache object can be generated according to the cold and hot information update operation. When the second process releases the cold and hot operation lock of the cold and hot node, the operation cache object is dequeued from the cache queue without lock, and the corresponding cold and hot information update operation is executed according to the operation cache object to realize the asynchronous update of cold and hot information. Thus, by adding a cache queue, lock contention between the first process and the second process is avoided, and by enqueuing and dequeuing without lock, it is ensured that the cache queue will not introduce new lock contention.

[0049] Specifically, see Figure 4 The diagram shows a flowchart of a hot / cold information update method provided in this embodiment. The hot / cold information update method is executed by a first process and a second process in parallel. The first process is used to perform memory operations, and the second process is used to scan and update hot / cold information. There can be multiple first processes, and this embodiment does not limit this.

[0050] See Figure 4 The operations performed by the first process include:

[0051] S401. Determine the reserved memory to be used for memory operations;

[0052] In this embodiment, the reserved memory of a specified size can be determined first based on the memory operation. The reserved memory of a specified size can be a single segment of reserved memory or multiple segments of non-contiguous reserved memory. The reserved memory can correspond to one hot or cold node or multiple hot or cold nodes.

[0053] Optionally, in any embodiment of this application, if the memory operation of the first process is a reserved memory allocation operation, then step S401 above can specifically be performing a memory allocation operation to determine the reserved memory of a specified size allocated to the virtual machine. If the memory operation of the first process is a reserved memory release operation, then step S401 above can specifically be performing a reserved memory release operation to determine the reserved memory of a specified size released by the virtual machine. If the memory operation of the first process is a virtual machine hot update operation, then step S401 above can specifically be performing a virtual machine hot update to determine the reserved memory of the virtual machine process that needs to be updated.

[0054] S402. Determine the hot and cold nodes corresponding to the reserved memory.

[0055] S403, Request the hot / cold operation lock for the hot / cold nodes.

[0056] If the operation lock is not acquired, it indicates that the hot / cold node is performing a hot / cold scan, or that another process performing memory operations is holding the hot / cold operation lock, and proceed to step S404; otherwise, if the node is not currently performing a mutual exclusion operation, the memory operation of the first process continues to be executed, and the hot / cold operation lock is released after execution to complete the current process.

[0057] If there is an operation cache object in the cache queue, then after the first process releases the cold and hot operation lock, the second process can request the cold and hot operation lock and continue to execute the steps of dequeuing the operation cache object from the cache queue without lock and performing the corresponding cold and hot information update operation according to the operation cache object.

[0058] If the reserved memory in step S402 corresponds to multiple hot and cold nodes, then in this step, when continuing to execute the memory operation of the first process, it can be determined that the reserved memory targeted by the memory operation corresponds to a portion of the current hot and cold nodes.

[0059] S404. If the cold and hot operation lock of the cold and hot node is held by the second process, then an operation cache object corresponding to the cold and hot information update operation is generated according to the cold and hot information update operation corresponding to the memory operation of the first process.

[0060] Specifically, an operation cache object can include the cache operation type, version number, and other fields that record operation information. When generating an operation cache object, considering that cache operations may occur frequently, a new resource pool for operation cache objects is added to reduce the overhead of allocation and release. Each time a new operation cache object is added, it is first allocated from the resource pool. If the resource pool is insufficient, it is then allocated from the host machine's system memory. The response information is then filled into the corresponding operation cache object. After that, a lock-free pairing is performed to add the operation cache object to the cache operation queue.

[0061] S405. Enqueue the operation cache object into the cache queue without locking.

[0062] At this point, the first process is complete.

[0063] See Figure 4 The operations performed by the second process include:

[0064] S406. Obtain a cold / hot operation lock for a cold / hot node that requires a cold / hot information scan.

[0065] S407. Scan the cold and hot information in the reserved memory corresponding to the cold and hot nodes, and update the cold and hot information set according to the scan results.

[0066] It should be noted that if the second process is used to scan the page table corresponding to the set of hot and cold information of the hot and cold nodes, the method further includes: if the second process scans the page table corresponding to the second reserved memory, then exit the scanning operation and release the hot and cold operation lock of the hot and cold node, and execute the lock-free dequeue operation cache object from the cache queue, and execute the corresponding hot and cold information update operation through the first process based on the operation cache object.

[0067] It should be noted that if the cold and hot information update operation corresponding to the reserved memory release operation has not been executed, that is, the release information has not been updated to the cold and hot information set, when the second process performs the scanning operation, if the released page table is scanned, the query will fail and the scanning can be automatically exited. The process will then proceed to execute the lock-free dequeue operation of the cache object from the cache queue, and the first process will perform the corresponding cold and hot information update operation according to the operation cache object to update the cold and hot information corresponding to the memory release operation in a timely manner.

[0068] S408. Determine whether the scan of this node has ended.

[0069] If the process is not completed, proceed to step S407; if it is completed, proceed to step S409.

[0070] S409. Dequeue the cached object from the cache queue without locking and perform the corresponding memory operation.

[0071] After the memory operations corresponding to the operation cache objects in the cache queue are executed, continue to execute step S410.

[0072] The dashed lines in the diagram represent the association between the first and second processes through a cache queue.

[0073] Optionally, in any embodiment of this application, if the memory operation of the first process is a reserved memory allocation operation, then the first process performs a corresponding hot and cold information update operation based on the operation cache object, including: determining the first reserved memory belonging to the hot and cold nodes whose hot and cold operation locks have been released among the reserved memory allocated by the reserved memory allocation operation; scanning the hot and cold information of the determined first reserved memory; and updating the hot and cold information to the hot and cold information set of the hot and cold nodes.

[0074] Optionally, in any embodiment of this application, if the memory operation of the first process is a reserved memory release operation, then the first process performs a corresponding hot and cold information update operation based on the operation cache object, including: determining the second reserved memory belonging to the hot and cold nodes whose hot and cold operation locks were released in the reserved memory released by the reserved memory release operation; and deleting the hot and cold information corresponding to the second reserved memory from the hot and cold information set of the hot and cold nodes.

[0075] Optionally, in any embodiment of this application, if the memory operation of the first process is a virtual machine hot update operation, then the step of performing the corresponding hot and cold information update operation by the first process according to the operation cache object includes: determining the third reserved memory belonging to the hot and cold node of the hot and cold operation lock being updated in the reserved memory being updated; and updating the hot and cold information corresponding to the third reserved memory in the hot and cold information set of the hot and cold node.

[0076] Optionally, in any embodiment of this application, the hot / cold information set includes multiple hot / cold items. Each hot / cold item includes the physical address of the reserved memory, the size of the reserved memory, and the virtual machine process to which the reserved memory belongs. Updating the hot / cold information set corresponding to the third reserved memory includes updating the virtual machine process in the hot / cold item corresponding to the hot upgrade process. Of course, in other implementations of this application, the hot / cold information may not store virtual machine processes, in which case updating the virtual machine processes in the hot / cold information is unnecessary.

[0077] Optionally, in any embodiment of this application, the second process is used to scan the page table corresponding to the cold and hot information sets of the cold and hot nodes. The method further includes: before the second process holds the cold and hot operation lock of the cold and hot nodes, executing the step of dequeuing the operation cache object from the cache queue without locking, and having the first process execute the corresponding cold and hot information update operation based on the operation cache object. Therefore, it can be ensured that operations left over due to lock contention are executed before the second process scans.

[0078] S410. Determine whether the hot and cold information updates for all nodes have ended. If not, continue to step S406; otherwise, complete the current process.

[0079] Optionally, in any embodiment of this application, the cache queue corresponds one-to-one with the hot and cold nodes. Therefore, after scanning a hot or cold node and releasing the hot / cold operation lock of that node, the cache queue corresponding to that node can be dequeued without locking to perform the corresponding hot / cold information update operation. This ensures that the hot / cold information operations occurring during the scanning period are updated in a timely manner and do not cause confusion with other hot / cold nodes.

[0080] This completes the synchronous or asynchronous update of all hot and cold information.

[0081] The method for updating hot and cold information in this embodiment can be executed by any suitable electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs.

[0082] Reference Figure 5 The diagram shows a structural schematic of an electronic device provided in an embodiment of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device.

[0083] like Figure 5 As shown, the electronic device may include: a processor 502, a communications interface 504, a memory 506, and a communications bus 508.

[0084] in:

[0085] The processor 502, communication interface 504, and memory 506 communicate with each other via communication bus 508.

[0086] Communication interface 504 is used to communicate with other electronic devices or servers.

[0087] The processor 502 is used to execute program 510, specifically the relevant steps in the above-described method embodiment for updating hot and cold information.

[0088] Specifically, program 510 may include program code that includes computer operation instructions.

[0089] Processor 502 may be a CPU, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The smart device may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.

[0090] Memory 506 is used to store program 510. Memory 506 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0091] The specific implementation of each step in program 510 can be found in the corresponding steps and units described in the above-described embodiment of the method for updating hot and cold information, and will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding process descriptions in the aforementioned method embodiments, and will not be repeated here.

[0092] This application also provides a computer program product, including computer instructions that instruct a computing device to perform an operation corresponding to any of the above-described methods for updating hot and cold information.

[0093] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.

[0094] The methods described in the embodiments of this application can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code downloaded over a network that is originally stored in a remote recording medium or a non-transitory machine-readable medium and will be stored in a local recording medium. Thus, the methods described herein can be stored on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA) for such software processing. It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the method for updating hot and cold information described herein. Furthermore, when a general-purpose computer accesses code for implementing the method for updating hot and cold information shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for executing the method for updating hot and cold information shown herein.

[0095] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.

[0096] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.

Claims

1. A method for updating hot / cold information, comprising: The physical address of the reserved memory targeted by the memory operation of the first process is determined. The execution of the memory operation will cause a change in the usage of the reserved memory and a change in the hot and cold information set. The hot and cold information set is used to record the hot and cold information of the reserved memory. The hot and cold information set includes multiple hot and cold items. The hot and cold items include the physical address of the reserved memory, the size of the reserved memory, and the virtual machine process to which the reserved memory belongs. Based on the physical address of the reserved memory, the cold and hot nodes corresponding to the reserved memory are determined. The cold and hot nodes include a set of cold and hot information. The cold and hot nodes are nodes in the cold and hot memory management structure used to record the cold and hot information of the reserved memory. The cold and hot memory management structure includes multiple cold and hot nodes. Request the cold / hot operation lock for the aforementioned cold / hot nodes; If the request fails and the cold and hot operation lock of the cold and hot node is held by the second process, then according to the cold and hot information update operation corresponding to the memory operation of the first process, an operation cache object corresponding to the cold and hot information update operation is generated, and the operation cache object is enqueued into the cache queue without lock. After the second process releases the hot and cold operation lock of the hot and cold node, it dequeues the operation cache object from the cache queue without lock and performs the corresponding hot and cold information update operation according to the operation cache object.

2. The method according to claim 1, wherein, The memory operations of the first process include: reserved memory allocation operations; The step of performing the corresponding hot / cold information update operation based on the operation cache object includes: Determine the first reserved memory belonging to the cold and hot nodes whose cold and hot operation locks have been released from the reserved memory allocated during the reserved memory allocation operation. Scan the determined hot and cold information of the first reserved memory and update the hot and cold information to the hot and cold information set of the hot and cold nodes.

3. The method according to claim 1, wherein, The memory operations of the first process include: reserved memory release operations; The step of performing the corresponding hot / cold information update operation based on the operation cache object includes: Determine the second reserved memory belonging to the cold and hot nodes of the released cold and hot operation lock among the reserved memory released by the reserved memory release operation; Delete the cold and hot information corresponding to the second reserved memory from the cold and hot information set of the cold and hot nodes.

4. The method according to claim 3, wherein, The second process is used to scan the page table corresponding to the set of hot and cold information of the hot and cold nodes, and the method further includes: If the second process scans the page table corresponding to the second reserved memory, it exits the scanning operation and releases the cold and hot operation lock of the cold and hot node, and executes the steps of dequeuing the operation cache object from the cache queue without lock, and performing the corresponding cold and hot information update operation according to the operation cache object.

5. The method according to claim 1, wherein, The memory operations of the first process include: virtual machine hot update operations; The step of performing the corresponding hot / cold information update operation based on the operation cache object includes: The third reserved memory that belongs to the cold and hot nodes of the updated cold and hot operation lock is identified in the reserved memory to be updated. Update the cold and hot information in the cold and hot information set of the cold and hot nodes that corresponds to the third reserved memory.

6. The method according to claim 5, wherein, The updating of the cold and hot information set of the cold and hot nodes corresponding to the cold and hot information of the third reserved memory includes: Update the virtual machine process in the cold / hot item corresponding to the hot upgrade process in the cold / hot information set.

7. The method according to claim 1, wherein, The first process is a foreground process, and the second process is a background process.

8. The method according to claim 7, wherein, The second process is used to scan the page table corresponding to the set of hot and cold information of the hot and cold nodes, and the method further includes: Before the second process holds the cold and hot operation lock of the cold and hot node, the steps of dequeuing the operation cache object from the cache queue without lock and performing the corresponding cold and hot information update operation according to the operation cache object are executed.

9. The method according to claim 1, wherein, The cache queue corresponds one-to-one with the hot and cold nodes.

10. A computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any one of claims 1-9.

11. A computer program product comprising computer instructions that instruct a computing device to perform the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Method and device for obtaining object-level memory access behavior

    CN102609254A

  • Concurrent lockless queue implementation method and device and storage medium

    CN110888727A