WO2022222977A1 - Method and apparatus for managing memory of physical server for running cloud service instances - Google Patents
Method and apparatus for managing memory of physical server for running cloud service instances Download PDFInfo
- Publication number
- WO2022222977A1 WO2022222977A1 PCT/CN2022/088044 CN2022088044W WO2022222977A1 WO 2022222977 A1 WO2022222977 A1 WO 2022222977A1 CN 2022088044 W CN2022088044 W CN 2022088044W WO 2022222977 A1 WO2022222977 A1 WO 2022222977A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- memory
- service instance
- memory area
- operating system
- physical
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 65
- 238000007726 management method Methods 0.000 claims description 97
- 230000006870 function Effects 0.000 description 20
- 238000013507 mapping Methods 0.000 description 16
- 238000012545 processing Methods 0.000 description 11
- 238000010586 diagram Methods 0.000 description 10
- 238000004590 computer program Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 4
- 238000002955 isolation Methods 0.000 description 4
- 230000001360 synchronised effect Effects 0.000 description 4
- 238000013519 translation Methods 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000005192 partition Methods 0.000 description 3
- 239000008186 active pharmaceutical agent Substances 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000013467 fragmentation Methods 0.000 description 1
- 238000006062 fragmentation reaction Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000002184 metal Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000000638 solvent extraction Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/10—Address translation
- G06F12/1009—Address translation using page tables, e.g. page table structures
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
Definitions
- the present application relates to the field of communications, and in particular, to a memory management method and apparatus for running a physical server of a cloud service instance.
- the operating system allocates 0-4 gigabytes (gigabyte, GB) of virtual memory space for each process, and the virtual memory address in the virtual memory space and the physical memory address in the physical memory are separated, which will give the process no need to care Physical memory addresses bring convenience and security, but the translation of virtual memory addresses and physical memory addresses consumes additional computer resources.
- the easiest way to record the correspondence between virtual memory addresses and physical memory addresses is to record the correspondence in a table. In order to make the translation speed fast enough, this table must be loaded in memory. However, if the table records each The correspondence between a virtual memory address and a physical memory address is very wasteful.
- the operating system uses paging to record the corresponding relationship between virtual memory addresses and physical memory addresses.
- Paging is to manage physical memory with a larger unit "page".
- the unit of 4KB is for physical memory paging and the page number is set, and the unit of 4 kilobytes (kilobyte, KB) is for virtual memory paging and the page number is set, and each physical memory page corresponds to a 64-byte (byte, B)
- the page data structure can be used to record the correspondence between the page number of the physical memory and the page number of the virtual memory.
- the operating system needs to divide an area from physical memory for storing these page data structures with 64B as the basic unit.
- cloud service instances run in the operating system of the physical server, and the cloud service instance actually runs on the physical memory allocated by the physical server to the operating system.
- the purpose is to provide physical memory for cloud service instances as much as possible, so as to maximize the creation of benefits, but if 1.5625% of the physical memory allocated to the operating system is used to store the page data structure, this is for cloud service providers. It is said to be a waste of physical memory resources.
- the present application provides a memory management method and device for running a physical server of a cloud service instance, in which non-overlapping operating system memory areas and service instance memory areas are set in the physical memory of the physical server, so as to
- the operating system allocates the operating system memory area, and allocates the service instance memory area for the cloud service instance in the operating system. Therefore, the page data structure needs to be generated for the memory in the operating system memory area, and the page data structure does not need to be generated for the service instance memory area. Since the number of generated page data structures is reduced, the space for storing the page data structures is also reduced, so as to achieve the purpose of providing physical memory for use by cloud service instances as much as possible.
- the present application provides a memory management method for a physical server.
- the physical server sets non-overlapping operating system memory areas and service instance memory areas in the physical memory, sets a memory address range for the cloud service instance in the service instance memory area, and records the memory address range, where the cloud service instance is in The operating system runs in this memory address range after booting.
- the operating system of the physical server runs in the operating system memory area.
- 1.5625% of the physical memory allocated to the operating system is used to store the page data structure, which occupies the memory quota of the cloud service instance running on the operating system.
- the embodiment of the present invention divides a special service instance memory area in the physical memory for the cloud service instance, and divides a special operating system memory area for the operating system in the physical memory.
- the operating system can use 1.5625% of the operating system memory area
- the page data structure is stored, but the cloud service instance does not run in the operating system memory area, but runs in the service instance memory area, because the operating system memory area is smaller than the physical memory provided to the operating system in the prior art (because it is from In the prior art, the physical memory provided to the operating system is divided), so the number of page data structures to be created is reduced, and the physical memory used to store the page data structures becomes smaller, thereby saving more storage space to Provided for use by cloud business instances.
- the physical server allocates a cloud service instance identifier to the cloud service instance, applies for a free memory space in the service instance memory area, and uses the address range of the memory space obtained by the application as the memory address range.
- the cloud service instance identifier and the memory address range of the cloud service instance in the service instance memory area are recorded in the management information area of the service instance memory area.
- the memory address range corresponding to different cloud service instances in the service instance memory area can be distinguished by the service instance identifier, so that memory isolation can be achieved between different cloud service instances, and multiple different cloud services can be run simultaneously in the service instance memory area. instance, the memory of multiple cloud service instances does not affect each other.
- the memory space occupied by the management information area is smaller, so that more memory space can be saved for use by the cloud business instance.
- the physical server writes the address corresponding to the memory address range of the cloud service instance in the service instance memory area in the page table of the cloud service instance in the memory area of the operating system.
- the physical server rewrites the address corresponding to the memory address range of the cloud service instance in the memory area of the service instance recorded in the memory area of the service instance into the page table of the cloud service instance middle.
- the operating system needs to be restarted.
- the data in the physical memory allocated to the operating system will be cleared. Therefore, the data in the physical memory of the cloud service instance running in the operating system will be lost, and in this application , because the cloud service instance runs in the memory area of the service instance instead of the memory area of the operating system, restarting the operating system will only clear the data in the physical memory corresponding to the memory area of the operating system. The data is not affected.
- the operating system restarts by rewriting the address to the page table, it is not necessary to rewrite the relevant data of the cloud service instance into the memory, which can realize the rapid recovery of the cloud service instance.
- the physical server allocates the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio.
- the cloud service provider can set a preset ratio according to actual needs, and can manage the memory in a refined manner.
- the physical server may also write the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory into the memory management unit, so as to realize the partition of memory.
- the physical server may also notify the memory management unit to modify the recorded memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so that the operating system The free memory space in the memory area is added to the service instance memory area, or the free memory space in the service instance memory area is added to the operating system memory area. In this way, the function of adjusting the range of the operating system memory area and the service instance memory area can be realized.
- the physical server generates a page data structure of the operating system memory area during the initialization of the operating system, and the page data structure includes attribute information of memory pages in the operating system memory area.
- the physical server does not generate the page data structure of the memory area of the service instance. In this way, the initialization speed of the operating system can be accelerated.
- the physical server traverses the memory management information table in the process of initializing the operating system, determines the memory in the operating system memory area, and establishes a page data structure corresponding to the memory in the operating system memory area.
- the operating system memory area stores page data structures.
- the memory management information table is E820. In this way, compatibility can be improved.
- the memory management information table includes: a tag value corresponding to the memory of the memory area of the service instance.
- the tag value corresponding to the memory of the business instance memory area is used to indicate that the memory belongs to the memory of the business instance memory area. In this way, it can be more compatible with the existing technology.
- the cloud service instance includes: a virtual machine or a secure container.
- a physical server in a second aspect, includes modules for executing the first aspect or any possible implementation manner of the first aspect.
- a physical server in a third aspect, includes a processor and a memory.
- the memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions in the memory to perform the operation steps of the method in any possible implementation manner of the first aspect.
- the present application provides a computer-readable storage medium.
- the computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to execute the methods of the above aspects.
- the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the methods of the above aspects.
- the present application may further combine to provide more implementation manners.
- FIG. 1 is a schematic diagram of a system architecture according to an embodiment of the present application.
- Fig. 2 is the structural representation of a server in Fig. 1;
- FIG. 3 is a schematic diagram of a correspondence between a virtual address and a physical address provided by an embodiment of the present application
- FIG. 4 is a schematic flowchart of a memory management method for a physical server provided by an embodiment of the present application
- FIG. 5 is a schematic structural diagram of the physical memory in FIG. 2;
- 6A is a schematic diagram of adjusting the memory in the business instance memory area in FIG. 3 to the memory in the operating system memory area;
- FIG. 6B is a schematic diagram of adjusting the memory in the operating system memory area in FIG. 3 to the memory in the service instance memory area.
- FIG. 1 exemplarily shows a system architecture to which the embodiments of the present application are applicable.
- the system may provide a cloud management platform function.
- Cloud management platform function Provide access interface (such as interface or Application Programming Interface (API)), tenant can operate client remote access access interface to register cloud account and password in cloud management platform, and log in cloud management platform , after the cloud management platform successfully authenticates the cloud account and password, the tenant can further select and purchase virtual machines of specific specifications (processor, memory, disk) on the cloud management platform. After the payment is successful, the cloud management platform provides the purchased virtual machine The remote login account and password of the virtual machine, the client can remotely log in to the virtual machine, and install and run the tenant's application in the virtual machine.
- API Application Programming Interface
- the logical function division of the cloud management platform user console, computing management service, network management service, storage management service, authentication service, and image management service.
- the user console provides interfaces or APIs to interact with tenants
- the computing management service is used to manage servers running virtual machines and containers and bare metal servers
- the network management service is used to manage network services (such as gateways, firewalls, etc.)
- the storage management service is used to manage Manage storage services (such as data bucket services)
- authentication services are used to manage tenant account passwords
- image management services are used to manage virtual machine images.
- Cloud management platform client function Receive control plane commands sent by the cloud management platform, create on the server according to the control plane control commands, and perform full life cycle management of virtual machines.
- tenants can create, manage, log in and operate virtual machines in the cloud data center through the cloud management platform.
- a virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. Anything that can be done in a server can be done in a virtual machine.
- a virtual machine When creating a virtual machine in a server, you need to use part of the hard disk and memory capacity of the physical machine as the hard disk and memory capacity of the virtual machine.
- Each virtual machine has an independent hard disk and operating system. virtual machine to operate.
- Virtual machines can also be called cloud servers (Elastic Compute Service, ECS), elastic instances (different cloud service providers provide different names).
- ECS Elastic Compute Service
- FIG. 2 exemplarily shows a schematic structural diagram of a server in FIG. 1 .
- the server may also be referred to as a physical server.
- the server 1 in FIG. 1 is used as an example for introduction. It should be noted that the server shown in FIG. 2 may be any server in the system architecture shown in FIG. 1 , and is not limited to server 1 .
- the server includes a hardware layer and a software layer
- the hardware layer is a conventional configuration of the server
- the peripheral component interconnect (PCI) device may be, for example, a network card, a graphics processing unit (graphics processing unit, GPU), offload cards, and other devices that can be plugged into the server's PCI/PCIe slots.
- PCI peripheral component interconnect
- the server may also include a processor and memory.
- the memory in the server in this embodiment of the present application may also be referred to as physical memory or storage.
- the server may further include a bus system, wherein the processor and the physical memory may be connected through the bus system.
- the processor can be a chip with signal processing capabilities.
- the processor may be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), or a It is a central processing unit (CPU), a network processor (NP), a digital signal processing circuit (DSP), or a microcontroller (microcontroller unit). , MCU), it can also be a programmable logic device (PLD) or other integrated chips.
- FPGA field programmable gate array
- ASIC application specific integrated circuit
- SoC system on chip
- MCU microcontroller unit
- MCU programmable logic device
- PLD programmable logic device
- each step of the method in the embodiments of the present application may be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.
- the steps of the method disclosed in conjunction with the embodiments of the present application may be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
- the software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art.
- the storage medium is located in the physical memory, and the processor reads the information in the physical memory, and completes the steps of the method in the embodiment of the present application in combination with its hardware.
- the physical memory in this embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
- the non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
- Volatile memory may be random access memory (RAM), which acts as an external cache.
- RAM random access memory
- DRAM dynamic random access memory
- SDRAM synchronous DRAM
- SDRAM double data rate synchronous dynamic random access memory
- ESDRAM enhanced synchronous dynamic random access memory
- SLDRAM synchronous link dynamic random access memory
- direct rambus RAM direct rambus RAM
- the physical memory may include two memory areas, which are an operating system memory area and a service instance memory area, respectively.
- the operating system runs in the operating system memory area, and allocates memory for cloud service instances in the service instance memory area.
- a memory management unit may also be set in the physical server.
- the memory management unit may be a memory management unit (memory management unit, MMU) or the like.
- MMU memory management unit
- the memory management unit can have other names, such as memory manager, memory management module, and so on.
- a memory management unit refers to a module, unit, or component, etc., used to manage memory. The following describes the memory management unit:
- One or more process programs are executed in the operating system, and the address issued by the program is the address of the virtual memory which is not related to the address of the physical memory. That is, the memory address seen in the program is the address of the virtual memory. For example, the virtual memory range is 0-4GB.
- the program reads and writes memory, it will be mapped to the actual physical memory. This mapping is called translation.
- This translation work can be done by Memory management unit (such as MMU) to complete.
- the memory management unit can receive the address of the virtual memory page sent by the processor, and find out the address corresponding to the address of the virtual memory page according to the mapping relationship between the address of the virtual memory page recorded in the page table and the address of the physical memory page.
- the address of the physical memory page, and the address of the found physical memory page is sent to the processor, and the processor reads or writes from the address corresponding to the offset in the physical memory page according to the address and offset of the physical memory page. related data.
- the software layer includes an operating system installed and running on the server (the operating system relative to the virtual machine can be called the host operating system), and the host operating system is provided with a virtual machine manager (virtual machine manager, VMM) (also known as Hypervisor, also known as Virtual Machine Monitor (VMM)).
- VMM virtual machine manager
- VMM also known as Hypervisor, also known as Virtual Machine Monitor (VMM)
- VMM virtual machine manager
- the role of the virtual machine manager is to realize the computing virtualization, network virtualization and storage virtualization of the virtual machine, and is responsible for managing the virtual machine.
- the virtual machine manager can virtualize a set of virtual hardware systems independent of real hardware for each virtual machine, such as virtual display, virtual hard disk, virtual processor (Virtual CPU, VCPU), virtual memory, virtual network card, etc.
- Applications may be run in the virtual machine based on virtual hardware and a virtual machine operating system, wherein the applications are applications installed and configured by the tenant.
- the virtual machine monitor may run in the operating system memory area mentioned in the embodiment of the present application, or may run in the memory area of the service instance, which is not limited in the embodiment of the present application.
- Computing virtualization refers to providing part of the processor and memory of the server to the virtual machine
- network virtualization refers to providing some functions of the network card (such as bandwidth) to the virtual machine
- storage virtualization refers to providing part of the disk to the virtual machine.
- the virtual machine manager can also achieve logical isolation between different virtual machines and manage virtual machines, such as creating virtual machines, emulating virtual hardware for virtual machines according to the hardware layer (hardware emulation function), deleting virtual machines, forwarding and/or processing running Network packets between all virtual machines on the server (such as virtual machine 1 and virtual machine 2) or forward network packets between virtual machines on the server and external networks (virtual switching function), processing virtual machines Generated I/O, etc.
- the running environments (such as virtual machine applications, operating systems, and virtual hardware) in different virtual machines are completely isolated.
- network packets need to be forwarded through a virtual manager.
- Tenants can log in to the virtual machine remotely, and operate the virtual machine to install, set, and uninstall applications in the virtual machine operating system environment.
- two modules may also be set in the virtual machine manager, a module for dividing a memory area and a module for allocating a memory area.
- the memory area division module can be used to divide the physical memory into the operating system memory area and the service instance memory area.
- the memory area allocation module can be used to allocate memory for virtual machines.
- the memory area partitioning module may also be referred to as a random access memory (RAM) partition module, and the memory area allocation module may also be referred to as an instance RAM allocator (instance RAM allocator) module.
- RAM random access memory
- instance RAM allocator instance RAM allocator
- the division of the units of the above apparatus is only a division of logical functions, and may be fully or partially integrated into a physical entity in actual implementation, or may be physically separated.
- the memory area allocation module and the memory area division module may be implemented by the processor of FIG. 1 by running program instructions stored in the memory area of the operating system.
- FIG. 2 only takes two virtual machines as an example for illustration. In practical applications, there is no limit to the number of virtual machines virtualized by one server.
- memory virtualization technology is to provide virtual machines with a continuous physical memory space starting from address 0, and to effectively isolate and schedule memory resources between virtual machines.
- Memory virtualization technology mainly involves guest virtual address (Guest Virtual Address, GVA)—> guest physical address (Guest Physical Address, GPA)—> host virtual address (Host Virtual Address, HVA)—> host physical address ( Host Physical Address, HPA) conversion.
- the virtual machine uses the guest physical address (Guest Physical Address, GPA) to represent the virtual machine
- GPA Guest Physical Address
- GVA is the address formed by the virtual machine's operating system mapping GPA.
- the virtual machine's operating system provides GVA to the process or application software set on the virtual machine's operating system, and the virtual machine's operating system records the GVA to GPA.
- the mapping relationship, the conversion of GVA to GPA is implemented by the page table of the operating system of the virtual machine.
- HPA is the actual physical memory address
- HVA is the address formed by the operating system of the host machine mapping the HPA
- the operating system of the host machine provides the HVA to the process (such as a virtual machine) on the operating system
- the operating system of the host machine uses the HVA. Record the mapping relationship between HVA and HPA.
- the conversion from HVA to HPA is implemented by the page table of the operating system of the host.
- FIG. 3 exemplarily shows a schematic diagram of a correspondence relationship between a virtual address and a physical address provided by an embodiment of the present application.
- virtual machine 1 and virtual machine 2 are set in the same server (hereinafter referred to as the host machine), and the virtual machine manager of the host machine sets the GPA address range of virtual machine 1 to 0-5GB, which corresponds to The HPA address range on physical memory is 1.5GB-4.5GB and 6.5GB-8.5GB.
- the virtual machine manager of the host machine sets the GPA address range of the virtual machine 2 to 0-4GB, which corresponds to the HPA address ranges of 9GB-11GB and 13GB-15GB on the physical memory.
- virtual machine 1 exclusively uses the GPA address range of 0-5GB
- virtual machine 2 exclusively uses the GPA address range of 0-4GB.
- Both the 0-5GB GPA address range and the 0-4GB GPA address range can correspond to different HPA address ranges on the physical memory, so as to achieve virtual machine memory isolation.
- the GPA address range is related to the virtual machine specifications described above.
- the tenant can set the virtual machine 1 with a memory size of 5G in the virtual machine specification in the cloud management platform.
- the virtual machine manager is notified by the cloud management platform that it needs to Create virtual machine 1 with a GPA of 0-5G.
- FIG. 4 exemplarily shows a schematic flowchart of a memory management method for a physical server provided by an embodiment of the present application.
- the method may be executed by the virtual machine manager in the host operating system in the above-mentioned FIG. 2 .
- the method may be executed by the memory area division module and the memory area allocation module in the virtual machine manager in FIG. 2 .
- the method may be executed by the processor shown in FIG. 2, and the related functions of the memory area division module and the memory area allocation module may be implemented by the processor executing program instructions stored in the memory area of the operating system.
- the method can include:
- the memory area division module is configured to set non-overlapping operating system memory areas and service instance memory areas in the physical memory of the physical server, where the operating system of the physical server runs in the operating system memory area.
- S201 may be executed by the aforementioned processor shown in FIG. 2 , and the relevant functions of the memory area division module may be implemented by the processor executing the program instructions stored in the memory area of the operating system.
- the memory area allocation module is configured to set a memory address range for the cloud service instance in the service instance memory area, and record the memory address range, where the cloud service instance runs in the memory address range after being started in the operating system.
- S202 may be executed by the processor shown in FIG. 2, and the relevant functions of the memory area allocation module may be implemented by the processor executing the program instructions stored in the memory area of the operating system.
- cloud service examples include, but are not limited to: virtual machines (virtual machines, VMs) and containers (containers).
- the benefits brought by the page data structure can include: fragmentation It can realize advanced features such as memory exchange, merging of the same memory pages, and memory on demand (Populate on demand, POD), etc.), but in fact, since a piece of memory is allocated to a cloud business instance, how does the cloud business instance use it? For this part of memory, the host operating system of the physical server will no longer interfere, nor will the memory in this memory area be used for other purposes. Therefore, even if the physical memory is used for the physical memory area allocated to the cloud service instance Establishing a page data structure does not fully utilize the benefits of the page data structure.
- the management of the service instance memory area in the embodiment of the present application abandons the management method through the page data structure according to the characteristics of the cloud computing service, thereby saving the page corresponding to the memory used for storing the memory of the cloud service instance
- the memory of the data structure based on this scheme, the cloud service provider can provide as much physical memory of the physical server as possible to the tenants, so as to obtain greater benefits.
- a page data structure of the operating system memory area can be generated, and the page data structure includes attribute information of the memory pages in the operating system memory area, such as physical memory and virtual memory in the operating system memory area.
- the page data structure includes attribute information of the memory pages in the operating system memory area, such as physical memory and virtual memory in the operating system memory area.
- the work of generating the page data structure is The amount is reduced, so the operating system initialization startup speed can be accelerated.
- the memory area allocation module may allocate a cloud service instance identifier to the cloud service instance, apply for a free memory space in the memory area of the service instance, and use the address range of the applied memory space as the physical memory of the cloud service instance
- the memory address range of the cloud service instance and the memory address range of the physical memory of the cloud service instance are recorded in the management information area of the service instance memory area.
- the content can also be executed by the processor shown in FIG. 2, and the relevant functions of the memory area allocation module can be implemented by the processor executing the program instructions stored in the memory area of the operating system.
- FIG. 5 exemplarily shows a schematic structural diagram of the physical memory in FIG. 2.
- the physical memory includes an operating system memory area and a service instance memory area.
- the memory area allocation module can perform memory management based on the management information area in the service instance memory area.
- the memory area allocation module establishes a management information area in the service instance memory area, and the management information area can be stored in a part of the area demarcated in the service instance memory area.
- FIG. 5 also schematically shows the physical memory area allocated by the memory area allocation module for cloud service instance 1 and the memory area allocated for cloud service instance 2 in the service instance memory area.
- the service instance memory area may further include free space, such as free space 2 .
- the memory area allocation module may record the mapping relationship between the identifier of cloud service instance 1 and the memory address range of the physical memory area of cloud service instance 1, and the identifier of cloud service instance 2 and the physical memory area of cloud service instance 2 in the management information area. The mapping relationship of the memory address range.
- the operating system memory area can be used to run the operating system, memory management can be performed based on the page data structure in the operating system memory area, that is, by establishing a page data structure in the operating system memory area, the Management of operating system memory areas.
- the page data structure may be stored in a portion of an area demarcated in the operating system memory area. In this way, the requirements of the operating environment of the operating system can be complied with.
- the operating system memory area in FIG. 5 may also include free space, such as free space 1 .
- a 4KB page in the operating system memory area corresponds to a 64B page data structure, and the page data structure may include the address of the virtual memory corresponding to the address of the physical memory of the 4KB page.
- the service instance memory area can be managed through the management information area. For example, according to the information recorded in the management information area, you can know which memory in the business instance memory area is allocated to which cloud service instance, and also know which memory in the business instance memory area is in an idle state. In this way, the memory in the memory area of the service instance in the idle state can be allocated to other cloud service instances for use.
- the memory address range corresponding to different cloud service instances in the service instance memory area can be distinguished by the service instance identifier, so that memory isolation can be achieved between different cloud service instances, and multiple cloud service instances can be run simultaneously in the service instance memory area.
- the memory of multiple cloud service instances does not affect each other.
- the memory space occupied by the management information area is smaller, so that more memory space can be saved for use by the cloud service instance.
- the cloud service instance When the operating system is restarted, the contents stored in the operating system memory area will be cleared. Since the business instance memory area is not an area that can be used to run the operating system, as the operating system restarts, the business instance memory area will be cleared. content will not be cleared. That is, the data in the memory area of the service instance will not be affected. Therefore, after the operating system is upgraded and restarted, the cloud service instance will not be affected.
- the cloud service can be quickly restored according to the information stored in the management information area of the memory area of the service instance. For instance, for the cloud service provider, the operating system can be upgraded at any time, and there is no need to worry about the data of the cloud service instance on the tenant side, so it is more convenient.
- the memory area allocation module can set virtual memory for the cloud service instance, and the address range of the virtual memory does not exist in essence, only to make the cloud service instance think that it is running in the memory address range set in the operating system, Therefore, in the above S202, the memory area allocation module may set a memory address range for the cloud service instance in the service instance memory area, and write the memory address of the physical memory of the cloud service instance in the page table of the cloud service instance in the operating system memory area The address corresponding to the range.
- the memory area allocation module can first record the memory address of the operating system memory area in the page table of the cloud service instance, and then modify the address in the page table of the cloud service instance so that the address points to the cloud service instance Memory in the business instance memory area.
- the compatibility of the embodiments of the present application can be improved.
- the cloud service instance when memory is allocated to a cloud service instance, the cloud service instance is allocated memory that can be used to run the memory area of the operating system.
- the memory area is not partitioned in the prior art, and the memory range of the physical server that the operating system can run is the same as the memory range that can be allocated to the cloud service instance.
- the memory of the memory area used for running the operating system can still be allocated to the cloud service instance, and then the address recorded in the page table of the cloud service instance can be modified.
- the memory area allocation module may first record an invalid memory address in the page table of the cloud service instance, and then modify the address so that the address points to the memory of the cloud service instance in the service instance memory area.
- the memory address range of the memory of the cloud service instance in the service instance memory area is recorded in the page table of the cloud service instance. In this way, the steps of modifying the address recorded in the page table of the cloud service instance can be reduced, and the solution can be simplified.
- the memory area allocation module may record the mapping relationship between the memory address range of the virtual memory of the cloud service instance and the memory address range of the physical memory of the cloud service instance in the page table.
- the mapping relationship is, for example, the mapping relationship between GVA and HPA in the above-mentioned FIG. 3 .
- the cloud service instance can run in the physical memory allocated for the cloud service instance according to the mapping relationship. Specifically, after the cloud service instance is started, the processor running the cloud service instance sends the virtual memory address of the cloud service instance and the identifier of the cloud service instance to the memory management unit. According to the mapping relationship in the page table, the memory management unit can The memory address range of the virtual memory that identifies the corresponding cloud service instance is converted into the memory range of the physical memory, and the processor is notified to access the memory range of the physical memory corresponding to the cloud service instance.
- a cloud service instance is used as a virtual machine for introduction below.
- the program of the virtual machine needs to be installed in the operating system, and after the program of the virtual machine is installed, the operating system can assign a process number to the virtual machine, and can also record the memory address range of the virtual memory of the virtual machine in the page table of the cloud service instance.
- the mapping relationship with the memory address range of the virtual machine's physical memory It should be noted that the page table of the cloud service instance refers to a page table used to record the mapping relationship between the address of the virtual memory and the address of the physical memory of the cloud service instance.
- the processor needs to run the process corresponding to the virtual machine
- the processor needs to send the address of the virtual memory corresponding to the process to the memory management unit according to the process ID of the virtual machine, and the memory management unit
- the address of the physical memory corresponding to the address of the virtual memory can be obtained.
- the memory management unit sends the found address of the physical memory to the processor, and the processor reads or writes relevant data from the address of the physical memory, so that the processor runs the program of the virtual machine stored in the physical memory the goal of.
- the processor runs the program of the virtual machine, the virtual machine can be started.
- the page table in the embodiment of the present application is different from the above-mentioned page data structure, and the page table includes the mapping relationship between the memory address range of the virtual memory of the cloud service instance and the memory address range of the physical memory of the virtual machine. , when the processor needs to access the physical memory of the cloud service instance, it can access the physical memory of the cloud service instance by querying the page table through the memory management unit.
- the page data structure is used to store the attribute information of the memory of the operating system memory area.
- a 64B page data structure corresponding to a 4KB page may include the address of the virtual memory corresponding to the address of the physical memory of the 4KB page.
- the processor can search according to the information stored in the page data structure.
- the 64B data structure corresponding to the 4KB page can also store other attribute information of the 4KB page, such as: information identifying which NUMA node the 4KB page belongs to, the number of times the 4KB page is referenced in the kernel, and how many times the 4KB page is simultaneously used process sharing and so on.
- the page data structure can be stored in the memory area of the operating system, and the page table of the cloud service instance can be stored in the memory area of the operating system or the memory area of the service instance.
- the page table of the cloud service instance When the page table of the cloud service instance is stored in the operating system memory area, when the operating system is restarted, the page table of the cloud service instance will be cleared. Since the information in the memory area of the service instance will not be cleared, after the operating system is restarted, the memory area allocation module can rewrite the address corresponding to the memory address range of the physical memory of the cloud service instance recorded in the memory area of the service instance to the cloud. in the page table of the business instance. Specifically, the memory area allocation module can quickly rebuild the page table of the cloud service instance based on the content recorded in the management information area, thereby speeding up the restarting speed of the operating system.
- the memory area dividing module in S201 may allocate the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio. For example, according to the ratio of 3.125%, each 4G physical memory is divided into 128M as the operating system memory area, and 3968M as the business instance memory area.
- multiple preset ratios may be set, and the memory of physical servers of different specifications may correspond to one of the preset ratios.
- the memory size required for the operation of the operating system may be determined according to experience, and then the preset ratio may be determined according to the total memory size of the physical server. In this way, the memory space of the memory area of the service instance can be increased as much as possible on the premise of meeting the memory requirements of the operating system, thereby increasing the number of cloud service instances.
- the memory area division module may specifically write the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory into the memory management unit. Specifically, the memory area division module can notify the memory management unit of the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory, and the memory management unit records the operating system in the memory management information table. The memory address range of the memory area in the physical memory and the memory address range of the business instance memory area in the physical memory.
- the memory management unit may include a memory management information table. For example, in the process of initializing the operating system (for example, when the physical server is powered on, the operating system is initialized), traverse the memory management information table, determine the memory of the operating system memory area, and establish the memory corresponding to the operating system memory area. Page data structure, which stores the page data structure in the operating system memory area.
- a tag value can be set for a segment of memory, and the tag value can indicate whether the segment of memory belongs to the operating system memory area.
- the tag value can also be used to indicate whether the segment of memory belongs to the business instance memory area.
- the memory management unit may determine the memory address range belonging to the operating system memory area and the memory address range belonging to the service instance memory area according to the tag value corresponding to the memory in the memory management information table.
- the memory management information table may specifically be an E820 table.
- the tag value corresponding to the memory address range of the segment of memory can be set to disable.
- the tag value corresponding to the memory address range of this segment of memory can be set as a new tag value, specifically, it can be distinguished from the existing tag value in the E820 table.
- the tag value of for example, the tag value can be defined as "VM".
- the memory area division module can dynamically adjust the operating system memory area and the service instance memory area: that is, the memory area division module can convert the memory in the operating system memory area into the memory in the service instance memory area, and the memory area division The module can convert the memory in the business instance memory area into the memory in the operating system memory area.
- the memory area division module can notify the memory management unit to modify the memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so as to make the memory area of the operating system free Add the memory space of the service instance to the memory area of the service instance, or add the free memory space in the memory area of the service instance to the memory area of the operating system.
- the step of notifying the memory management unit may be performed by the aforementioned processor shown in FIG. 2 , and the relevant functions of the memory area division module may be implemented by the processor executing program instructions stored in the memory area of the operating system.
- the memory of the unused service instance memory area can be adjusted to the operating system memory area. It is worth noting that after this part of the memory is adjusted to the operating system memory area, a page data structure needs to be established for this part of the memory, and memory is allocated from the operating system memory area to store the page data structure.
- FIG. 6A exemplarily shows a schematic diagram of adjusting the memory in the memory area of the business instance in FIG. 5 to the memory in the memory area of the operating system.
- the free space 2 in the memory area of the business instance can be converted into the operating system memory area.
- the page data structure created for the free space 2 needs to be stored in the operating system memory area.
- the unused operating system memory area memory can be adjusted to the business instance memory area. After being adjusted to operate the business instance memory area, the memory occupied by the page data structure corresponding to this part of the memory is released. .
- FIG. 6B exemplarily shows a schematic diagram of adjusting the memory space in the operating system memory area in FIG. 5 to the memory of the service instance memory area.
- the free space 1 can be converted from the operating system memory area to the service instance memory area of memory.
- the memory space occupied by the page data structure corresponding to the free space 1 in the operating system memory area can be released.
- the memory area allocation module may record the usage status of the memory of the business instance memory area in the management information area, and the usage status of the memory may include an occupied status and an idle status.
- a memory block is marked as occupied, it means that the memory block is allocated for use by the cloud service instance.
- the memory block is marked as free, it means that the memory block is not currently allocated to the cloud service instance.
- the memory block can be allocated to the cloud service instance.
- the usage status of the memory can be recorded by means of bits (ie, bitmap).
- the memory area of a business instance is 512GB, and one bit is used to represent a memory block with a size of 1GB (it can also be a memory block of other size, such as a 4M memory block).
- the bit position corresponding to the memory block can be set to 1
- the bit position corresponding to the memory block can be set to 0. It can be seen that in this method, a certain number of bits can be used to manage the memory of the business memory area. Compared with the method of building a page data structure to manage the memory, the storage space occupied by the management information area is smaller, so it can be further Save more storage space.
- the usage status of the memory block may be recorded by recording the memory address range. For example, if "00000000aafe8000-00000000aaffd000" is allocated for use by cloud service instance 1, the information that "00000000aafe8000-00000000aaffd000" is occupied can be recorded in the management information area. It can be seen that in this method, the memory of the business memory area can be managed by recording the starting address of the memory block and the usage status of the memory block. Compared with the method of establishing a page data structure to manage the memory, the management information area occupies more The storage space is smaller, so it can further save more storage space.
- the memory area allocation module can record the usage status of this part of the memory area in the management information area. For example, in FIG. 6B above, when the memory area division module adjusts the free space 1 to the service instance memory area, the memory area allocation module can record information such as the free space 1 is currently in an idle state in the management information area.
- the management information area also includes NUMA affinity information of the cloud service instance in the memory area of the service instance memory area.
- the NUMA affinity information may be information of a NUMA node managed by the memory, such as information of a processing core associated with the NUMA node, information of a NUMA node number to which the memory belongs, and the like.
- the memory area allocation module may allocate memory for the cloud service instance, and the name of the method for allocating memory may be called in a variety of ways, for example, it may be called a class partner algorithm. The name is not qualified.
- the method of allocating memory is described below through an example: For example, the memory area of a business instance is 512 GB, and cloud business instance 1 needs 100 GB of memory, so the 100 GB memory block is allocated to the cloud business instance 1. After that, when cloud service instance 2 requests a 20 GB memory block, 20 GB of memory is allocated to cloud service instance 2 from the memory in the idle state of the memory area of the service instance. After the cloud service instance 1 no longer needs memory, you can release the 100 GB memory block occupied by the cloud service instance 1, and update the usage status of the 100 GB memory block from the occupied state to the idle state in the management information area.
- the present application also provides a computer program product, the computer program product includes: computer program code or instructions, when the computer program code or instructions are run on a computer, the computer is made to execute FIG. 4 Relevant method steps involved in S201 and S202.
- the present application further provides a computer-readable storage medium, where the computer-readable medium stores program codes, and when the program codes are executed on a computer, the computer is made to execute S201 and S201 in FIG. 4 . Relevant method steps involved in S202.
- the present application further provides a chip system, where the chip system may include a processor.
- the processor is coupled to the memory and can be used to execute the relevant method steps involved in S201 and S202 in Fig. 4 .
- the chip system further includes a memory.
- Memory used to store computer programs (also called code, or instructions).
- the processor is used to call and run the computer program from the memory, so that the device with the chip system installed performs the relevant method steps involved in S201 and S202 in FIG. 4 .
- At least one involved in the embodiments of the present application includes one or more; wherein, multiple refers to greater than or equal to two.
- words such as “first” and “second” are only used for the purpose of distinguishing the description objects, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
- a computer program product includes one or more computer instructions.
- the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
- Computer instructions may be stored on or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server, or data center over a wire (e.g.
- coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless means to transmit to another website site, computer, server or data center.
- a computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media.
- Useful media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, high-density digital video disc (DVD)), or semiconductor media (eg, solid state disc (SSD)) )Wait.
- the network equipment in the above apparatus embodiments corresponds to the terminal equipment and the network equipment or terminal equipment in the method embodiments, and corresponding steps are performed by corresponding modules or units, for example, the communication unit (transceiver) performs the receiving or sending in the method embodiments.
- the steps other than sending and receiving can be performed by the processing unit (processor).
- processor For functions of specific units, reference may be made to corresponding method embodiments.
- the number of processors may be one or more.
- a component may be, but is not limited to, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer.
- an application running on a computing device and the computing device may be components.
- One or more components may reside within a process and/or thread of execution, and a component may be localized on one computer and/or distributed between two or more computers.
- these components can execute from various computer readable media having various data structures stored thereon.
- a component may, for example, be based on a signal having one or more data packets (eg, data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet interacting with other systems via signals) Communicate through local and/or remote processes.
- data packets eg, data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet interacting with other systems via signals
- the disclosed system, apparatus and method may be implemented in other manners.
- the apparatus embodiments described above are only illustrative.
- the division of units is only a logical function division.
- there may be other division methods for example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented.
- the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
- Units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
- the functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer-readable storage medium.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Memory System Of A Hierarchy Structure (AREA)
- Stored Programmes (AREA)
Abstract
The present application provides a method and apparatus for managing a memory of a physical server for running cloud service instances. An operating system memory area and a service instance memory area that do not overlap each other are provided in a physical memory of the physical server. The operating system of the physical server runs in the operating system memory area. A memory address range is set for cloud service instances in the service instance memory area, and the memory address range is recorded, wherein the cloud service instances run in the memory address range after being started in the operating system. Since page data structures are generated for the memory in the operating system memory area, but there is no need to generate page data structures for the service instance memory area, the number of the generated page data structures is reduced, and therefore, the space for storing the page data structures is also reduced, and the purpose of providing the physical memory for cloud service instances as much as possible can be achieved.
Description
本申请涉及通信领域,尤其涉及一种用于运行云业务实例的物理服务器的内存管理方法和装置。The present application relates to the field of communications, and in particular, to a memory management method and apparatus for running a physical server of a cloud service instance.
随着云计算的不断发展并趋于成熟,云计算产品不断得到企业广泛的认同和使用,同时物理服务器的内存规格也随着中央处理器(central processing unit,CPU)的更新迭代不断提升。With the continuous development and maturity of cloud computing, cloud computing products have been widely recognized and used by enterprises, and the memory specifications of physical servers have also been continuously improved with the update and iteration of the central processing unit (CPU).
操作系统为每个进程分配0-4吉字节(gigabyte,GB)的虚拟内存空间,而虚拟内存空间中的虚拟内存地址和物理内存中的物理内存地址是分离的,这样会给进程无需关心物理内存地址,带来便利性和安全性,但虚拟内存地址和物理内存地址的翻译会额外耗费计算机资源。而记录虚拟内存地址和物理内存地址的对应关系最简单的办法就是把该对应关系记录在一张表中,为了让翻译速度足够地快,这个表必须加载在内存中,但是,若表中分别记录每个虚拟内存地址和物理内存地址的对应关系,这种记录方式非常的浪费。The operating system allocates 0-4 gigabytes (gigabyte, GB) of virtual memory space for each process, and the virtual memory address in the virtual memory space and the physical memory address in the physical memory are separated, which will give the process no need to care Physical memory addresses bring convenience and security, but the translation of virtual memory addresses and physical memory addresses consumes additional computer resources. The easiest way to record the correspondence between virtual memory addresses and physical memory addresses is to record the correspondence in a table. In order to make the translation speed fast enough, this table must be loaded in memory. However, if the table records each The correspondence between a virtual memory address and a physical memory address is very wasteful.
因此,现有技术中,操作系统采用了分页的方式来记录虚拟内存地址和物理内存地址的对应关系,分页就是以更大尺寸的单位“页”来管理物理内存,而在操作系统中,以4KB为单位为物理内存分页并设置页编号,并以4千字节(kilobyte,KB)为单位为虚拟内存分页并设置页编号,并且每个物理内存页对应一个64字节(byte,B)的页数据结构,页数据结构可以用于记录物理内存的页编号与虚拟内存的页编号的对应关系。Therefore, in the prior art, the operating system uses paging to record the corresponding relationship between virtual memory addresses and physical memory addresses. Paging is to manage physical memory with a larger unit "page". The unit of 4KB is for physical memory paging and the page number is set, and the unit of 4 kilobytes (kilobyte, KB) is for virtual memory paging and the page number is set, and each physical memory page corresponds to a 64-byte (byte, B) The page data structure can be used to record the correspondence between the page number of the physical memory and the page number of the virtual memory.
为了维护所有的页数据结构,操作系统需要从物理内存中划分出一块区域用于存储这些以64B为基本单位的页数据结构。按照每4KB物理内存块对应64B的页数据结构计算,为了管理所有的4KB物理内存块,操作系统需要使用64B/4KB=1.5625%的物理内存存放多个页数据结构。In order to maintain all page data structures, the operating system needs to divide an area from physical memory for storing these page data structures with 64B as the basic unit. According to the 64B page data structure corresponding to each 4KB physical memory block, in order to manage all 4KB physical memory blocks, the operating system needs to use 64B/4KB=1.5625% of the physical memory to store multiple page data structures.
在公有云领域,云业务实例运行在物理服务器的操作系统中,且云业务实例实际运行在物理服务器分配给操作系统的物理内存上,对于物理服务器的所有者,即对于云服务提供商而言,目的是尽可能的将物理内存提供给云业务实例使用,才能最大化创造收益,但是若分配给操作系统的物理内存的1.5625%都要用来存放页数据结构,这对于云服务提供商来说是非常浪费物理内存资源的。In the public cloud field, cloud service instances run in the operating system of the physical server, and the cloud service instance actually runs on the physical memory allocated by the physical server to the operating system. For the owner of the physical server, that is, for the cloud service provider , the purpose is to provide physical memory for cloud service instances as much as possible, so as to maximize the creation of benefits, but if 1.5625% of the physical memory allocated to the operating system is used to store the page data structure, this is for cloud service providers. It is said to be a waste of physical memory resources.
发明内容SUMMARY OF THE INVENTION
为了解决上述问题,本申请提供了一种用于运行云业务实例的物理服务器的内存管理方法和装置,在物理服务器的物理内存中设置互不重叠的操作系统内存区和业务实例内存区,为操作系统分配操作系统内存区,且为操作系统中的云业务实例分配业务实例内存区,因此,需为操作系统内存区的内存生成页数据结构,而无需为业务实例内存区生成页数据结构,由于生成的页数据结构的数量减少,因此用于存储页数据结构的空间也随之减少,可实现尽可能将物理内存提供给云业务实例使用的目的。In order to solve the above problems, the present application provides a memory management method and device for running a physical server of a cloud service instance, in which non-overlapping operating system memory areas and service instance memory areas are set in the physical memory of the physical server, so as to The operating system allocates the operating system memory area, and allocates the service instance memory area for the cloud service instance in the operating system. Therefore, the page data structure needs to be generated for the memory in the operating system memory area, and the page data structure does not need to be generated for the service instance memory area. Since the number of generated page data structures is reduced, the space for storing the page data structures is also reduced, so as to achieve the purpose of providing physical memory for use by cloud service instances as much as possible.
第一方面,本申请提供一种物理服务器的内存管理方法。该方法中,物理服务器在物理内存设置互不重叠的操作系统内存区和业务实例内存区,在业务实例内存区为云业务实例设置内存地址范围,并记录该内存地址范围,其中云业务实例在操作系统中启动后运行在该内存地址范围。其中物理服务器的操作系统运行在操作系统内存区。In a first aspect, the present application provides a memory management method for a physical server. In this method, the physical server sets non-overlapping operating system memory areas and service instance memory areas in the physical memory, sets a memory address range for the cloud service instance in the service instance memory area, and records the memory address range, where the cloud service instance is in The operating system runs in this memory address range after booting. The operating system of the physical server runs in the operating system memory area.
针对现有技术,分配给操作系统的物理内存的1.5625%要用来存放页数据结构,而侵占了运行在操作系统的云业务实例的内存配额,基于现有技术中提供给操作系统的物理内存,本发明实施例为云业务实例在该物理内存中划分一个专门的业务实例内存区,在该物理内存中为操作系统划分一个专门的操作系统内存区,操作系统可以用操作系统内存区1.5625%存放页数据结构,但云业务实例不运行在操作系统内存区,而运行在业务实例内存区中,由于操作系统内存区相对于现有技术中提供给操作系统的物理内存变小(因为是从现有技术中提供给操作系统的物理内存划分出来的),因此需创建的页数据结构的数量减少,进而用于存储页数据结构的物理内存变小,进而可以节省出更多的存储空间以提供给云业务实例使用。According to the prior art, 1.5625% of the physical memory allocated to the operating system is used to store the page data structure, which occupies the memory quota of the cloud service instance running on the operating system. Based on the physical memory provided to the operating system in the prior art , the embodiment of the present invention divides a special service instance memory area in the physical memory for the cloud service instance, and divides a special operating system memory area for the operating system in the physical memory. The operating system can use 1.5625% of the operating system memory area The page data structure is stored, but the cloud service instance does not run in the operating system memory area, but runs in the service instance memory area, because the operating system memory area is smaller than the physical memory provided to the operating system in the prior art (because it is from In the prior art, the physical memory provided to the operating system is divided), so the number of page data structures to be created is reduced, and the physical memory used to store the page data structures becomes smaller, thereby saving more storage space to Provided for use by cloud business instances.
在一种可能的实施方式中,物理服务器为云业务实例分配云业务实例标识,在业务实例内存区申请一段空闲的内存空间,并将申请得到的内存空间的地址范围作为该内存地址范围。在业务实例内存区的管理信息区记录云业务实例标识与该云业务实例在业务实例内存区的内存地址范围。In a possible implementation, the physical server allocates a cloud service instance identifier to the cloud service instance, applies for a free memory space in the service instance memory area, and uses the address range of the memory space obtained by the application as the memory address range. The cloud service instance identifier and the memory address range of the cloud service instance in the service instance memory area are recorded in the management information area of the service instance memory area.
通过业务实例标识可区分不同云业务实例在业务实例内存区对应的内存地址范围,从而可在不同的云业务实例之间实现内存隔离,并支持在业务实例内存区同时运行多个不同的云业务实例,多个云业务实例之间内存互不影响。且相比业务实例内存区对应的页数据结构占用的内存空间,该管理信息区占用的内存空间更小,从而可以节省更多的内存空间给云业务实例使用。The memory address range corresponding to different cloud service instances in the service instance memory area can be distinguished by the service instance identifier, so that memory isolation can be achieved between different cloud service instances, and multiple different cloud services can be run simultaneously in the service instance memory area. instance, the memory of multiple cloud service instances does not affect each other. In addition, compared with the memory space occupied by the page data structure corresponding to the memory area of the business instance, the memory space occupied by the management information area is smaller, so that more memory space can be saved for use by the cloud business instance.
在一种可能的实施方式中,物理服务器在操作系统内存区的云业务实例的页表中写入该云业务实例在业务实例内存区的内存地址范围对应的地址。In a possible implementation manner, the physical server writes the address corresponding to the memory address range of the cloud service instance in the service instance memory area in the page table of the cloud service instance in the memory area of the operating system.
通过在操作系统内存区的云业务实例的页表中写入云业务实例在业务实例内存区中的地址范围对应的地址,可以保证处理器在操作系统中启动云业务实例时,通过查询云业务实例的页表,获得云业务实例在业务实例内存区中的地址范围对应的地址,从而使得处理器可根据所获得的该地址在业务实例内存区运行云业务实例。By writing the address corresponding to the address range of the cloud service instance in the memory area of the service instance into the page table of the cloud service instance in the memory area of the operating system, you can ensure that when the processor starts the cloud service instance in the operating system, it can query the cloud service by querying the cloud service instance. The page table of the instance obtains the address corresponding to the address range of the cloud service instance in the service instance memory area, so that the processor can run the cloud service instance in the service instance memory area according to the obtained address.
在一种可能的实施方式中,物理服务器在操作系统重新启动之后,将业务实例内存区记录的该云业务实例在业务实例内存区的内存地址范围对应的地址重新写入云业务实例的页表中。In a possible implementation manner, after the operating system is restarted, the physical server rewrites the address corresponding to the memory address range of the cloud service instance in the memory area of the service instance recorded in the memory area of the service instance into the page table of the cloud service instance middle.
云服务提供商会对操作系统进行升级、打补丁、或修补漏洞之后,需对操作系统 进行重启。现有技术中若操作系统重启,则会对分配给操作系统的物理内存中的数据清除,因此,运行在操作系统中的云业务实例在该物理内存中的数据会丢失,而在本申请中,由于云业务实例运行在业务实例内存区中,而不是运行在操作系统内存区中,因此操作系统重启只会造成操作系统内存区对应的物理内存中的数据清除,对业务实例内存区中的数据没有影响,在操作系统重启之后,通过重新写入地址到页表中,无需重新写入云业务实例的相关数据到内存中,可实现云业务实例的快速恢复。After the cloud service provider upgrades the operating system, applies patches, or fixes vulnerabilities, the operating system needs to be restarted. In the prior art, if the operating system is restarted, the data in the physical memory allocated to the operating system will be cleared. Therefore, the data in the physical memory of the cloud service instance running in the operating system will be lost, and in this application , because the cloud service instance runs in the memory area of the service instance instead of the memory area of the operating system, restarting the operating system will only clear the data in the physical memory corresponding to the memory area of the operating system. The data is not affected. After the operating system restarts, by rewriting the address to the page table, it is not necessary to rewrite the relevant data of the cloud service instance into the memory, which can realize the rapid recovery of the cloud service instance.
在一种可能的实施方式中,物理服务器以预设比例将物理服务器的物理内存分配给操作系统内存区和业务实例内存区。如此,云服务提供商可根据实际需要设置预设比例,可精细化地对内存进行管理。In a possible implementation manner, the physical server allocates the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio. In this way, the cloud service provider can set a preset ratio according to actual needs, and can manage the memory in a refined manner.
在一种可能的实施方式中,物理服务器还可以将操作系统内存区在物理内存中的内存地址范围和业务实例内存区在物理内存中的内存地址范围写入内存管理单元中,以实现对物理内存的划分。In a possible implementation manner, the physical server may also write the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory into the memory management unit, so as to realize the partition of memory.
在一种可能的实施方式中,物理服务器还可以通知内存管理单元修改记录的操作系统内存区在物理内存中的内存地址范围和操作系统内存区在物理内存中的内存地址范围,以将操作系统内存区中空闲的内存空间加入至业务实例内存区,或将业务实例内存区中空闲的内存空间加入至操作系统内存区。如此,可以实现操作系统内存区和业务实例内存区的范围可调的功能。In a possible implementation manner, the physical server may also notify the memory management unit to modify the recorded memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so that the operating system The free memory space in the memory area is added to the service instance memory area, or the free memory space in the service instance memory area is added to the operating system memory area. In this way, the function of adjusting the range of the operating system memory area and the service instance memory area can be realized.
在一种可能的实施方式中,物理服务器在操作系统进行初始化的过程中,生成操作系统内存区的页数据结构,页数据结构包括操作系统内存区中内存页的属性信息。物理服务器在操作系统进行初始化的过程中,不生成业务实例内存区的页数据结构。如此,可以加快操作系统初始化速度。In a possible implementation manner, the physical server generates a page data structure of the operating system memory area during the initialization of the operating system, and the page data structure includes attribute information of memory pages in the operating system memory area. During the initialization process of the operating system, the physical server does not generate the page data structure of the memory area of the service instance. In this way, the initialization speed of the operating system can be accelerated.
在一种可能的实施方式中,物理服务器在操作系统进行初始化的过程中,遍历内存管理信息表,确定出操作系统内存区的内存,并建立操作系统内存区的内存对应的页数据结构,在操作系统内存区存储页数据结构。In a possible implementation, the physical server traverses the memory management information table in the process of initializing the operating system, determines the memory in the operating system memory area, and establishes a page data structure corresponding to the memory in the operating system memory area. The operating system memory area stores page data structures.
在一种可能的实施方式中,内存管理信息表为E820。如此,可以提高兼容性。In a possible implementation, the memory management information table is E820. In this way, compatibility can be improved.
在一种可能的实施方式中,在内存管理信息表中包括:业务实例内存区的内存对应的标签值。业务实例内存区的内存对应的标签值用于指示:内存属于业务实例内存区的内存。如此,可以与现有技术更加兼容。In a possible implementation manner, the memory management information table includes: a tag value corresponding to the memory of the memory area of the service instance. The tag value corresponding to the memory of the business instance memory area is used to indicate that the memory belongs to the memory of the business instance memory area. In this way, it can be more compatible with the existing technology.
在一种可能的实施方式中,云业务实例包括:虚拟机或安全容器。In a possible implementation, the cloud service instance includes: a virtual machine or a secure container.
第二方面,提供了一种物理服务器,该物理服务器包括用于执行第一方面或第一方面任一种可能实现方式中的各个模块。In a second aspect, a physical server is provided, where the physical server includes modules for executing the first aspect or any possible implementation manner of the first aspect.
第三方面,提供了一种物理服务器,该物理服务器包括处理器和存储器。存储器中用于存储计算机执行指令,处理器执行存储器中的计算机执行指令以执行第一方面的任一种可能实现方式中方法的操作步骤。In a third aspect, a physical server is provided, the physical server includes a processor and a memory. The memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions in the memory to perform the operation steps of the method in any possible implementation manner of the first aspect.
第四方面,本申请提供一种计算机可读存储介质,计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面的方法。In a fourth aspect, the present application provides a computer-readable storage medium. The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to execute the methods of the above aspects.
第五方面,本申请提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述各方面的方法。In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the methods of the above aspects.
本申请在上述各方面提供的实现方式的基础上,还可以进行进一步组合以提供更 多实现方式。On the basis of the implementation manners provided by the above aspects, the present application may further combine to provide more implementation manners.
图1是本申请实施例的一种系统架构示意图;1 is a schematic diagram of a system architecture according to an embodiment of the present application;
图2为图1中一个服务器的结构示意图;Fig. 2 is the structural representation of a server in Fig. 1;
图3为本申请实施例提供的一种虚拟地址与物理地址之间的对应关系的示意图;3 is a schematic diagram of a correspondence between a virtual address and a physical address provided by an embodiment of the present application;
图4为本申请实施例提供的一种物理服务器的内存管理方法的流程示意图;4 is a schematic flowchart of a memory management method for a physical server provided by an embodiment of the present application;
图5为图2中的物理内存的结构示意图;5 is a schematic structural diagram of the physical memory in FIG. 2;
图6A为将图3中业务实例内存区中的内存调整为操作系统内存区的内存的示意图;6A is a schematic diagram of adjusting the memory in the business instance memory area in FIG. 3 to the memory in the operating system memory area;
图6B为将图3中操作系统内存区中的内存调整为业务实例内存区的内存的示意图。FIG. 6B is a schematic diagram of adjusting the memory in the operating system memory area in FIG. 3 to the memory in the service instance memory area.
下面将结合附图对本申请实施例作进一步地详细描述。The embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
图1示例性示出了本申请实施例适用的一种系统架构,如图1所示,该系统可以提供云管理平台功能。云管理平台功能:提供访问接口(如界面或应用程序编程接口(Application Programming Interface,API)),租户可操作客户端远程接入访问接口在云管理平台注册云账号和密码,并登录云管理平台,云管理平台对云账号和密码鉴权成功后,租户可进一步在云管理平台付费选择并购买特定规格(处理器、内存、磁盘)的虚拟机,付费购买成功后,云管理平台提供所购买的虚拟机的远程登录账号密码,客户端可远程登录该虚拟机,在该虚拟机中安装并运行租户的应用。FIG. 1 exemplarily shows a system architecture to which the embodiments of the present application are applicable. As shown in FIG. 1 , the system may provide a cloud management platform function. Cloud management platform function: Provide access interface (such as interface or Application Programming Interface (API)), tenant can operate client remote access access interface to register cloud account and password in cloud management platform, and log in cloud management platform , after the cloud management platform successfully authenticates the cloud account and password, the tenant can further select and purchase virtual machines of specific specifications (processor, memory, disk) on the cloud management platform. After the payment is successful, the cloud management platform provides the purchased virtual machine The remote login account and password of the virtual machine, the client can remotely log in to the virtual machine, and install and run the tenant's application in the virtual machine.
云管理平台逻辑功能划分:用户控制台、计算管理服务、网络管理服务、存储管理服务、鉴权服务、镜像管理服务。用户控制台提供界面或API与租户交互,计算管理服务用于管理运行虚拟机和容器的服务器以及裸金属服务器,网络管理服务用于管理网络服务(如网关、防火墙等),存储管理服务用于管理存储服务(如数据桶服务),鉴权服务用于管理租户的账号密码,镜像管理服务用于管理虚拟机镜像。The logical function division of the cloud management platform: user console, computing management service, network management service, storage management service, authentication service, and image management service. The user console provides interfaces or APIs to interact with tenants, the computing management service is used to manage servers running virtual machines and containers and bare metal servers, the network management service is used to manage network services (such as gateways, firewalls, etc.), and the storage management service is used to manage Manage storage services (such as data bucket services), authentication services are used to manage tenant account passwords, and image management services are used to manage virtual machine images.
云管理平台客户端功能:接收云管理平台发送的控制面命令,根据控制面控制命令在服务器上创建并对虚拟机进行全生命周期管理。Cloud management platform client function: Receive control plane commands sent by the cloud management platform, create on the server according to the control plane control commands, and perform full life cycle management of virtual machines.
因此,租户可通过云管理平台在云数据中心中创建、管理、登录和操作虚拟机。Therefore, tenants can create, manage, log in and operate virtual machines in the cloud data center through the cloud management platform.
其中,虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。在服务器中能够完成的工作在虚拟机中都能够实现。在服务器中创建虚拟机时,需要将实体机的部分硬盘和内存容量作为虚拟机的硬盘和内存容量,每个虚拟机都有独立的硬盘和操作系统,虚拟机的用户可以像使用服务器一样对虚拟机进行操作。Among them, a virtual machine (Virtual Machine) refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. Anything that can be done in a server can be done in a virtual machine. When creating a virtual machine in a server, you need to use part of the hard disk and memory capacity of the physical machine as the hard disk and memory capacity of the virtual machine. Each virtual machine has an independent hard disk and operating system. virtual machine to operate.
虚拟机也可称为云服务器(Elastic Compute Service,ECS)、弹性实例(不同的云服务提供商提供不同的叫法)。Virtual machines can also be called cloud servers (Elastic Compute Service, ECS), elastic instances (different cloud service providers provide different names).
图2示例性示出了图1中一个服务器的结构示意图。本申请实施例中服务器也可 以称为物理服务器。图2中是以图1中的服务器1为例进行介绍的,需要说明的是,图2所示的服务器可以为图1所示的系统架构中的任一个服务器,并不局限于服务器1。FIG. 2 exemplarily shows a schematic structural diagram of a server in FIG. 1 . In this embodiment of the present application, the server may also be referred to as a physical server. In FIG. 2 , the server 1 in FIG. 1 is used as an example for introduction. It should be noted that the server shown in FIG. 2 may be any server in the system architecture shown in FIG. 1 , and is not limited to server 1 .
如图2所示,服务器包括硬件层和软件层,硬件层为服务器的常规配置,其中外设部件互连标准(peripheral component interconnect,PCI)设备可例如为网卡、图形处理器(graphics processing unit,GPU)、卸载卡等可插置到服务器的PCI/PCIe插槽上的设备。As shown in FIG. 2, the server includes a hardware layer and a software layer, and the hardware layer is a conventional configuration of the server, wherein the peripheral component interconnect (PCI) device may be, for example, a network card, a graphics processing unit (graphics processing unit, GPU), offload cards, and other devices that can be plugged into the server's PCI/PCIe slots.
如图2所示,在硬件层中,服务器还可以包括处理器和内存。本申请实施例中服务器中的内存也可以称为物理内存或存储器。As shown in Figure 2, in the hardware layer, the server may also include a processor and memory. The memory in the server in this embodiment of the present application may also be referred to as physical memory or storage.
进一步的,该服务器还可以进一步包括总线系统,其中,处理器和物理内存可以通过总线系统相连。Further, the server may further include a bus system, wherein the processor and the physical memory may be connected through the bus system.
处理器可以是一个芯片,具有信号的处理能力。例如,该处理器可以是现场可编程门阵列(field programmable gate array,FPGA),可以是专用集成芯片(application specific integrated circuit,ASIC),还可以是系统芯片(system on chip,SoC),还可以是中央处理器(central processor unit,CPU),还可以是网络处理器(network processor,NP),还可以是数字信号处理电路(digital signal processor,DSP),还可以是微控制器(micro controller unit,MCU),还可以是可编程控制器(programmable logic device,PLD)或其他集成芯片。The processor can be a chip with signal processing capabilities. For example, the processor may be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), or a It is a central processing unit (CPU), a network processor (NP), a digital signal processing circuit (DSP), or a microcontroller (microcontroller unit). , MCU), it can also be a programmable logic device (PLD) or other integrated chips.
在实现过程中,本申请实施例中方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于物理内存,处理器读取物理内存中的信息,结合其硬件完成本申请实施例中方法的步骤。In the implementation process, each step of the method in the embodiments of the present application may be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiments of the present application may be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. The storage medium is located in the physical memory, and the processor reads the information in the physical memory, and completes the steps of the method in the embodiment of the present application in combination with its hardware.
可以理解,本申请实施例中的物理内存可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。应注意,本文描述的物理内存区旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the physical memory in this embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory. Volatile memory may be random access memory (RAM), which acts as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM) ) and direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the physical memory areas described herein are intended to include, but not be limited to, these and any other suitable types of memory.
本申请实施例中物理内存可以包括两个内存区,分别为操作系统内存区和业务实例内存区。操作系统运行在操作系统内存区,并在业务实例内存区为云业务实例分配 内存。In this embodiment of the present application, the physical memory may include two memory areas, which are an operating system memory area and a service instance memory area, respectively. The operating system runs in the operating system memory area, and allocates memory for cloud service instances in the service instance memory area.
如图2所示,该物理服务器中还可以设置内存管理单元。内存管理单元可以为内存管理单元(memory management unit,MMU)等。在有些场景下,内存管理单元可以有其他名称,比如内存管理器、内存管理模块等等。内存管理单元是指用于对内存进行管理的模块、单元或组件等。下面对内存管理单元进行介绍:As shown in FIG. 2 , a memory management unit may also be set in the physical server. The memory management unit may be a memory management unit (memory management unit, MMU) or the like. In some scenarios, the memory management unit can have other names, such as memory manager, memory management module, and so on. A memory management unit refers to a module, unit, or component, etc., used to manage memory. The following describes the memory management unit:
操作系统中会执行一个或多个进程程序,程序发出的地址是与物理内存的地址无关的虚拟内存的地址。即,程序中看到的内存地址是虚拟内存的地址,例如虚拟内存范围为0-4GB,程序读写内存时会被映射到实际的物理内存中,这个映射称为翻译,这个翻译工作可以由内存管理单元(比如MMU)来完成。One or more process programs are executed in the operating system, and the address issued by the program is the address of the virtual memory which is not related to the address of the physical memory. That is, the memory address seen in the program is the address of the virtual memory. For example, the virtual memory range is 0-4GB. When the program reads and writes memory, it will be mapped to the actual physical memory. This mapping is called translation. This translation work can be done by Memory management unit (such as MMU) to complete.
举个例子:内存管理单元可以接收处理器发出的虚拟内存页的地址,根据页表中记录的虚拟内存页的地址与物理内存页的地址的映射关系,查找出该虚拟内存页的地址对应的物理内存页的地址,并将查找到的物理内存页的地址发送给处理器,处理器按照该物理内存页的地址和偏移量从物理内存页中偏移量对应的地址读出或写入相关数据。For example, the memory management unit can receive the address of the virtual memory page sent by the processor, and find out the address corresponding to the address of the virtual memory page according to the mapping relationship between the address of the virtual memory page recorded in the page table and the address of the physical memory page. The address of the physical memory page, and the address of the found physical memory page is sent to the processor, and the processor reads or writes from the address corresponding to the offset in the physical memory page according to the address and offset of the physical memory page. related data.
如图2所示,软件层包括安装并运行在服务器上的操作系统(相对虚拟机的操作系统可称为宿主机操作系统),宿主机操作系统中设置有虚拟机管理器(virtual machine manager,VMM)(又可称为Hypervisor,又可称虚拟机监视器(Virtual Machine Monitor,VMM))。虚拟机管理器的作用是实现虚拟机的计算虚拟化、网络虚拟化以及存储虚拟化,并负责管理虚拟机。As shown in Figure 2, the software layer includes an operating system installed and running on the server (the operating system relative to the virtual machine can be called the host operating system), and the host operating system is provided with a virtual machine manager (virtual machine manager, VMM) (also known as Hypervisor, also known as Virtual Machine Monitor (VMM)). The role of the virtual machine manager is to realize the computing virtualization, network virtualization and storage virtualization of the virtual machine, and is responsible for managing the virtual machine.
虚拟机管理器可以为每个虚拟机虚拟出一套与真实硬件无关的虚拟硬件系统,如虚拟显示器、虚拟硬盘、虚拟处理器(Virtual CPU,VCPU)、虚拟内存、虚拟网卡等。虚拟机中可基于虚拟硬件和虚拟机操作系统运行应用(applications),其中该应用为租户安装并配置的应用。本申请实施例中虚拟机监视器可以运行在本申请实施例中提到的操作系统内存区,也可以运行在业务实例内存区,本申请实施例对此不做限制。The virtual machine manager can virtualize a set of virtual hardware systems independent of real hardware for each virtual machine, such as virtual display, virtual hard disk, virtual processor (Virtual CPU, VCPU), virtual memory, virtual network card, etc. Applications (applications) may be run in the virtual machine based on virtual hardware and a virtual machine operating system, wherein the applications are applications installed and configured by the tenant. In the embodiment of the present application, the virtual machine monitor may run in the operating system memory area mentioned in the embodiment of the present application, or may run in the memory area of the service instance, which is not limited in the embodiment of the present application.
计算虚拟化是指将服务器的处理器和内存的部分提供给虚拟机,网络虚拟化是指将网卡的部分功能(如带宽)提供给虚拟机,存储虚拟化是指将部分磁盘提供给虚拟机。虚拟机管理器还可实现不同虚拟机之间的逻辑隔离并管理虚拟机,例如创建虚拟机、根据硬件层为虚拟机模拟虚拟硬件(硬件模拟功能)、删除虚拟机、转发和/或处理运行在该服务器上的所有虚拟机(例如虚拟机1和虚拟机2)之间的网络报文或转发该服务器上的虚拟机与外部网络之间的网络报文(虚拟交换功能),处理虚拟机产生的I/O等。Computing virtualization refers to providing part of the processor and memory of the server to the virtual machine, network virtualization refers to providing some functions of the network card (such as bandwidth) to the virtual machine, and storage virtualization refers to providing part of the disk to the virtual machine. . The virtual machine manager can also achieve logical isolation between different virtual machines and manage virtual machines, such as creating virtual machines, emulating virtual hardware for virtual machines according to the hardware layer (hardware emulation function), deleting virtual machines, forwarding and/or processing running Network packets between all virtual machines on the server (such as virtual machine 1 and virtual machine 2) or forward network packets between virtual machines on the server and external networks (virtual switching function), processing virtual machines Generated I/O, etc.
不同虚拟机中的运行环境(如虚拟机应用、操作系统和虚拟硬件)是完全隔离的,虚拟机1和虚拟机2之间要进行通信需经过虚拟管理器转发网络报文。The running environments (such as virtual machine applications, operating systems, and virtual hardware) in different virtual machines are completely isolated. To communicate between virtual machine 1 and virtual machine 2, network packets need to be forwarded through a virtual manager.
租户可远程登录虚拟机,在虚拟机操作系统环境下操作虚拟机安装、设置以及卸载应用。Tenants can log in to the virtual machine remotely, and operate the virtual machine to install, set, and uninstall applications in the virtual machine operating system environment.
如图2所示,虚拟机管理器中还可以设置两个模块,为内存区划分模块和内存区分配模块。其中,内存区划分模块可以用于将物理内存划分为操作系统内存区和业务 实例内存区。内存区分配模块可以用于为虚拟机分配内存。内存区划分模块还可以称为随机存储器(random access memory,RAM)划分(partition)模块,内存区分配模块还可以称为实例随机存储器内存分配(instance RAM allocator)模块。As shown in FIG. 2 , two modules may also be set in the virtual machine manager, a module for dividing a memory area and a module for allocating a memory area. The memory area division module can be used to divide the physical memory into the operating system memory area and the service instance memory area. The memory area allocation module can be used to allocate memory for virtual machines. The memory area partitioning module may also be referred to as a random access memory (RAM) partition module, and the memory area allocation module may also be referred to as an instance RAM allocator (instance RAM allocator) module.
应理解,以上装置的单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。本申请实施例中,内存区分配模块和内存区划分模块可以由上述图1的处理器通过运行操作系统内存区存储的程序指令实现。It should be understood that the division of the units of the above apparatus is only a division of logical functions, and may be fully or partially integrated into a physical entity in actual implementation, or may be physically separated. In this embodiment of the present application, the memory area allocation module and the memory area division module may be implemented by the processor of FIG. 1 by running program instructions stored in the memory area of the operating system.
如图2所示,操作系统中为不同的租户设置不同的虚拟机。需要说明的是一台物理服务器可以同时提供多个虚拟机,图2中仅仅是以两个虚拟机为例进行示意,实际应用中,对一个服务器虚拟出的虚拟机的数量不做限制。As shown in Figure 2, different virtual machines are set for different tenants in the operating system. It should be noted that one physical server can provide multiple virtual machines at the same time, and FIG. 2 only takes two virtual machines as an example for illustration. In practical applications, there is no limit to the number of virtual machines virtualized by one server.
内存虚拟化技术的目的是为了提供给虚拟机一个从0地址开始的连续物理内存空间,在虚拟机之间有效隔离和调度内存资源。The purpose of memory virtualization technology is to provide virtual machines with a continuous physical memory space starting from address 0, and to effectively isolate and schedule memory resources between virtual machines.
内存虚拟化技术主要涉及客户机虚拟地址(Guest Virtual Address,GVA)—>客户机物理地址(Guest Physical Address,GPA)—>宿主机虚拟地址(Host Virtual Address,HVA)—>宿主机物理地址(Host Physical Address,HPA)的转换。Memory virtualization technology mainly involves guest virtual address (Guest Virtual Address, GVA)—> guest physical address (Guest Physical Address, GPA)—> host virtual address (Host Virtual Address, HVA)—> host physical address ( Host Physical Address, HPA) conversion.
而在虚拟化技术中,物理主机上往往运行有多个虚拟机,每个虚拟机均以为自己独占物理主机的内存空间,因此虚拟机以客户机物理地址(Guest Physical Address,GPA)表示虚拟机所拥有的内存空间,其中该内存空间被虚拟机认为是连续的(即可以理解为虚拟机认为自己拥有一个完成的物理内存条)。In the virtualization technology, there are often multiple virtual machines running on a physical host, and each virtual machine thinks that it occupies the memory space of the physical host. Therefore, the virtual machine uses the guest physical address (Guest Physical Address, GPA) to represent the virtual machine The memory space owned by the virtual machine, which is considered to be continuous by the virtual machine (that is, it can be understood that the virtual machine thinks that it has a completed physical memory bank).
GVA是虚拟机的操作系统对GPA进行映射而形成的地址,虚拟机的操作系统将GVA提供给设置在虚拟机的操作系统上的进程或应用软件使用,虚拟机的操作系统记录GVA到GPA的映射关系,GVA到GPA的转化是由虚拟机的操作系统的页表实现的。GVA is the address formed by the virtual machine's operating system mapping GPA. The virtual machine's operating system provides GVA to the process or application software set on the virtual machine's operating system, and the virtual machine's operating system records the GVA to GPA. The mapping relationship, the conversion of GVA to GPA is implemented by the page table of the operating system of the virtual machine.
HPA是实际的物理内存地址,HVA是宿主机的操作系统对HPA进行映射而形成的地址,宿主机的操作系统将HVA提供给操作系统上的进程(例如虚拟机)使用,宿主机的操作系统记录HVA到HPA的映射关系,HVA到HPA的转化是由宿主机的操作系统的页表实现的。HPA is the actual physical memory address, HVA is the address formed by the operating system of the host machine mapping the HPA, the operating system of the host machine provides the HVA to the process (such as a virtual machine) on the operating system, and the operating system of the host machine uses the HVA. Record the mapping relationship between HVA and HPA. The conversion from HVA to HPA is implemented by the page table of the operating system of the host.
图3示例性示出了本申请实施例提供的一种虚拟地址与物理地址之间的对应关系的示意图。如图3所示,虚拟机1和虚拟机2设置在同一个服务器(下称宿主机)中,宿主机的虚拟机管理器将虚拟机1的GPA地址范围设置为0-5GB,其对应于物理内存上的HPA地址范围1.5GB-4.5GB以及6.5GB-8.5GB。并且,宿主机的虚拟机管理器将虚拟机2的GPA地址范围设置为0-4GB,对应于物理内存上的HPA地址范围9GB-11GB以及13GB-15GB。因此虚拟机1独占使用0-5GB的GPA地址范围,虚拟机2独占使用0-4GB的GPA地址范围。该0-5GB的GPA地址范围和该0-4GB的GPA地址范围均可对应至物理内存上的不同的HPA地址范围,从而实现虚拟机内存的隔离。FIG. 3 exemplarily shows a schematic diagram of a correspondence relationship between a virtual address and a physical address provided by an embodiment of the present application. As shown in Figure 3, virtual machine 1 and virtual machine 2 are set in the same server (hereinafter referred to as the host machine), and the virtual machine manager of the host machine sets the GPA address range of virtual machine 1 to 0-5GB, which corresponds to The HPA address range on physical memory is 1.5GB-4.5GB and 6.5GB-8.5GB. Moreover, the virtual machine manager of the host machine sets the GPA address range of the virtual machine 2 to 0-4GB, which corresponds to the HPA address ranges of 9GB-11GB and 13GB-15GB on the physical memory. Therefore, virtual machine 1 exclusively uses the GPA address range of 0-5GB, and virtual machine 2 exclusively uses the GPA address range of 0-4GB. Both the 0-5GB GPA address range and the 0-4GB GPA address range can correspond to different HPA address ranges on the physical memory, so as to achieve virtual machine memory isolation.
其中,GPA地址范围与上文所描述的虚拟机规格相关,例如租户可以在云管理平台中设置虚拟机规格中内存大小为5G的虚拟机1,此时虚拟机管理器被云管理平台通知需创建GPA为0-5G的虚拟机1。Among them, the GPA address range is related to the virtual machine specifications described above. For example, the tenant can set the virtual machine 1 with a memory size of 5G in the virtual machine specification in the cloud management platform. At this time, the virtual machine manager is notified by the cloud management platform that it needs to Create virtual machine 1 with a GPA of 0-5G.
基于上述内容,图4示例性示出了本申请实施例提供的一种物理服务器的内存管理方法的流程示意图。该方法可以由上述图2中的宿主机操作系统中的虚拟机管理器执行。再比如该方法可以由上述图2中的虚拟机管理器中的内存区划分模块和内存区分配模块执行。再比如,该方法可以由前述图2中的处理器执行,可通过处理器执行操作系统内存区存储的程序指令实现内存区划分模块和内存区分配模块的相关功能。该方法可以包括:Based on the above content, FIG. 4 exemplarily shows a schematic flowchart of a memory management method for a physical server provided by an embodiment of the present application. The method may be executed by the virtual machine manager in the host operating system in the above-mentioned FIG. 2 . For another example, the method may be executed by the memory area division module and the memory area allocation module in the virtual machine manager in FIG. 2 . For another example, the method may be executed by the processor shown in FIG. 2, and the related functions of the memory area division module and the memory area allocation module may be implemented by the processor executing program instructions stored in the memory area of the operating system. The method can include:
S201,内存区划分模块用于在物理服务器的物理内存设置互不重叠的操作系统内存区和业务实例内存区,其中物理服务器的操作系统运行在操作系统内存区。S201 , the memory area division module is configured to set non-overlapping operating system memory areas and service instance memory areas in the physical memory of the physical server, where the operating system of the physical server runs in the operating system memory area.
S201可以由前述图2所示的处理器执行,可通过处理器执行操作系统内存区存储的程序指令实现内存区划分模块的相关功能。S201 may be executed by the aforementioned processor shown in FIG. 2 , and the relevant functions of the memory area division module may be implemented by the processor executing the program instructions stored in the memory area of the operating system.
S202,内存区分配模块用于在业务实例内存区为云业务实例设置内存地址范围,并记录该内存地址范围,其中云业务实例在操作系统中启动后运行在该内存地址范围。S202, the memory area allocation module is configured to set a memory address range for the cloud service instance in the service instance memory area, and record the memory address range, where the cloud service instance runs in the memory address range after being started in the operating system.
S202可以由前述图2所示的处理器执行,可通过处理器执行操作系统内存区存储的程序指令实现内存区分配模块的相关功能。S202 may be executed by the processor shown in FIG. 2, and the relevant functions of the memory area allocation module may be implemented by the processor executing the program instructions stored in the memory area of the operating system.
在本申请实施例中云业务实例包括但不限于:虚拟机(virtual machine,VM)、容器(container)。In the embodiments of this application, cloud service examples include, but are not limited to: virtual machines (virtual machines, VMs) and containers (containers).
在实际应用中,由于当业务实例内存区中的一块内存划分给云业务实例之后,该部分内存基本上不会再另做他用,直至被释放。基于此,物理服务器对业务实例内存区的内存管理也就不需要通过页数据结构进行管理。另一方面,物理服务器不通过页数据结构管理业务实例内存区的内存,看似在内存管理上会失去很多由页数据结构带来的好处(页数据结构带来的好处,例如可以包括:碎片少,能够实现内存交换、相同内存页合并、内存按需分配(Populate on demand,POD)等高级特性等),但是实际上,由于一块内存被划分给云业务实例之后,该云业务实例如何使用该部分内存,物理服务器的宿主机操作系统不会再进行干涉,也不会将该内存区中的内存再挪作他用,因此即使在物理内存上针对该分配给云业务实例的物理内存区建立页数据结构,也并不会将页数据结构的好处充分发挥。基于上述理由,本申请实施例中针对业务实例内存区的管理上针对云计算业务的特点舍弃了通过页数据结构进行管理的方式,进而可以节省出用于存储云业务实例内存的内存对应的页数据结构的内存,基于此方案,云服务提供商可以将物理服务器的物理内存尽可能多地提供给租户使用,从而获得更大的收益。In practical applications, after a piece of memory in the memory area of a business instance is allocated to a cloud business instance, this part of the memory will basically not be used for other purposes until it is released. Based on this, the memory management of the memory area of the business instance by the physical server does not need to be managed by the page data structure. On the other hand, the physical server does not manage the memory in the memory area of the business instance through the page data structure. It seems that many of the benefits brought by the page data structure will be lost in memory management (the benefits brought by the page data structure, for example, can include: fragmentation It can realize advanced features such as memory exchange, merging of the same memory pages, and memory on demand (Populate on demand, POD), etc.), but in fact, since a piece of memory is allocated to a cloud business instance, how does the cloud business instance use it? For this part of memory, the host operating system of the physical server will no longer interfere, nor will the memory in this memory area be used for other purposes. Therefore, even if the physical memory is used for the physical memory area allocated to the cloud service instance Establishing a page data structure does not fully utilize the benefits of the page data structure. Based on the above reasons, the management of the service instance memory area in the embodiment of the present application abandons the management method through the page data structure according to the characteristics of the cloud computing service, thereby saving the page corresponding to the memory used for storing the memory of the cloud service instance The memory of the data structure, based on this scheme, the cloud service provider can provide as much physical memory of the physical server as possible to the tenants, so as to obtain greater benefits.
进一步,操作系统进行初始化的过程中,可生成操作系统内存区的页数据结构,页数据结构包括操作系统内存区中内存页的属性信息,比如可以包括操作系统内存区中的物理内存和虚拟内存之间的对应关系。而基于本发明实施例的内存分区,操作系统进行初始化的过程中,仅生成操作系统内存区对应的页数据结构,而不生成业务实例内存区的页数据结构,因此,生成页数据结构的工作量下降,因此可以加速操作系统初始化启动速度。Further, during the initialization of the operating system, a page data structure of the operating system memory area can be generated, and the page data structure includes attribute information of the memory pages in the operating system memory area, such as physical memory and virtual memory in the operating system memory area. Correspondence between. However, based on the memory partition of the embodiment of the present invention, in the process of initializing the operating system, only the page data structure corresponding to the operating system memory area is generated, and the page data structure of the business instance memory area is not generated. Therefore, the work of generating the page data structure is The amount is reduced, so the operating system initialization startup speed can be accelerated.
在S202中,具体可以由内存区分配模块为云业务实例分配云业务实例标识,在业 务实例内存区申请一段空闲的内存空间,并将申请得到的内存空间的地址范围作为云业务实例的物理内存的内存地址范围,在业务实例内存区的管理信息区记录云业务实例标识与云业务实例的物理内存的内存地址范围。该内容也可以由前述图2所示的处理器执行,可通过处理器执行操作系统内存区存储的程序指令实现内存区分配模块的相关功能。In S202, the memory area allocation module may allocate a cloud service instance identifier to the cloud service instance, apply for a free memory space in the memory area of the service instance, and use the address range of the applied memory space as the physical memory of the cloud service instance The memory address range of the cloud service instance and the memory address range of the physical memory of the cloud service instance are recorded in the management information area of the service instance memory area. The content can also be executed by the processor shown in FIG. 2, and the relevant functions of the memory area allocation module can be implemented by the processor executing the program instructions stored in the memory area of the operating system.
并请参见图5,图5示例性示出了一种图2中的物理内存的结构示意图,如图5所示,物理内存中包括操作系统内存区和业务实例内存区。内存区分配模块可以在业务实例内存区中基于管理信息区进行内存管理。内存区分配模块在业务实例内存区中建立管理信息区,该管理信息区可存储于在业务实例内存区中划出的一部分区域中。Referring to FIG. 5, FIG. 5 exemplarily shows a schematic structural diagram of the physical memory in FIG. 2. As shown in FIG. 5, the physical memory includes an operating system memory area and a service instance memory area. The memory area allocation module can perform memory management based on the management information area in the service instance memory area. The memory area allocation module establishes a management information area in the service instance memory area, and the management information area can be stored in a part of the area demarcated in the service instance memory area.
图5中还在业务实例内存区中示意性示出了内存区分配模块为云业务实例1分配的物理内存区和为云业务实例2分配的内存区。并且,业务实例内存区中还可以包括空闲空间,比如空闲空间2。内存区分配模块可以在管理信息区中记录云业务实例1的标识与云业务实例1的物理内存区的内存地址范围的映射关系,以及云业务实例2的标识与云业务实例2的物理内存区的内存地址范围的映射关系。FIG. 5 also schematically shows the physical memory area allocated by the memory area allocation module for cloud service instance 1 and the memory area allocated for cloud service instance 2 in the service instance memory area. In addition, the service instance memory area may further include free space, such as free space 2 . The memory area allocation module may record the mapping relationship between the identifier of cloud service instance 1 and the memory address range of the physical memory area of cloud service instance 1, and the identifier of cloud service instance 2 and the physical memory area of cloud service instance 2 in the management information area. The mapping relationship of the memory address range.
继续参见图5,由于操作系统内存区可以用于运行操作系统,因此,在操作系统内存区中可以基于页数据结构进行内存管理,即通过在操作系统内存区中建立页数据结构的方式实现对操作系统内存区的管理。该页数据结构可存储于在操作系统内存区中划出的一部分区域中。如此,可以兼容操作系统运行环境的要求。图5中的操作系统内存区中还可以包括空闲空间,比如空闲空间1。操作系统内存区中一个4KB页对应一个64B的页数据结构,该页数据结构可以包括该4KB页的物理内存的地址所对应的虚拟内存的地址。Continuing to refer to FIG. 5, since the operating system memory area can be used to run the operating system, memory management can be performed based on the page data structure in the operating system memory area, that is, by establishing a page data structure in the operating system memory area, the Management of operating system memory areas. The page data structure may be stored in a portion of an area demarcated in the operating system memory area. In this way, the requirements of the operating environment of the operating system can be complied with. The operating system memory area in FIG. 5 may also include free space, such as free space 1 . A 4KB page in the operating system memory area corresponds to a 64B page data structure, and the page data structure may include the address of the virtual memory corresponding to the address of the physical memory of the 4KB page.
一方面,由于通过管理信息区记录了云业务实例标识与云业务实例的物理内存的内存地址范围,因此,可以通过管理信息区对业务实例内存区进行管理。比如可以根据管理信息区记录的信息知道业务实例内存区的哪些内存分配给了哪个云业务实例,还可以知道业务实例内存区的哪些内存处于空闲状态。如此,可以将处于空闲状态的业务实例内存区的内存分配给其他云业务实例使用。On the one hand, since the cloud service instance identifier and the memory address range of the physical memory of the cloud service instance are recorded through the management information area, the service instance memory area can be managed through the management information area. For example, according to the information recorded in the management information area, you can know which memory in the business instance memory area is allocated to which cloud service instance, and also know which memory in the business instance memory area is in an idle state. In this way, the memory in the memory area of the service instance in the idle state can be allocated to other cloud service instances for use.
另一方面,通过业务实例标识可区分不同云业务实例在业务实例内存区对应的内存地址范围,从而可在不同的云业务实例之间实现内存隔离,并支持在业务实例内存区同时运行多个不同的云业务实例,多个云业务实例之间内存互不影响。On the other hand, the memory address range corresponding to different cloud service instances in the service instance memory area can be distinguished by the service instance identifier, so that memory isolation can be achieved between different cloud service instances, and multiple cloud service instances can be run simultaneously in the service instance memory area. For different cloud service instances, the memory of multiple cloud service instances does not affect each other.
相比业务实例内存区对应的页数据结构占用的内存空间,该管理信息区占用的内存空间更小,从而可以节省更多的内存空间给云业务实例使用。Compared with the memory space occupied by the page data structure corresponding to the memory area of the service instance, the memory space occupied by the management information area is smaller, so that more memory space can be saved for use by the cloud service instance.
当操作系统重新启动的情况下,操作系统内存区存储的内容会被清除,而由于业务实例内存区并不是可以用于运行操作系统的区域,因此随着操作系统的重新启动,业务实例内存区的内容并不会被清除。即业务实例内存区的数据不会受到影响,因此在操作系统进行系统升级重启后升级后,不会影响到云业务实例,可以根据业务实例内存区的管理信息区存储的信息,快速恢复云业务实例,对于云服务提供商而言,可以随时进行操作系统升级,无需顾忌会影响到租户侧的云业务实例的数据,因此更加便利。When the operating system is restarted, the contents stored in the operating system memory area will be cleared. Since the business instance memory area is not an area that can be used to run the operating system, as the operating system restarts, the business instance memory area will be cleared. content will not be cleared. That is, the data in the memory area of the service instance will not be affected. Therefore, after the operating system is upgraded and restarted, the cloud service instance will not be affected. The cloud service can be quickly restored according to the information stored in the management information area of the memory area of the service instance. For instance, for the cloud service provider, the operating system can be upgraded at any time, and there is no need to worry about the data of the cloud service instance on the tenant side, so it is more convenient.
值得注意的是,内存区分配模块可以为云业务实例设置虚拟内存,而该虚拟内存的地址范围实质上不存在,仅为了让云业务实例认为自己在操作系统中设置好的内存地址范围运行,因此在上述S202中,内存区分配模块可以在业务实例内存区为云业务实例设置内存地址范围,并在操作系统内存区的云业务实例的页表中写入云业务实例的物理内存的内存地址范围对应的地址。It is worth noting that the memory area allocation module can set virtual memory for the cloud service instance, and the address range of the virtual memory does not exist in essence, only to make the cloud service instance think that it is running in the memory address range set in the operating system, Therefore, in the above S202, the memory area allocation module may set a memory address range for the cloud service instance in the service instance memory area, and write the memory address of the physical memory of the cloud service instance in the page table of the cloud service instance in the operating system memory area The address corresponding to the range.
比如,内存区分配模块可以在云业务实例的页表中先记录操作系统内存区的内存的地址,之后对云业务实例的页表中的该地址进行修改,以使该地址指向该云业务实例在业务实例内存区的内存。如此,可以提高本申请实施例的兼容性,比如针对一些方案,该方案中为云业务实例分配内存时,会为该云业务实例分配可以用于运行操作系统的内存区的内存。比如现有技术中并不会对内存区进行分区处理,操作系统可以运行的物理服务器的内存范围与可以分配给云业务实例的内存范围相同。针对此类方案,仍然可以将用于运行操作系统的内存区的内存分配给云业务实例,之后再对云业务实例的页表中记录的地址进行修改。For example, the memory area allocation module can first record the memory address of the operating system memory area in the page table of the cloud service instance, and then modify the address in the page table of the cloud service instance so that the address points to the cloud service instance Memory in the business instance memory area. In this way, the compatibility of the embodiments of the present application can be improved. For example, in some solutions, when memory is allocated to a cloud service instance, the cloud service instance is allocated memory that can be used to run the memory area of the operating system. For example, the memory area is not partitioned in the prior art, and the memory range of the physical server that the operating system can run is the same as the memory range that can be allocated to the cloud service instance. For such a solution, the memory of the memory area used for running the operating system can still be allocated to the cloud service instance, and then the address recorded in the page table of the cloud service instance can be modified.
再比如,内存区分配模块可以在云业务实例的页表中先记录无效的内存地址,之后对该地址进行修改,以使该地址指向该云业务实例在业务实例内存区的内存。For another example, the memory area allocation module may first record an invalid memory address in the page table of the cloud service instance, and then modify the address so that the address points to the memory of the cloud service instance in the service instance memory area.
再比如,当云业务实例安装时,在云业务实例的页表中记录该云业务实例在业务实例内存区的内存的内存地址范围。如此,可以减少修改云业务实例的页表中记录的地址的步骤,简化方案。For another example, when the cloud service instance is installed, the memory address range of the memory of the cloud service instance in the service instance memory area is recorded in the page table of the cloud service instance. In this way, the steps of modifying the address recorded in the page table of the cloud service instance can be reduced, and the solution can be simplified.
具体的,内存区分配模块可以在页表中记录云业务实例的虚拟内存的内存地址范围与云业务实例的物理内存的内存地址范围的映射关系。该映射关系比如为上述图3中的GVA到HPA的映射关系。Specifically, the memory area allocation module may record the mapping relationship between the memory address range of the virtual memory of the cloud service instance and the memory address range of the physical memory of the cloud service instance in the page table. The mapping relationship is, for example, the mapping relationship between GVA and HPA in the above-mentioned FIG. 3 .
云业务实例可以根据该映射关系运行在为云业务实例分配的物理内存中。具体的,云业务实例启动后,运行云业务实例的处理器发送云业务实例的虚拟内存地址和云业务实例的标识至内存管理单元,内存管理单元根据页表中的该映射关系,可以将与标识对应的云业务实例的虚拟内存的内存地址范围转换为物理内存的内存范围,并通知处理器访问云业务实例对应的物理内存的内存范围。The cloud service instance can run in the physical memory allocated for the cloud service instance according to the mapping relationship. Specifically, after the cloud service instance is started, the processor running the cloud service instance sends the virtual memory address of the cloud service instance and the identifier of the cloud service instance to the memory management unit. According to the mapping relationship in the page table, the memory management unit can The memory address range of the virtual memory that identifies the corresponding cloud service instance is converted into the memory range of the physical memory, and the processor is notified to access the memory range of the physical memory corresponding to the cloud service instance.
为了更清楚的介绍本申请实施例,下面以云业务实例为虚拟机进行介绍。In order to introduce the embodiments of the present application more clearly, a cloud service instance is used as a virtual machine for introduction below.
虚拟机的程序需要在操作系统安装,且在虚拟机的程序安装后,操作系统可以为虚拟机分配进程号,还可以在云业务实例的页表中记录该虚拟机的虚拟内存的内存地址范围与该虚拟机的物理内存的内存地址范围的映射关系。需要说明的是,云业务实例的页表是指用于记录该云业务实例的虚拟内存的地址和物理内存的地址之间的映射关系的页表。The program of the virtual machine needs to be installed in the operating system, and after the program of the virtual machine is installed, the operating system can assign a process number to the virtual machine, and can also record the memory address range of the virtual memory of the virtual machine in the page table of the cloud service instance. The mapping relationship with the memory address range of the virtual machine's physical memory. It should be noted that the page table of the cloud service instance refers to a page table used to record the mapping relationship between the address of the virtual memory and the address of the physical memory of the cloud service instance.
当虚拟机要在操作系统中启动,即处理器需运行该虚拟机对应的进程,则处理器需根据该虚拟机的进程号向内存管理单元发出该进程对应的虚拟内存的地址,内存管理单元通过查询云业务实例的页表,可以得到该虚拟内存的地址对应的物理内存的地址。进而,内存管理单元将查找到的物理内存的地址发送给处理器,处理器从该物理内存的地址读出或写入相关数据,以达到处理器运行存储于该物理内存中的虚拟机的程序的目的。当处理器运行虚拟机的程序,则可以启动该虚拟机。When the virtual machine is to be started in the operating system, that is, the processor needs to run the process corresponding to the virtual machine, the processor needs to send the address of the virtual memory corresponding to the process to the memory management unit according to the process ID of the virtual machine, and the memory management unit By querying the page table of the cloud service instance, the address of the physical memory corresponding to the address of the virtual memory can be obtained. Further, the memory management unit sends the found address of the physical memory to the processor, and the processor reads or writes relevant data from the address of the physical memory, so that the processor runs the program of the virtual machine stored in the physical memory the goal of. When the processor runs the program of the virtual machine, the virtual machine can be started.
需要说明的是,本申请实施例中的页表与上述页数据结构是不同的,页表中包括云业务实例的虚拟内存的内存地址范围与该虚拟机的物理内存的内存地址范围的映射关系,在处理器需要访问该云业务实例的物理内存时,可以通过内存管理单元查询页表的方式,进而访问云业务实例的物理内存。It should be noted that the page table in the embodiment of the present application is different from the above-mentioned page data structure, and the page table includes the mapping relationship between the memory address range of the virtual memory of the cloud service instance and the memory address range of the physical memory of the virtual machine. , when the processor needs to access the physical memory of the cloud service instance, it can access the physical memory of the cloud service instance by querying the page table through the memory management unit.
然而,页数据结构则是用于存储操作系统内存区的内存的属性信息的。举个例子,一个4KB页对应的64B的页数据结构可以包括该4KB页的物理内存的地址所对应的虚拟内存的地址,如此,当处理器需要进行反向查找(即处理器需要根据物理内存的地址,查找该物理内存的地址所对应的虚拟地址)时,处理器可以根据页数据结构中存储的信息查找。However, the page data structure is used to store the attribute information of the memory of the operating system memory area. For example, a 64B page data structure corresponding to a 4KB page may include the address of the virtual memory corresponding to the address of the physical memory of the 4KB page. In this way, when the processor needs to perform a reverse lookup (that is, the processor needs to When searching for the virtual address corresponding to the address of the physical memory), the processor can search according to the information stored in the page data structure.
另外,该4KB页对应的64B的数据结构还可以存储该4KB页的其他属性信息,比如:标识该4k页属于哪个NUMA节点的信息,内核中引用该4KB页的次数,该4KB页同时被多少个进程共享等等信息。In addition, the 64B data structure corresponding to the 4KB page can also store other attribute information of the 4KB page, such as: information identifying which NUMA node the 4KB page belongs to, the number of times the 4KB page is referenced in the kernel, and how many times the 4KB page is simultaneously used process sharing and so on.
页数据结构可以存储于操作系统内存区,而云业务实例的页表可以存储于操作系统内存区,也可以存储于业务实例内存区。The page data structure can be stored in the memory area of the operating system, and the page table of the cloud service instance can be stored in the memory area of the operating system or the memory area of the service instance.
当云业务实例的页表存储于操作系统内存区,当操作系统重新启动的情况下,该云业务实例的页表会被清除。而由于业务实例内存区的信息不会被清除,因此在操作系统重新启动之后,内存区分配模块可以将业务实例内存区记录的云业务实例的物理内存的内存地址范围对应的地址重新写入云业务实例的页表中。具体的,内存区分配模块可以基于管理信息区记录的内容快速重建该云业务实例的页表,从而可以加快操作系统的重启速度。When the page table of the cloud service instance is stored in the operating system memory area, when the operating system is restarted, the page table of the cloud service instance will be cleared. Since the information in the memory area of the service instance will not be cleared, after the operating system is restarted, the memory area allocation module can rewrite the address corresponding to the memory address range of the physical memory of the cloud service instance recorded in the memory area of the service instance to the cloud. in the page table of the business instance. Specifically, the memory area allocation module can quickly rebuild the page table of the cloud service instance based on the content recorded in the management information area, thereby speeding up the restarting speed of the operating system.
当云业务实例的页表存储于业务实例内存区,当操作系统重新启动的情况下,该云业务实例的页表不会被清除,继而无需重建该云业务实例的页表,从而可以加快操作系统的重启速度。When the page table of the cloud service instance is stored in the memory area of the service instance, when the operating system is restarted, the page table of the cloud service instance will not be cleared, and then there is no need to rebuild the page table of the cloud service instance, which can speed up the operation. System restart speed.
S201中内存区划分模块可以以预设比例将物理服务器的物理内存分配给操作系统内存区和业务实例内存区。比如按照3.125%比例,每4G物理内存划分128M作为操作系统内存区,3968M作为业务实例内存区。The memory area dividing module in S201 may allocate the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio. For example, according to the ratio of 3.125%, each 4G physical memory is divided into 128M as the operating system memory area, and 3968M as the business instance memory area.
可选地,可以设置多个预设比例,不同规格的物理服务器的内存可以对应其中一个预设比例。比如可以根据经验确定操作系统运行所需的内存大小,继而根据物理服务器的总的内存大小确定该预设比例。如此,可以在满足操作系统运行的内存需求的前提下,尽可能的提高业务实例内存区的内存空间,进而可以增加云业务实例的数量。Optionally, multiple preset ratios may be set, and the memory of physical servers of different specifications may correspond to one of the preset ratios. For example, the memory size required for the operation of the operating system may be determined according to experience, and then the preset ratio may be determined according to the total memory size of the physical server. In this way, the memory space of the memory area of the service instance can be increased as much as possible on the premise of meeting the memory requirements of the operating system, thereby increasing the number of cloud service instances.
S201中,内存区划分模块具体可将操作系统内存区在物理内存中的内存地址范围和业务实例内存区在物理内存中的内存地址范围写入内存管理单元中。具体的,内存区划分模块可以将操作系统内存区在物理内存中的内存地址范围和业务实例内存区在物理内存中的内存地址范围通知内存管理单元,内存管理单元在内存管理信息表记录操作系统内存区在物理内存中的内存地址范围和业务实例内存区在物理内存中的内存地址范围。In S201, the memory area division module may specifically write the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory into the memory management unit. Specifically, the memory area division module can notify the memory management unit of the memory address range of the operating system memory area in the physical memory and the memory address range of the business instance memory area in the physical memory, and the memory management unit records the operating system in the memory management information table. The memory address range of the memory area in the physical memory and the memory address range of the business instance memory area in the physical memory.
内存管理单元中可以包括内存管理信息表。比如,可以在操作系统进行初始化的过程中(比如当物理服务器开机后,操作系统进行初始化),遍历内存管理信息表,确定出操作系统内存区的内存,并建立操作系统内存区的内存对应的页数据结构,在 操作系统内存区存储页数据结构。The memory management unit may include a memory management information table. For example, in the process of initializing the operating system (for example, when the physical server is powered on, the operating system is initialized), traverse the memory management information table, determine the memory of the operating system memory area, and establish the memory corresponding to the operating system memory area. Page data structure, which stores the page data structure in the operating system memory area.
其中,物理内存的内存管理信息表中可以为一段内存设置标签值,该标签值可以指示出该段内存是否属于操作系统内存区。并且,该标签值还可以用于指示该段内存是否属于业务实例内存区。Wherein, in the memory management information table of the physical memory, a tag value can be set for a segment of memory, and the tag value can indicate whether the segment of memory belongs to the operating system memory area. In addition, the tag value can also be used to indicate whether the segment of memory belongs to the business instance memory area.
内存管理单元可以根据内存管理信息表中内存对应的标签值确定出属于操作系统内存区的内存地址范围,以及属于业务实例内存区的内存地址范围。The memory management unit may determine the memory address range belonging to the operating system memory area and the memory address range belonging to the service instance memory area according to the tag value corresponding to the memory in the memory management information table.
可选地,内存管理信息表具体可为E820表。并且,在内存管理信息表中,当一段内存属于操作系统内存区的内存,该段内存的内存地址范围对应的标签值可以被设置为unable。当一段内存为业务实例内存区的内存,该段内存的内存地址范围对应的标签值可以被设置为一个新增的标签值,具体为可能够与E820表中的已有的标签值区分开来的标签值,该标签值比如可以定义为“VM”。Optionally, the memory management information table may specifically be an E820 table. Moreover, in the memory management information table, when a segment of memory belongs to the memory of the operating system memory area, the tag value corresponding to the memory address range of the segment of memory can be set to disable. When a segment of memory is the memory of the business instance memory area, the tag value corresponding to the memory address range of this segment of memory can be set as a new tag value, specifically, it can be distinguished from the existing tag value in the E820 table. The tag value of , for example, the tag value can be defined as "VM".
在上述方案中,内存区划分模块可以对操作系统内存区和业务实例内存区进行动态调整:即内存区划分模块可以将操作系统内存区的内存转换为业务实例内存区的内存,且内存区划分模块可以将业务实例内存区的内存可以转换为操作系统内存区的内存。In the above solution, the memory area division module can dynamically adjust the operating system memory area and the service instance memory area: that is, the memory area division module can convert the memory in the operating system memory area into the memory in the service instance memory area, and the memory area division The module can convert the memory in the business instance memory area into the memory in the operating system memory area.
具体的,内存区划分模块可通知内存管理单元修改其记录的操作系统内存区在物理内存中的内存地址范围和操作系统内存区在物理内存中的内存地址范围,以将操作系统内存区中空闲的内存空间加入至业务实例内存区,或将业务实例内存区中空闲的内存空间加入至操作系统内存区。通知内存管理单元的步骤可以由前述图2所示的处理器执行,可通过处理器执行操作系统内存区存储的程序指令实现内存区划分模块的相关功能。Specifically, the memory area division module can notify the memory management unit to modify the memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so as to make the memory area of the operating system free Add the memory space of the service instance to the memory area of the service instance, or add the free memory space in the memory area of the service instance to the memory area of the operating system. The step of notifying the memory management unit may be performed by the aforementioned processor shown in FIG. 2 , and the relevant functions of the memory area division module may be implemented by the processor executing program instructions stored in the memory area of the operating system.
因此,通过以上方案,未被使用的业务实例内存区的内存可被调整至操作系统内存区。值得注意是,该部分内存被调整为操作系统内存区之后,需要为该部分内存建立页数据结构,并从操作系统内存区分配内存用于存储该页数据结构。Therefore, through the above solution, the memory of the unused service instance memory area can be adjusted to the operating system memory area. It is worth noting that after this part of the memory is adjusted to the operating system memory area, a page data structure needs to be established for this part of the memory, and memory is allocated from the operating system memory area to store the page data structure.
图6A示例性示出了将图5中业务实例内存区中的内存调整为操作系统内存区的内存的示意图,如图6A所示,业务实例内存区中的空闲空间2可以被转换为操作系统内存区的内存。且,需要在操作系统内存区存储为空闲空间2创建的页数据结构。FIG. 6A exemplarily shows a schematic diagram of adjusting the memory in the memory area of the business instance in FIG. 5 to the memory in the memory area of the operating system. As shown in FIG. 6A , the free space 2 in the memory area of the business instance can be converted into the operating system memory area. Also, the page data structure created for the free space 2 needs to be stored in the operating system memory area.
另一方面,通过以上方案,未被使用的操作系统内存区内存可被调整至业务实例内存区,被调整为操作业务实例内存区之后,该部分内存对应的页数据结构所占用的内存被释放。On the other hand, through the above solution, the unused operating system memory area memory can be adjusted to the business instance memory area. After being adjusted to operate the business instance memory area, the memory occupied by the page data structure corresponding to this part of the memory is released. .
图6B示例性示出了将图5中操作系统内存区中的内存空间调整为业务实例内存区的内存的示意图,如图6B所示,空闲空间1可以从操作系统内存区转换为业务实例内存区的内存。相对应的,空闲空间1对应的页数据结构在操作系统内存区占用的内存空间可以被释放。FIG. 6B exemplarily shows a schematic diagram of adjusting the memory space in the operating system memory area in FIG. 5 to the memory of the service instance memory area. As shown in FIG. 6B , the free space 1 can be converted from the operating system memory area to the service instance memory area of memory. Correspondingly, the memory space occupied by the page data structure corresponding to the free space 1 in the operating system memory area can be released.
进一步,内存区分配模块可以在管理信息区记录业务实例内存区的内存的使用状态,内存的使用状态可以包括被占用状态和空闲状态。当一个内存块被标记为被占用状态,则表示该内存块被分配给云业务实例使用。当内存块被标记为空闲状态,则表 示该内存块当前未被分配给云业务实例使用,当有内存分配需求时,可以将该内存块分配给云业务实例。Further, the memory area allocation module may record the usage status of the memory of the business instance memory area in the management information area, and the usage status of the memory may include an occupied status and an idle status. When a memory block is marked as occupied, it means that the memory block is allocated for use by the cloud service instance. When the memory block is marked as free, it means that the memory block is not currently allocated to the cloud service instance. When there is a memory allocation requirement, the memory block can be allocated to the cloud service instance.
举个例子,可以通过比特位的方式(即位图)记录内存的使用状态。比如,业务实例内存区为512GB,一个比特位用于表示1GB大小的内存块(也可以是其他大小的内存块,比如4M内存块),若该内存块被分配给云业务实例使用,处于被占用状态,则可以将该内存块对应的比特位置1,若该内存块处于空闲状态,则可以将该内存块对应的比特位置0。可以看出,该方式中通过一定数量的比特位可以管理业务内存区的内存,相比要建立页数据结构来管理内存的方式来说,管理信息区占据的存储空间较小,因此可以进一步的节省更多的存储空间。For example, the usage status of the memory can be recorded by means of bits (ie, bitmap). For example, the memory area of a business instance is 512GB, and one bit is used to represent a memory block with a size of 1GB (it can also be a memory block of other size, such as a 4M memory block). In the occupied state, the bit position corresponding to the memory block can be set to 1, and if the memory block is in an idle state, the bit position corresponding to the memory block can be set to 0. It can be seen that in this method, a certain number of bits can be used to manage the memory of the business memory area. Compared with the method of building a page data structure to manage the memory, the storage space occupied by the management information area is smaller, so it can be further Save more storage space.
在其他示例中,可以通过记录内存地址范围的方式记录该内存块的使用状态。比如,若“00000000aafe8000-00000000aaffd000”被分配给云业务实例1使用,则可以在管理信息区记录“00000000aafe8000-00000000aaffd000”处于被占用状态的信息。可以看出,该方式中通过记录内存块的起始地址,以及内存块的使用状态可以管理业务内存区的内存,相比要建立页数据结构来管理内存的方式来说,管理信息区占据的存储空间较小,因此可以进一步的节省更多的存储空间。In other examples, the usage status of the memory block may be recorded by recording the memory address range. For example, if "00000000aafe8000-00000000aaffd000" is allocated for use by cloud service instance 1, the information that "00000000aafe8000-00000000aaffd000" is occupied can be recorded in the management information area. It can be seen that in this method, the memory of the business memory area can be managed by recording the starting address of the memory block and the usage status of the memory block. Compared with the method of establishing a page data structure to manage the memory, the management information area occupies more The storage space is smaller, so it can further save more storage space.
值得注意的是,当内存区划分模块将未被使用的业务实例内存区的内存可被调整至操作系统内存区,则内存区分配模块可以在管理信息区记录该部分内存区的使用状态。比如上述图6B中,当内存区划分模块将空闲空间1调整至业务实例内存区,内存区分配模块可以将空闲空间1当前处于空闲状态等信息可以被记录于管理信息区。It is worth noting that when the memory area division module can adjust the memory of the unused service instance memory area to the operating system memory area, the memory area allocation module can record the usage status of this part of the memory area in the management information area. For example, in FIG. 6B above, when the memory area division module adjusts the free space 1 to the service instance memory area, the memory area allocation module can record information such as the free space 1 is currently in an idle state in the management information area.
进一步,管理信息区还包括云业务实例在业务实例内存区的内存的NUMA的亲和性信息。本申请实施例中NUMA的亲和性信息可以为内存管理的NUMA节点的信息,比如NUMA节点关联的处理核的信息、内存所属的NUMA节点号信息等。Further, the management information area also includes NUMA affinity information of the cloud service instance in the memory area of the service instance memory area. In this embodiment of the present application, the NUMA affinity information may be information of a NUMA node managed by the memory, such as information of a processing core associated with the NUMA node, information of a NUMA node number to which the memory belongs, and the like.
进一步,在S202中,内存区分配模块可以为云业务实例分配内存,分配内存的方法的名称可能会有多种叫法,比如可能叫类伙伴算法,本申请实施例中对分配内存的方法的名称不做限定。下面再通过一个例子对分配内存的方法进行介绍:比如业务实例内存区为512GB,云业务实例1需要100GB的内存,则将100G的内存块划分给该云业务实例1。之后,云业务实例2请求20G的内存块,则从业务实例内存区处于空闲状态的内存中划分20GB的内存给云业务实例2。之后云业务实例1不再需要内存,则可以将云业务实例1占用的100GB内存块释放,在管理信息区将该100GB的内存块的使用状态的信息从被占用状态更新为空闲状态。Further, in S202, the memory area allocation module may allocate memory for the cloud service instance, and the name of the method for allocating memory may be called in a variety of ways, for example, it may be called a class partner algorithm. The name is not qualified. The method of allocating memory is described below through an example: For example, the memory area of a business instance is 512 GB, and cloud business instance 1 needs 100 GB of memory, so the 100 GB memory block is allocated to the cloud business instance 1. After that, when cloud service instance 2 requests a 20 GB memory block, 20 GB of memory is allocated to cloud service instance 2 from the memory in the idle state of the memory area of the service instance. After the cloud service instance 1 no longer needs memory, you can release the 100 GB memory block occupied by the cloud service instance 1, and update the usage status of the 100 GB memory block from the occupied state to the idle state in the management information area.
根据本申请实施例提供的方法,本申请还提供一种计算机程序产品,该计算机程序产品包括:计算机程序代码或指令,当该计算机程序代码或指令在计算机上运行时,使得该计算机执行图4中S201和S202涉及的相关方法步骤。According to the method provided by the embodiments of the present application, the present application also provides a computer program product, the computer program product includes: computer program code or instructions, when the computer program code or instructions are run on a computer, the computer is made to execute FIG. 4 Relevant method steps involved in S201 and S202.
根据本申请实施例提供的方法,本申请还提供一种计算机可读存储介质,该计算机可读介质存储有程序代码,当该程序代码在计算机上运行时,使得该计算机执行图4中S201和S202涉及的相关方法步骤。According to the method provided by the embodiment of the present application, the present application further provides a computer-readable storage medium, where the computer-readable medium stores program codes, and when the program codes are executed on a computer, the computer is made to execute S201 and S201 in FIG. 4 . Relevant method steps involved in S202.
根据本申请实施例提供的方法,本申请还提供一种芯片系统,该芯片系统可以包括处理器。该处理器与存储器耦合,可用于执行图4中S201和S202涉及的相关方法 步骤。可选地,该芯片系统还包括存储器。存储器,用于存储计算机程序(也可以称为代码,或指令)。处理器,用于从存储器调用并运行计算机程序,使得安装有芯片系统的设备执行图4中S201和S202涉及的相关方法步骤。According to the method provided by the embodiment of the present application, the present application further provides a chip system, where the chip system may include a processor. The processor is coupled to the memory and can be used to execute the relevant method steps involved in S201 and S202 in Fig. 4 . Optionally, the chip system further includes a memory. Memory, used to store computer programs (also called code, or instructions). The processor is used to call and run the computer program from the memory, so that the device with the chip system installed performs the relevant method steps involved in S201 and S202 in FIG. 4 .
本申请实施例涉及的至少一个,包括一个或者多个;其中,多个是指大于或者等于两个。另外,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述对象的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。At least one involved in the embodiments of the present application includes one or more; wherein, multiple refers to greater than or equal to two. In addition, in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing the description objects, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
应理解,本申请中的术语“第一”、“第二”、“第三”、“第四”、“第五”、“第六”是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。It should be understood that the terms "first", "second", "third", "fourth", "fifth" and "sixth" in this application are used to distinguish similar objects, and are not necessarily used for description a particular order or sequence. "And/or" is used to describe the relationship between related objects, indicating that there can be three kinds of relationships, for example, "A and/or B" can mean: only A, only B, and both A and B exist , where A and B can be singular or plural. The character "/" generally indicates that the associated objects are an "or" relationship.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,高密度数字视频光盘(digital video disc,DVD))、或者半导体介质(例如,固态硬盘(solid state disc,SSD))等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When computer instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device. Computer instructions may be stored on or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server, or data center over a wire (e.g. coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg infrared, wireless, microwave, etc.) means to transmit to another website site, computer, server or data center. A computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media. Useful media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, high-density digital video disc (DVD)), or semiconductor media (eg, solid state disc (SSD)) )Wait.
需要指出的是,本专利申请文件的一部分包含受著作权保护的内容。除了对专利局的专利文件或记录的专利文档内容制作副本以外,著作权人保留著作权。It should be noted that a part of this patent application file contains content protected by copyright. Except for making copies of the patent files of the Patent Office or the contents of the recorded patent files, the copyright owner reserves the right to copyright.
上述各个装置实施例中网络设备与终端设备和方法实施例中的网络设备或终端设备对应,由相应的模块或单元执行相应的步骤,例如通信单元(收发器)执行方法实施例中接收或发送的步骤,除发送、接收外的其它步骤可以由处理单元(处理器)执行。具体单元的功能可以参考相应的方法实施例。其中,处理器可以为一个或多个。The network equipment in the above apparatus embodiments corresponds to the terminal equipment and the network equipment or terminal equipment in the method embodiments, and corresponding steps are performed by corresponding modules or units, for example, the communication unit (transceiver) performs the receiving or sending in the method embodiments. The steps other than sending and receiving can be performed by the processing unit (processor). For functions of specific units, reference may be made to corresponding method embodiments. The number of processors may be one or more.
在本说明书中使用的术语“部件”、“模块”、“系统”等用于表示计算机相关的实体、硬件、固件、硬件和软件的组合、软件、或执行中的软件。例如,部件可以是但不限于,在处理器上运行的进程、处理器、对象、可执行文件、执行线程、程序和/或计算机。通过图示,在计算设备上运行的应用和计算设备都可以是部件。一个或多个部件可驻留在进程和/或执行线程中,部件可位于一个计算机上和/或分布在两个或更多个计算机之间。此外,这些部件可从在上面存储有各种数据结构的各种计算机可读介质执行。部件可例如根据具有一个或多个数据分组(例如来自与本地系统、分布式系统和/或网络间的另一部件交互的二个部件的数据,例如通过信号与其它系统交互的互联网)的信号通过本地和/或远程进程来通信。The terms "component", "module", "system" and the like are used in this specification to refer to a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a computing device and the computing device may be components. One or more components may reside within a process and/or thread of execution, and a component may be localized on one computer and/or distributed between two or more computers. In addition, these components can execute from various computer readable media having various data structures stored thereon. A component may, for example, be based on a signal having one or more data packets (eg, data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet interacting with other systems via signals) Communicate through local and/or remote processes.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各种说明性逻辑块(illustrative logical block)和步骤(step),能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the various illustrative logical blocks and steps described in connection with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware accomplish. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, for example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。Units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer-readable storage medium.
以上,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, and should cover within the scope of protection of this application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (15)
- 一种用于运行云业务实例的物理服务器的内存管理方法,其特征在于,包括:A memory management method for running a physical server of a cloud service instance, comprising:在物理服务器的物理内存设置互不重叠的操作系统内存区和业务实例内存区,其中所述物理服务器的操作系统运行在所述操作系统内存区;A non-overlapping operating system memory area and a service instance memory area are set in the physical memory of the physical server, wherein the operating system of the physical server runs in the operating system memory area;在所述业务实例内存区为所述云业务实例设置内存地址范围,并记录所述内存地址范围,其中所述云业务实例在所述操作系统中启动后运行在所述内存地址范围。A memory address range is set for the cloud service instance in the service instance memory area, and the memory address range is recorded, wherein the cloud service instance runs in the memory address range after being started in the operating system.
- 根据权利要求1所述的方法,其特征在于,所述在业务实例内存区为所述云业务实例设置内存地址范围,包括:The method according to claim 1, wherein the setting a memory address range for the cloud service instance in the service instance memory area comprises:为所述云业务实例分配云业务实例标识;assigning a cloud service instance identifier to the cloud service instance;在所述业务实例内存区申请一段空闲的内存空间,并将申请得到的所述内存空间的地址范围作为所述内存地址范围;Apply for a section of free memory space in the business instance memory area, and use the address range of the memory space obtained by the application as the memory address range;在所述业务实例内存区的管理信息区记录所述云业务实例标识与所述内存地址范围。The cloud service instance identifier and the memory address range are recorded in the management information area of the service instance memory area.
- 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, wherein the method further comprises:在所述操作系统内存区的所述云业务实例的页表中写入所述内存地址范围对应的地址。Write the address corresponding to the memory address range in the page table of the cloud service instance in the operating system memory area.
- 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, wherein the method further comprises:在所述操作系统重新启动之后,将所述业务实例内存区记录的所述内存地址范围对应的地址重新写入所述云业务实例的页表中。After the operating system is restarted, the address corresponding to the memory address range recorded in the memory area of the service instance is rewritten into the page table of the cloud service instance.
- 根据权利要求1至4任一项所述的方法,其特征在于,所述在物理服务器的物理内存中设置操作系统内存区和业务实例内存区,包括:The method according to any one of claims 1 to 4, wherein the setting of the operating system memory area and the service instance memory area in the physical memory of the physical server includes:以预设比例将物理服务器的物理内存分配给所述操作系统内存区和所述业务实例内存区。Allocate the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio.
- 根据权利要求1-5任一项所述的方法,其特征在于,所述在物理服务器的物理内存中设置操作系统内存区和业务实例内存区,还包括:The method according to any one of claims 1-5, wherein the setting of the operating system memory area and the service instance memory area in the physical memory of the physical server further comprises:将所述操作系统内存区在所述物理内存中的内存地址范围和所述业务实例内存区在所述物理内存中的内存地址范围写入内存管理单元中。Write the memory address range of the operating system memory area in the physical memory and the memory address range of the service instance memory area in the physical memory into the memory management unit.
- 根据权利要求6所述的方法,其特征在于,所述方法还包括:The method according to claim 6, wherein the method further comprises:通知所述内存管理单元修改记录的所述操作系统内存区在所述物理内存中的内存地址范围和所述操作系统内存区在所述物理内存中的内存地址范围,以将操作系统内存区中空闲的内存空间加入至所述业务实例内存区,或将所述业务实例内存区中空闲的内存空间加入至所述操作系统内存区。Notify the memory management unit to modify the recorded memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so that the operating system memory area The free memory space is added to the service instance memory area, or the free memory space in the service instance memory area is added to the operating system memory area.
- 一种用于运行云业务实例的物理服务器,其特征在于,包括:A physical server for running a cloud service instance, comprising:内存区划分模块,用于在物理服务器的物理内存设置互不重叠的操作系统内存区和业务实例内存区,其中所述物理服务器的操作系统运行在所述操作系统内存区;a memory area dividing module, configured to set non-overlapping operating system memory areas and business instance memory areas in the physical memory of a physical server, wherein the operating system of the physical server runs in the operating system memory area;内存区分配模块,用于在所述业务实例内存区为所述云业务实例设置内存地址范围,并记录所述内存地址范围,其中所述云业务实例在所述操作系统中启动后运行在所述内存地址范围。A memory area allocation module, configured to set a memory address range for the cloud service instance in the service instance memory area, and record the memory address range, wherein the cloud service instance runs in the cloud service instance after being started in the operating system. range of memory addresses.
- 根据权利要求8所述的物理服务器,其特征在于,所述内存区分配模块,具体用于:The physical server according to claim 8, wherein the memory area allocation module is specifically used for:为所述云业务实例分配云业务实例标识;assigning a cloud service instance identifier to the cloud service instance;在所述业务实例内存区申请一段空闲的内存空间,并将申请得到的所述内存空间的地址范围作为所述内存地址范围;Apply for a section of free memory space in the business instance memory area, and use the address range of the memory space obtained by the application as the memory address range;在所述业务实例内存区的管理信息区记录所述云业务实例标识与所述内存地址范围。The cloud service instance identifier and the memory address range are recorded in the management information area of the service instance memory area.
- 根据权利要求9所述的物理服务器,其特征在于,所述内存区分配模块,还用于:The physical server according to claim 9, wherein the memory area allocation module is further configured to:在所述操作系统内存区的所述云业务实例的页表中写入所述内存地址范围对应的地址。Write the address corresponding to the memory address range in the page table of the cloud service instance in the operating system memory area.
- 根据权利要求10所述的物理服务器,其特征在于,所述内存区分配模块,还用于:The physical server according to claim 10, wherein the memory area allocation module is further configured to:在所述操作系统重新启动之后,将所述业务实例内存区记录的所述内存地址范围对应的地址重新写入所述云业务实例的页表中。After the operating system is restarted, the address corresponding to the memory address range recorded in the memory area of the service instance is rewritten into the page table of the cloud service instance.
- 根据权利要求8至11任一项所述的物理服务器,其特征在于,所述内存区划分模块,具体用于:The physical server according to any one of claims 8 to 11, wherein the memory area division module is specifically used for:以预设比例将物理服务器的物理内存分配给所述操作系统内存区和所述业务实例内存区。Allocate the physical memory of the physical server to the operating system memory area and the service instance memory area in a preset ratio.
- 根据权利要求8-12任一项所述的物理服务器,其特征在于,所述内存区划分模块,还用于:The physical server according to any one of claims 8-12, wherein the memory area division module is further configured to:将所述操作系统内存区在所述物理内存中的内存地址范围和所述业务实例内存区在所述物理内存中的内存地址范围写入内存管理单元中。Write the memory address range of the operating system memory area in the physical memory and the memory address range of the service instance memory area in the physical memory into the memory management unit.
- 根据权利要求13所述的物理服务器,其特征在于,所述内存区划分模块,还用于:The physical server according to claim 13, wherein the memory area division module is further configured to:通知所述内存管理单元修改记录的所述操作系统内存区在所述物理内存中的内存地址范围和所述操作系统内存区在所述物理内存中的内存地址范围,以将操作系统内存区中空闲的内存空间加入至所述业务实例内存区,或将所述业务实例内存区中空闲的内存空间加入至所述操作系统内存区。Notify the memory management unit to modify the recorded memory address range of the operating system memory area in the physical memory and the memory address range of the operating system memory area in the physical memory, so that the operating system memory area The free memory space is added to the service instance memory area, or the free memory space in the service instance memory area is added to the operating system memory area.
- 一种用于运行云业务实例的物理服务器,其特征在于,包括处理器和物理内存,所述物理内存存储有程序指令,所述处理器运行所述程序指令以执行以下方法:A physical server for running a cloud service instance, comprising a processor and a physical memory, wherein the physical memory stores program instructions, and the processor executes the program instructions to execute the following method:在物理服务器的物理内存设置互不重叠的操作系统内存区和业务实例内存区,其中所述物理服务器的操作系统运行在所述操作系统内存区;A non-overlapping operating system memory area and a service instance memory area are set in the physical memory of the physical server, wherein the operating system of the physical server runs in the operating system memory area;在所述业务实例内存区为所述云业务实例设置内存地址范围,并记录所述内存地址范围,其中所述云业务实例在所述操作系统中启动后运行在所述内存地址范围。A memory address range is set for the cloud service instance in the service instance memory area, and the memory address range is recorded, wherein the cloud service instance runs in the memory address range after being started in the operating system.
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110430939 | 2021-04-21 | ||
CN202110430939.1 | 2021-04-21 | ||
CN202110700121.7A CN115221073A (en) | 2021-04-21 | 2021-06-23 | Memory management method and device for physical server for running cloud service instance |
CN202110700121.7 | 2021-06-23 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022222977A1 true WO2022222977A1 (en) | 2022-10-27 |
Family
ID=83606945
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/088044 WO2022222977A1 (en) | 2021-04-21 | 2022-04-21 | Method and apparatus for managing memory of physical server for running cloud service instances |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115221073A (en) |
WO (1) | WO2022222977A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118175160A (en) * | 2024-05-13 | 2024-06-11 | 中移(苏州)软件技术有限公司 | Processing method and device of bare metal server and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080005522A1 (en) * | 2003-08-07 | 2008-01-03 | Siemens Corporate Research, Inc. | Advanced memory management architecture for large data volumes |
CN103608792A (en) * | 2013-05-28 | 2014-02-26 | 华为技术有限公司 | Method and system for supporting resource isolation under multi-core architecture |
CN107977264A (en) * | 2016-10-24 | 2018-05-01 | 阿里巴巴集团控股有限公司 | The dispatching method and device of a kind of virutal machine memory resource |
CN109343956A (en) * | 2018-09-20 | 2019-02-15 | 阿里巴巴集团控股有限公司 | A kind of operating system configuration method and device |
-
2021
- 2021-06-23 CN CN202110700121.7A patent/CN115221073A/en active Pending
-
2022
- 2022-04-21 WO PCT/CN2022/088044 patent/WO2022222977A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080005522A1 (en) * | 2003-08-07 | 2008-01-03 | Siemens Corporate Research, Inc. | Advanced memory management architecture for large data volumes |
CN103608792A (en) * | 2013-05-28 | 2014-02-26 | 华为技术有限公司 | Method and system for supporting resource isolation under multi-core architecture |
CN107977264A (en) * | 2016-10-24 | 2018-05-01 | 阿里巴巴集团控股有限公司 | The dispatching method and device of a kind of virutal machine memory resource |
CN109343956A (en) * | 2018-09-20 | 2019-02-15 | 阿里巴巴集团控股有限公司 | A kind of operating system configuration method and device |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118175160A (en) * | 2024-05-13 | 2024-06-11 | 中移(苏州)软件技术有限公司 | Processing method and device of bare metal server and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN115221073A (en) | 2022-10-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20190155548A1 (en) | Computer system and storage access apparatus | |
US9612966B2 (en) | Systems, methods and apparatus for a virtual machine cache | |
WO2018120986A1 (en) | Method for forwarding packet and physical host | |
JP4942966B2 (en) | Partition bus | |
US20180336158A1 (en) | Systems and methods for data transfer with coherent and non-coherent bus topologies and attached external memory | |
CA2734069A1 (en) | Provisioning virtual resources using name resolution | |
US10296369B2 (en) | Systems and methods for protocol termination in a host system driver in a virtualized software defined storage architecture | |
US9542108B2 (en) | Efficient migration of virtual storage devices to a remote node using snapshots | |
US9436386B2 (en) | Shared reference counters among a plurality of virtual storage devices | |
US20180335956A1 (en) | Systems and methods for reducing data copies associated with input/output communications in a virtualized storage environment | |
US11922072B2 (en) | System supporting virtualization of SR-IOV capable devices | |
EP4407470A1 (en) | Request processing method, apparatus and system | |
US10235195B2 (en) | Systems and methods for discovering private devices coupled to a hardware accelerator | |
EP4421631A1 (en) | Data migration method and apparatus, and electronic device | |
US20230051825A1 (en) | System supporting virtualization of sr-iov capable devices | |
WO2022222977A1 (en) | Method and apparatus for managing memory of physical server for running cloud service instances | |
CN111367472A (en) | Virtualization method and device | |
US20220358049A1 (en) | Memory access handling for peripheral component interconnect devices | |
US11836356B2 (en) | Snapshots with smart network interface controller | |
US10228859B2 (en) | Efficiency in active memory sharing | |
TWI811730B (en) | Method, system and computer readable medium for limiting data accessibility in composed systems | |
US11687280B2 (en) | Method and system for efficient servicing of storage access requests | |
US12013787B2 (en) | Dual personality memory for autonomous multi-tenant cloud environment | |
WO2022068753A1 (en) | Server system, and container setting method and apparatus | |
US10599334B2 (en) | Use of capi-attached storage as extended memory |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22791083 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22791083 Country of ref document: EP Kind code of ref document: A1 |