Managing memory

Embodiments of the present disclosure provide a method and apparatus for managing memory. Embodiments of the present disclosure, is related to a method and apparatus for managing memory, comprising: monitoring usage status of memory in a first computer device so as to determine available addresses; mapping at least one part of the available addresses to externally accessible shared addresses; and managing the shared addresses on the basis of a memory table so that the at least one part of the available addresses are accessible to a second computer device via the shared addresses, wherein the memory is connected to a dual in-line memory module interface of the first computer device.

RELATED APPLICATION

This Application claims priority from Provisional Application Serial No. CN201310750628.9 filed on Dec. 26, 2013 entitled “METHOD AND APPARATUS FOR MANAGING MEMORY,” the content and teachings of which are hereby incorporated by reference in their entirety.

FIELD OF INVENTION

Various embodiments of the present disclosure relate to resource management, and more specifically, for managing memory.

BACKGROUND

With the development of computer hardware techniques, there have been advancements made in various types of communication interfaces and storage media, and these techniques provide a hardware basis for achieving higher-speed memory access. With the development of computer software techniques and high-speed network techniques, resource sharing can be achieved across a plurality of computer devices. Increasing the efficiency of resource sharing has become a focus of attention.

Memory resources can be shared between a plurality of computer devices. There may be levels of memory on the basis of difference in access speed. For example, a computer device may have multiple levels of memory, such as cache, internal memory and hard disk. Since these memories have different hardware features and access speed, their sharing policies also differ.

Sharing of memory devices like hard disks has been achieved. However, due to limitations of memory's access speed and transmission efficiency between the memory and the central processing unit (CPU) of a computer device, efficiently sharing memory between a plurality of computer devices poses a challenge. Various embodiments of the present disclosure focuses on how to achieve memory sharing, and thus reference made to the memory throughout the context of the present disclosure refers to the memory in a computer device.

In an existing cluster environment typically each computer device (e.g. server) in the cluster has its own memory. Since the memory size is a critical factor affecting the computer device's data processing capability, to cause the computer device to have higher data processing capability, usually a large-capacity memory is configured in the computer device. While running a different application, the computer device often requires support of different amounts of memory, and therefore needs for memory vary considerably between the peak value and the valley value.

When the computer device executes a large application, shortage of memory resources might occur; when the computer device is lightly loaded, however, a number of memory resources may be free. The memory (e.g. Random Access Memory (RAM)) is still at a high price, so it is desired to share memory between a plurality of computer devices so as to increase the utilization efficiency of memory and further reduce the cost.

SUMMARY

Therefore, there exists a need to develop a technical solution for managing memory, that can support memory sharing between a plurality of computer devices, and implement the technical solution without changing existing configuration of computer devices in a cluster environment.

In one embodiment of the present disclosure, there is provided a method for managing memory that includes monitoring usage status of memory in a first computer device so as to determine available addresses; mapping at least one part of the available addresses to externally accessible shared addresses; and managing the shared addresses on the basis of a memory table so that the at least one part of the available addresses are accessible to a second computer device via the shared addresses, wherein the memory is connected/coupled to a dual in-line memory module interface of the first computer device.

In one embodiment of the present disclosure, the mapping at least one part of the available addresses to the externally accessible shared addresses includes registering at least one part of the available addresses to a network adapter of the first computer device; and obtaining a shared address corresponding to the at least one part of the available addresses on the basis of configuration of the network adapter.

In one embodiment of the present disclosure, there is provided a method for managing memory including in response to a memory shortage occurring in a second computer device, requesting memory from a first computer device, wherein the memory is a memory in accordance with the present disclosure.

In one embodiment of the present disclosure, there is releasing the memory in response to the second computer device completing using the memory.

In one embodiment of the present disclosure there is provided an apparatus for managing memory that includes a monitoring module configured to monitor usage status of memory in a first computer device so as to determine available addresses; a mapping module configured to map at least one part of the available addresses to externally accessible shared addresses; and a managing module configured to manage the shared addresses on the basis of a memory table so that the at least one part of the available addresses are accessible to a second computer device via the shared addresses, wherein the memory is connected/coupled to a dual in-line memory module interface of the first computer device.

In one embodiment of the present disclosure the mapping module includes a registering module configured to register at least one part of the available addresses to a network adapter of the first computer device; and an obtaining module configured to obtain a shared address corresponding to the at least one part of the available addresses on the basis of configuration of the network adapter.

In one embodiment of the present disclosure, there is provided an apparatus for managing memory that includes a requesting module configured to, in response to a memory shortage occurring in a second computer device, request memory from a first computer device, wherein the memory is a memory in accordance with the present disclosure.

In one embodiment of the present invention, there is a releasing module configured to release the memory in response to the second computer device completing using the memory. Each of the separate modules disclosed above may be combined into a single module to perform the task method disclosed above.

By means of the methods and apparatuses as described in the present disclosure, a technical solution for managing memory can be provided, which can support memory sharing between a plurality of computer devices so as to utilize free memory resources in a lightly loaded computer device and reduce the hardware cost of the computer device while increasing the resource utilization efficiency.

DETAILED DESCRIPTION

FIG. 1illustrates an exemplary computer system100that is capable of implementing embodiments of the present disclosure. As illustrated inFIG. 1, the computer system100may include: CPU (Central Process Unit)101, RAM (Random Access Memory)102, ROM (Read Only Memory)103, System Bus104, Hard Drive Controller105, Keyboard Controller106, Serial Interface Controller107, Parallel Interface Controller108, Display Controller109, Hard Drive110, Keyboard111, Serial Peripheral Equipment112, Parallel Peripheral Equipment113and Display114. Among above devices, CPU101, RAM102, ROM103, Hard Drive Controller105, Keyboard Controller106, Serial Interface Controller107, Parallel Interface Controller108and Display Controller109are coupled to the System Bus104. Hard Drive110is coupled to Hard Drive Controller105. Keyboard111is coupled to Keyboard Controller106. Serial Peripheral Equipment112is coupled to Serial Interface Controller107. Parallel Peripheral Equipment113is coupled to Parallel Interface Controller108. And, Display114is coupled to Display Controller109. It should be understood that the structure as illustrated inFIG. 1is only for the exemplary purpose rather than to be construed as a limitation to the embodiments of the present disclosure. In some cases, some devices may be added to or removed from the computer system100based on specific situations.

FIG. 2schematically illustrates an exemplary architecture diagram200of memory connection relationships according to one embodiment of the present disclosure. As shown inFIG. 2, a CPU210is connected to memory (e.g. RAM250) through a dual in-line memory module (DIMM) interface. DIMM offers a 64-bit data channel and thus provides high speed data access. In addition, CPU210may further be connected to a north bridge220and a south bridge230, and flash memory (e.g. flash memory252and254) may be connected to north bridge220and south bridge230respectively. North bridge220and south bridge230may transmit data between CPU210and flash memory252/254. Those skilled in the art should understand CPU's210access speed to flash memory252/254is not as good as its access speed to RAM250, and there is a considerable difference.

Note although flash memory252and254can expand the capacity of memory available to CPU to some extent, due to limitations with self data transmission speed and time latency of north bridge220and south bridge230, CPU's210access speed to flash memory252and254is not considered to be satisfactory enough.

Embodiments of the present disclosure as shown inFIG. 2have certain disadvantages. On the one hand, although CPU210can access RAM250via DIMM240at high speed, as RAM250is priced highly and its capacity is rather limited, installing large-capacity RAM on the computer device may not be handy. On the other hand, although flash memory252and254is relatively cheap and has large capacity, as the access speed of CPU210to the flash memory via north bridge220and south bridge230is rather satisfactory, the flash memory fails to provide strong support in expanding the memory capacity.

Therefore, it is a need to provide a technical solution for managing memory in a computer device more effectively, and also provide free memory space for usage by other computer device while expanding the memory capacity of the computer device.

To this end, various embodiments of the present disclosure provide a method and apparatus for managing memory. Specifically,FIG. 3schematically shows an architecture diagram300of memory connection relationships according to one embodiment of the present disclosure. As shown inFIG. 3, architecture diagram300differs from architecture diagram200inFIG. 2in besides RAM250, further connecting flash memory356to DIMM240.

Thereby, CPU210can access RAM250and/or flash memory356via DIMM240. On the one hand, RAM250boasts higher data access speed and can provide high speed but low latency memory to CPU210; while on the other hand, flash memory356is at a low cost and may have a larger storage capacity. In addition, the data access speed supported by DIMM240interface is relatively higher than that supported by north bridge220and south bridge230, so faster and larger-capacity memory may be provided to CPU210.

According to the architecture diagram shown inFIG. 3, not only the computer device's own memory capacity can be expanded, but also when the computer device's workload is low, free memory resources may be provided to other computer device. On the basis of the principle shown inFIG. 3, one embodiment of the present disclosure provides a method for managing memory that includes monitoring usage status of memory in a first computer device so as to determine available addresses; mapping at least one part of the available addresses to an externally accessible shared address; and managing the shared addresses on the basis of a memory table so that the at least one part of the available addresses are accessible to a second computer device via the shared addresses, wherein the memory is connected to a dual in-line memory module interface of the first computer device.

Note throughout the context of the present disclosure the term “available address” refers to a free memory address in memory of the first computer device that is currently not occupied by any application.

Further note throughout the context of the present disclosure, the term “shared address” refers to an address that is accessible via a network by one or more second computer devices. Moreover, in the present disclosure the “shared address” is accessed exclusively. In other words, once any part of these addresses are allocated to a certain second computer device, then these addresses can only be accessed by the second computer device exclusively; before the part of addresses are released by the second computer device, and cannot be accessed by other computer device.

FIG. 4schematically shows a flowchart400of a method for managing memory according to one embodiment of the present disclosure. Specifically, in step S402usage status of memory in a first computer device is monitored so as to determine available addresses, wherein the memory is connected to a dual in-line memory module interface of the first computer device.

In this embodiment the computer device may also have a hybrid type of memory. For example, flash memory has use flash solid state drive (SSD), and alternatively, may further use phase change memory. In addition to concrete types of memory as mentioned in the present disclosure, those skilled in the art may further use other type of storage device that is currently known or to be developed later, so long as CPU can communicate with the storage device via the DIMM interface.

In step S404, at least one part of the available addresses are mapped to an externally accessible shared address. The computer device may select one part of available addresses according to a predetermined sharing policy. For example, it may be predetermined which type of memory is to be selected from hybrid memory, it may be predetermined how much memory space is reserved for the usage of the computer device, etc. Specifically, since the access speed of memory of RAM type is relatively high, a large proportion of RAMs may be reserved for usage by the computer device; or all RAMs may be used for the computer device itself, and one part of addresses in the flash memory (e.g. no more than 15%) are used for other computer device.

In step S406, the shared addresses are managed on the basis of a memory table so that a second computer device can access at least one part of the available addresses via the shared address. A memory table may be maintained for managing a portion of the memory that is selected from the available addresses and mapped to the shared address. The memory table may maintain the current usage status of the shared addresses so as to support the second computer device to access the at least one part of the available addresses via the shared addresses. In this embodiment, the shared address is a memory address that is accessible to other computer device (e.g. second computer device) via a network.

Note according to the principle of the present disclosure, although the first computer device can access its own memory via the shared address, the present disclosure mainly relates to a second computer device other than the first computer device accessing the memory in the first computer device.

In specific implementation, the first computer device may obtain memory resources required by employing other techniques. For example, the first computer device may use a “global memory table” to record usage status (e.g. available and occupied) of memory. When one part of the available addresses are mapped to a shared address, the status of this part of addresses is marked as “occupied.” The first computer device may first request memory resources from the “global memory table;” and if not satisfactory, then the first computer device may request to access an address that is not yet occupied by any other computer device among the shared addresses of the first computer device; and if still not satisfactory, then the first computer device may request to access a shared address of other computer device.

In one embodiment of the present disclosure, mapping at least one part of the available addresses to externally accessible shared addresses includes registering the at least one part of the available addresses to a network adapter of the first computer device; and obtaining a shared address corresponding to the at least one part of the available addresses on the basis of configuration of the network adapter.

According to various embodiments of the present disclosure, the memory needs to be shared via a network between various computer devices. Therefore, the shared address needs to be registered with the network adapter of the first computer device. Those skilled in the art should understand the first computer device may communicate with other computer devices via the network adapter, so the available address of the memory needs to be converted into externally accessible shared addresses on the basis of configuration of the network adapter.

Briefly speaking, an address of the network adapter may be added before (or at other position of) the available address so that other computer device may first find, via the address of the network adapter, the first computer device providing the shared memory and then access the shared memory according to the memory address within the first computer device. With reference toFIG. 5, there is shown a block diagram500of address mapping relationships according to one embodiment of the present disclosure.

The illustration made above is merely an example of a format of the shared address, and those skilled in the art may further adopt other format.

In one embodiment of the present disclosure, the memory table describes usage status of the shared address, usage status at least comprising “available” and “occupied,” and initially usage status being “available.” Since the shared address is an address that is accessible via a network to other computer device, the usage status in the memory table refers to status whether the memory is occupied by other computer device other than the first computer device. Initially, the entire range of the shared addresses may be set as “available.” Specifically, the memory table may be represented using a data structure as shown in Table 1 below. Those skilled in the art should understand Table 1 merely illustrates an example of the data structure of the memory table, and alternatively, other data structure may further be used to define the memory table.

In one embodiment of the present disclosure, managing the shared addresses on the basis of a memory table so that at least one part of the available addresses are accessible to a second computer device via the shared addresses includes in response to a use request from the second computer device, allocating to the second computer device at least one part of shared addresses with “available” usage status among the shared addresses; and updating usage status of the at least one part of shared addresses as “occupied.”

When receiving a request from the second computer device, memory in the first computer device may be allocated to the second computer device. Since the memory table saves information regarding whether the shared addresses are “available” or not, a shared address with “available” usage status among the shared addresses may be allocated to the second computer device on the basis of contents in a “usage status” column in the memory table.

As some ranges of the shared addresses are occupied by other computer devices, status of shared addresses within these ranges may be updated as “occupied.” For example, suppose a current memory table is as shown in Table 1 above, when the second computer device (e.g. with a device name of MemoryClient1) requests a memory space of 100 MB, it may access 100M memory with “available” usage status within a range MemoryServer1[0x00 . . . 1 . . . 0, 0x00 . . . 4 . . . 0] among the shared addresses. An address range MemoryServer1[0x00 . . . 1 . . . 0, 0x00 . . . 2 . . . 0] is allocated to the second computer device, at which point the memory table is updated as shown in Table 2.

In one embodiment of the present disclosure, disclosed is in response to a release request from the second computer device, releasing a shared address corresponding to the release request; and updating usage status of the released shared address as “available.” Continuing the foregoing example, after the second computer device releases memory having an address range of MemoryServer1[0x00 . . . 1 . . . 0, 0x00 . . . 4 . . . 0], the memory table may be updated once again and the updated memory table is as shown in Table 1 above.

FIG. 6schematically shows an architecture diagram600of a technical solution for sharing memory between a memory server (corresponding to the first computer device) and a memory client (corresponding to the second computer device) according to one embodiment of the present disclosure. As shown inFIG. 6, in a memory server610, RAM250and flash memory356may be connected to DIMM240. At this point, at least one part of memory space in RAM250and flash memory356may be accessed by other computer device via shared addresses.

A memory client1630, a memory client2632and a memory client N634may access a shared part of memory in memory server610via shared addresses through a network620. Note the embodiments of the present disclosure are not intended to limit the amount of memory servers and memory clients in the computer device cluster, but note the memory server and the memory client are relative concepts.

For example, when a computer device A shares its own memory with other computer device, computer device A acts as the memory server in relation to the other computer device consuming memory; however, when memory resources of computer device A are insufficient and computer device A is requesting memory resources to other computer device, computer device A becomes the memory client in relation to the other computer device supplying shared resources. In addition, according to the embodiments of the present disclosure, one computer device may concurrently act as not only the memory server but also the memory client.

Since the speed at which the computer device accesses other computer device is usually lower than the speed at which the computer device accesses its own memory resources, the situation where memory of the computer device is exhausted and the computer device has to request memory resources to other memory server should be avoided to the extent possible.

According to the embodiments of the present disclosure, various measures may be taken to avoid the situation where the computer device acting as a memory server is typically short of memory resources. For example, a maximum value of shared memory may be set, for example, at most 15% of total memory resources are shared; after the memory client uses memory resources, resources being allocated previously may be returned to the memory server; where necessary, a shared address whose current usage status is “available” may be returned to the memory server; or where necessary, the memory client is notified to release allocated resources, and these resources are returned to the memory server, etc.

In one embodiment of the present disclosure in response to a resource shortage occurring in the first computer device, returning to the first computer device memory associated with at least one part of shared addresses with “available” usage status; demapping the returned memory to corresponding shared addresses. In this embodiment, a resource with “available” usage status is currently not used by any computer device and belongs to free memory resources, so the memory may be returned to the first computer device so as to be called by an application running on the first computer device.

In one embodiment of the present disclosure in response to a release request from the second computer device, returning to the first computer device memory associated with a shared address corresponding to the release request; and demapping the returned memory to corresponding shared addresses.

In this embodiment, resources released by the second computer device may be directly returned to the first computer device so as to be called by an application running on the first computer device, no matter whether a memory resource shortage occurs in the first computer device. In various embodiments of the present disclosure, usage status of memory in the first computer device may be monitored periodically; when the usage status matches the sharing policy, available addresses may be determined using the above mentioned method. Thereby, more available memory resources may be reserved for the first computer device.

In one embodiment of the present disclosure, “returnable” usage status may further be set in the memory table, the status representing that a corresponding shared address is currently free and may be returned as a priority when the first computer device is in short of resources.

In one embodiment of the present disclosure, the memory is at least one of: solid state memory, solid state disk memory phase change memory and random access memory. These memories may have varied data access efficiency, varied capacities and varying hardware costs.

With reference to the accompanying drawings, detailed description has been presented to concrete implementation of a memory server for sharing memory with other computer device. With respect to the memory server, various embodiments of the present disclosure further provide a method for using memory in a memory server.

In one embodiment of the present disclosure, there is provided a method for managing memory where, in response to a memory shortage occurring in a second computer device, requesting memory from a first computer device. In this embodiment, the second computer device acts as a memory client and requests memory resources in the first computer device (acting as a memory server) in case of a memory resource shortage.

In one embodiment of the present disclosure, the memory is released in response to the second computer device completing using the memory. When the memory client completes usage, memory allocated by the first computer device to the second computer device may be released. Subsequently, the first computer device may handle the memory released by the second computer device as described above.

FIGS. 7A and 7Bschematically show block diagrams700A and700B for managing memory according to one embodiment of the present disclosure, respectively. Specifically,FIG. 7Aprovides an apparatus for managing memory having a monitoring module710A configured to monitor usage status of memory in a first computer device so as to determine available addresses; a mapping module720A configured to map at least one part of the available addresses to externally accessible shared addresses; and a managing module730A configured to manage the shared addresses on the basis of a memory table so that the at least one part of the available addresses are accessible to a second computer device via the shared addresses, wherein the memory is connected to a dual in-line memory module interface of the first computer device. Advantageously, each of the mapping module, the monitoring module and the managing module, and any sub-components (registering module, obtaining module etc., mentioned below) associated with any of these modules, can be combined together into a single memory module configured to perform the individual tasks of each of these modules or sub-modules/components.

In one embodiment of the present disclosure, mapping module720A includes a registering module configured to register the at least one part of the available addresses to a network adapter of the first computer device; and an obtaining module configured to obtain a shared address corresponding to the at least one part of the available addresses on the basis of configuration of the network adapter.

In one embodiment of the present disclosure, the memory table describes usage status of the shared addresses, the usage status at least comprising “available” and “occupied,” and initially the usage status is “available.”

In one embodiment of the present disclosure, managing module730A includes an allocating module configured to, in response to a use request from the second computer device, allocate to the second computer device at least one part of shared addresses with “available” usage status among the shared addresses; and a first updating module configured to update usage status of the at least one part of shared addresses as “occupied.”

In one embodiment of the present disclosure, there further includes a first releasing module configured to, in response to a release request from the second computer device, release a shared address corresponding to the release request; and a second updating module configured to update usage status of the released shared address as “available.”

In one embodiment of the present disclosure, there further includes a first returning module configured to, in response to a resource shortage occurring in the first computer device, return to the first computer device memory associated with at least one part of shared addresses with “available” usage status; and a first demapping module configured to demap the returned memory to corresponding shared addresses.

In one embodiment of the present disclosure, there includes a second returning module configured to, in response to a release request from the second computer device, return to the first computer device memory associated with a shared address corresponding to the release request; and a second demapping module configured to demap the returned memory to corresponding shared addresses.

In one embodiment of the present disclosure, the memory is at least one of: solid state disk memory, phase change memory and random access memory.

FIG. 7Bprovides an apparatus for managing memory, that includes a requesting module710B configured to, in response to a memory shortage occurring in a second computer device, request memory from a first computer device.

In one embodiment of the present disclosure, there further includes a releasing module720B configured to release the memory in response to the second computer device completing using the memory.