WO2024041219A1 - Memory management method, electronic device, chip system, and readable storage medium - Google Patents
Memory management method, electronic device, chip system, and readable storage medium Download PDFInfo
- Publication number
- WO2024041219A1 WO2024041219A1 PCT/CN2023/105048 CN2023105048W WO2024041219A1 WO 2024041219 A1 WO2024041219 A1 WO 2024041219A1 CN 2023105048 W CN2023105048 W CN 2023105048W WO 2024041219 A1 WO2024041219 A1 WO 2024041219A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- physical address
- data
- memory space
- target application
- electronic device
- Prior art date
Links
- 238000007726 management method Methods 0.000 title claims abstract description 91
- 238000004891 communication Methods 0.000 claims abstract description 78
- 230000006854 communication Effects 0.000 claims abstract description 78
- 238000000034 method Methods 0.000 claims abstract description 63
- 238000013507 mapping Methods 0.000 claims description 40
- 238000004590 computer program Methods 0.000 claims description 21
- 238000005516 engineering process Methods 0.000 abstract description 27
- 238000013468 resource allocation Methods 0.000 abstract description 2
- 230000005540 biological transmission Effects 0.000 description 37
- 230000006870 function Effects 0.000 description 25
- 238000010586 diagram Methods 0.000 description 21
- 230000008569 process Effects 0.000 description 13
- 230000005236 sound signal Effects 0.000 description 13
- 238000012545 processing Methods 0.000 description 12
- 238000010295 mobile communication Methods 0.000 description 11
- 230000003993 interaction Effects 0.000 description 7
- 230000009467 reduction Effects 0.000 description 7
- 230000000694 effects Effects 0.000 description 6
- 238000013461 design Methods 0.000 description 5
- 229920001621 AMOLED Polymers 0.000 description 4
- 238000013528 artificial neural network Methods 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000013500 data storage Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000002093 peripheral effect Effects 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000013523 data management Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000018109 developmental process Effects 0.000 description 2
- 230000007774 longterm Effects 0.000 description 2
- 230000005012 migration Effects 0.000 description 2
- 238000013508 migration Methods 0.000 description 2
- 230000005855 radiation Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 239000008186 active pharmaceutical agent Substances 0.000 description 1
- 230000003321 amplification Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000003416 augmentation Effects 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 230000007175 bidirectional communication Effects 0.000 description 1
- 230000002457 bidirectional effect Effects 0.000 description 1
- 238000013529 biological neural network Methods 0.000 description 1
- 210000000988 bone and bone Anatomy 0.000 description 1
- 210000004556 brain Anatomy 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000001149 cognitive effect Effects 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000003862 health status Effects 0.000 description 1
- 230000008140 language development Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 210000002569 neuron Anatomy 0.000 description 1
- 238000003199 nucleic acid amplification method Methods 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 229920001690 polydopamine Polymers 0.000 description 1
- 239000002096 quantum dot Substances 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
Definitions
- the present application relates to the field of communication technology, and in particular to a memory management method, electronic equipment, chip system and readable storage medium.
- Remote Direct Memory Access (RDMA) technology is a network transmission technology that directly accesses the storage area of a remote computer. Compared with traditional network technology, RDMA technology can bypass the operating system protocol stack and reduce data transmission. The number of copies avoids the overhead of user-mode and kernel-mode switching, thereby occupying smaller system resources and reducing latency.
- RDMA Remote Direct Memory Access
- a certain amount of physical address space needs to be pre-registered with the RDMA system for data caching by the RDMA network card during the process of sending and receiving data.
- a corresponding physical address space needs to be pre-allocated for each application.
- the memory resources of the memory in the electronic device are limited, and the pre-allocated fixed-size physical address space may not be sufficient.
- the memory requirements of some applications may be greater than the memory requirements of some applications, resulting in a waste of resources.
- This application provides a memory management method, electronic device, chip system and readable storage medium, which solves the problem of unreasonable memory resource allocation in the existing RDMA technology to a certain extent.
- the present application provides a memory management method, which is applied to a first electronic device.
- the method includes: determining the amount of data to be stored by a target application and the effective memory space in the physical address space associated with the target application.
- the effective memory space Including memory space indicated by N first physical address units, each of the first physical address units includes at least one physical address with data read and write permissions, N is an integer greater than or equal to 0; if the amount of data is greater than the effective memory space , then the effective memory space is expanded according to the first difference between the data amount and the effective memory space; if the data amount is less than the effective memory space, the effective memory space is expanded according to the second difference between the effective memory space and the data amount. Make reductions.
- the effective memory space Based on the memory management method provided by this application, based on the difference between the amount of data to be stored by the target application and the effective memory space with data read and write permissions in the physical address space corresponding to the target application, it is determined whether the effective memory space meets the current requirements of the application.
- the memory space required for the amount of data to be stored thereby dynamically adjusting the effective memory space of the target application.
- the effective memory space can be expanded according to the first difference between the data amount and the effective memory space, so that the expanded effective memory space satisfies The memory space required by the application.
- the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data, thereby releasing some unused memory space. Effective memory space occupied to avoid wasting memory resources.
- the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
- the method further includes:
- the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, and M is an integer greater than or equal to 1;
- the effective memory space is expanded according to the first difference between the data amount and the effective memory space, including:
- the memory space of the m first physical address units is greater than or equal to the first difference value. 1 ⁇ m+N ⁇ M; divide the M virtual address units into m virtual address units corresponding to the second physical address units are remapped to m first physical address units.
- the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, M is an integer greater than or equal to 1, and the effective memory space includes N first physical address units corresponding to N virtual address units among M virtual address units, 1 ⁇ N ⁇ M;
- the effective memory space is reduced according to the second difference between the effective memory space and the amount of data, including:
- the preset threshold When the second difference is greater than or equal to the preset threshold, n virtual address units corresponding to the n first physical address units among the N virtual address units are remapped to the second physical address unit, and the n first physical addresses
- the memory space of the unit is less than or equal to the second difference value
- the preset threshold is greater than 0, and 1 ⁇ n ⁇ N.
- the target application is an application installed in the first electronic device.
- the amount of data to be stored is the amount of data of the target application, or the amount of data of the application installed in the second electronic device received by the first electronic device.
- the present application provides an electronic device, including: a processor configured to run a computer program stored in a memory to implement the method in any possible implementation of the first aspect.
- this application provides another electronic device, including: a processor and a remote direct data access network card;
- the remote direct data access network card is used to determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application.
- the effective memory space includes the memory space indicated by N first physical address units, each of which A physical address unit includes at least one physical address with data read and write permissions, and N is an integer greater than or equal to 0; if the amount of data is greater than the effective memory space, the remote direct data access network card is also used to send the first interrupt information to the processor , the first interrupt information includes the first difference between the data amount and the effective memory space, and the processor is used to expand the effective memory space according to the first difference; if the data amount is less than the effective memory space, the remote direct data access network card also The processor is configured to send second interrupt information to the processor, where the second interrupt information includes a second difference between the effective memory space and the data amount, and the processor is configured to reduce the effective memory space according to the second difference.
- the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
- the processor is also used to:
- Remote direct data access network cards are also used for:
- the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, and M is an integer greater than or equal to 1;
- the processor is also used for:
- the memory space of the m first physical address units is greater than or equal to the first difference value. 1 ⁇ m+N ⁇ M; divide the M virtual address units into m virtual address units corresponding to the second physical address units are remapped to m first physical address units.
- the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, M is an integer greater than or equal to 1, and the effective memory space includes N first physical address units corresponding to N virtual address units among M virtual address units, 1 ⁇ N ⁇ M;
- the processor is also configured to: when the second difference is greater than or equal to the preset threshold, remap n virtual address units corresponding to the n first physical address units among the N virtual address units to the second physical address unit, The memory space of n first physical address units is less than or equal to the second difference, the preset threshold is greater than 0, and 1 ⁇ n ⁇ N.
- the target application is an application installed in the electronic device.
- the amount of data to be stored is the amount of data received by the first remote direct data access network card and sent by the second remote direct data access network card.
- this application provides a chip system.
- the chip system includes a processor, and the processor executes the calculation stored in the memory.
- this application provides a computer-readable storage medium.
- the computer-readable storage medium stores a computer program.
- the computer program is executed by a processor, the method in any possible implementation manner of the first aspect is implemented.
- the present application provides a computer program product, which when the computer program product is run on an electronic device, causes the electronic device to execute the method in any possible implementation of the first aspect.
- Figure 1 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
- Figure 2 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
- Figure 3 is a schematic diagram of data transmission based on traditional network communication technology provided by an embodiment of the present application.
- Figure 4 is a schematic diagram of data transmission based on existing RDMA communication technology provided by an embodiment of the present application.
- Figure 5 is a schematic diagram of the mapping relationship between virtual address space, page table and physical address space provided by the embodiment of the present application;
- Figure 6 is a schematic flow chart of a memory management method provided by an embodiment of the present application.
- Figure 7 is a schematic diagram of the mapping relationship between the virtual address space of a target application and the second physical address unit provided by an embodiment of the present application;
- Figure 8 is a schematic diagram of the mapping relationship between the virtual address space and the physical address space of a target application provided by an embodiment of the present application;
- Figure 9 is a schematic diagram of the mapping relationship between the virtual address space and the physical address space of another target application provided by an embodiment of the present application.
- Figure 10 is a schematic diagram of the interaction between the target application, the processor and the RDMA network card in the electronic device provided by the embodiment of the present application;
- Figure 11 is a schematic diagram of interaction between a first electronic device and a second electronic device provided by an embodiment of the present application
- Figure 12 is another schematic diagram of interaction between the target application, the processor and the RDMA network card in the electronic device provided by the embodiment of the present application.
- a and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, Where A and B can be singular or plural.
- the character "/" generally indicates that the related objects are in an "or” relationship.
- the memory management method provided by the embodiment of the present application can be applied to mobile phones, tablet computers, wearable devices, augmented reality (AR)/virtual reality (VR) devices, notebook computers, ultra-mobile personal computers (ultra- On electronic devices such as mobile personal computers (UMPC), netbooks, personal digital assistants (personal digital assistants, PDAs), servers, etc., the embodiments of this application do not place any restrictions on the specific types of electronic devices.
- AR augmented reality
- VR virtual reality
- UMPC mobile personal computers
- netbooks personal digital assistants
- PDAs personal digital assistants, servers, etc.
- the electronic device 100 may include a processor (central processing unit, CPU) 110, an external memory interface 120, an internal memory 121, a universal serial bus ( universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C , headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (subscriber identification module, SIM) card interface 195, RDMA network card 196, etc.
- a processor central processing unit, CPU
- CPU central processing unit
- external memory interface 120 may include a universal serial bus (univers serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C , headphone interface 170D, sensor module 180
- the sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor L, a bone conduction sensor, etc.
- the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 .
- the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently.
- the components illustrated may be implemented in hardware, software, or a combination of software and hardware.
- the CPU 110 may include one or more processing units.
- the CPU 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), an image signal processor (image signal processor) , ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc.
- application processor application processor, AP
- modem processor graphics processing unit
- ISP image signal processor
- controller memory
- video codec digital signal processor
- DSP digital signal processor
- baseband processor baseband processor
- neural network processor neural-network processing unit
- the controller may be the nerve center and command center of the electronic device 100 .
- the controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
- CPU 110 may include one or more interfaces.
- Interfaces may include integrated circuit (inter-integrated circuit, I2C) interface, integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver transmitter (universal asynchronous receiver) /transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and/ Or universal serial bus (USB) interface, etc.
- I2C integrated circuit
- I2S integrated circuit built-in audio
- PCM pulse code modulation
- PCM pulse code modulation
- UART universal asynchronous receiver transmitter
- MIPI mobile industry processor interface
- GPIO general-purpose input/output
- SIM subscriber identity module
- USB universal serial bus
- the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (derail clock line, SCL).
- CPU 110 may include multiple sets of I2C buses.
- the CPU 110 can couple touch sensors, chargers, flashes, cameras 193, etc. respectively through different I2C bus interfaces.
- the CPU 110 can be coupled to a touch sensor through an I2C interface, so that the CPU 110 and the touch sensor communicate through the I2C bus interface to implement the touch function of the electronic device 100 .
- the I2S interface can be used for audio communication.
- CPU 110 may include multiple sets of I2S buses.
- the CPU 110 can be coupled with the audio module 170 through the I2S bus to implement communication between the CPU 110 and the audio module 170 .
- the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface to implement the function of answering calls through a Bluetooth headset.
- the PCM interface can also be used for audio communications to sample, quantize and encode analog signals.
- the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
- the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface to implement the function of answering calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
- the UART interface is a universal serial data bus used for asynchronous communication.
- the bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
- the UART interface is typically used to connect CPU110 and wireless communication module 160.
- the CPU 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
- the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
- the MIPI interface can be used to connect the CPU 110 with peripheral devices such as the display screen 194 and the camera 193 .
- MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
- the CPU 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100 .
- the CPU 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device 100 .
- the GPIO interface can be configured through software.
- the GPIO interface can be configured as a control signal or as a data signal.
- the GPIO interface can be used to connect the CPU 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc.
- the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
- the USB interface 130 is an interface that complies with the USB standard specification, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.
- the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through them. This interface can also be used to connect other electronic devices 100, such as AR devices, etc.
- the interface connection relationships between the modules illustrated in the embodiments of the present application are only schematic illustrations and do not constitute a structural limitation of the electronic device 100 .
- the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
- the charging management module 140 is used to receive charging input from the charger.
- the charger can be a wireless charger or a wired charger.
- the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
- the charging management module 140 may receive wireless charging input through the wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142, it can also provide power to the electronic device 100 through the power management module 141.
- the power management module 141 is used to connect the battery 142, the charging management module 140 and the CPU 110.
- the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the CPU 110, internal memory 121, external memory, display screen 194, camera 193, wireless communication module 160, etc.
- the power management module 141 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters.
- the power management module 141 may also be provided in the CPU 110 .
- the power management module 141 and the charging management module 140 may also be provided in the same device.
- the wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
- Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
- Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
- the mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 .
- the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
- the mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation.
- the mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation.
- at least part of the functional modules of the mobile communication module 150 may be disposed in the CPU 110 .
- at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the CPU 110 .
- a modem processor may include a modulator and a demodulator.
- the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
- the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
- the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
- the application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194.
- the modem processor may be a stand-alone device.
- the modem processor may be independent of the CPU 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
- the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellites.
- WLAN wireless local area networks
- System global navigation satellite system, GNSS
- frequency modulation frequency modulation, FM
- near field communication technology near field communication, NFC
- infrared technology infrared, IR
- the wireless communication module 160 may be one or more devices integrating at least one communication MMU.
- the wireless communication module 160 may be an RDMA network card.
- the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the CPU 110 .
- the wireless communication module 160 can also receive the signal to be sent from the CPU 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
- the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
- the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
- the GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi) -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
- GPS global positioning system
- GLONASS global navigation satellite system
- BDS Beidou navigation satellite system
- QZSS quasi-zenith satellite system
- SBAS satellite based augmentation systems
- the electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like.
- the GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
- CPU 110 may include one or more GPUs that execute program instructions to generate or change display information.
- the display screen 194 is used to display images, videos, etc.
- Display 194 includes a display panel.
- the display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode).
- LCD liquid crystal display
- OLED organic light-emitting diode
- AMOLED organic light-emitting diode
- FLED flexible light-emitting diode
- Miniled MicroLed, Micro-oLed, quantum dot light emitting diode (QLED), etc.
- the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
- the electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
- the ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera sensor through the lens, the optical signal is converted into an electrical signal, and the camera sensor passes the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
- Camera 193 is used to capture still images or video.
- the object passes through the lens to produce an optical image that is projected onto the photosensitive element.
- the photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
- CMOS complementary metal-oxide-semiconductor
- the photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to convert it into a digital image signal.
- ISP outputs digital image signals to DSP for processing.
- DSP converts digital image signals into standard RGB, YUV and other format image signals.
- the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
- Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
- Video codecs are used to compress or decompress digital video.
- Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
- MPEG moving picture experts group
- MPEG2 MPEG2, MPEG3, MPEG4, etc.
- NPU is a neural network (NN) computing processor.
- NN neural network
- Intelligent cognitive applications of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, etc.
- the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
- the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be disposed in the CPU 110 , or some functional modules of the audio module 170 may be disposed in the CPU 110 .
- Speaker 170A also called “speaker” is used to convert audio electrical signals into sound signals.
- the electronic device 100 can listen to music through the speaker 170A, or listen to hands-free calls.
- Receiver 170B also called “earpiece” is used to convert audio electrical signals into sound signals.
- the electronic device 100 answers a call or a voice message, the voice can be heard by bringing the receiver 170B close to the human ear.
- Microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak close to the microphone 170C with the human mouth and input the sound signal to the microphone 170C.
- the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which in addition to collecting sound signals, may also implement a noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions, etc.
- the headphone interface 170D is used to connect wired headphones.
- the headphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
- OMTP open mobile terminal platform
- CTIA cellular telecommunications industry association of the USA
- the buttons 190 include a power button, a volume button, etc.
- Key 190 may be a mechanical key. It can also be a touch button.
- the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
- the motor 191 can generate vibration prompts.
- the motor 191 can be used for vibration prompts for incoming calls and can also be used for touch vibration feedback.
- touch operations for different applications can correspond to different vibration feedback effects.
- the motor 191 can also respond to different vibration feedback effects for touch operations in different areas of the display screen 194 .
- Different application scenarios such as time reminders, receiving information, alarm clocks, games, etc.
- the touch vibration feedback effect can also be customized.
- the indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, or may be used to indicate messages, missed calls, notifications, etc.
- the SIM card interface 195 is used to connect a SIM card.
- the SIM card can be connected to or separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 .
- the electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
- SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different.
- the SIM card interface 195 is also compatible with different types of SIM cards.
- the SIM card interface 195 is also compatible with external memory cards.
- the electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications.
- the electronic device 100 uses an eSIM, that is, an embedded SIM card.
- the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
- the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
- the external memory card communicates with the CPU 110 through the external memory interface 120 to implement the data storage function. Such as saving music, videos, etc. files in external memory card.
- Internal memory 121 may be used to store computer executable program code, which includes instructions.
- the CPU 110 executes instructions stored in the internal memory 121 to execute various functional applications and data processing of the electronic device 100 .
- the internal memory 121 may include a program storage area and a data storage area. Among them, the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.).
- the storage data area may store data created during use of the electronic device 100 (such as audio data, phone book, etc.).
- the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
- FIG 2 is a schematic diagram of the software structure of the electronic device according to the embodiment of the present application.
- the operating system in the electronic device can be Android, Microsoft Window System (Windows), Apple Mobile Operating System (iOS) or Harmony OS, etc.
- the operating system of the electronic device is the Hongmeng system as an example.
- the Hongmeng system can be divided into four layers, including the kernel layer, system service layer, framework layer and application layer.
- the layers communicate through software interfaces.
- the kernel layer includes the kernel abstract layer (KAL) and driver subsystem.
- KAL includes multiple kernels, such as the Linux Kernel, the lightweight IoT system kernel LiteOS, etc.
- the driver subsystem can include the Hardware Driver Foundation (HDF).
- HDF Hardware Driver Foundation
- the hardware driver framework can provide unified peripheral access capabilities and driver development and management framework.
- the multi-core kernel layer can select the corresponding core for processing according to the needs of the system.
- the system service layer is the core capability set of Hongmeng system.
- the system service layer provides services to applications through the framework layer.
- This layer may include a system basic capability subsystem set, a basic software service subsystem set, an enhanced software service subsystem set, and a hardware service subsystem set.
- the basic capability subsystem set of the system provides basic capabilities for the operation, scheduling, migration and other operations of distributed applications on Hongmeng system devices.
- the Ark multi-language runtime provides C or C++ or JavaScript (JS) multi-language runtime and basic system class libraries. It can also be used for static Java programs using the Ark compiler (that is, using Java in the application or framework layer). Language development part) provides the runtime.
- the basic software service subsystem set provides public and general software services for Hongmeng system.
- the enhanced software service subsystem set provides Hongmeng system with differentiated capability-enhanced software services for different devices. It can include smart screen proprietary business, wearable proprietary business, and Internet of Things (IoT) proprietary business subsystems.
- IoT Internet of Things
- the hardware service subsystem set provides hardware services for Hongmeng system. It can include subsystems such as location services, biometric identification, wearable proprietary hardware services, and IoT proprietary hardware services.
- the framework layer provides multi-language user program frameworks and Ability frameworks such as Java, C, C++, and JS for Hongmeng system application development.
- Two user interface (UI) frameworks including Java UI for Java language framework, JS UI framework suitable for JS language), and multi-language framework application program interface (Application Programming Interface, API) that is open to the public for various software and hardware services.
- UI user interface
- API Application Programming Interface
- the application layer includes system applications and third-party applications (or extended applications).
- System applications may include applications installed by default on the desktop, control bar, settings, phone and other electronic devices.
- Extended applications can be non-essential applications developed and designed by manufacturers of electronic devices, such as electronic device manager, replacement migration, notes, weather and other applications.
- Third-party non-system applications can be developed by other manufacturers, but can run applications in the Hongmeng system, such as games, navigation, social networking or shopping applications.
- PA Provides the ability to run tasks in the background and a unified data access abstraction.
- PA mainly provides support for FA, such as providing computing power as a background service, or providing data access capabilities as a data warehouse.
- Applications developed based on FA or PA can implement specific business functions, support cross-device scheduling and distribution, and provide users with a consistent and efficient application experience.
- Multiple electronic devices running the Hongmeng system can achieve hardware mutual assistance and resource sharing through distributed soft buses, distributed device virtualization, distributed data management and distributed task scheduling.
- the operating system is generally divided into two states: the kernel running state (hereinafter referred to as the kernel state) and the user running state (hereinafter referred to as the user state).
- the operating system has operating system applications executed in the kernel mode and applications executed in the user mode.
- Ordinary applications and user-mode applications have lower execution permissions than kernel-mode applications.
- kernel-mode applications can access all hardware resources in electronic devices, such as internal memory, external memory cards, network cards, etc.
- User-mode applications have limited access to hardware resources, so user-mode applications cannot perform data transmission, data storage, or data reading.
- an MMU memory management unit 111 (as shown in FIG. 1 ) is provided between the CPU 110 of an electronic device, the internal memory 121 and the external memory interface 120 bus.
- the CPU 110 needs to access the internal memory 121 (ie, the memory mentioned above), a virtual address can be provided, and the MMU can map the virtual address to a physical address, thereby enabling the CPU 110 to read data from the internal memory 121 based on the physical address. Or write data into the internal memory 121.
- the virtual address is an address in the virtual address space that can be recognized or generated by the operating system in the electronic device, and its size range can be determined by the number of bits of the operating system running in the CPU 110 . For example, if the operating system running in CPU110 is 32-bit, the virtual address is also 32-bit, and its address range can be 0-0xFFFFFF (4GB); if the operating system running in CPU110 is 64-bit, the virtual address is also 64-bit, Its address space can be 0-0xFFFFFFFFFFFFFFFF (16EB).
- the virtual address can be divided into multiple virtual address spaces according to actual needs, such as user-mode virtual address space and kernel-mode virtual address space.
- User-mode virtual address space can be accessed by user-mode applications (such as reading, writing, opening, closing, or drawing) and kernel-mode applications (such as process management, storage management, file management, or device management).
- Kernel-mode virtual address space can only be accessed by Kernel-mode applications access it at runtime.
- the address range of the virtual address space is [0x00000000, 0xFFFFFF]
- the address range of the user-mode virtual address space can be [0x00000000, 0x80000000) (that is, the 0th GB-2nd GB)
- the address range of the kernel-mode virtual address space can be [0x80000000, 0xFFFFFFFF] (i.e. 2GB-4th GB).
- the physical address may be an address in the address space actually owned by a hardware storage device such as the internal memory 121.
- the address space of the physical address can be smaller than the address space of the virtual address. For example, when the size of the address space of the virtual address can be 4GB, the size of the address space of the physical address can be 256MB.
- the sending end CPU needs to copy the application's to-be-sent data to the cache space of the TCP/IP protocol stack in kernel mode. , and then copied to the cache space of the driver layer and the cache space of the traditional network card in sequence.
- the traditional network card at the sending end can send the data to be sent to the traditional network card at the receiving end based on the pre-established communication link. In this process, a large amount of space is required. CPU resources are required to copy the data, and conversion between user mode and kernel mode is required, resulting in a long delay during data transmission.
- RDMA Remote Direct Memory Access
- RDMA Remote Direct Memory Access
- both the receiving end and the sending end can be electronic devices such as servers, clients, and mobile phone terminals.
- the electronic devices at least include an Ethernet network card (i.e., RDMA network card) with remote direct memory access function and a CPU.
- the RDMA network card is mainly used in Data reading operations and/or data writing operations are performed during data transmission.
- the MMU usually divides the virtual address space and the physical address space into multiple virtual pages with a fixed space size and multiple physical pages with a fixed space size respectively based on the paging management mechanism for management.
- the number of virtual addresses in the virtual page is related to the number of physical pages.
- the number of physical addresses in is the same.
- the fixed space size can be 4kb, 16kb, 64kb, etc.
- Each virtual page is provided with a corresponding virtual page number.
- Each virtual page includes at least one virtual address.
- Each virtual address corresponds to the virtual page number of the virtual page to which it belongs and the page offset in the virtual page to which it belongs.
- the so-called intra-page offset is the displacement amount of the virtual address relative to the virtual base address in the virtual page to which it belongs.
- Each physical page is provided with a corresponding physical page number.
- Each physical page includes at least one physical address, and each physical address corresponds to the physical page number of the physical page to which it belongs.
- the processor determines the virtual address space corresponding to the application.
- the MMU can convert and map the application's virtual address space to the physical address space, and create and fill in the application's virtual address space in the local memory.
- a page table that maps virtual addresses in the address space to physical addresses in the corresponding physical address space.
- the application can send a registration request to the RDMA network card, causing the RDMA network card to save the page table used to indicate the mapping relationship between the application's virtual address space and physical address space to the network card memory of the RDMA network card.
- the page table includes multiple page table entries.
- the number of page table entries is the same as the number of virtual pages in the virtual address space.
- Each page table entry is used to indicate the virtual page number and physical address of the virtual page in the virtual address space.
- the mapping relationship between physical page numbers in the space As shown in Figure 5, assume that there are 6 virtual pages in the virtual address space mapped to the page numbers of 6 physical pages in the physical address space.
- the virtual page numbers of the 6 virtual pages are 0 to 5.
- the page table records The physical page number of the physical page that corresponds to the virtual page number of each virtual page.
- the RDMA network card After the RDMA network card receives the virtual address sent by the application sender, it can determine the physical page number of the physical page corresponding to the virtual page number of the virtual page to which the virtual address belongs through the page table. According to the physical base address and virtual address in the physical page The physical address corresponding to the virtual address can be determined by the intra-page offset in the virtual page to which it belongs.
- Existing RDMA communication technology generally includes two communication operation modes.
- the first is a message-type operation mode, such as send operation and receive operation
- the second is a memory-type operation mode, such as RDMA Read operation and RDMA Write operation.
- the second electronic device triggers the receive operation command to determine the physical address used to receive data.
- the application of the first electronic device can cache the data to be sent in the pre-allocated physical address space and send it to the first electronic device.
- the first RDMA network card in the device sends a send operation command
- the first RDMA network card caches the data to be sent into the RDMA memory and encapsulates the data to be sent to generate a data packet, so as to communicate through the pre-created communication between the first electronic device and the second electronic device.
- the link is transmitted to the second RDMA network card in the second electronic device.
- the second RDMA network card can store the data in the data packet into a physical address used to receive the data.
- the second electronic device can provide the first electronic device with the accessible virtual address space and its access rights in the second electronic device through the pre-created communication link.
- the application in the first electronic device can send an RDMA Read operation instruction to the first RDMA network card in the first electronic device.
- the RDMA Read operation instruction includes the virtual address where the data to be read is stored in the second electronic device and the username used in the first electronic device.
- the first RDMA network card can transmit the Read request packet corresponding to the RDMA Read operation instruction to the second RDMA network card in the second electronic device through the communication link.
- the second RDMA network card can transmit the read request packet corresponding to the RDMA Read operation instruction to the second RDMA network card in the second electronic device according to the pre-stored page.
- the table determines the physical address corresponding to the virtual address that stores the data to be read, and encapsulates the data to be read into a data packet and transmits it back to the first RDMA network card through the communication link.
- the first RDMA network card can query the pre-stored page table to The data to be read is written in the physical address in the first electronic device corresponding to the virtual address used to receive the data.
- the application in the first electronic device can send an RDMA Write operation instruction to the first RDMA network card in the first electronic device.
- the Write operation instruction includes the virtual address and data size used to receive data in the second electronic device.
- the first RDMA network card is from Obtain the data to be sent from the physical address space corresponding to the application, cache the data to be sent and the virtual address used to receive the data in the second electronic device to the RDMA memory of the first RDMA network card, and then encapsulate it into a data packet to create a data package in advance.
- the communication link is transmitted to the second RDMA network card.
- the second RDMA network card can decapsulate the data packet and store the data in the data packet to the second electronic device for receiving data by querying the pre-stored page table.
- the virtual address corresponds to the physical address.
- the first electronic device and the second electronic device can establish a communication link through a Socket connection or a Connection Manager (Connection Manager, CM) connection, and exchange some RDMA communication data through the communication link.
- CM Connection Manager
- the first electronic device can obtain the virtual address of the virtual address space in the second electronic device
- the second electronic device can obtain the virtual address of the virtual address space in the first electronic device.
- the physical address in the physical address space corresponding to the application, and the mapping relationship between the virtual address space and the physical address space of the application are fixed.
- each application needs to be allocated a corresponding physical address space.
- the storage resources of the memory are limited.
- each application can only access the corresponding pre-allocated address space. physical address space, and the size of the physical address space corresponding to each application cannot be changed according to the actual required memory space.
- the physical address space of some applications may not meet the actual memory requirements of the application, while the physical address space of some applications may not be able to meet the actual memory requirements of the application. Greater than the actual memory requirements of the application, leaving part of the physical address space unused.
- One method is: when the application detects that the current communication memory cannot meet the memory space required for communication data in the current business scenario, it can choose to disconnect Mapping relationship with the current physical address space, re-registering a new physical address space to match the memory space required for communication data in the current business scenario. Although this method can dynamically adjust the memory space corresponding to the application according to actual business needs, However, the method of disconnecting the mapping relationship with the current physical address space and re-registering it is cumbersome and time-consuming.
- Another method is: the application can register multiple physical address spaces with different fixed space sizes to the RDMA system based on the memory space required for communication data in different business scenarios, but only use one of them during each data transmission. One physical address space, other unused physical address spaces are idle, wasting more memory resources.
- this application provides a memory management method, electronic device, chip system and readable storage medium, which dynamically adjusts the corresponding data according to the amount of data to be stored in the target application.
- An effective memory space with data read and write permissions in the physical address space.
- the effective memory space is greater than the amount of data to be stored, the unused first physical address unit in the effective memory space is released.
- the effective memory space is less than the amount of data to be stored, When measuring, the effective memory space is expanded so that the effective memory space meets the memory requirements of the application in different business scenarios, thereby allocating corresponding memory resources to the application reasonably.
- Figure 6 is a schematic flow chart of a memory management method provided by an embodiment of the present application. It mainly involves the target application in the electronic device performing data transmission based on RDMA technology. The electronic device dynamically adjusts the physical address space associated with the target application. of effective memory space.
- This memory management method can be applied to electronic devices with RDMA communication functions.
- the electronic devices include internal memory, processors and RDMA network cards. The following is an exemplary description of the memory management method provided by this application with reference to FIG. 6 .
- S601. Determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application.
- the effective memory space includes memory spaces indicated by N first physical address units, and each first physical address unit includes at least A physical address with data read and write permissions, N is an integer greater than or equal to 0.
- the target application installed in the electronic device registers the corresponding physical address space
- the target application will generate data to be stored during subsequent data transmission with applications installed on other electronic devices based on RDMA communication operations.
- the electronic device can determine whether it is necessary to pre-register the target application based on the relative size between the effective memory space in the pre-registered physical address space and the amount of data to be stored. The registered effective memory space is adjusted so that the data to be stored by the target application can be cached in the effective memory space associated with it.
- the effective memory space is the memory space indicated by all the first physical address units in the physical address space.
- the memory space of a first physical address unit corresponding to the internal memory is provided with both data writing permission and data reading permission.
- a physical page, a first physical address unit includes one or more physical addresses with data writing permissions and data reading permissions.
- the physical address space pre-registered by the target application may include one or more second physical address units with a fixed size, wherein the second physical address unit is configured not to have data writing permission but to have data reading permission. of the physical page, the second physical address unit includes at least one physical address that does not have data writing permission but has data reading permission.
- the number of second physical address units in the pre-registered physical address space is 1, and the space size of the second physical address unit can be 4kb, then all the virtual address units in the target application can be The virtual address units are mapped to the second physical address unit.
- the physical address space pre-registered by the target application includes a first physical address unit, and the first physical address unit Corresponds to a virtual address unit in the virtual address space of the target application; or the physical address unit pre-registered by the target application includes a first physical address unit and a second physical address unit, where the first physical address unit is the same as the target application corresponds to one of the virtual address units in the virtual address space, and the remaining virtual address units correspond to the second physical address unit.
- the pre-registered effective memory space When performing the first data transmission based on this physical address space, it is necessary to determine whether the pre-registered effective memory space needs to be adjusted based on the relative size between the memory space required for the first data transmission and the pre-registered effective memory space. That is, if the pre-registered effective memory space is If the registered effective memory space is larger than the memory space required for the first data transmission, the first physical address unit used in the pre-registered effective memory space will be recycled and expanded. If the pre-registered effective memory space is smaller than the memory space required for the first data transmission, memory space, expand the pre-registered effective memory space.
- the physical address space associated with the target application may be the effective memory space in the physical address space adjusted during the last data transmission process. Effective memory space. For example, if the electronic device adjusts the pre-registered effective memory space for the first time during the first data transmission, then in the second data transmission after the first data transmission, the physical address space associated with the target application will The effective memory space is the effective memory space after the first adjustment. The electronic device needs to determine whether the effective memory space after the first adjustment meets the memory space required for the second data transmission, and then determine whether the effective memory space needs to be adjusted again.
- the data to be stored by the target application may be the data of the target application sent by the first electronic device to the application on the second electronic device based on the RDMA communication operation.
- Data for example, the RDMA communication operation can be a send operation or an RDMA Write operation.
- the data to be stored may also be data of an application on the second electronic device received by the first electronic device based on the RDMA communication operation.
- the RDMA communication operation may Think of receive operation or RDMA Read operation.
- the effective memory space can be expanded according to the first difference between the data amount and the effective memory space.
- m first physical address units may be allocated to the target application from the memory space in the internal memory that is not registered by other applications based on the first difference value, where m is an integer greater than or equal to 1, and m first physical addresses
- the memory space of the unit is greater than or equal to the first difference value, 1 ⁇ m+N ⁇ M. That is to say, the expanded effective memory space meets the memory space required by the amount of data to be stored by the target application.
- mapping table between the virtual address space and the physical address space of the target application needs to be updated to compare the M virtual address units with the second
- the m virtual address units corresponding to the physical address units are remapped to m first physical address units.
- the physical address space of the target application includes 3 first physical address units. Each first physical address unit corresponds to a virtual address unit of the target application. In the virtual address space of the target application The other M-3 virtual address units all correspond to the second physical address unit, and the sizes of a first physical address unit, a virtual address unit and a second physical address unit are all 4kb, that is, the effective memory space of the target application is 12kb. , then it is determined that the amount of data stored by the target application is greater than the effective memory space and the first difference between the two is 3kb.
- the effective memory space of the target application can be extended by 1 first physical address unit, that is, allocate a physical page (i.e. page in Figure 8) to the target application from a memory space that has not been registered by other applications, and set the physical page as the first page with data writing permissions and data reading permissions.
- the physical address unit makes the effective memory space of the target application expand to 16kb, thereby meeting the memory space required for the amount of data to be stored by the target application. Accordingly, the mapping table needs to be updated to remap one of the other M-3 virtual address units corresponding to the second physical address unit in the virtual address space of the target application to the extended first physical address. unit.
- the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data. Specifically, assuming that the effective memory space includes N first physical address units corresponding to N virtual address units among the M virtual address units of the target application, then when the second difference is greater than or equal to the preset threshold When the preset threshold is greater than 0, the effective memory space is reduced by n first physical address units, 1 ⁇ n ⁇ N, and the memory space of n first physical address units is less than or equal to the second difference.
- mapping table between the virtual address space and the physical address space of the target application needs to be updated, and n of the N virtual address units are The virtual address unit is remapped to a second physical address unit.
- the preset threshold may be the size of the memory space indicated by a first physical address unit.
- the mapping relationship between the virtual address space and the physical address space of the application shown in FIG. 9 refer to the schematic diagram of the mapping relationship between the virtual address space and the physical address space of the application shown in FIG. 9 .
- the sizes of the first physical address unit, virtual address unit and second physical address unit are all 4kb
- the preset threshold is 4kb
- the amount of data to be stored by the target application is 8kb
- the physical address space of the target application includes 3 first The physical address unit, that is, the effective memory space of the target application is 12kb.
- Each first physical address unit corresponds to a virtual address unit of the target application.
- the other M-3 virtual address units in the virtual address space of the target application are all the same as the second If the physical address unit corresponds, the effective memory space is greater than the amount of data stored by the target application, and the second difference between the two is 4kb, which is equal to the preset threshold.
- the effective memory space of the target application can be reduced by one first physical address unit, and the first physical address unit can be released, that is, the relationship between the first physical address unit and the virtual address unit in the target application can be released.
- Mapping relationship the released first physical address unit is a physical page without read and write permissions.
- the mapping table needs to be updated to remap the virtual address unit corresponding to the first physical address unit to the target application.
- the second physical memory unit needs to be updated to remap the virtual address unit corresponding to the first physical address unit to the target application.
- the amount of data to be stored by the target application is less than the effective memory space of the target application, and the second difference between the effective memory space and the amount of data is greater than 0 and less than the preset threshold, there is no need to change the target application.
- the size of the effective memory space is less than the effective memory space of the target application, and the second difference between the effective memory space and the amount of data is greater than 0 and less than the preset threshold, there is no need to change the target application.
- the size of the effective memory space is the size of the effective memory space.
- the electronic device can use two different triggering methods, namely the active triggering method and the passive triggering method, so that the processor in the electronic device can be stored according to the installed target application.
- the effective memory space in the physical address space associated with the target application is expanded or reduced based on the difference between the amount of data and the effective memory space of the target application.
- the first electronic device includes a first processor and a first RDMA network card
- the first target application is installed in the first electronic device
- the second electronic device includes a second processor and a second RDMA network card
- the first electronic device includes a second processor and a second RDMA network card.
- the second target application is installed in the second electronic device, and the first electronic device and the second electronic device can perform data transmission based on RDMA technology.
- the first processor when the first target application in the first electronic device writes the data to be stored into the physical address space associated with the first target application, the first processor can be actively triggered to cause the first processor to write the data to be stored in the physical address space associated with the first target application.
- the effective memory space in the physical address space is expanded or reduced.
- the data to be stored by the first target application is: based on the first type of RDMA communication operation, the first electronic device sends the data of the first target application to the second RDMA network card of the second electronic device through the first RDMA network card.
- the first type of RDMA communication operation can be a send operation or an RDMA Write operation.
- the first processor includes a virtual memory management unit and a physical memory management unit
- the virtual memory management unit runs in user mode. , used to determine the virtual address space corresponding to the application when receiving the application's memory allocation request.
- the physical memory management unit runs in the kernel mode and is used to allocate the corresponding physical address space to the application and dynamically expand and reduce the effective memory space in the application's physical address space through active triggering.
- the virtual memory management unit can fall into the kernel state through system calls, allowing the physical memory management module to allocate the corresponding physical address space to the application.
- the active triggering method includes the following steps:
- the first target application sends a query request to the physical memory management unit through the virtual memory management unit.
- the first target application may send a query request to the physical memory management unit through the virtual memory management unit.
- the first target application can send a query request to the virtual memory management unit by calling the query API (Application Programming Interface, application program interface) interface, and the virtual memory management unit can make the first target application call the function through the ioctl (input/output control) system
- the physical memory management unit trapped in the kernel state causes the physical memory management unit to receive the query request sent by the first target application.
- the physical memory management unit determines the effective memory space in the physical address space associated with the first target application.
- the physical memory management unit can determine the effective memory space in the physical address space of the first target application according to the mapping table, and transmit the size of the effective memory space to the first target application through the virtual memory management unit.
- the mapping table is an initial mapping table pre-registered by the first target application.
- the mapping table may be an updated mapping table corresponding to the adjusted physical address space during the last data transmission.
- the first target application determines whether the amount of data to be stored is greater than the effective memory space.
- the first target application can determine whether the amount of data to be stored is greater than the effective memory space based on the obtained size of the effective memory space. Specifically, if the amount of data to be stored is less than the effective memory space, a reduction request can be sent to the physical memory management unit through the virtual memory management unit based on the memory reduction API interface. The reduction request can include the amount of data between the effective memory space and the amount of data to be stored. The second difference; if the amount of data to be stored is greater than the effective memory space, an expansion request can be sent to the physical memory management unit through the virtual memory management unit based on the memory expansion API interface. The expansion request can include the amount of data to be stored and the effective memory. The first difference between the spaces is used to actively trigger the physical memory management unit to expand or reduce the effective memory space.
- the physical memory management unit expands the effective memory space according to the first difference between the amount of data to be stored and the effective memory space, or expands the effective memory space according to the second difference between the effective memory space and the amount of data to be stored. Memory space is reduced.
- the physical memory management unit can expand and reduce the effective memory space of the first target application according to the method provided in steps S602 and S603 in the above embodiment.
- the active triggering method also includes the following steps:
- the physical memory management unit can send a signal of successful expansion or successful reduction to the first target application through the virtual memory management unit, so that the first target application can store the data to be stored in the updated physical address space.
- the physical memory management unit can also send an instruction to update the mapping table to the first RDMA network card, so that the first RDMA network card
- the network card stores the updated mapping table corresponding to the first target application into the network card memory.
- the first processor may receive the data of the second target application from the first RDMA network card. After interrupting the information, the effective memory space in the first physical address space is expanded or reduced through passive triggering.
- the data to be stored by the first target application is: Based on the second type of RDMA communication operation, the first electronic device The data of the second target application sent by the second RDMA network card of the second electronic device is received through the first RDMA network card.
- the second type of RDMA communication operation may be a receive operation or an RDMA Read operation.
- the first target application when the first electronic device performs the second type of RDMA communication operation, can send an RDMA communication operation instruction to the first RDMA network card on the first electronic device, where the RDMA communication
- the operation instructions include a virtual base address corresponding to the physical base address in the physical address space used by the first electronic device to store the obtained data.
- the first RDMA network card obtains the data sent by the second target application on the second electronic device.
- the first RDMA network card can determine the physical base address corresponding to the virtual base address according to the pre-stored mapping table between the virtual address space and the physical address space of the first target application, and use the physical base address as The starting address stores the obtained data into an effective memory space in the physical address space of the first target application. Therefore, after the first RDMA network card obtains the data of the second target application sent by the second RDMA network card, it needs to confirm whether the memory address space of the first target application meets the amount of data to be stored. If it does not meet the requirement or there is remaining memory address space, time, thereby adjusting the memory address space of the first target application through passive triggering.
- the passive triggering method includes the following steps:
- the first RDMA network card determines the amount of data to be stored by the first target application.
- the amount of data to be stored by the first target application is the data of the second target application sent by the first RDMA network card of the first electronic device and received by the second RDMA network card of the second electronic device.
- the first RDMA network card determines whether the amount of data to be stored by the first target application is greater than the effective memory space associated with the first target application.
- the first RDMA network card can determine the effective memory space in the physical address space associated with the first target application based on the pre-stored mapping table corresponding to the first target application, and then determine whether the amount of data to be stored is greater than the effective memory. space. If the amount of data to be stored is greater than the effective memory space, the first RDMA network card can send first interrupt information to the virtual memory management unit in the first processor. The first interrupt information can include the amount of data to be stored and the effective memory space. The first difference; if the amount of data to be stored in the first target application is less than the effective memory space, the RDMA network card can send the second interrupt information to the processor, and the second interrupt information can include the difference between the effective memory space and the amount of data to be stored. the second difference, thereby triggering the physical memory management unit to adjust the effective memory space of the first target application according to the first difference or the second difference through passive triggering.
- the physical memory management unit expands the effective memory space according to the first difference between the amount of data to be stored and the effective memory space, or expands the effective memory space according to the second difference between the effective memory space and the amount of data to be stored. Memory space is reduced.
- the physical memory management unit may, after receiving the first interrupt signal sent by the first RDMA network card, expand the effective memory space according to the first difference value, or may, after receiving the second interrupt signal sent by the first RDMA network card, The effective memory space is reduced according to the second difference value.
- the passive triggering method also includes the following steps:
- the physical memory management unit may send an instruction to update the mapping table to the first RDMA network card, so that the first RDMA network card stores the updated mapping table corresponding to the first target application into the network card memory.
- this application also provides a physical address space registration method.
- the specific process of registering the physical address space of the target application installed in the electronic device before data transmission based on RDMA communication technology is exemplified. instruction of.
- the registration method of the physical address space of the target application includes the following steps:
- the target application sends a memory allocation request to the virtual memory management unit.
- the target application can call the memory Apply for an API interface to send a memory allocation request to the virtual memory management unit.
- the virtual memory management unit After receiving the memory allocation request sent by the target application, the virtual memory management unit allocates the corresponding virtual address space to the target application.
- the virtual memory management unit when the virtual memory management unit receives a memory allocation request sent by each target application in the electronic device, it can allocate a virtual address space of the same size to each target application, and each The virtual addresses in the target application's virtual address space are the same.
- the target application can determine the size of the virtual address space required at runtime, and then the target application can send a memory allocation request containing the required virtual address space size information to the virtual memory management unit.
- a virtual address space having the same space size as the virtual address space size required by each application may be allocated from the user state virtual address space of the first electronic device.
- the virtual address space of the target application includes at least one virtual address unit.
- the virtual address unit is a virtual page with a preset space size that divides the virtual address space based on the paging management mechanism.
- Each virtual address unit includes at least a virtual address.
- the virtual memory management unit can fall into the kernel state through system calls, causing the physical memory management unit to allocate physical address space for the target application.
- the physical address space allocated by the memory management unit for the target application may include a second physical address unit, and the second physical address unit is a physical page that is set to have data reading permission but not data writing permission.
- Each second physical address unit includes one or more physical addresses with data writing authority, and the number of physical addresses in the second physical address unit is the same as the number of virtual addresses in the virtual address unit.
- the physical address space in the internal memory of the electronic device is 2GB and the size of the virtual address space of the target application is 4GB
- the physical address space can be divided into 524288 physical pages of 4kb based on the paging management mechanism.
- the virtual address space can be divided into 1049576 virtual pages with a size of 4kb.
- all virtual address units in the virtual address space of the target application can be mapped to one second physical address unit.
- the physical address space allocated by the memory management unit for the target application may include a second physical address unit and an effective memory space with a smaller space.
- the virtual address space of the target application includes M virtual address units
- the effective memory space includes N first physical address units
- N is an integer greater than or equal to 0, and among the N first physical address units and the M virtual address units
- Each first physical address unit includes at least one with data read and write permission.
- the physical address that is, the RDMA network card can write data to the physical address in the first physical address unit, and can also read the pre-cached data in the physical address.
- the number of the first physical address unit and the second physical address unit in the allocated physical address space may be 1, and the first physical address unit may be mapped to one of the virtual address units in the virtual address space of the target application. address unit, and map other virtual address units in the virtual address space of the target application to the second physical address unit.
- the number of physical addresses in the first physical address unit is the same as the number of physical addresses in the second physical address unit.
- the processor and the RDMA network card can determine whether the physical address in the physical address space corresponding to the target application is in the mapping table. Have data read and write permissions, determine the size of the effective memory space in the physical address space of the target application, so that in the subsequent data transmission process, it can be compared based on the difference between the amount of data to be stored by the target application and the size of the effective memory space. Memory space is expanded and reclaimed.
- the physical memory management unit allocates the corresponding physical address space for the target application, it needs to create an initial mapping table between the virtual address space and the physical address space for the target application, and store the initial mapping table in the internal memory.
- the initial mapping table is used to indicate the mapping relationship between the page number of each virtual address unit in the virtual address space and the page number of the physical address unit in the physical address space, as well as the set read and write permissions of the physical address unit.
- the physical memory management unit After the physical memory management unit allocates the corresponding physical address space to the target application, the physical memory management unit can send a successful allocation signal to the target application through the virtual memory management unit.
- the target application After receiving the successful allocation signal, the target application sends a registration request to the RDMA network card.
- the registration request contains the identification of the target application.
- the RDMA network card After receiving the registration request, the RDMA network card registers the initial mapping table between the physical address space and the virtual address space of the target application.
- the RDMA network card can store the initial mapping in the memory space into the network card memory according to the identification of the target application, so that the RDMA network card has the permission to read and write the data of the physical address in the physical address space of the target application.
- the electronic device can pre-allocate the second physical address unit without data writing permission to the target application, so that the subsequent data transmission process based on RDMA communication technology can be based on the amount of data to be stored by the target application.
- the difference between the effective memory space with data read and write permissions in the physical address space corresponding to the target application determines whether the effective memory space meets the memory space required for the amount of data to be stored by the application, thereby dynamically adjusting the effective memory space of the target application. Memory space. If the effective memory space does not meet the memory space required by the amount of data to be stored, the effective memory space can be expanded according to the first difference between the data amount and the effective memory space, so that the expanded effective memory space Meet the memory space required by the application.
- the effective memory space meets the memory space required by the amount of data to be stored, the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data, thereby releasing some Use unoccupied effective memory space to avoid wasting memory resources, thereby rationally allocating memory resources to target applications and improving memory resource utilization.
- the embodiment of this application also provides the following content:
- An embodiment of the present application provides a computer program product.
- the program product includes a program.
- the electronic device causes the memory management method shown in the above embodiments.
- Embodiments of the present application provide a computer-readable storage medium.
- the computer-readable storage medium stores a computer program.
- the computer program is executed by a processor, the memory management method shown in the above embodiments is implemented.
- An embodiment of the present application provides a chip, which includes a memory and a processor.
- the processor executes a computer program stored in the memory to control the above-mentioned electronic device to execute the memory management method shown in the above-mentioned embodiments.
- the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
- this application can implement all or part of the processes in the methods of the above embodiments by instructing relevant hardware through a computer program.
- the computer program can be stored in a computer-readable storage medium.
- the computer program When executed by a processor, the steps of each of the above method embodiments may be implemented.
- the computer program includes computer program code, which may be in the form of source code, object code, executable file or some intermediate form.
- the computer-readable storage medium may at least include: any entity or device capable of carrying computer program code to the camera device/terminal device, recording media, computer memory, read-only memory (ROM), random access Memory (random access memory, RAM), electrical carrier signals, telecommunications signals, and software distribution media.
- ROM read-only memory
- RAM random access Memory
- electrical carrier signals telecommunications signals
- software distribution media For example, U disk, mobile hard disk, magnetic disk or CD, etc.
- computer-readable media may not be electrical carrier signals and telecommunications signals.
- the disclosed devices/devices and methods can be implemented in other ways.
- the apparatus/equipment embodiments described above are only illustrative.
- the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or units. Components may be combined or may be integrated into another system, or some features may be ignored, or not implemented.
- the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
- the term “if” may be interpreted as “when” or “once” or “in response to determining” or “in response to detecting” depending on the context. ". Similarly, the phrase “if determined” or “if [the described condition or event] is detected” may be interpreted, depending on the context, to mean “once determined” or “in response to a determination” or “once the [described condition or event] is detected ]” or “in response to detection of [the described condition or event]”.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephone Function (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The present application relates to the technical field of communications, and provides a memory management method, an electronic device, a chip system, and a readable storage medium, which solve the problem of inappropriate memory resource allocation in existing RDMA technologies to a certain extent. The method is applied to a first electronic device and comprises: determining the amount of data to be stored of a target application and a valid memory space in a physical address space associated with the target application, the valid memory space comprising memory spaces indicated by N first physical address units, each first physical address unit comprising at least one physical address having a data read-write permission, wherein N is an integer greater than or equal to 0; if the amount of data is greater than the valid memory space, expanding the valid memory space according to a first difference between the amount of data and the valid memory space; and if the amount of data is smaller than the valid memory space, reducing the valid memory space according to a second difference between the valid memory space and the amount of data.
Description
本申请要求于2022年08月26日提交国家知识产权局、申请号为202211033616.X、申请名称为“内存管理方法、电子设备、芯片***及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application submitted to the State Intellectual Property Office on August 26, 2022, with the application number 202211033616.X and the application name "Memory management method, electronic device, chip system and readable storage medium", The entire contents of which are incorporated herein by reference.
本申请涉及通信技术领域,尤其涉及一种内存管理方法、电子设备、芯片***及可读存储介质。The present application relates to the field of communication technology, and in particular to a memory management method, electronic equipment, chip system and readable storage medium.
远程直接数据存取(Remote Direct Memory Access,RDMA)技术是一种直接访问远端计算机存储区的网络传输技术,与传统的网络技术相比,RDMA技术可以绕过操作***协议栈,减少数据的拷贝次数,避免用户态内核态切换开销,从而占用较小的***资源并降低时延。Remote Direct Memory Access (RDMA) technology is a network transmission technology that directly accesses the storage area of a remote computer. Compared with traditional network technology, RDMA technology can bypass the operating system protocol stack and reduce data transmission. The number of copies avoids the overhead of user-mode and kernel-mode switching, thereby occupying smaller system resources and reducing latency.
电子设备中的应用基于RDMA技术进行数据传输的过程中,需要向RDMA***预先注册一定量的物理地址空间,用于RDMA网卡在发送数据以及接收数据的过程中进行数据缓存。当电子设备上有多个应用同时运行时,就需要为每个应用预先分配对应的物理地址空间,但是,电子设备中的存储器的内存资源有限,预先分配的固定大小的物理地址空间可能无法满足有些应用的内存需求,也可能大于有些应用的内存需求而造成资源浪费。In the process of data transmission based on RDMA technology in applications in electronic equipment, a certain amount of physical address space needs to be pre-registered with the RDMA system for data caching by the RDMA network card during the process of sending and receiving data. When multiple applications are running simultaneously on an electronic device, a corresponding physical address space needs to be pre-allocated for each application. However, the memory resources of the memory in the electronic device are limited, and the pre-allocated fixed-size physical address space may not be sufficient. The memory requirements of some applications may be greater than the memory requirements of some applications, resulting in a waste of resources.
发明内容Contents of the invention
本申请提供一种内存管理方法、电子设备、芯片***及可读存储介质,一定程度上解决了现有的RDMA技术中内存资源分配不合理的问题。This application provides a memory management method, electronic device, chip system and readable storage medium, which solves the problem of unreasonable memory resource allocation in the existing RDMA technology to a certain extent.
为达到上述目的,本申请采用如下技术方案:In order to achieve the above purpose, this application adopts the following technical solutions:
第一方面,本申请提供一种内存管理方法,应用于第一电子设备,该方法包括:确定目标应用待存储的数据量和与目标应用关联的物理地址空间中的有效内存空间,有效内存空间包括N个第一物理地址单元指示的内存空间,每个所述第一物理地址单元包括至少一个具备数据读写权限的物理地址,N为大于或等于0的整数;若数据量大于有效内存空间,则根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展;若数据量小于有效内存空间,则根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减。In a first aspect, the present application provides a memory management method, which is applied to a first electronic device. The method includes: determining the amount of data to be stored by a target application and the effective memory space in the physical address space associated with the target application. The effective memory space Including memory space indicated by N first physical address units, each of the first physical address units includes at least one physical address with data read and write permissions, N is an integer greater than or equal to 0; if the amount of data is greater than the effective memory space , then the effective memory space is expanded according to the first difference between the data amount and the effective memory space; if the data amount is less than the effective memory space, the effective memory space is expanded according to the second difference between the effective memory space and the data amount. Make reductions.
基于本申请提供的内存管理方法,根据目标应用待存储的数据量和目标应用对应的物理地址空间中的具备数据读写权限的有效内存空间之间的差值,确定有效内存空间是否满足应用当前待存储的数据量所需的内存空间,从而动态调整目标应用的有效内存空间。其中,若有效内存空间不满足待存储的数据量所需的内存空间,则可以根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展,使得扩展后的有效内存空间满足应用所需的内存空间,若有效内存空间满足待存储的数据量所需的内存空间,则可以根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减,从而释放部分未占用的有效内存空间,避免浪费内存资源。Based on the memory management method provided by this application, based on the difference between the amount of data to be stored by the target application and the effective memory space with data read and write permissions in the physical address space corresponding to the target application, it is determined whether the effective memory space meets the current requirements of the application. The memory space required for the amount of data to be stored, thereby dynamically adjusting the effective memory space of the target application. Among them, if the effective memory space does not meet the memory space required by the amount of data to be stored, the effective memory space can be expanded according to the first difference between the data amount and the effective memory space, so that the expanded effective memory space satisfies The memory space required by the application. If the effective memory space meets the memory space required by the amount of data to be stored, the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data, thereby releasing some unused memory space. Effective memory space occupied to avoid wasting memory resources.
在第一方面的一个可能的实现方式中,物理地址空间中还包括第二物理地址单元,第二物理地址单元包括至少一个不具备数据写入权限的物理地址。In a possible implementation of the first aspect, the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
在第一方面的一个可能的实现方式中,该方法还包括:In a possible implementation of the first aspect, the method further includes:
在接收到目标应用发送的内存分配请求时,为目标应用分配第二物理地址单元;在接收到目标应用发送的基于远程直接数据存取通信的注册请求时,对第二物理地址单元与目标应用的虚拟地址空间之间的初始映射表进行注册。When receiving a memory allocation request sent by the target application, allocate a second physical address unit to the target application; when receiving a registration request based on remote direct data access communication sent by the target application, assign the second physical address unit to the target application The initial mapping table between virtual address spaces is registered.
在第一方面的一个可能的实现方式中,目标应用的虚拟地址空间包括M个虚拟地址单元,每个虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数;
In a possible implementation of the first aspect, the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, and M is an integer greater than or equal to 1;
根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展,包括:The effective memory space is expanded according to the first difference between the data amount and the effective memory space, including:
根据第一差值为目标应用分配m个第一物理地址单元,m个第一物理地址单元的内存空间大于或等于第一差值,1≤m+N<M;将M个虚拟地址单元中与第二物理地址单元对应的m个虚拟地址单元重映射至m个第一物理地址单元。Allocate m first physical address units to the target application according to the first difference value. The memory space of the m first physical address units is greater than or equal to the first difference value. 1≤m+N<M; divide the M virtual address units into m virtual address units corresponding to the second physical address units are remapped to m first physical address units.
在第一方面的一个可能的实现方式中,目标应用的虚拟地址空间包括M个虚拟地址单元,每个虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数,有效内存空间包括与M个虚拟地址单元中的N个虚拟地址单元对应的N个第一物理地址单元,1≤N≤M;In a possible implementation of the first aspect, the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, M is an integer greater than or equal to 1, and the effective memory space includes N first physical address units corresponding to N virtual address units among M virtual address units, 1≤N≤M;
根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减,包括:The effective memory space is reduced according to the second difference between the effective memory space and the amount of data, including:
当第二差值大于或等于预设阈值时,将N个虚拟地址单元中与n个第一物理地址单元对应的n个虚拟地址单元重映射至第二物理地址单元,n个第一物理地址单元的内存空间小于或等于第二差值,预设阈值大于0,1≤n<N。When the second difference is greater than or equal to the preset threshold, n virtual address units corresponding to the n first physical address units among the N virtual address units are remapped to the second physical address unit, and the n first physical addresses The memory space of the unit is less than or equal to the second difference value, the preset threshold is greater than 0, and 1≤n<N.
在第一方面的一个可能的实现方式中,目标应用为第一电子设备中安装的应用。In a possible implementation of the first aspect, the target application is an application installed in the first electronic device.
在第一方面的一个可能的实现方式中,待存储的数据量为目标应用的数据量,或者第一电子设备接收到的第二电子设备中安装的应用的数据量。In a possible implementation of the first aspect, the amount of data to be stored is the amount of data of the target application, or the amount of data of the application installed in the second electronic device received by the first electronic device.
第二方面,本申请提供一种电子设备,包括:处理器,所述处理器用于运行存储器中存储的计算机程序,以实现第一方面的任一可能的实现方式中的方法。In a second aspect, the present application provides an electronic device, including: a processor configured to run a computer program stored in a memory to implement the method in any possible implementation of the first aspect.
第三方面,本申请提供另一种电子设备,包括:处理器和远程直接数据存取网卡;In the third aspect, this application provides another electronic device, including: a processor and a remote direct data access network card;
远程直接数据存取网卡用于确定目标应用待存储的数据量和与目标应用关联的物理地址空间中的有效内存空间,有效内存空间包括N个第一物理地址单元指示的内存空间,每个第一物理地址单元包括至少一个具备数据读写权限的物理地址,N为大于或等于0的整数;若数据量大于有效内存空间,远程直接数据存取网卡还用于向处理器发送第一中断信息,第一中断信息包括数据量与有效内存空间之间的第一差值,处理器用于根据第一差值对有效内存空间进行扩展;若数据量小于有效内存空间,远程直接数据存取网卡还用于向处理器发送第二中断信息,第二中断信息包括有效内存空间与数据量之间的第二差值,处理器用于根据第二差值对有效内存空间进行缩减。The remote direct data access network card is used to determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application. The effective memory space includes the memory space indicated by N first physical address units, each of which A physical address unit includes at least one physical address with data read and write permissions, and N is an integer greater than or equal to 0; if the amount of data is greater than the effective memory space, the remote direct data access network card is also used to send the first interrupt information to the processor , the first interrupt information includes the first difference between the data amount and the effective memory space, and the processor is used to expand the effective memory space according to the first difference; if the data amount is less than the effective memory space, the remote direct data access network card also The processor is configured to send second interrupt information to the processor, where the second interrupt information includes a second difference between the effective memory space and the data amount, and the processor is configured to reduce the effective memory space according to the second difference.
在第三方面的一个可能的实现方式中,物理地址空间中还包括第二物理地址单元,第二物理地址单元包括至少一个不具备数据写入权限的物理地址。In a possible implementation of the third aspect, the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
在第三方面的一个可能的实现方式中,处理器还用于:In a possible implementation of the third aspect, the processor is also used to:
在接收到目标应用发送的内存分配请求时,为目标应用分配第二物理地址单元;When receiving a memory allocation request sent by the target application, allocate a second physical address unit to the target application;
远程直接数据存取网卡还用于:Remote direct data access network cards are also used for:
在接收到目标应用发送的基于远程直接数据存取通信的注册请求时,对第二物理地址单元与目标应用的虚拟地址空间之间的初始映射表进行注册。When a registration request based on remote direct data access communication sent by the target application is received, an initial mapping table between the second physical address unit and the virtual address space of the target application is registered.
在第三方面的一个可能的实现方式中,目标应用的虚拟地址空间包括M个虚拟地址单元,每个虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数;In a possible implementation of the third aspect, the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, and M is an integer greater than or equal to 1;
处理器还用于:The processor is also used for:
根据第一差值为目标应用分配m个第一物理地址单元,m个第一物理地址单元的内存空间大于或等于第一差值,1≤m+N<M;将M个虚拟地址单元中与第二物理地址单元对应的m个虚拟地址单元重映射至m个第一物理地址单元。Allocate m first physical address units to the target application according to the first difference value. The memory space of the m first physical address units is greater than or equal to the first difference value. 1≤m+N<M; divide the M virtual address units into m virtual address units corresponding to the second physical address units are remapped to m first physical address units.
在第三方面的一个可能的实现方式中,目标应用的虚拟地址空间包括M个虚拟地址单元,每个虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数,有效内存空间包括与M个虚拟地址单元中的N个虚拟地址单元对应的N个第一物理地址单元,1≤N≤M;In a possible implementation of the third aspect, the virtual address space of the target application includes M virtual address units, each virtual address unit includes at least one virtual address, M is an integer greater than or equal to 1, and the effective memory space includes N first physical address units corresponding to N virtual address units among M virtual address units, 1≤N≤M;
处理器还用于:当第二差值大于或等于预设阈值时,将N个虚拟地址单元中与n个第一物理地址单元对应的n个虚拟地址单元重映射至第二物理地址单元,n个第一物理地址单元的内存空间小于或等于第二差值,预设阈值大于0,1≤n<N。The processor is also configured to: when the second difference is greater than or equal to the preset threshold, remap n virtual address units corresponding to the n first physical address units among the N virtual address units to the second physical address unit, The memory space of n first physical address units is less than or equal to the second difference, the preset threshold is greater than 0, and 1≤n<N.
在第三方面的一个可能的实现方式中,目标应用为电子设备中安装的应用。In a possible implementation of the third aspect, the target application is an application installed in the electronic device.
在第三方面的一个可能的实现方式中,待存储的数据量为第一远程直接数据存取网卡接收到的第二远程直接数据存取网卡发送的数据量。In a possible implementation of the third aspect, the amount of data to be stored is the amount of data received by the first remote direct data access network card and sent by the second remote direct data access network card.
第四方面,本申请提供一种芯片***,芯片***包括处理器,处理器执行存储器中存储的计
算机程序,以实现第一方面的任一可能的实现方式中的方法。In a fourth aspect, this application provides a chip system. The chip system includes a processor, and the processor executes the calculation stored in the memory. A computer program to implement the method in any possible implementation manner of the first aspect.
第五方面,本申请提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现第一方面的任一可能的实现方式中的方法。In a fifth aspect, this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method in any possible implementation manner of the first aspect is implemented.
第六方面,本申请提供一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行第一方面的任一可能的实现方式中的方法。In a sixth aspect, the present application provides a computer program product, which when the computer program product is run on an electronic device, causes the electronic device to execute the method in any possible implementation of the first aspect.
本申请提供的第二方面至第六方面的技术效果可以参见上述第一方面的各个可能的实现方式的技术效果,此处不再赘述。The technical effects of the second to sixth aspects provided by this application can be referred to the technical effects of each possible implementation of the above-mentioned first aspect, and will not be described again here.
图1为本申请实施例提供的一种电子设备的结构示意图;Figure 1 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
图2为本申请实施例提供的一种电子设备的软件结构示意图;Figure 2 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application;
图3为本申请实施例提供的一种基于传统的网络通信技术进行数据传输的示意图;Figure 3 is a schematic diagram of data transmission based on traditional network communication technology provided by an embodiment of the present application;
图4为本申请实施例提供的一种基于现有的RDMA通信技术进行数据传输的示意图;Figure 4 is a schematic diagram of data transmission based on existing RDMA communication technology provided by an embodiment of the present application;
图5为本申请实施例提供的虚拟地址空间、页表和物理地址空间之间的映射关系示意图;Figure 5 is a schematic diagram of the mapping relationship between virtual address space, page table and physical address space provided by the embodiment of the present application;
图6为本申请实施例提供的一种内存管理方法的流程示意图;Figure 6 is a schematic flow chart of a memory management method provided by an embodiment of the present application;
图7为本申请实施例提供的一种目标应用的虚拟地址空间与第二物理地址单元之间的映射关系示意图;Figure 7 is a schematic diagram of the mapping relationship between the virtual address space of a target application and the second physical address unit provided by an embodiment of the present application;
图8为本申请实施例提供的一种目标应用的虚拟地址空间与物理地址空间之间的映射关系示意图;Figure 8 is a schematic diagram of the mapping relationship between the virtual address space and the physical address space of a target application provided by an embodiment of the present application;
图9为本申请实施例提供的另一种目标应用的虚拟地址空间与物理地址空间之间的映射关系示意图;Figure 9 is a schematic diagram of the mapping relationship between the virtual address space and the physical address space of another target application provided by an embodiment of the present application;
图10为本申请实施例提供的电子设备中的目标应用、处理器与RDMA网卡之间的一种交互示意图;Figure 10 is a schematic diagram of the interaction between the target application, the processor and the RDMA network card in the electronic device provided by the embodiment of the present application;
图11为本申请实施例提供的第一电子设备与第二电子设备之间进行交互的示意图;Figure 11 is a schematic diagram of interaction between a first electronic device and a second electronic device provided by an embodiment of the present application;
图12为本申请实施例提供的电子设备中的目标应用、处理器与RDMA网卡之间的另一种交互示意图。Figure 12 is another schematic diagram of interaction between the target application, the processor and the RDMA network card in the electronic device provided by the embodiment of the present application.
下面结合本申请实施例中的附图以及相关实施例,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个或两个以上(包含两个)。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The technical solutions in the embodiments of the present application will be described below with reference to the drawings and related embodiments in the embodiments of the present application. In the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a," "the," "above," "the" and "the" are intended to also include, for example, "a "or more" unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one" and "one or more" refer to one or more than two (including two). The term "and/or" is used to describe the relationship between associated objects, indicating that there can be three relationships; for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, Where A and B can be singular or plural. The character "/" generally indicates that the related objects are in an "or" relationship.
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。术语“连接”包括直接连接和间接连接,除非另外说明。“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。Reference in this specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Therefore, the phrases "in one embodiment", "in some embodiments", "in other embodiments", "in other embodiments", etc. appearing in different places in this specification are not necessarily References are made to the same embodiment, but rather to "one or more but not all embodiments" unless specifically stated otherwise. The terms “including,” “includes,” “having,” and variations thereof all mean “including but not limited to,” unless otherwise specifically emphasized. The term "connected" includes both direct and indirect connections unless otherwise stated. “First” and “second” are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features.
在本申请实施例中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请
实施例中被描述为“示例性地”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of this application, words such as "exemplarily" or "for example" are used to represent examples, illustrations or explanations. this application Any embodiment or design described in the embodiments as "exemplary" or "such as" is not intended to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.
本申请实施例提供的内存管理方法可以应用于手机、平板电脑、可穿戴设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)、服务器等电子设备上,本申请实施例对电子设备的具体类型不作任何限制。The memory management method provided by the embodiment of the present application can be applied to mobile phones, tablet computers, wearable devices, augmented reality (AR)/virtual reality (VR) devices, notebook computers, ultra-mobile personal computers (ultra- On electronic devices such as mobile personal computers (UMPC), netbooks, personal digital assistants (personal digital assistants, PDAs), servers, etc., the embodiments of this application do not place any restrictions on the specific types of electronic devices.
请参照图1,为本申请实施例提供的电子设备100的结构示意图,该电子设备100可以包括处理器(central processing unit,CPU)110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195,RDMA网卡196等。其中,传感器模块180可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器L,骨传导传感器等。Please refer to Figure 1, which is a schematic structural diagram of an electronic device 100 provided by an embodiment of the present application. The electronic device 100 may include a processor (central processing unit, CPU) 110, an external memory interface 120, an internal memory 121, a universal serial bus ( universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C , headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (subscriber identification module, SIM) card interface 195, RDMA network card 196, etc. Among them, the sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor L, a bone conduction sensor, etc.
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently. The components illustrated may be implemented in hardware, software, or a combination of software and hardware.
CPU110可以包括一个或多个处理单元,例如:CPU110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The CPU 110 may include one or more processing units. For example, the CPU 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), an image signal processor (image signal processor) , ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors.
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the electronic device 100 . The controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
在一些实施例中,CPU110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronousreceiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, CPU 110 may include one or more interfaces. Interfaces may include integrated circuit (inter-integrated circuit, I2C) interface, integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver transmitter (universal asynchronous receiver) /transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and/ Or universal serial bus (USB) interface, etc.
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,CPU110可以包含多组I2C总线。CPU110可以通过不同的I2C总线接口分别耦合触摸传感器,充电器,闪光灯,摄像头193等。例如:CPU110可以通过I2C接口耦合触摸传感器,使CPU110与触摸传感器通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (derail clock line, SCL). In some embodiments, CPU 110 may include multiple sets of I2C buses. The CPU 110 can couple touch sensors, chargers, flashes, cameras 193, etc. respectively through different I2C bus interfaces. For example, the CPU 110 can be coupled to a touch sensor through an I2C interface, so that the CPU 110 and the touch sensor communicate through the I2C bus interface to implement the touch function of the electronic device 100 .
I2S接口可以用于音频通信。在一些实施例中,CPU110可以包含多组I2S总线。CPU110可以通过I2S总线与音频模块170耦合,实现CPU110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, CPU 110 may include multiple sets of I2S buses. The CPU 110 can be coupled with the audio module 170 through the I2S bus to implement communication between the CPU 110 and the audio module 170 . In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface to implement the function of answering calls through a Bluetooth headset.
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communications to sample, quantize and encode analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface to implement the function of answering calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接
CPU110与无线通信模块160。例如:CPU110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus used for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect CPU110 and wireless communication module 160. For example, the CPU 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
MIPI接口可以被用于连接CPU110与显示屏194,摄像头193等***器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,CPU110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。CPU110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the CPU 110 with peripheral devices such as the display screen 194 and the camera 193 . MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc. In some embodiments, the CPU 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100 . The CPU 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device 100 .
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接CPU110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the CPU 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与***设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备100,例如AR设备等。The USB interface 130 is an interface that complies with the USB standard specification, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through them. This interface can also be used to connect other electronic devices 100, such as AR devices, etc.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only schematic illustrations and do not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备100供电。The charging management module 140 is used to receive charging input from the charger. Among them, the charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB interface 130 . In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through the wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142, it can also provide power to the electronic device 100 through the power management module 141.
电源管理模块141用于连接电池142,充电管理模块140与CPU110。电源管理模块141接收电池142和/或充电管理模块140的输入,为CPU110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于CPU110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used to connect the battery 142, the charging management module 140 and the CPU 110. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the CPU 110, internal memory 121, external memory, display screen 194, camera 193, wireless communication module 160, etc. The power management module 141 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters. In some other embodiments, the power management module 141 may also be provided in the CPU 110 . In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于CPU110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与CPU110的至少部分模块被设置在同一个器件中。The mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least part of the functional modules of the mobile communication module 150 may be disposed in the CPU 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the CPU 110 .
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于CPU110,与移动通信模块150或其他功能模块设置在同一个器件中。
A modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the CPU 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星***(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信MMU的一个或多个器件,例如无线通信模块160可以为RDMA网卡。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到CPU110。无线通信模块160还可以从CPU110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellites. System (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication MMU. For example, the wireless communication module 160 may be an RDMA network card. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the CPU 110 . The wireless communication module 160 can also receive the signal to be sent from the CPU 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯***(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位***(global positioning system,GPS),全球导航卫星***(global navigation satellite system,GLONASS),北斗卫星导航***(beidou navigation satellite system,BDS),准天顶卫星***(quasi-zenith satellite system,QZSS)和/或星基增强***(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi) -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。CPU110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. CPU 110 may include one or more GPUs that execute program instructions to generate or change display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, etc. Display 194 includes a display panel. The display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode). emitting diode (AMOLED), flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera sensor through the lens, the optical signal is converted into an electrical signal, and the camera sensor passes the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object passes through the lens to produce an optical image that is projected onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to convert it into a digital image signal. ISP outputs digital image signals to DSP for processing. DSP converts digital image signals into standard RGB, YUV and other format image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can continuously learn by itself. Intelligent cognitive applications of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, etc.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于CPU110中,或将音频模块170的部分功能模块设置于CPU110中。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be disposed in the CPU 110 , or some functional modules of the audio module 170 may be disposed in the CPU 110 .
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。Speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to hands-free calls.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。Receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be heard by bringing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak close to the microphone 170C with the human mouth and input the sound signal to the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which in addition to collecting sound signals, may also implement a noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions, etc.
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动终端平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The headphone interface 170D is used to connect wired headphones. The headphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The buttons 190 include a power button, a volume button, etc. Key 190 may be a mechanical key. It can also be a touch button. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。The motor 191 can generate vibration prompts. The motor 191 can be used for vibration prompts for incoming calls and can also be used for touch vibration feedback. For example, touch operations for different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. The motor 191 can also respond to different vibration feedback effects for touch operations in different areas of the display screen 194 . Different application scenarios (such as time reminders, receiving information, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, or may be used to indicate messages, missed calls, notifications, etc.
SIM卡接口195用于连接SIM卡。SIM卡可以通过***SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时***多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 . The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与CPU110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the CPU 110 through the external memory interface 120 to implement the data storage function. Such as saving music, videos, etc. files in external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。CPU110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作***,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。Internal memory 121 may be used to store computer executable program code, which includes instructions. The CPU 110 executes instructions stored in the internal memory 121 to execute various functional applications and data processing of the electronic device 100 . The internal memory 121 may include a program storage area and a data storage area. Among them, the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.). The storage data area may store data created during use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
参见图2,为本申请实施例的电子设备的软件结构示意图。电子设备中的操作***可以是安卓(Android)***,微软窗口***(Windows),苹果移动操作***(iOS)或者鸿蒙***(Harmony OS)等。在此,以电子设备的操作***为鸿蒙***为例进行说明。Refer to Figure 2, which is a schematic diagram of the software structure of the electronic device according to the embodiment of the present application. The operating system in the electronic device can be Android, Microsoft Window System (Windows), Apple Mobile Operating System (iOS) or Harmony OS, etc. Here, the operating system of the electronic device is the Hongmeng system as an example.
在一些实施例中,可将鸿蒙***分为四层,包括内核层、***服务层、框架层以及应用层,
层与层之间通过软件接口通信。In some embodiments, the Hongmeng system can be divided into four layers, including the kernel layer, system service layer, framework layer and application layer. The layers communicate through software interfaces.
如图2所示,内核层包括内核抽象层(Kernel Abstract Layer,KAL)和驱动子***。KAL下包括多个内核,如Linux***的内核Linux Kernel、轻量级物联网***内核LiteOS等。驱动子***则可以包括硬件驱动框架(Hardware Driver Foundation,HDF)。硬件驱动框架能够提供统一外设访问能力和驱动开发、管理框架。多内核的内核层可以根据***的需求选择相应的内核进行处理。As shown in Figure 2, the kernel layer includes the kernel abstract layer (KAL) and driver subsystem. KAL includes multiple kernels, such as the Linux Kernel, the lightweight IoT system kernel LiteOS, etc. The driver subsystem can include the Hardware Driver Foundation (HDF). The hardware driver framework can provide unified peripheral access capabilities and driver development and management framework. The multi-core kernel layer can select the corresponding core for processing according to the needs of the system.
***服务层是鸿蒙***的核心能力集合,***服务层通过框架层对应用程序提供服务。该层可包括***基本能力子***集、基础软件服务子***集、增强软件服务子***集以及硬件服务子***集。The system service layer is the core capability set of Hongmeng system. The system service layer provides services to applications through the framework layer. This layer may include a system basic capability subsystem set, a basic software service subsystem set, an enhanced software service subsystem set, and a hardware service subsystem set.
***基本能力子***集为分布式应用在鸿蒙***的设备上的运行、调度、迁移等操作提供了基础能力。可包括分布式软总线、分布式数据管理、分布式任务调度、方舟多语言运行时、公共基础库、多模输入、图形、安全、人工智能(Artificial Intelligence,AI)、用户程序框架等子***。其中,方舟多语言运行时提供了C或C++或JavaScript(JS)多语言运行时和基础的***类库,也可以为使用方舟编译器静态化的Java程序(即应用程序或框架层中使用Java语言开发的部分)提供运行时。The basic capability subsystem set of the system provides basic capabilities for the operation, scheduling, migration and other operations of distributed applications on Hongmeng system devices. Can include distributed soft bus, distributed data management, distributed task scheduling, Ark multi-language runtime, common basic library, multi-mode input, graphics, security, artificial intelligence (AI), user program framework and other subsystems . Among them, the Ark multi-language runtime provides C or C++ or JavaScript (JS) multi-language runtime and basic system class libraries. It can also be used for static Java programs using the Ark compiler (that is, using Java in the application or framework layer). Language development part) provides the runtime.
基础软件服务子***集为鸿蒙***提供公共的、通用的软件服务。可包括事件通知、电话、多媒体、面向X设计(Design For X,DFX)、MSDP&DV等子***。The basic software service subsystem set provides public and general software services for Hongmeng system. Can include event notification, telephone, multimedia, Design For X (Design For X, DFX), MSDP&DV and other subsystems.
增强软件服务子***集为鸿蒙***提供针对不同设备的、差异化的能力增强型软件服务。可包括智慧屏专有业务、穿戴专有业务、物联网(Internet of Things,IoT)专有业务子***组成。The enhanced software service subsystem set provides Hongmeng system with differentiated capability-enhanced software services for different devices. It can include smart screen proprietary business, wearable proprietary business, and Internet of Things (IoT) proprietary business subsystems.
硬件服务子***集为鸿蒙***提供硬件服务。可包括位置服务、生物特征识别、穿戴专有硬件服务、IoT专有硬件服务等子***。The hardware service subsystem set provides hardware services for Hongmeng system. It can include subsystems such as location services, biometric identification, wearable proprietary hardware services, and IoT proprietary hardware services.
框架层为鸿蒙***应用开发提供了Java、C、C++、JS等多语言的用户程序框架和能力(Ability)框架,两种用户界面(User Interface,UI)框架(包括适用于Java语言的Java UI框架、适用于JS语言的JS UI框架),以及各种软硬件服务对外开放的多语言框架应用程序接口(Application Programming Interface,API)。根据***的组件化裁剪程度,鸿蒙***设备支持的API也会有所不同。The framework layer provides multi-language user program frameworks and Ability frameworks such as Java, C, C++, and JS for Hongmeng system application development. Two user interface (UI) frameworks (including Java UI for Java language framework, JS UI framework suitable for JS language), and multi-language framework application program interface (Application Programming Interface, API) that is open to the public for various software and hardware services. Depending on the degree of component tailoring of the system, the APIs supported by Hongmeng system devices will also be different.
应用层包括***应用和第三方应用(或称为扩展应用)。***应用可包括桌面、控制栏、设置、电话等电子设备默认安装的应用程序。扩展应用可以是由电子设备的制造商开发设计的、非必要的应用,如电子设备管家、换机迁移、便签、天气等应用程序。而第三方非***应用则可以是由其他厂商开发,但是可以在鸿蒙***中运行应用程序,如游戏、导航、社交或购物等应用程序。The application layer includes system applications and third-party applications (or extended applications). System applications may include applications installed by default on the desktop, control bar, settings, phone and other electronic devices. Extended applications can be non-essential applications developed and designed by manufacturers of electronic devices, such as electronic device manager, replacement migration, notes, weather and other applications. Third-party non-system applications can be developed by other manufacturers, but can run applications in the Hongmeng system, such as games, navigation, social networking or shopping applications.
提供后台运行任务的能力以及统一的数据访问抽象。PA主要为FA提供支持,例如作为后台服务提供计算能力,或作为数据仓库提供数据访问能力。基于FA或PA开发的应用,能够实现特定的业务功能,支持跨设备调度与分发,为用户提供一致、高效的应用体验。Provides the ability to run tasks in the background and a unified data access abstraction. PA mainly provides support for FA, such as providing computing power as a background service, or providing data access capabilities as a data warehouse. Applications developed based on FA or PA can implement specific business functions, support cross-device scheduling and distribution, and provide users with a consistent and efficient application experience.
多个运行鸿蒙***的电子设备之间可以通过分布式软总线、分布式设备虚拟化、分布式数据管理和分布式任务调度实现硬件互助和资源共享。Multiple electronic devices running the Hongmeng system can achieve hardware mutual assistance and resource sharing through distributed soft buses, distributed device virtualization, distributed data management and distributed task scheduling.
操作***一般分为两种状态:内核运行态(以下简称内核态)和用户运行态(以下简称用户态),相应的,操作***中具有在内核态执行的操作***应用以及在用户态执行的普通应用,用户态应用相较于内核态应用具有较低的执行权限。一般内核态应用可以访问电子设备中的所有硬件资源,例如内部存储器、外部存储卡、网卡等,用户态应用可以访问的硬件资源有限,因此用户态应用在执行数据传输、数据存储或数据读取等操作时,需要通过***调用以及产生中断信号的方式陷入内核态(即调用处于内核的计算机程序),从而实现相应的操作。The operating system is generally divided into two states: the kernel running state (hereinafter referred to as the kernel state) and the user running state (hereinafter referred to as the user state). Correspondingly, the operating system has operating system applications executed in the kernel mode and applications executed in the user mode. Ordinary applications and user-mode applications have lower execution permissions than kernel-mode applications. Generally, kernel-mode applications can access all hardware resources in electronic devices, such as internal memory, external memory cards, network cards, etc. User-mode applications have limited access to hardware resources, so user-mode applications cannot perform data transmission, data storage, or data reading. When waiting for an operation, you need to fall into the kernel state (that is, call the computer program in the kernel) through system calls and generate interrupt signals, so as to implement the corresponding operations.
一般电子设备的CPU110与内部存储器121以及外部存储器接口120的总线之间设置有MMU(memory management unit,内存管理单元)111(如图1中所示)。当CPU110需要访问内部存储器121(即前述中的内存)时,可以提供一个虚拟地址,MMU可以将该虚拟地址映射为物理地址,进而使CPU110能够基于该物理地址,从内部存储器121中读取数据或向内部存储器121中写入数据。
In general, an MMU (memory management unit) 111 (as shown in FIG. 1 ) is provided between the CPU 110 of an electronic device, the internal memory 121 and the external memory interface 120 bus. When the CPU 110 needs to access the internal memory 121 (ie, the memory mentioned above), a virtual address can be provided, and the MMU can map the virtual address to a physical address, thereby enabling the CPU 110 to read data from the internal memory 121 based on the physical address. Or write data into the internal memory 121.
虚拟地址为电子设备中的操作***能够识别或产生的虚拟地址空间中的某个地址,其大小范围可以由CPU110中运行的操作***的位数确定。比如,如果CPU110中运行的操作***为32位,虚拟地址也为32位,其地址范围可以为0-0xFFFFFFFF(4GB);如果CPU110中运行的操作***为64位,虚拟地址也为64位,其地址空间可以为0-0xFFFFFFFFFFFFFFFF(16EB)。The virtual address is an address in the virtual address space that can be recognized or generated by the operating system in the electronic device, and its size range can be determined by the number of bits of the operating system running in the CPU 110 . For example, if the operating system running in CPU110 is 32-bit, the virtual address is also 32-bit, and its address range can be 0-0xFFFFFFFF (4GB); if the operating system running in CPU110 is 64-bit, the virtual address is also 64-bit, Its address space can be 0-0xFFFFFFFFFFFFFFFF (16EB).
其中,虚拟地址可以根据实际需要被划分为多个虚拟地址空间,比如用户态虚拟地址空间和内核态虚拟地址空间。用户态虚拟地址空间可以由用户态应用(比如读、写、打开、关闭或绘图)和内核态应用(比如进程管理、存储管理、文件管理或设备管理)访问,内核态虚拟地址空间可以仅由内核态应用在运行时访问。例如,虚拟地址空间的地址范围为[0x00000000,0xFFFFFFFF],则用户态虚拟地址空间的地址范围可以为[0x00000000,0x80000000)(即第0GB-第2GB),内核态虚拟地址空间的地址范围可以为[0x80000000,0xFFFFFFFF](即第2GB-第4GB)。Among them, the virtual address can be divided into multiple virtual address spaces according to actual needs, such as user-mode virtual address space and kernel-mode virtual address space. User-mode virtual address space can be accessed by user-mode applications (such as reading, writing, opening, closing, or drawing) and kernel-mode applications (such as process management, storage management, file management, or device management). Kernel-mode virtual address space can only be accessed by Kernel-mode applications access it at runtime. For example, the address range of the virtual address space is [0x00000000, 0xFFFFFFFF], then the address range of the user-mode virtual address space can be [0x00000000, 0x80000000) (that is, the 0th GB-2nd GB), and the address range of the kernel-mode virtual address space can be [0x80000000, 0xFFFFFFFF] (i.e. 2GB-4th GB).
物理地址可以为内部存储器121等硬件存储设备实际所具有的地址空间中的某个地址。物理地址的地址空间可以小于虚拟地址的地址空间,比如当虚拟地址的地址空间的大小可以为4GB时,物理地址的地址空间的大小可以为256MB。The physical address may be an address in the address space actually owned by a hardware storage device such as the internal memory 121. The address space of the physical address can be smaller than the address space of the virtual address. For example, when the size of the address space of the virtual address can be 4GB, the size of the address space of the physical address can be 256MB.
如图3所示,发送端的应用和接收端的应用基于传统的网络通信技术进行数据传输的过程中,发送端的CPU需要将应用的待发送数据拷贝至内核态的TCP/IP协议栈的缓存空间中,然后依次拷贝至驱动层的缓存空间以及传统网卡的缓存空间中,最终发送端的传统网卡可以基于预先建立的通信链路将待发送数据发送至接收端的传统网卡,在该过程中,需要占用大量的CPU资源对数据进行拷贝,且需要在用户态与内核态之间进行转换,导致数据传输过程中的时延较长。As shown in Figure 3, during the process of data transmission between the sending end application and the receiving end application based on traditional network communication technology, the sending end CPU needs to copy the application's to-be-sent data to the cache space of the TCP/IP protocol stack in kernel mode. , and then copied to the cache space of the driver layer and the cache space of the traditional network card in sequence. Finally, the traditional network card at the sending end can send the data to be sent to the traditional network card at the receiving end based on the pre-established communication link. In this process, a large amount of space is required. CPU resources are required to copy the data, and conversion between user mode and kernel mode is required, resulting in a long delay during data transmission.
RDMA(Remote Direct Memory Access,远程直接内存访问)技术是一种基于RDMA网卡使得发送端可以直接将数据通过网络传送到接收端的内存中的网络数据传输技术,与传统的网络通信技术相比,RDMA能够绕过操作***的协议栈、减少数据的拷贝次数,从而占用较少的CPU资源,减少时延。其中,接收端和发送端均可以是服务器、客户端、手机终端等电子设备,电子设备至少包括具有远端直接内存访问功能的以太网网卡(即RDMA网卡)和CPU,RDMA网卡主要用于在数据传输的过程中执行数据读取操作和/或数据写入操作。RDMA (Remote Direct Memory Access) technology is a network data transmission technology based on the RDMA network card that allows the sender to directly transmit data to the receiver's memory through the network. Compared with traditional network communication technology, RDMA It can bypass the protocol stack of the operating system and reduce the number of data copies, thereby occupying less CPU resources and reducing latency. Among them, both the receiving end and the sending end can be electronic devices such as servers, clients, and mobile phone terminals. The electronic devices at least include an Ethernet network card (i.e., RDMA network card) with remote direct memory access function and a CPU. The RDMA network card is mainly used in Data reading operations and/or data writing operations are performed during data transmission.
MMU通常基于分页管理机制将虚拟地址空间和物理地址空间分别分割成多个具有固定空间大小的虚拟页和多个具有固定空间大小的物理页进行管理,虚拟页中的虚拟地址的数量与物理页中的物理地址的数量相同,示例性的,固定空间大小可以为4kb、16kb、64kb等。每个虚拟页被设有对应的虚拟页号,每个虚拟页包括至少一个虚拟地址,每个虚拟地址对应有所属的虚拟页的虚拟页号以及在所属的虚拟页中的页内偏移量,所谓页内偏移量为虚拟地址相对于所属的虚拟页中的虚拟基地址的位移量。每个物理页被设有对应的物理页号,每个物理页包括至少一个物理地址,每个物理地址对应有所属的物理页的物理页号。The MMU usually divides the virtual address space and the physical address space into multiple virtual pages with a fixed space size and multiple physical pages with a fixed space size respectively based on the paging management mechanism for management. The number of virtual addresses in the virtual page is related to the number of physical pages. The number of physical addresses in is the same. For example, the fixed space size can be 4kb, 16kb, 64kb, etc. Each virtual page is provided with a corresponding virtual page number. Each virtual page includes at least one virtual address. Each virtual address corresponds to the virtual page number of the virtual page to which it belongs and the page offset in the virtual page to which it belongs. , the so-called intra-page offset is the displacement amount of the virtual address relative to the virtual base address in the virtual page to which it belongs. Each physical page is provided with a corresponding physical page number. Each physical page includes at least one physical address, and each physical address corresponds to the physical page number of the physical page to which it belongs.
如图4所示,电子设备中的应用基于RDMA通信进行数据传输之前,需要申请一段可用于存放数据的物理地址空间。具体的,处理器在接收到应用的内存分配请求后,确定与应用对应的虚拟地址空间,MMU可以将应用的虚拟地址空间转换映射至物理地址空间,并在本地内存中创建并填写应用的虚拟地址空间中的虚拟地址与对应的物理地址空间中的物理地址之间的映射关系的页表。申请成功后,应用可以向RDMA网卡发送注册请求,使得RDMA网卡将用于指示应用的虚拟地址空间和物理地址空间之间的映射关系的页表保存至RDMA网卡的网卡存储器中。As shown in Figure 4, before applications in electronic equipment transmit data based on RDMA communication, they need to apply for a physical address space that can be used to store data. Specifically, after receiving the application's memory allocation request, the processor determines the virtual address space corresponding to the application. The MMU can convert and map the application's virtual address space to the physical address space, and create and fill in the application's virtual address space in the local memory. A page table that maps virtual addresses in the address space to physical addresses in the corresponding physical address space. After the application is successful, the application can send a registration request to the RDMA network card, causing the RDMA network card to save the page table used to indicate the mapping relationship between the application's virtual address space and physical address space to the network card memory of the RDMA network card.
参照图5,为一种虚拟地址空间、页表和物理地址空间之间的映射关系示意图。其中,页表包括多个页表项,页表项的数量与虚拟地址空间中的虚拟页的数量相同,每个页表项用于指示虚拟地址空间中的虚拟页的虚拟页号与物理地址空间中的物理页的物理页号之间的映射关系。如图5所示,假设虚拟地址空间中有6个虚拟页映射至物理地址空间中的6个物理页的页号中,6个虚拟页的虚拟页号为0至5,页表中记录有与每个虚拟页的虚拟页号对应的物理页的物理页号。Refer to Figure 5, which is a schematic diagram of the mapping relationship between virtual address space, page table and physical address space. The page table includes multiple page table entries. The number of page table entries is the same as the number of virtual pages in the virtual address space. Each page table entry is used to indicate the virtual page number and physical address of the virtual page in the virtual address space. The mapping relationship between physical page numbers in the space. As shown in Figure 5, assume that there are 6 virtual pages in the virtual address space mapped to the page numbers of 6 physical pages in the physical address space. The virtual page numbers of the 6 virtual pages are 0 to 5. The page table records The physical page number of the physical page that corresponds to the virtual page number of each virtual page.
RDMA网卡在接收到应用发送端发送的虚拟地址后,通过页表可以确定与虚拟地址所属的虚拟页的虚拟页号对应的物理页的物理页号,根据物理页中的物理基址以及虚拟地址在所属虚拟页中的页内偏移量,可以确定该虚拟地址对应的物理地址。After the RDMA network card receives the virtual address sent by the application sender, it can determine the physical page number of the physical page corresponding to the virtual page number of the virtual page to which the virtual address belongs through the page table. According to the physical base address and virtual address in the physical page The physical address corresponding to the virtual address can be determined by the intra-page offset in the virtual page to which it belongs.
现有的RDMA通信技术一般包括两种通信操作方式,第一种为消息型操作方式,例如send操作和receive操作,第二种为内存型操作方式,例如RDMA Read操作和RDMA Write操作。基
于消息型操作方式,第二电子设备触发receive操作指令,确定用于接收数据的物理地址,第一电子设备的应用可以将待发送数据缓存至预先分配的物理地址空间中,并向第一电子设备中的第一RDMA网卡发送send操作指令,第一RDMA网卡将待发送数据缓存至RDMA内存并将待发送数据进行封装生成数据包,以通过第一电子设备与第二电子设备预先创建的通信链路传输给第二电子设备中的第二RDMA网卡,第二RDMA网卡对数据包进行解封后可以将数据包中的数据存储至用于接收数据的物理地址中。Existing RDMA communication technology generally includes two communication operation modes. The first is a message-type operation mode, such as send operation and receive operation, and the second is a memory-type operation mode, such as RDMA Read operation and RDMA Write operation. base In the message-type operation mode, the second electronic device triggers the receive operation command to determine the physical address used to receive data. The application of the first electronic device can cache the data to be sent in the pre-allocated physical address space and send it to the first electronic device. The first RDMA network card in the device sends a send operation command, and the first RDMA network card caches the data to be sent into the RDMA memory and encapsulates the data to be sent to generate a data packet, so as to communicate through the pre-created communication between the first electronic device and the second electronic device. The link is transmitted to the second RDMA network card in the second electronic device. After decapsulating the data packet, the second RDMA network card can store the data in the data packet into a physical address used to receive the data.
基于内存型操作方式,第二电子设备可以通过预先创建的通信链路为第一电子设备提供第二电子设备中可访问的虚拟地址空间及其访问权限。第一电子设备中的应用可以向第一电子设备中的第一RDMA网卡发送RDMA Read操作指令,RDMA Read操作指令包括第二电子设备中存储待读取数据的虚拟地址以及第一电子设备中用于接收数据的虚拟地址,第一RDMA网卡可以将与RDMA Read操作指令对应的Read请求包通过通信链路传输给第二电子设备中的第二RDMA网卡,第二RDMA网卡可以根据预先存储的页表确定存储待读取数据的虚拟地址对应的物理地址,并将待读取数据封装成数据包后通过通信链路传输回第一RDMA网卡,第一RDMA网卡可以通过查询预先存储的页表将待读取数据写入第一电子设备中的与用于接收数据的虚拟地址对应的物理地址中。Based on the memory-type operation mode, the second electronic device can provide the first electronic device with the accessible virtual address space and its access rights in the second electronic device through the pre-created communication link. The application in the first electronic device can send an RDMA Read operation instruction to the first RDMA network card in the first electronic device. The RDMA Read operation instruction includes the virtual address where the data to be read is stored in the second electronic device and the username used in the first electronic device. Based on the virtual address of the received data, the first RDMA network card can transmit the Read request packet corresponding to the RDMA Read operation instruction to the second RDMA network card in the second electronic device through the communication link. The second RDMA network card can transmit the read request packet corresponding to the RDMA Read operation instruction to the second RDMA network card in the second electronic device according to the pre-stored page. The table determines the physical address corresponding to the virtual address that stores the data to be read, and encapsulates the data to be read into a data packet and transmits it back to the first RDMA network card through the communication link. The first RDMA network card can query the pre-stored page table to The data to be read is written in the physical address in the first electronic device corresponding to the virtual address used to receive the data.
第一电子设备中的应用可以向第一电子设备中的第一RDMA网卡发送RDMA Write操作指令,Write操作指令包括第二电子设备中用于接收数据的虚拟地址以及数据大小,第一RDMA网卡从与应用对应的物理地址空间中获取待发送数据,并将待发送数据以及第二电子设备中用于接收数据的虚拟地址缓存至第一RDMA网卡的RDMA内存后封装成数据包,以通过预先创建的通信链路传输给第二RDMA网卡,第二RDMA网卡可以对数据包进行解封,并通过查询预先存储的页表将数据包中的数据存储至第二电子设备中的与用于接收数据的虚拟地址对应的物理地址中。The application in the first electronic device can send an RDMA Write operation instruction to the first RDMA network card in the first electronic device. The Write operation instruction includes the virtual address and data size used to receive data in the second electronic device. The first RDMA network card is from Obtain the data to be sent from the physical address space corresponding to the application, cache the data to be sent and the virtual address used to receive the data in the second electronic device to the RDMA memory of the first RDMA network card, and then encapsulate it into a data packet to create a data package in advance. The communication link is transmitted to the second RDMA network card. The second RDMA network card can decapsulate the data packet and store the data in the data packet to the second electronic device for receiving data by querying the pre-stored page table. The virtual address corresponds to the physical address.
需要说明的是,在进行数据传输之前,第一电子设备和第二电子设备可以通过Socket连接或连接管理器(Connection Manager,CM)连接建立通信链路,并通过通信链路交换一些RDMA通信所需的信息,例如:第一电子设备可以获取第二电子设备中的虚拟地址空间的虚拟地址,第二电子设备可以获取第一电子设备中的虚拟地址空间的虚拟地址。It should be noted that before data transmission, the first electronic device and the second electronic device can establish a communication link through a Socket connection or a Connection Manager (Connection Manager, CM) connection, and exchange some RDMA communication data through the communication link. For example, the first electronic device can obtain the virtual address of the virtual address space in the second electronic device, and the second electronic device can obtain the virtual address of the virtual address space in the first electronic device.
基于上述现有的RDMA通信技术进行数据传输的过程中,与应用对应的物理地址空间中的物理地址,以及应用的虚拟地址空间与物理地址空间之间的映射关系都是固定不变。当电子设备上有多个应用同时运行时,就需要为每个应用分配对应的物理地址空间,但是存储器的存储资源有限,在数据传输的过程中,每个应用只能访问对应的预先分配的物理地址空间,且不能根据实际所需的内存空间改变与每个应用对应的物理地址空间的大小,导致有些应用的物理地址空间可能无法满足应用实际的内存需求,而有些应用的物理地址空间可能大于应用实际的内存需求,使得部分物理地址空间未被利用。In the process of data transmission based on the above-mentioned existing RDMA communication technology, the physical address in the physical address space corresponding to the application, and the mapping relationship between the virtual address space and the physical address space of the application are fixed. When multiple applications are running simultaneously on an electronic device, each application needs to be allocated a corresponding physical address space. However, the storage resources of the memory are limited. During the data transmission process, each application can only access the corresponding pre-allocated address space. physical address space, and the size of the physical address space corresponding to each application cannot be changed according to the actual required memory space. As a result, the physical address space of some applications may not meet the actual memory requirements of the application, while the physical address space of some applications may not be able to meet the actual memory requirements of the application. Greater than the actual memory requirements of the application, leaving part of the physical address space unused.
现有技术中有用于扩展与应用对应的物理地址空间的方法,一种方法为:当应用检测到当前的通信内存不能满足当前业务场景中的通信数据所需的内存空间时,可以选择断开与当前的物理地址空间之间的映射关系,重新注册新的物理地址空间匹配当前业务场景中的通信数据所需的内存空间,虽然该方法可以根据实际的业务需求动态调整应用对应的内存空间,但是断开与当前的物理地址空间之间的映射关系并重新进行注册的方式比较繁琐且耗时。另一种方法为:应用可以根据不同的业务场景中的通信数据所需的内存空间,向RDMA***注册多个具有不同固定空间大小的物理地址空间,但在每次数据传输过程中仅使用其中一个物理地址空间,其他未被使用的物理地址空间处于闲置状态,浪费较多的内存资源。There are methods in the existing technology for expanding the physical address space corresponding to the application. One method is: when the application detects that the current communication memory cannot meet the memory space required for communication data in the current business scenario, it can choose to disconnect Mapping relationship with the current physical address space, re-registering a new physical address space to match the memory space required for communication data in the current business scenario. Although this method can dynamically adjust the memory space corresponding to the application according to actual business needs, However, the method of disconnecting the mapping relationship with the current physical address space and re-registering it is cumbersome and time-consuming. Another method is: the application can register multiple physical address spaces with different fixed space sizes to the RDMA system based on the memory space required for communication data in different business scenarios, but only use one of them during each data transmission. One physical address space, other unused physical address spaces are idle, wasting more memory resources.
因此,针对现有的RDMA技术中内存资源分配不合理的问题,本申请提供一种内存管理方法、电子设备、芯片***及可读存储介质,根据目标应用待存储的数据量动态的调整对应的物理地址空间中具备数据读写权限的有效内存空间,当有效内存空间大于待存储的数据量时,释放有效内存空间中未被利用的第一物理地址单元,当有效内存空间小于待存储的数据量时,对有效内存空间进行扩展,使得有效内存空间满足应用在不同业务场景下的内存需求,从而为应用合理的分配对应的内存资源。Therefore, in order to solve the problem of unreasonable allocation of memory resources in the existing RDMA technology, this application provides a memory management method, electronic device, chip system and readable storage medium, which dynamically adjusts the corresponding data according to the amount of data to be stored in the target application. An effective memory space with data read and write permissions in the physical address space. When the effective memory space is greater than the amount of data to be stored, the unused first physical address unit in the effective memory space is released. When the effective memory space is less than the amount of data to be stored, When measuring, the effective memory space is expanded so that the effective memory space meets the memory requirements of the application in different business scenarios, thereby allocating corresponding memory resources to the application reasonably.
下面以具体地实施例对本申请的技术方案进行详细说明。下面这几个具体的实施例可以相互
结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。The technical solution of the present application will be described in detail below with specific examples. The following specific embodiments can be mutually In combination, the same or similar concepts or processes may not be described again in some embodiments.
图6为本申请实施例提供的一种内存管理方法的流程示意图,主要涉及电子设备中的目标应用在基于RDMA技术进行数据传输的过程中,电子设备动态调整与目标应用关联的物理地址空间中的有效内存空间的过程。该内存管理方法可应用于具备RDMA通信功能的电子设备,电子设备包括内部存储器、处理器和RDMA网卡。下面参考图6对本申请提供的内存管理方法进行示例性的说明。Figure 6 is a schematic flow chart of a memory management method provided by an embodiment of the present application. It mainly involves the target application in the electronic device performing data transmission based on RDMA technology. The electronic device dynamically adjusts the physical address space associated with the target application. of effective memory space. This memory management method can be applied to electronic devices with RDMA communication functions. The electronic devices include internal memory, processors and RDMA network cards. The following is an exemplary description of the memory management method provided by this application with reference to FIG. 6 .
S601,确定目标应用待存储的数据量和与目标应用关联的物理地址空间中的有效内存空间,有效内存空间包括N个第一物理地址单元指示的内存空间,每个第一物理地址单元包括至少一个具备数据读写权限的物理地址,N为大于或等于0的整数。S601. Determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application. The effective memory space includes memory spaces indicated by N first physical address units, and each first physical address unit includes at least A physical address with data read and write permissions, N is an integer greater than or equal to 0.
需要说明的是,电子设备中安装的目标应用在注册了对应的物理地址空间后,目标应用基于RDMA通信操作与其他电子设备上安装的应用进行后续的数据传输的过程中会产生待存储的数据。电子设备在目标应用注册了物理地址空间后的首次数据传输过程中,可以基于预先注册的物理地址空间中的有效内存空间与待存储的数据量之间的相对大小,确定是否需要对目标应用预先注册的有效内存空间进行调整,以便将目标应用待存储的数据可以缓存至与之关联的有效内存空间中。It should be noted that after the target application installed in the electronic device registers the corresponding physical address space, the target application will generate data to be stored during subsequent data transmission with applications installed on other electronic devices based on RDMA communication operations. . During the first data transmission process after the target application registers the physical address space, the electronic device can determine whether it is necessary to pre-register the target application based on the relative size between the effective memory space in the pre-registered physical address space and the amount of data to be stored. The registered effective memory space is adjusted so that the data to be stored by the target application can be cached in the effective memory space associated with it.
其中,有效内存空间为物理地址空间中所有的第一物理地址单元所指示的内存空间,一个第一物理地址单元对应内部存储器的内存空间中被设有同时具备数据写入权限和数据读取权限的一个物理页,一个第一物理地址单元包括一个或者多个具备数据写入权限和数据读取权限的物理地址。Among them, the effective memory space is the memory space indicated by all the first physical address units in the physical address space. The memory space of a first physical address unit corresponding to the internal memory is provided with both data writing permission and data reading permission. A physical page, a first physical address unit includes one or more physical addresses with data writing permissions and data reading permissions.
在一个示例中,若目标应用预先注册的物理地址空间中不存在有效内存空间,则基于该物理地址空间进行首次数据传输时,需要为目标应用分配有效内存空间,即对与目标应用预先注册的物理地址空间中的有效内存空间进行扩展,从而使有效内存空间满足首次数据传输所需的内存空间。示例性的,目标应用预先注册的物理地址空间可以包括一个或者多个具有固定大小的第二物理地址单元,其中,第二物理单元为被设有不具备数据写入权限但具备数据读取权限的物理页,第二物理地址单元包括至少一个不具备数据写入权限但具备数据读取权限的物理地址。例如,如图7所示,预先注册的物理地址空间中的第二物理地址单元的数量为1,且第二物理地址单元的空间大小可以为4kb,则可以将目标应用的虚拟地址空间中所有的虚拟地址单元均映射至第二物理地址单元。In one example, if there is no valid memory space in the physical address space pre-registered by the target application, then when performing the first data transmission based on the physical address space, it is necessary to allocate valid memory space to the target application, that is, to allocate valid memory space to the target application. The effective memory space in the physical address space is expanded so that the effective memory space meets the memory space required for the first data transfer. For example, the physical address space pre-registered by the target application may include one or more second physical address units with a fixed size, wherein the second physical address unit is configured not to have data writing permission but to have data reading permission. of the physical page, the second physical address unit includes at least one physical address that does not have data writing permission but has data reading permission. For example, as shown in Figure 7, the number of second physical address units in the pre-registered physical address space is 1, and the space size of the second physical address unit can be 4kb, then all the virtual address units in the target application can be The virtual address units are mapped to the second physical address unit.
在另一个示例中,目标应用预先注册的物理地址空间中存在具有固定空间大小的有效内存空间,例如,目标应用预先注册的物理地址空间中包括一个第一物理地址单元,该第一物理地址单元与目标应用的虚拟地址空间中的一个虚拟地址单元对应;或者目标应用预先注册的物理地址单元中包括一个第一物理地址单元以及一个第二物理地址单元,其中,第一物理地址单元与目标应用的虚拟地址空间中的其中一个虚拟地址单元对应,其余虚拟地址单元均与第二物理地址单元对应。基于该物理地址空间进行首次数据传输时,需要根据首次数据传输所需的内存空间与预注册的有效内存空间之间的相对大小,确定是否需要对预注册的有效内存空间进行调整,即若预注册的有效内存空间大于首次数据传输所需的内存空间,则对预注册的有效内存空间中被利用的第一物理地址单元进行回收扩展,若预注册的有效内存空间小于首次数据传输所需的内存空间,则对预注册的有效内存空间进行扩展。In another example, there is an effective memory space with a fixed space size in the physical address space pre-registered by the target application. For example, the physical address space pre-registered by the target application includes a first physical address unit, and the first physical address unit Corresponds to a virtual address unit in the virtual address space of the target application; or the physical address unit pre-registered by the target application includes a first physical address unit and a second physical address unit, where the first physical address unit is the same as the target application corresponds to one of the virtual address units in the virtual address space, and the remaining virtual address units correspond to the second physical address unit. When performing the first data transmission based on this physical address space, it is necessary to determine whether the pre-registered effective memory space needs to be adjusted based on the relative size between the memory space required for the first data transmission and the pre-registered effective memory space. That is, if the pre-registered effective memory space is If the registered effective memory space is larger than the memory space required for the first data transmission, the first physical address unit used in the pre-registered effective memory space will be recycled and expanded. If the pre-registered effective memory space is smaller than the memory space required for the first data transmission, memory space, expand the pre-registered effective memory space.
还需要说明的是,电子设备在首次数据传输之后的后续数据传输过程中,与目标应用关联的物理地址空间可以为在上次数据传输过程中对物理地址空间中的有效内存空间进行调整后的有效内存空间。示例性的,若电子设备在首次数据传输的过程中对预注册的有效内存空间进行了首次调整,则在首次数据传输之后的第二次数据传输中,与目标应用关联的物理地址空间中的有效内存空间为首次调整后的有效内存空间,电子设备需判断首次调整后的有效内存空间是否满足第二次数据传输所需的内存空间,进而确定是否需要再次对有效内存空间进行调整。It should also be noted that during the subsequent data transmission process after the first data transmission of the electronic device, the physical address space associated with the target application may be the effective memory space in the physical address space adjusted during the last data transmission process. Effective memory space. For example, if the electronic device adjusts the pre-registered effective memory space for the first time during the first data transmission, then in the second data transmission after the first data transmission, the physical address space associated with the target application will The effective memory space is the effective memory space after the first adjustment. The electronic device needs to determine whether the effective memory space after the first adjustment meets the memory space required for the second data transmission, and then determine whether the effective memory space needs to be adjusted again.
在本申请实施例中,若目标应用为第一电子设备上安装的应用,则目标应用待存储的数据可以为第一电子设备基于RDMA通信操作向第二电子设备上的应用发送的目标应用的数据,示例性的,RDMA通信操作可以为send操作或者RDMA Write操作。待存储的数据也可以为第一电子设备基于RDMA通信操作接收到的第二电子设备上的应用的数据,示例性的,RDMA通信操作可
以为receive操作或RDMA Read操作。In this embodiment of the present application, if the target application is an application installed on the first electronic device, the data to be stored by the target application may be the data of the target application sent by the first electronic device to the application on the second electronic device based on the RDMA communication operation. Data, for example, the RDMA communication operation can be a send operation or an RDMA Write operation. The data to be stored may also be data of an application on the second electronic device received by the first electronic device based on the RDMA communication operation. For example, the RDMA communication operation may Think of receive operation or RDMA Read operation.
S602,若数据量大于有效内存空间,则根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展。S602, if the data amount is larger than the effective memory space, expand the effective memory space according to the first difference between the data amount and the effective memory space.
若目标应用待存储的数据量大于目标应用的有效内存空间,则可以根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展。具体的,可以根据第一差值,从内部存储器中未被其他应用注册的内存空间中为目标应用分配m个第一物理地址单元,m为大于或等于1的整数,m个第一物理地址单元的内存空间大于或等于第一差值,1≤m+N<M,也就是说,扩展后的有效内存空间满足目标应用待存储的数据量所需的内存空间。此外,根据第一差值确定扩展的第一物理地址单元的数量后,需对目标应用的虚拟地址空间与物理地址空间之间的映射表进行更新,将M个虚拟地址单元中的与第二物理地址单元对应的m个虚拟地址单元重映射至m个第一物理地址单元。If the amount of data to be stored by the target application is greater than the effective memory space of the target application, the effective memory space can be expanded according to the first difference between the data amount and the effective memory space. Specifically, m first physical address units may be allocated to the target application from the memory space in the internal memory that is not registered by other applications based on the first difference value, where m is an integer greater than or equal to 1, and m first physical addresses The memory space of the unit is greater than or equal to the first difference value, 1≤m+N<M. That is to say, the expanded effective memory space meets the memory space required by the amount of data to be stored by the target application. In addition, after determining the number of extended first physical address units based on the first difference value, the mapping table between the virtual address space and the physical address space of the target application needs to be updated to compare the M virtual address units with the second The m virtual address units corresponding to the physical address units are remapped to m first physical address units.
示例性的,参考图8所示的目标应用的虚拟地址空间与物理地址空间之间的映射关系示意图。假设,目标应用待存储的数据量为15kb,目标应用的物理地址空间包括3个第一物理地址单元,每个第一物理地址单元对应目标应用的一个虚拟地址单元,目标应用的虚拟地址空间中的其他M-3个虚拟地址单元均与第二物理地址单元对应,且一个第一物理地址单元、虚拟地址单元以及第二物理地址单元的大小均为4kb,即目标应用的有效内存空间为12kb,则确定目标应用存储的数据量大于有效内存空间且两者之间的第一差值为3kb,对应的,如图8所示,可以将目标应用的有效内存空间扩展1个第一物理地址单元,即从未被其他应用注册的内存空间中为目标应用再分配一个物理页(即图8中的page),并将该物理页设置为具备数据写入权限和数据读取权限的第一物理地址单元,使得目标应用扩展后的有效内存空间的大小为16kb,从而满足目标应用待存储的数据量所需的内存空间。相应的,需要对映射表进行更新,以将目标应用的虚拟地址空间中的与第二物理地址单元对应其他M-3个虚拟地址单元中的一个虚拟地址单元重映射至扩展的第一物理地址单元。For example, refer to the schematic diagram of the mapping relationship between the virtual address space and the physical address space of the target application shown in FIG. 8 . Assume that the amount of data to be stored in the target application is 15kb. The physical address space of the target application includes 3 first physical address units. Each first physical address unit corresponds to a virtual address unit of the target application. In the virtual address space of the target application The other M-3 virtual address units all correspond to the second physical address unit, and the sizes of a first physical address unit, a virtual address unit and a second physical address unit are all 4kb, that is, the effective memory space of the target application is 12kb. , then it is determined that the amount of data stored by the target application is greater than the effective memory space and the first difference between the two is 3kb. Correspondingly, as shown in Figure 8, the effective memory space of the target application can be extended by 1 first physical address unit, that is, allocate a physical page (i.e. page in Figure 8) to the target application from a memory space that has not been registered by other applications, and set the physical page as the first page with data writing permissions and data reading permissions. The physical address unit makes the effective memory space of the target application expand to 16kb, thereby meeting the memory space required for the amount of data to be stored by the target application. Accordingly, the mapping table needs to be updated to remap one of the other M-3 virtual address units corresponding to the second physical address unit in the virtual address space of the target application to the extended first physical address. unit.
S603,若数据量小于有效内存空间,则根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减。S603, if the data amount is less than the effective memory space, reduce the effective memory space according to the second difference between the effective memory space and the data amount.
若目标应用待存储的数据量小于目标应用的有效内存空间,则可以根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减。具体的,假设有效内存空间包括与目标应用的M个虚拟地址单元中的N个所述虚拟地址单元对应的N个所述第一物理地址单元,则当第二差值大于或等于预设阈值时,预设阈值大于0,将有效内存空间缩减n个第一物理地址单元,1≤n<N,n个第一物理地址单元的内存空间小于或等于第二差值。此外,根据第二差值确定需要缩减的第一物理地址单元的数量后,需对目标应用的虚拟地址空间与物理地址空间之间的映射表进行更新,将N个虚拟地址单元中的n个虚拟地址单元重映射至第二物理地址单元。If the amount of data to be stored by the target application is less than the effective memory space of the target application, the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data. Specifically, assuming that the effective memory space includes N first physical address units corresponding to N virtual address units among the M virtual address units of the target application, then when the second difference is greater than or equal to the preset threshold When the preset threshold is greater than 0, the effective memory space is reduced by n first physical address units, 1≤n<N, and the memory space of n first physical address units is less than or equal to the second difference. In addition, after determining the number of first physical address units that need to be reduced based on the second difference, the mapping table between the virtual address space and the physical address space of the target application needs to be updated, and n of the N virtual address units are The virtual address unit is remapped to a second physical address unit.
示例性的,预设阈值可以为一个第一物理地址单元指示的内存空间的大小。For example, the preset threshold may be the size of the memory space indicated by a first physical address unit.
示例性的,参考图9所示的应用的虚拟地址空间与物理地址空间之间的映射关系示意图。假设,第一物理地址单元、虚拟地址单元以及第二物理地址单元的大小均为4kb,预设阈值为4kb,目标应用待存储的数据量为8kb,目标应用的物理地址空间包括3个第一物理地址单元,即目标应用的有效内存空间为12kb,每个第一物理地址单元对应目标应用的一个虚拟地址单元,目标应用的虚拟地址空间中的其他M-3个虚拟地址单元均与第二物理地址单元对应,则有效内存空间大于目标应用存储的数据量,且两者之间的第二差值为4kb,等于预设阈值。如图9所示,可以将目标应用的有效内存空间缩减1个第一物理地址单元,并释放该第一物理地址单元,即解除该第一物理地址单元与目标应用中的虚拟地址单元之间的映射关系,释放后的该第一物理地址单元为未设置有读写权限的物理页,此外,需要更新映射表,以将与该第一物理地址单元对应的虚拟地址单元重映射至目标应用的第二物理内存单元。For example, refer to the schematic diagram of the mapping relationship between the virtual address space and the physical address space of the application shown in FIG. 9 . Assume that the sizes of the first physical address unit, virtual address unit and second physical address unit are all 4kb, the preset threshold is 4kb, the amount of data to be stored by the target application is 8kb, and the physical address space of the target application includes 3 first The physical address unit, that is, the effective memory space of the target application is 12kb. Each first physical address unit corresponds to a virtual address unit of the target application. The other M-3 virtual address units in the virtual address space of the target application are all the same as the second If the physical address unit corresponds, the effective memory space is greater than the amount of data stored by the target application, and the second difference between the two is 4kb, which is equal to the preset threshold. As shown in Figure 9, the effective memory space of the target application can be reduced by one first physical address unit, and the first physical address unit can be released, that is, the relationship between the first physical address unit and the virtual address unit in the target application can be released. Mapping relationship, the released first physical address unit is a physical page without read and write permissions. In addition, the mapping table needs to be updated to remap the virtual address unit corresponding to the first physical address unit to the target application. The second physical memory unit.
可以理解的是,若目标应用待存储的数据量小于目标应用的有效内存空间,且有效内存空间与数据量之间的第二差值大于0且小于预设阈值,则不需要改变目标应用的有效内存空间的大小。It can be understood that if the amount of data to be stored by the target application is less than the effective memory space of the target application, and the second difference between the effective memory space and the amount of data is greater than 0 and less than the preset threshold, there is no need to change the target application. The size of the effective memory space.
在本申请实施例中,基于不同类型的RDMA通信操作,电子设备可以通过两种不同的触发方式,即主动触发方式和被动触发方式,使得电子设备中的处理器可以根据安装的目标应用待存储
的数据量以及目标应用的有效内存空间的差值,对与目标应用关联的物理地址空间中的有效内存空间进行扩展或缩减。In the embodiment of the present application, based on different types of RDMA communication operations, the electronic device can use two different triggering methods, namely the active triggering method and the passive triggering method, so that the processor in the electronic device can be stored according to the installed target application. The effective memory space in the physical address space associated with the target application is expanded or reduced based on the difference between the amount of data and the effective memory space of the target application.
在一个示例中,假设,第一电子设备包括第一处理器以及第一RDMA网卡,第一电子设备中安装有第一目标应用,第二电子设备包括第二处理器以及第二RDMA网卡,第二电子设备中安装有第二目标应用,第一电子设备和第二电子设备可以基于RDMA技术进行数据传输。下面参考图10和图11所示的交互图,对这两种不同的触发方式进行示例性的说明。In one example, it is assumed that the first electronic device includes a first processor and a first RDMA network card, the first target application is installed in the first electronic device, the second electronic device includes a second processor and a second RDMA network card, and the first electronic device includes a second processor and a second RDMA network card. The second target application is installed in the second electronic device, and the first electronic device and the second electronic device can perform data transmission based on RDMA technology. These two different triggering methods will be exemplified below with reference to the interaction diagrams shown in Figures 10 and 11 .
方式一,主动触发方式。Method 1, active triggering method.
在该方式一中,第一电子设备中的第一目标应用在将待存储的数据写入与第一目标应用关联的物理地址空间时,可以通过主动触发的方式使得第一处理器对第一物理地址空间中的有效内存空间进行扩展或缩减。相应的,第一目标应用待存储的数据为:基于第一类RDMA通信操作,第一电子设备通过第一RDMA网卡向第二电子设备的第二RDMA网卡发送的第一目标应用的数据,示例性的,第一类RDMA通信操作可以为send操作或RDMA Write操作。In this method one, when the first target application in the first electronic device writes the data to be stored into the physical address space associated with the first target application, the first processor can be actively triggered to cause the first processor to write the data to be stored in the physical address space associated with the first target application. The effective memory space in the physical address space is expanded or reduced. Correspondingly, the data to be stored by the first target application is: based on the first type of RDMA communication operation, the first electronic device sends the data of the first target application to the second RDMA network card of the second electronic device through the first RDMA network card. Example Specifically, the first type of RDMA communication operation can be a send operation or an RDMA Write operation.
作为示例而非限定,参考图10所示的目标应用、处理器以及RDMA网卡之间的交互示意图,其中第一处理器包括虚拟内存管理单元和物理内存管理单元,虚拟内存管理单元在用户态运行,用于在接收到应用的内存分配请求时确定与应用对应的虚拟地址空间。物理内存管理单元在内核态运行,用于为应用分配对应的物理地址空间,并通过主动触发方式动态扩展和缩减应用的物理地址空间中的有效内存空间。虚拟内存管理单元可以通过***调用的方式陷入内核态,使得物理内存管理模块为应用分配对应的物理地址空间。As an example and not a limitation, refer to the interaction diagram between the target application, the processor and the RDMA network card shown in Figure 10, in which the first processor includes a virtual memory management unit and a physical memory management unit, and the virtual memory management unit runs in user mode. , used to determine the virtual address space corresponding to the application when receiving the application's memory allocation request. The physical memory management unit runs in the kernel mode and is used to allocate the corresponding physical address space to the application and dynamically expand and reduce the effective memory space in the application's physical address space through active triggering. The virtual memory management unit can fall into the kernel state through system calls, allowing the physical memory management module to allocate the corresponding physical address space to the application.
如图10所示,主动触发方式包括如下步骤:As shown in Figure 10, the active triggering method includes the following steps:
S1001,第一目标应用通过虚拟内存管理单元向物理内存管理单元发送查询请求。S1001. The first target application sends a query request to the physical memory management unit through the virtual memory management unit.
第一目标应用在将待存储的数据存储至对应的物理地址空间之前,可以通过虚拟内存管理单元向物理内存管理单元发送查询请求。其中,第一目标应用可以通过调用查询API(ApplicationProgramming Interface,应用程序接口)接口向虚拟内存管理单元发送查询请求,虚拟内存管理单元可以通过ioctl(input/output control)***调用函数使得第一目标应用陷入内核态中的物理内存管理单元,使得物理内存管理单元接收到第一目标应用发送的查询请求。Before storing the data to be stored in the corresponding physical address space, the first target application may send a query request to the physical memory management unit through the virtual memory management unit. Among them, the first target application can send a query request to the virtual memory management unit by calling the query API (Application Programming Interface, application program interface) interface, and the virtual memory management unit can make the first target application call the function through the ioctl (input/output control) system The physical memory management unit trapped in the kernel state causes the physical memory management unit to receive the query request sent by the first target application.
S1002,物理内存管理单元确定第一目标应用关联的物理地址空间中的有效内存空间。S1002. The physical memory management unit determines the effective memory space in the physical address space associated with the first target application.
物理内存管理单元在接收到查询请求后,可以根据映射表确定第一目标应用的物理地址空间中的有效内存空间,并将有效内存空间的空间大小通过虚拟内存管理单元传输给第一目标应用。After receiving the query request, the physical memory management unit can determine the effective memory space in the physical address space of the first target application according to the mapping table, and transmit the size of the effective memory space to the first target application through the virtual memory management unit.
其中,在第一目标应用进行首次数据传输时,映射表为第一目标应用预先注册的初始映射表。在后续的数据传输过程中,映射表可以为在上一次数据传输时与调整后的物理地址空间对应的更新后的映射表。Wherein, when the first target application performs the first data transmission, the mapping table is an initial mapping table pre-registered by the first target application. In the subsequent data transmission process, the mapping table may be an updated mapping table corresponding to the adjusted physical address space during the last data transmission.
S1003,第一目标应用确定待存储的数据量是否大于有效内存空间。S1003. The first target application determines whether the amount of data to be stored is greater than the effective memory space.
第一目标应用可以根据获取到的有效内存空间的大小,确定待存储的数据量是否大于有效内存空间。具体的,若待存储的数据量小于有效内存空间,则可以基于内存缩减API接口通过虚拟内存管理单元向物理内存管理单元发送缩减请求,缩减请求可以包括有效内存空间与待存储的数据量之间的第二差值;若待存储的数据量大于有效内存空间,则可以基于内存扩展API接口通过虚拟内存管理单元向物理内存管理单元发送扩展请求,扩展请求可以包括待存储的数据量与有效内存空间之间的第一差值,以主动触发物理内存管理单元对有效内存空间进行扩展或缩减。The first target application can determine whether the amount of data to be stored is greater than the effective memory space based on the obtained size of the effective memory space. Specifically, if the amount of data to be stored is less than the effective memory space, a reduction request can be sent to the physical memory management unit through the virtual memory management unit based on the memory reduction API interface. The reduction request can include the amount of data between the effective memory space and the amount of data to be stored. The second difference; if the amount of data to be stored is greater than the effective memory space, an expansion request can be sent to the physical memory management unit through the virtual memory management unit based on the memory expansion API interface. The expansion request can include the amount of data to be stored and the effective memory. The first difference between the spaces is used to actively trigger the physical memory management unit to expand or reduce the effective memory space.
S1004,物理内存管理单元根据待存储的数据量与有效内存空间之间的第一差值对有效内存空间进行扩展,或根据有效内存空间与待存储的数据量之间的第二差值对有效内存空间进行缩减。S1004. The physical memory management unit expands the effective memory space according to the first difference between the amount of data to be stored and the effective memory space, or expands the effective memory space according to the second difference between the effective memory space and the amount of data to be stored. Memory space is reduced.
物理内存管理单元在接收到扩展请求和缩减请求时,可以根据上述实施例中步骤S602和S603提供的方法对第一目标应用的有效内存空间进行扩展和缩减。When receiving the expansion request and the reduction request, the physical memory management unit can expand and reduce the effective memory space of the first target application according to the method provided in steps S602 and S603 in the above embodiment.
可选地,物理内存管理单元对第一目标应用的有效内存空间进行扩展和缩减之后,主动触发方式还包括如下步骤:Optionally, after the physical memory management unit expands and reduces the effective memory space of the first target application, the active triggering method also includes the following steps:
S1005,物理内存管理单元可以通过虚拟内存管理单元向第一目标应用发送成功扩展或成功缩减的信号,使得第一目标应用可以将待存储的数据存储至更新后的物理地址空间中。S1005, the physical memory management unit can send a signal of successful expansion or successful reduction to the first target application through the virtual memory management unit, so that the first target application can store the data to be stored in the updated physical address space.
S1006,物理内存管理单元还可以向第一RDMA网卡发送更新映射表的指令,使得第一RDMA
网卡将与第一目标应用对应的更新后的映射表存储至网卡存储器中。S1006, the physical memory management unit can also send an instruction to update the mapping table to the first RDMA network card, so that the first RDMA network card The network card stores the updated mapping table corresponding to the first target application into the network card memory.
方式二,被动触发方式。Method two, passive triggering method.
在该方式二中,第一电子设备的第一RDMA网卡在接收到第二电子设备的第二RDMA网卡发送的第二目标应用的数据时,第一处理器可以在接收到第一RDMA网卡的中断信息后通过被动触发的方式对第一物理地址空间中的有效内存空间进行扩展或缩减,则相应的,第一目标应用待存储的数据为:基于第二类RDMA通信操作,第一电子设备通过第一RDMA网卡接收到的第二电子设备的第二RDMA网卡发送的第二目标应用的数据。示例性的,第二类RDMA通信操作可以为receive操作或RDMA Read操作。In the second method, when the first RDMA network card of the first electronic device receives the data of the second target application sent by the second RDMA network card of the second electronic device, the first processor may receive the data of the second target application from the first RDMA network card. After interrupting the information, the effective memory space in the first physical address space is expanded or reduced through passive triggering. Correspondingly, the data to be stored by the first target application is: Based on the second type of RDMA communication operation, the first electronic device The data of the second target application sent by the second RDMA network card of the second electronic device is received through the first RDMA network card. For example, the second type of RDMA communication operation may be a receive operation or an RDMA Read operation.
需要说明的是,在方式二中,第一电子设备在执行第二类RDMA通信操作时,第一目标应用可以向第一电子设备上的第一RDMA网卡发送RDMA通信操作指令,其中,RDMA通信操作指令包括第一电子设备用于存储获取到的数据的物理地址空间中的物理基址对应的虚拟基址,第一RDMA网卡获取到第二电子设备上的第二目标应用发送的数据后先缓存至第一RDMA网卡中,第一RDMA网卡可以根据预存的第一目标应用的虚拟地址空间与物理地址空间之间的映射表,确定虚拟基址对应的物理基址,并以物理基址为起始地址将获取到的数据存储至第一目标应用的物理地址空间中的有效内存空间中。因此,第一RDMA网卡在获取到第二RDMA网卡发送的第二目标应用的数据后,需确认第一目标应用的内存地址空间是否满足待存储的数据量,当不满足或者内存地址空间有剩余时,从而通过被动触发方式对第一目标应用的内存地址空间进行调整。It should be noted that in the second method, when the first electronic device performs the second type of RDMA communication operation, the first target application can send an RDMA communication operation instruction to the first RDMA network card on the first electronic device, where the RDMA communication The operation instructions include a virtual base address corresponding to the physical base address in the physical address space used by the first electronic device to store the obtained data. The first RDMA network card obtains the data sent by the second target application on the second electronic device. Cached to the first RDMA network card, the first RDMA network card can determine the physical base address corresponding to the virtual base address according to the pre-stored mapping table between the virtual address space and the physical address space of the first target application, and use the physical base address as The starting address stores the obtained data into an effective memory space in the physical address space of the first target application. Therefore, after the first RDMA network card obtains the data of the second target application sent by the second RDMA network card, it needs to confirm whether the memory address space of the first target application meets the amount of data to be stored. If it does not meet the requirement or there is remaining memory address space, time, thereby adjusting the memory address space of the first target application through passive triggering.
作为示例而非限定,参考图11所示的第一电子设备与第二电子设备之间的交互示意图,被动触发方法包括以下步骤:As an example and not a limitation, with reference to the interaction diagram between the first electronic device and the second electronic device shown in Figure 11, the passive triggering method includes the following steps:
S1101,第一RDMA网卡确定第一目标应用待存储的数据量。S1101. The first RDMA network card determines the amount of data to be stored by the first target application.
其中,第一目标应用待存储的数据量为第一电子设备的第一RDMA网卡接收第二电子设备的第二RDMA网卡发送的第二目标应用的数据。The amount of data to be stored by the first target application is the data of the second target application sent by the first RDMA network card of the first electronic device and received by the second RDMA network card of the second electronic device.
S1102,第一RDMA网卡确定第一目标应用待存储的数据量是否大于与第一目标应用关联的有效内存空间。S1102. The first RDMA network card determines whether the amount of data to be stored by the first target application is greater than the effective memory space associated with the first target application.
具体的,第一RDMA网卡可以根据预先存储的与第一目标应用对应的映射表,确定与第一目标应用关联的物理地址空间中的有效内存空间,进而确定待存储的数据量是否大于有效内存空间。若待存储的数据量大于有效内存空间,第一RDMA网卡可以向第一处理器中的虚拟内存管理单元发送第一中断信息,第一中断信息可以包括待存储的数据量与有效内存空间之间的第一差值;若第一目标应用待存储的数据量小于有效内存空间,RDMA网卡可以向处理器发送第二中断信息,第二中断信息可以包括有效内存空间与待存储的数据量之间的第二差值,从而通过被动触发的方式触发物理内存管理单元根据第一差值或第二差值对第一目标应用的有效内存空间进行调整。Specifically, the first RDMA network card can determine the effective memory space in the physical address space associated with the first target application based on the pre-stored mapping table corresponding to the first target application, and then determine whether the amount of data to be stored is greater than the effective memory. space. If the amount of data to be stored is greater than the effective memory space, the first RDMA network card can send first interrupt information to the virtual memory management unit in the first processor. The first interrupt information can include the amount of data to be stored and the effective memory space. The first difference; if the amount of data to be stored in the first target application is less than the effective memory space, the RDMA network card can send the second interrupt information to the processor, and the second interrupt information can include the difference between the effective memory space and the amount of data to be stored. the second difference, thereby triggering the physical memory management unit to adjust the effective memory space of the first target application according to the first difference or the second difference through passive triggering.
S1103,物理内存管理单元根据待存储的数据量与有效内存空间之间的第一差值对有效内存空间进行扩展,或根据有效内存空间与待存储的数据量之间的第二差值对有效内存空间进行缩减。S1103. The physical memory management unit expands the effective memory space according to the first difference between the amount of data to be stored and the effective memory space, or expands the effective memory space according to the second difference between the effective memory space and the amount of data to be stored. Memory space is reduced.
物理内存管理单元可以在接收到第一RDMA网卡发送的第一中断信号后,可以根据第一差值对有效内存空间进行扩展,也可以在接收到第一RDMA网卡发送的第二中断信号后,根据第二差值对有效内存空间进行缩减。The physical memory management unit may, after receiving the first interrupt signal sent by the first RDMA network card, expand the effective memory space according to the first difference value, or may, after receiving the second interrupt signal sent by the first RDMA network card, The effective memory space is reduced according to the second difference value.
其中,对第一目标应用的有效内存空间进行扩展和缩减的方法可以参考根据上述方法实施例中步骤S602和S603的具体描述,此处不再赘述。For the method of expanding and reducing the effective memory space of the first target application, reference may be made to the specific description of steps S602 and S603 in the above method embodiment, which will not be described again here.
可选地,物理内存管理单元对第一目标应用的有效内存空间进行扩展和缩减之后,被动触发方式还包括如下步骤:Optionally, after the physical memory management unit expands and reduces the effective memory space of the first target application, the passive triggering method also includes the following steps:
S1104,物理内存管理单元可以向第一RDMA网卡发送更新映射表的指令,使得第一RDMA网卡将与第一目标应用对应的更新后的映射表存储至网卡存储器中。S1104. The physical memory management unit may send an instruction to update the mapping table to the first RDMA network card, so that the first RDMA network card stores the updated mapping table corresponding to the first target application into the network card memory.
基于上述实施例,本申请还提供了一种物理地址空间的注册方法。下面参考图12所示的电子设备中的目标应用、处理器与RDMA网卡的交互示意图,对电子设备中安装的目标应用在基于RDMA通信技术进行数据传输之前注册物理地址空间的具体过程进行示例性的说明。Based on the above embodiments, this application also provides a physical address space registration method. Referring below to the schematic diagram of the interaction between the target application, the processor and the RDMA network card in the electronic device shown in Figure 12, the specific process of registering the physical address space of the target application installed in the electronic device before data transmission based on RDMA communication technology is exemplified. instruction of.
如图12所示,目标应用的物理地址空间的注册方法包括如下步骤:As shown in Figure 12, the registration method of the physical address space of the target application includes the following steps:
S1201,目标应用向虚拟内存管理单元发送内存分配请求。示例性的,目标应用可以调用内存
申请API接口向虚拟内存管理单元发送内存分配请求。S1201. The target application sends a memory allocation request to the virtual memory management unit. For example, the target application can call the memory Apply for an API interface to send a memory allocation request to the virtual memory management unit.
S1202,虚拟内存管理单元在接收到目标应用发送的内存分配请求后,为目标应用分配对应的虚拟地址空间。S1202: After receiving the memory allocation request sent by the target application, the virtual memory management unit allocates the corresponding virtual address space to the target application.
需要说明的是,在一个示例中,虚拟内存管理单元在接收到电子设备中的每个目标应用发送的内存分配请求时,可以为每个目标应用分配相同空间大小的虚拟地址空间,且每个目标应用的虚拟地址空间中的虚拟地址是相同的。在另一个示例中,目标应用可以确定运行时所需的虚拟地址空间的大小,则目标应用可以将包含所需的虚拟地址空间大小信息的内存分配请求发送给虚拟内存管理单元后,虚拟内存单元可以根据每个目标应用所需的虚拟地址空间大小,从第一电子设备的用户态虚拟地址空间中为每个应用分配与其所需的虚拟地址空间大小具有相同空间大小的虚拟地址空间。It should be noted that, in one example, when the virtual memory management unit receives a memory allocation request sent by each target application in the electronic device, it can allocate a virtual address space of the same size to each target application, and each The virtual addresses in the target application's virtual address space are the same. In another example, the target application can determine the size of the virtual address space required at runtime, and then the target application can send a memory allocation request containing the required virtual address space size information to the virtual memory management unit. According to the virtual address space size required by each target application, a virtual address space having the same space size as the virtual address space size required by each application may be allocated from the user state virtual address space of the first electronic device.
在本申请实施例中,目标应用的虚拟地址空间包括至少一个虚拟地址单元,虚拟地址单元为基于分页管理机制将虚拟地址空间分成的具有预设空间大小的虚拟页,每个虚拟地址单元包括至少一个虚拟地址。In this embodiment of the present application, the virtual address space of the target application includes at least one virtual address unit. The virtual address unit is a virtual page with a preset space size that divides the virtual address space based on the paging management mechanism. Each virtual address unit includes at least a virtual address.
S1203,虚拟内存管理单元可以通过***调用的方式陷入内核态,使物理内存管理单元为目标应用分配物理地址空间。S1203, the virtual memory management unit can fall into the kernel state through system calls, causing the physical memory management unit to allocate physical address space for the target application.
在一个示例中,内存管理单元为目标应用分配的物理地址空间可以包括一个第二物理地址单元,第二物理地址单元为被设置为具备数据读取权限而不具备数据写入权限的物理页,每个第二物理地址单元包括一个或多个具备数据写入权限的物理地址,第二物理地址单元中的物理地址的个数与虚拟地址单元中的虚拟地址个数相同。In one example, the physical address space allocated by the memory management unit for the target application may include a second physical address unit, and the second physical address unit is a physical page that is set to have data reading permission but not data writing permission. Each second physical address unit includes one or more physical addresses with data writing authority, and the number of physical addresses in the second physical address unit is the same as the number of virtual addresses in the virtual address unit.
示例性的,若电子设备中内部存储器中的物理地址空间的大小为2GB,目标应用的虚拟地址空间的大小为4GB,基于分页管理机制可以将物理地址空间均分成524288个大小为4kb的物理页,相应的,可以将虚拟地址空间均分成1049576个大小为4kb的虚拟页。参考图7所示的目标应用的虚拟地址空间与第二物理地址单元之间的映射关系示意图,可以将目标应用的虚拟地址空间中所有的虚拟地址单元映射至一个第二物理地址单元。For example, if the size of the physical address space in the internal memory of the electronic device is 2GB and the size of the virtual address space of the target application is 4GB, the physical address space can be divided into 524288 physical pages of 4kb based on the paging management mechanism. , Correspondingly, the virtual address space can be divided into 1049576 virtual pages with a size of 4kb. Referring to the schematic diagram of the mapping relationship between the virtual address space of the target application and the second physical address unit shown in FIG. 7 , all virtual address units in the virtual address space of the target application can be mapped to one second physical address unit.
在另一个示例中,内存管理单元为目标应用分配的物理地址空间可以包括第二物理地址单元以及空间较小的有效内存空间。其中,目标应用的虚拟地址空间包括M个虚拟地址单元,有效内存空间包括N个第一物理地址单元,N为大于或等于0的整数,N个第一物理地址单元与M个虚拟地址单元中的N个虚拟地址单元一一对应,其中,第一物理地址单元为被设置成具备数据读取权限以及数据写入权限的物理页,每个第一物理地址单元包括至少一个具备数据读写权限的物理地址,即RDMA网卡可以向第一物理地址单元中的物理地址中写入数据,也可以读取该物理地址中预先缓存的数据。示例性的,分配的物理地址空间中的第一物理地址单元以及第二物理地址单元的数量均可以为1,可以将该第一物理地址单元映射至目标应用的虚拟地址空间中的其中一个虚拟地址单元,并将目标应用的虚拟地址空间中的其他虚拟地址单元均映射至第二物理地址单元。可选地,第一物理地址单元中的物理地址与第二物理地址单元中的物理地址的数量相同。In another example, the physical address space allocated by the memory management unit for the target application may include a second physical address unit and an effective memory space with a smaller space. Among them, the virtual address space of the target application includes M virtual address units, the effective memory space includes N first physical address units, N is an integer greater than or equal to 0, and among the N first physical address units and the M virtual address units There is a one-to-one correspondence between N virtual address units, where the first physical address unit is a physical page set to have data read permission and data write permission. Each first physical address unit includes at least one with data read and write permission. The physical address, that is, the RDMA network card can write data to the physical address in the first physical address unit, and can also read the pre-cached data in the physical address. For example, the number of the first physical address unit and the second physical address unit in the allocated physical address space may be 1, and the first physical address unit may be mapped to one of the virtual address units in the virtual address space of the target application. address unit, and map other virtual address units in the virtual address space of the target application to the second physical address unit. Optionally, the number of physical addresses in the first physical address unit is the same as the number of physical addresses in the second physical address unit.
可以理解是,目标应用的物理地址空间包括不具备数据写入权限的第二物理地址单元时,处理器以及RDMA网卡可以根据映射表中,与目标应用对应的物理地址空间中的物理地址的是否具备数据读写权限,确定与目标应用的物理地址空间中的有效内存空间的大小,以便在后续的数据传输过程中根据目标应用待存储的数据量以及有效内存空间的大小之间的差值对内存空间进行扩展和回收。It can be understood that when the physical address space of the target application includes a second physical address unit that does not have data write permission, the processor and the RDMA network card can determine whether the physical address in the physical address space corresponding to the target application is in the mapping table. Have data read and write permissions, determine the size of the effective memory space in the physical address space of the target application, so that in the subsequent data transmission process, it can be compared based on the difference between the amount of data to be stored by the target application and the size of the effective memory space. Memory space is expanded and reclaimed.
进一步的,物理内存管理单元在为目标应用分配好对应的物理地址空间后,需要为目标应用创建虚拟地址空间与物理地址空间之间的初始映射表,并将初始映射表存储至内部存储器中。初始映射表用于指示虚拟地址空间中的每个虚拟地址单元的页号与物理地址空间中的物理地址单元的页号之间的映射关系,以及物理地址单元被设置的读写权限。Further, after the physical memory management unit allocates the corresponding physical address space for the target application, it needs to create an initial mapping table between the virtual address space and the physical address space for the target application, and store the initial mapping table in the internal memory. The initial mapping table is used to indicate the mapping relationship between the page number of each virtual address unit in the virtual address space and the page number of the physical address unit in the physical address space, as well as the set read and write permissions of the physical address unit.
S1204,物理内存管理单元在为目标应用分配好对应的物理地址空间后,可以通过虚拟内存管理单元向目标应用发送成功分配的信号。S1204: After the physical memory management unit allocates the corresponding physical address space to the target application, the physical memory management unit can send a successful allocation signal to the target application through the virtual memory management unit.
S1205,目标应用在接收到成功分配的信号后,向RDMA网卡发送注册请求。S1205: After receiving the successful allocation signal, the target application sends a registration request to the RDMA network card.
其中,注册请求中包含目标应用的标识。
Among them, the registration request contains the identification of the target application.
S1206,RDMA网卡在接收到注册请求后,对目标应用的物理地址空间与虚拟地址空间之间的初始映射表进行注册。S1206: After receiving the registration request, the RDMA network card registers the initial mapping table between the physical address space and the virtual address space of the target application.
具体的,RDMA网卡可以根据目标应用的标识将内存空间中的初始映射至存储至网卡存储器中,使得RDMA网卡具备对目标应用的物理地址空间中的物理地址的数据读取和写入的权限。Specifically, the RDMA network card can store the initial mapping in the memory space into the network card memory according to the identification of the target application, so that the RDMA network card has the permission to read and write the data of the physical address in the physical address space of the target application.
基于本申请提供的内存管理方法,电子设备可以预先为目标应用分配不具备数据写入权限的第二物理地址单元,以便在后续基于RDMA通信技术的数据传输过程可以根据目标应用待存储的数据量和目标应用对应的物理地址空间中的具备数据读写权限的有效内存空间之间的差值,确定有效内存空间是否满足应用待存储的数据量所需的内存空间,从而动态调整目标应用的有效内存空间,若有效内存空间不满足待存储的数据量所需的内存空间,则可以根据数据量与有效内存空间之间的第一差值对有效内存空间进行扩展,使得扩展后的有效内存空间满足应用所需的内存空间,若有效内存空间满足待存储的数据量所需的内存空间,则可以根据有效内存空间与数据量之间的第二差值对有效内存空间进行缩减,从而释放部分未占用的有效内存空间,避免浪费内存资源,从而为目标应用合理的分配内存资源,提高内存资源的利用率。Based on the memory management method provided by this application, the electronic device can pre-allocate the second physical address unit without data writing permission to the target application, so that the subsequent data transmission process based on RDMA communication technology can be based on the amount of data to be stored by the target application. The difference between the effective memory space with data read and write permissions in the physical address space corresponding to the target application determines whether the effective memory space meets the memory space required for the amount of data to be stored by the application, thereby dynamically adjusting the effective memory space of the target application. Memory space. If the effective memory space does not meet the memory space required by the amount of data to be stored, the effective memory space can be expanded according to the first difference between the data amount and the effective memory space, so that the expanded effective memory space Meet the memory space required by the application. If the effective memory space meets the memory space required by the amount of data to be stored, the effective memory space can be reduced according to the second difference between the effective memory space and the amount of data, thereby releasing some Use unoccupied effective memory space to avoid wasting memory resources, thereby rationally allocating memory resources to target applications and improving memory resource utilization.
基于上述实施例提供的内存管理方法,本申请实施例还提供以下内容:Based on the memory management method provided by the above embodiment, the embodiment of this application also provides the following content:
本申请实施例提供了一种计算机程序产品,该程序产品包括程序,当该程序被电子设备运行时,使得电子设备上述各实施例中示出的内存管理方法。An embodiment of the present application provides a computer program product. The program product includes a program. When the program is run by an electronic device, the electronic device causes the memory management method shown in the above embodiments.
本申请实施例提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述各个实施例中示出的内存管理方法。Embodiments of the present application provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the memory management method shown in the above embodiments is implemented.
本申请实施例提供一种芯片,该芯片包括存储器和处理器,该处理器执行存储器中存储的计算机程序,以实现控制上述电子设备执行上述各个实施例中示出的内存管理方法。An embodiment of the present application provides a chip, which includes a memory and a processor. The processor executes a computer program stored in the memory to control the above-mentioned electronic device to execute the memory management method shown in the above-mentioned embodiments.
上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读存储介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this application can implement all or part of the processes in the methods of the above embodiments by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. The computer program When executed by a processor, the steps of each of the above method embodiments may be implemented. Wherein, the computer program includes computer program code, which may be in the form of source code, object code, executable file or some intermediate form. The computer-readable storage medium may at least include: any entity or device capable of carrying computer program code to the camera device/terminal device, recording media, computer memory, read-only memory (ROM), random access Memory (random access memory, RAM), electrical carrier signals, telecommunications signals, and software distribution media. For example, U disk, mobile hard disk, magnetic disk or CD, etc. In some jurisdictions, subject to legislation and patent practice, computer-readable media may not be electrical carrier signals and telecommunications signals.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, each embodiment is described with its own emphasis. For parts that are not detailed or documented in a certain embodiment, please refer to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, or a combination of computer software and electronic hardware. 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 specific application, but such implementations should not be considered beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed devices/devices and methods can be implemented in other ways. For example, the apparatus/equipment embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or units. Components may be combined or may be integrated into another system, or some features may be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It will be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and/or components but does not exclude one or more other The presence or addition of features, integers, steps, operations, elements, components and/or collections thereof.
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
It will also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. ". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be interpreted, depending on the context, to mean "once determined" or "in response to a determination" or "once the [described condition or event] is detected ]" or "in response to detection of [the described condition or event]".
另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of this application and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
最后应说明的是:以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。
Finally, it should be noted that the above are only specific implementation modes of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be covered by this application. within the scope of protection applied for. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims (17)
- 一种内存管理方法,应用于第一电子设备,其特征在于,所述方法包括:A memory management method, applied to a first electronic device, characterized in that the method includes:确定目标应用待存储的数据量和与所述目标应用关联的物理地址空间中的有效内存空间,所述有效内存空间包括N个第一物理地址单元指示的内存空间,每个所述第一物理地址单元包括至少一个具备数据读写权限的物理地址,N为大于或等于0的整数;Determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application. The effective memory space includes memory spaces indicated by N first physical address units, each of the first physical address units. The address unit includes at least one physical address with data read and write permissions, and N is an integer greater than or equal to 0;若所述数据量大于所述有效内存空间,则根据所述数据量与所述有效内存空间之间的第一差值对所述有效内存空间进行扩展;If the amount of data is greater than the effective memory space, the effective memory space is expanded according to the first difference between the amount of data and the effective memory space;若所述数据量小于所述有效内存空间,则根据所述有效内存空间与所述数据量之间的第二差值对所述有效内存空间进行缩减。If the data amount is less than the effective memory space, the effective memory space is reduced according to the second difference between the effective memory space and the data amount.
- 根据权利要求1所述的方法,其特征在于,所述物理地址空间中还包括第二物理地址单元,所述第二物理地址单元包括至少一个不具备数据写入权限的物理地址。The method according to claim 1, characterized in that the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
- 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, further comprising:在接收到所述目标应用发送的内存分配请求时,为所述目标应用分配所述第二物理地址单元;When receiving the memory allocation request sent by the target application, allocate the second physical address unit to the target application;在接收到所述目标应用发送的基于远程直接数据存取通信的注册请求时,对所述第二物理地址单元与所述目标应用的虚拟地址空间之间的初始映射表进行注册。When a registration request based on remote direct data access communication sent by the target application is received, an initial mapping table between the second physical address unit and the virtual address space of the target application is registered.
- 根据权利要求2或3所述的方法,其特征在于,所述目标应用的虚拟地址空间包括M个虚拟地址单元,每个所述虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数;The method according to claim 2 or 3, characterized in that the virtual address space of the target application includes M virtual address units, each of the virtual address units includes at least one virtual address, and M is greater than or equal to 1. integer;所述根据所述数据量与所述有效内存空间之间的第一差值对所述有效内存空间进行扩展,包括:Expanding the effective memory space according to the first difference between the data amount and the effective memory space includes:根据所述第一差值为所述目标应用分配m个所述第一物理地址单元,m个所述第一物理地址单元的内存空间大于或等于所述第一差值,1≤m+N<M;Allocate m first physical address units to the target application according to the first difference, and the memory space of the m first physical address units is greater than or equal to the first difference, 1≤m+N <M;将所述M个虚拟地址单元中与所述第二物理地址单元对应的m个所述虚拟地址单元重映射至m个所述第一物理地址单元。Remap m virtual address units corresponding to the second physical address units among the M virtual address units to m first physical address units.
- 根据权利要求2至4任一项所述的方法,其特征在于,所述目标应用的虚拟地址空间包括M个虚拟地址单元,每个所述虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数,所述有效内存空间包括与所述M个虚拟地址单元中的N个所述虚拟地址单元对应的N个所述第一物理地址单元,1≤N≤M;The method according to any one of claims 2 to 4, characterized in that the virtual address space of the target application includes M virtual address units, each of the virtual address units includes at least one virtual address, and M is greater than or An integer equal to 1, the effective memory space includes N first physical address units corresponding to N virtual address units among the M virtual address units, 1≤N≤M;所述根据所述有效内存空间与所述数据量之间的第二差值对所述有效内存空间进行缩减,包括:The reducing the effective memory space according to the second difference between the effective memory space and the data amount includes:当所述第二差值大于或等于预设阈值时,将所述N个虚拟地址单元中与n个所述第一物理地址单元对应的n个所述虚拟地址单元重映射至所述第二物理地址单元,n个所述第一物理地址单元的内存空间小于或等于所述第二差值,所述预设阈值大于0,1≤n<N。When the second difference is greater than or equal to the preset threshold, n virtual address units corresponding to n first physical address units among the N virtual address units are remapped to the second Physical address units, the memory spaces of n first physical address units are less than or equal to the second difference, the preset threshold is greater than 0, and 1≤n<N.
- 根据权利要求1至5任一项所述的方法,其特征在于,所述目标应用为所述第一电子设备中安装的应用。The method according to any one of claims 1 to 5, wherein the target application is an application installed in the first electronic device.
- 根据权利要求1至6任一项所述的方法,其特征在于,所述待存储的数据量为所述目标应用的数据量,或者所述第一电子设备接收到的第二电子设备中安装的应用的数据量。The method according to any one of claims 1 to 6, characterized in that the amount of data to be stored is the amount of data of the target application, or the amount of data received by the first electronic device is installed in the second electronic device. The amount of data used by the application.
- 一种电子设备,其特征在于,所述电子设备包括处理器,所述处理器用于运行存储器中存储的计算机程序,以实现如权利要求1至7任一项所述的方法。An electronic device, characterized in that the electronic device includes a processor, and the processor is used to run a computer program stored in a memory to implement the method according to any one of claims 1 to 7.
- 一种电子设备,其特征在于,所述电子设备包括处理器和第一远程直接数据存取网卡;An electronic device, characterized in that the electronic device includes a processor and a first remote direct data access network card;所述第一远程直接数据存取网卡用于确定目标应用待存储的数据量和与所述目标应用关联的物理地址空间中的有效内存空间,所述有效内存空间包括N个第一物理地址单元指示的内存空间,每个所述第一物理地址单元包括至少一个具备数据读写权限的物理地址,N为大于或等于0的整数;The first remote direct data access network card is used to determine the amount of data to be stored by the target application and the effective memory space in the physical address space associated with the target application. The effective memory space includes N first physical address units. In the indicated memory space, each first physical address unit includes at least one physical address with data read and write permissions, and N is an integer greater than or equal to 0;若所述数据量大于所述有效内存空间,所述第一远程直接数据存取网卡还用于向所述处理器发送第一中断信息,所述第一中断信息包括所述数据量与所述有效内存空间之间的第一差值,所述处理器用于根据所述第一差值对所述有效内存空间进行扩展; If the data amount is greater than the effective memory space, the first remote direct data access network card is also used to send first interrupt information to the processor, where the first interrupt information includes the data amount and the A first difference between effective memory spaces, the processor is configured to expand the effective memory space according to the first difference;若所述数据量小于所述有效内存空间,所述第一远程直接数据存取网卡还用于向所述处理器发送第二中断信息,所述第二中断信息包括所述有效内存空间与所述数据量之间的第二差值,所述处理器用于根据所述第二差值对所述有效内存空间进行缩减。If the amount of data is less than the effective memory space, the first remote direct data access network card is also used to send second interrupt information to the processor, where the second interrupt information includes the effective memory space and all the memory space. The processor is configured to reduce the effective memory space according to the second difference between the data amounts.
- 根据权利要求9所述的电子设备,其特征在于,所述物理地址空间中还包括第二物理地址单元,所述第二物理地址单元包括至少一个不具备数据写入权限的物理地址。The electronic device according to claim 9, wherein the physical address space further includes a second physical address unit, and the second physical address unit includes at least one physical address that does not have data writing permission.
- 根据权利要求10所述的电子设备,其特征在于,所述处理器还用于:The electronic device according to claim 10, wherein the processor is further configured to:在接收到所述目标应用发送的内存分配请求时,为所述目标应用分配所述第二物理地址单元;When receiving the memory allocation request sent by the target application, allocate the second physical address unit to the target application;所述第一远程直接数据存取网卡还用于:The first remote direct data access network card is also used for:在接收到所述目标应用发送的基于远程直接数据存取通信的注册请求时,对所述第二物理地址单元与所述目标应用的虚拟地址空间之间的初始映射表进行注册。When a registration request based on remote direct data access communication sent by the target application is received, an initial mapping table between the second physical address unit and the virtual address space of the target application is registered.
- 根据权利要求10或11所述的电子设备,其特征在于,所述目标应用的虚拟地址空间包括M个虚拟地址单元,每个所述虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数;The electronic device according to claim 10 or 11, characterized in that the virtual address space of the target application includes M virtual address units, each of the virtual address units includes at least one virtual address, and M is greater than or equal to 1 an integer;所述处理器还用于:The processor is also used to:根据所述第一差值为所述目标应用分配m个所述第一物理地址单元,m个所述第一物理地址单元的内存空间大于或等于所述第一差值,1≤m+N<M;Allocate m first physical address units to the target application according to the first difference, and the memory space of the m first physical address units is greater than or equal to the first difference, 1≤m+N <M;将所述M个虚拟地址单元中与所述第二物理地址单元对应的m个所述虚拟地址单元重映射至m个所述第一物理地址单元。Remap m virtual address units corresponding to the second physical address units among the M virtual address units to m first physical address units.
- 根据权利要求10至12任一项所述的电子设备,其特征在于,所述目标应用的虚拟地址空间包括M个虚拟地址单元,每个所述虚拟地址单元包括至少一个虚拟地址,M为大于或等于1的整数,所述有效内存空间包括与所述M个虚拟地址单元中的N个所述虚拟地址单元对应的N个所述第一物理地址单元,1≤N≤M;The electronic device according to any one of claims 10 to 12, wherein the virtual address space of the target application includes M virtual address units, each of the virtual address units includes at least one virtual address, and M is greater than Or an integer equal to 1, the effective memory space includes N first physical address units corresponding to N virtual address units among the M virtual address units, 1≤N≤M;所述处理器还用于:The processor is also used to:当所述第二差值大于或等于预设阈值时,将所述N个虚拟地址单元中与n个所述第一物理地址单元对应的n个所述虚拟地址单元重映射至所述第二物理地址单元,n个所述第一物理地址单元的内存空间小于或等于所述第二差值,所述预设阈值大于0,1≤n<N;When the second difference is greater than or equal to the preset threshold, n virtual address units corresponding to n first physical address units among the N virtual address units are remapped to the second Physical address units, the memory space of n first physical address units is less than or equal to the second difference, the preset threshold is greater than 0, 1≤n<N;将所述N个虚拟地址单元中的n个所述虚拟地址单元重映射至所述第二物理地址单元。Remap n virtual address units among the N virtual address units to the second physical address unit.
- 根据权利要求9至13任一项所述的电子设备,其特征在于,所述目标应用为所述电子设备中安装的应用。The electronic device according to any one of claims 9 to 13, wherein the target application is an application installed in the electronic device.
- 根据权利要求9至14任一项所述的电子设备,其特征在于,所述待存储的数据量为所述第一远程直接数据存取网卡接收到的第二远程直接数据存取网卡发送的数据量。The electronic device according to any one of claims 9 to 14, wherein the amount of data to be stored is the amount of data received by the first remote direct data access network card and sent by the second remote direct data access network card. The amount of data.
- 一种芯片***,其特征在于,所述芯片***包括处理器,所述处理器执行存储器中存储的计算机程序,以实现如权利要求1至7任一项所述的方法。A chip system, characterized in that the chip system includes a processor, and the processor executes a computer program stored in a memory to implement the method according to any one of claims 1 to 7.
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的方法。 A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211033616.XA CN117667369A (en) | 2022-08-26 | 2022-08-26 | Memory management method, electronic device, chip system and readable storage medium |
CN202211033616.X | 2022-08-26 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2024041219A1 true WO2024041219A1 (en) | 2024-02-29 |
Family
ID=90012425
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/105048 WO2024041219A1 (en) | 2022-08-26 | 2023-06-30 | Memory management method, electronic device, chip system, and readable storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN117667369A (en) |
WO (1) | WO2024041219A1 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118193140A (en) * | 2024-05-17 | 2024-06-14 | 浙江大学海南研究院 | Data management method, device and storage medium based on virtual memory |
CN118193140B (en) * | 2024-05-17 | 2024-07-26 | 浙江大学海南研究院 | Data management method, device and storage medium based on virtual memory |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070162641A1 (en) * | 2005-12-28 | 2007-07-12 | Intel Corporation | Method and apparatus for utilizing platform support for direct memory access remapping by remote DMA ("RDMA")-capable devices |
CN109445945A (en) * | 2018-10-29 | 2019-03-08 | 努比亚技术有限公司 | Memory allocation method, mobile terminal, server and the storage medium of application program |
CN110515727A (en) * | 2019-08-16 | 2019-11-29 | 苏州浪潮智能科技有限公司 | A kind of the memory headroom operating method and relevant apparatus of FPGA |
CN111221758A (en) * | 2019-09-30 | 2020-06-02 | 华为技术有限公司 | Method and computer equipment for processing remote direct memory access request |
CN111414248A (en) * | 2019-01-04 | 2020-07-14 | 阿里巴巴集团控股有限公司 | Memory management method and device and computing equipment |
-
2022
- 2022-08-26 CN CN202211033616.XA patent/CN117667369A/en active Pending
-
2023
- 2023-06-30 WO PCT/CN2023/105048 patent/WO2024041219A1/en unknown
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070162641A1 (en) * | 2005-12-28 | 2007-07-12 | Intel Corporation | Method and apparatus for utilizing platform support for direct memory access remapping by remote DMA ("RDMA")-capable devices |
CN109445945A (en) * | 2018-10-29 | 2019-03-08 | 努比亚技术有限公司 | Memory allocation method, mobile terminal, server and the storage medium of application program |
CN111414248A (en) * | 2019-01-04 | 2020-07-14 | 阿里巴巴集团控股有限公司 | Memory management method and device and computing equipment |
CN110515727A (en) * | 2019-08-16 | 2019-11-29 | 苏州浪潮智能科技有限公司 | A kind of the memory headroom operating method and relevant apparatus of FPGA |
CN111221758A (en) * | 2019-09-30 | 2020-06-02 | 华为技术有限公司 | Method and computer equipment for processing remote direct memory access request |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118193140A (en) * | 2024-05-17 | 2024-06-14 | 浙江大学海南研究院 | Data management method, device and storage medium based on virtual memory |
CN118193140B (en) * | 2024-05-17 | 2024-07-26 | 浙江大学海南研究院 | Data management method, device and storage medium based on virtual memory |
Also Published As
Publication number | Publication date |
---|---|
CN117667369A (en) | 2024-03-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020192456A1 (en) | Voice interaction method and electronic device | |
WO2021258809A1 (en) | Data synchronization method, electronic device, and computer readable storage medium | |
WO2021121052A1 (en) | Multi-screen cooperation method and system, and electronic device | |
WO2022100304A1 (en) | Method and apparatus for transferring application content across devices, and electronic device | |
EP4239477A1 (en) | Virtual memory management method and electronic device | |
WO2021104259A1 (en) | Method and terminal for data sharing between fast application and native application | |
WO2021017935A1 (en) | Wakelock management method and electronic device | |
US20230385112A1 (en) | Memory Management Method, Electronic Device, and Computer-Readable Storage Medium | |
WO2022017474A1 (en) | Task processing method and related apparatus | |
WO2021073183A1 (en) | Always on display method and mobile device | |
WO2024001810A1 (en) | Device interaction method, electronic device and computer-readable storage medium | |
WO2023179123A1 (en) | Bluetooth audio playback method, electronic device, and storage medium | |
CN114969769A (en) | Access control method, electronic device and system | |
CN110413383B (en) | Event processing method, device, terminal and storage medium | |
CN115238299A (en) | Access control method based on security level, related device and system | |
WO2021121036A1 (en) | Key customization method and device for folding device, and storage medium | |
WO2024021995A1 (en) | Memory access method and apparatus | |
WO2024041219A1 (en) | Memory management method, electronic device, chip system, and readable storage medium | |
WO2022042245A1 (en) | Method for determining physical address, and chip system | |
WO2023051094A1 (en) | Memory recovery method and apparatus, electronic device, and readable storage medium | |
CN115729684B (en) | Input/output request processing method and electronic equipment | |
WO2022042469A1 (en) | Video telephone calling method, terminal device, and storage medium | |
WO2022042363A1 (en) | Shared library multiplexing method and electronic device | |
WO2024007944A1 (en) | Method for extending memory isolation domain, and electronic device | |
CN115543600A (en) | Memory space management method and memory space management device |
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: 23856309 Country of ref document: EP Kind code of ref document: A1 |