WO2016206421A1 - Memory access processing method and device, and storage medium - Google Patents

Memory access processing method and device, and storage medium Download PDF

Info

Publication number
WO2016206421A1
WO2016206421A1 PCT/CN2016/077238 CN2016077238W WO2016206421A1 WO 2016206421 A1 WO2016206421 A1 WO 2016206421A1 CN 2016077238 W CN2016077238 W CN 2016077238W WO 2016206421 A1 WO2016206421 A1 WO 2016206421A1
Authority
WO
WIPO (PCT)
Prior art keywords
area
memory
access
preset
interface function
Prior art date
Application number
PCT/CN2016/077238
Other languages
French (fr)
Chinese (zh)
Inventor
武八一
刘强
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016206421A1 publication Critical patent/WO2016206421A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control

Definitions

  • the present application relates to the field of computer technology, for example, to a memory access processing method, apparatus, and storage medium.
  • the memory supported by the CPU can theoretically reach up to 2 ⁇ 64 bytes.
  • the TLB Translation Lookaside Buffer
  • the kernel accesses the physical address of the entire memory area, the address access is randomly distributed in the entire memory space due to different memory size requirements of different modules. In this way, in actual operation, a large number of TLB miss exceptions will inevitably occur. It is necessary to continuously load new TLB entries from the page table to complete virtual and real address translation, resulting in lower memory access performance and higher CPU usage. .
  • the embodiment of the invention provides a memory access processing method, device, storage medium and device, which can improve the memory access performance of the system and reduce the occupancy rate of the CPU.
  • Receiving an access memory request of the preset interface function in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory
  • the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  • the method includes:
  • the method further includes:
  • the memory address of the second area is re-accessed according to the replaced dynamic TLB mapping entry.
  • the dividing the memory area into the first area and the second area according to the preset rule includes:
  • a part of the NORMAL area preset in the memory area is divided into the second area; the DMA area and the NORMAL area preset in the memory area are not set to the first The portion of the second zone is set to the first zone.
  • the method further includes:
  • the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
  • the memory access processing method further includes:
  • the second interface function of the first interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the required memory amount is greater than the second preset value.
  • an embodiment of the present invention further provides a memory access processing apparatus, including:
  • the area dividing module is configured to divide the memory area into the first area and the second area according to the preset rule
  • An entry establishing module configured to establish, in a transport backup buffer TLB entry, a fixed TLB mapping entry corresponding to the first region and a dynamic TLB mapping entry corresponding to the second region; the dynamic TLB mapping entry is used according to The preset page table is replaced by a mapping relationship;
  • a processing module configured to receive an access memory request of the preset interface function, and accessing the memory address of the first area according to the fixed TLB mapping entry, where the access memory request requests access to the first area, In the case that the access memory request requests access to the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  • the device further includes:
  • Loading a module configured to reload the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
  • the processing module is further configured to re-access the memory address of the second area according to the replaced dynamic TLB mapping entry.
  • the device further includes:
  • the first preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function and the memory access frequency in the preset interface function are less than the first preset value
  • the access address interval of the second area corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address range of the first area.
  • the method further includes:
  • the second preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second region, and The second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and accesses the memory request The corresponding amount of memory is greater than the second preset value.
  • Embodiments of the present invention also provide a computer storage medium storing computer executable instructions, the computer executable instructions being configured to perform the above method.
  • the embodiment of the invention further provides a device, the device comprising:
  • One or more processors are One or more processors;
  • One or more programs the one or more programs being stored in the memory, and when executed by the one or more processors, do the following:
  • Receiving an access memory request of the preset interface function in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory In case the request is requested to access the second zone, according to the dynamic TLB mapping bar The memory address of the second area is accessed.
  • the TLB dynamic entry is replaced when the page table is dynamically loaded, and when the first region is accessed, the access can be directly performed according to the fixed TLB entry, thereby reducing the probability of occurrence of the TLB miss exception, without avoiding continuous page interruption.
  • the new TLB entries are loaded in the table, which improves the memory access performance of the system and reduces the CPU usage.
  • FIG. 1 is a schematic flowchart of a first embodiment of a memory access processing method according to the present invention
  • FIG. 2 is a schematic diagram of a refinement process of accessing a memory in an embodiment of a memory access processing method according to the present invention
  • FIG. 3 is a schematic flowchart of a second embodiment of a memory access processing method according to the present invention.
  • FIG. 4 is a schematic flowchart of a third embodiment of a memory access processing method according to the present invention.
  • FIG. 5 is a schematic flowchart diagram of a fourth embodiment of a memory access processing method according to the present invention.
  • FIG. 6 is a schematic diagram of functional modules of a first embodiment of a memory access processing apparatus according to the present invention.
  • FIG. 7 is a schematic structural diagram of a refinement function of the processing module of FIG. 6;
  • FIG. 8 is a schematic diagram of functional modules of a second embodiment of a memory access processing apparatus according to the present invention.
  • FIG. 9 is a schematic diagram of functional modules of a third embodiment of a memory access processing apparatus according to the present invention.
  • FIG. 10 is a schematic diagram of functional modules of a fourth embodiment of a memory access processing apparatus according to the present invention.
  • FIG. 11 is a schematic structural diagram of hardware of a device for performing a memory access processing method according to an embodiment of the present invention.
  • the embodiment of the present invention provides a memory access processing method.
  • the memory access processing method includes the following steps:
  • Step S10 dividing the memory area into the first area and the second area according to a preset rule
  • the memory access processing method provided by the embodiment of the present invention can be applied to a computer system, and can be used to control memory address access.
  • the above memory partitioning method can be set according to actual needs.
  • the preset rule may be a dividing rule of a memory address.
  • the memory area includes a DMA area (ZONE_DMA) and a NORMAL area (ZONE_NORMAL).
  • the address space of the DMA area may range from 0 to 512 M.
  • the address space of the NORMAL area may be 512 M or more.
  • the memory can be divided into the first area and the second area according to the address. For example, when the system memory is initialized, a part of the NORMAL area of the memory area is divided into a second area; the remaining part of the NORMAL area that is not divided into the second area and the DMA area are set as the first area. . Since the second area is a part of the original NORMAL area, the addressing requirements of the 32-bit DMA device can be balanced. It should be noted that the starting address of the second zone can be determined based on actual memory and TLB mapping entries in the system.
  • Step S20 establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset The page table is replaced by a mapping relationship;
  • TLB mapping entries exist in the TLB entry, and are used to access the memory area according to the TLB mapping entry when the preset interface function performs memory access.
  • the TLB mapping entry includes a fixed TLB mapping entry and a dynamic TLB mapping entry, wherein the fixed TLB mapping entry is used for linear fixed mapping of the first region of the high frequency access, and the mapping relationship is not replaced; the dynamic TLB mapping entry is used for the low frequency The second zone entry of the degree access is dynamically replaced and loaded.
  • Fixed TLB mapping entries and dynamic TLB mapping entries complete the mapping of the entire memory space.
  • the above preset page table can be the kernel page table swapper_pg_dir.
  • Dynamic TLB mapping entries can continuously load new TLB entries (ie, TLB mapping entries) from the page table to complete virtual and real address translation.
  • TLB mapping entries ie, TLB mapping entries
  • the space of the related address may be divided in the following manner:
  • Step S30 receiving an access memory request of the preset interface function, and accessing the memory address of the first area according to the fixed TLB mapping entry, where the access memory request requests access to the first area, In the case where the access memory request requests access to the second zone, according to the dynamic TLB The mapping entry accesses the memory address of the second zone.
  • the first zone in this embodiment may be referred to as a low end zone, and the second zone may be referred to as a high end zone.
  • step S30 includes
  • Step S31 in the case that the preset interface function is accessed to access the memory request, determining whether the memory area accessed this time is the first area or the second area according to the preset access address range of the access memory request;
  • Step S32 determining that the memory area of the current access is the first area, performing step S34;
  • Step S33 determining that the memory area of the current access is not the first area, determining that the memory area of the current access is the second area, performing step S35;
  • Step S34 accessing the memory address of the first area according to the fixed TLB mapping entry
  • Step S35 accessing the memory address of the second area according to the dynamic TLB mapping entry.
  • the related functions involving memory access in the kernel can be modified. Fix the high frequency access interface to the first area of physical memory.
  • the kernel is similar to kmalloc, kfree, get_free_page and other related interfaces.
  • the kernel is used frequently and the application memory size is relatively small. It can be set in the first area.
  • operations need to be performed through the second area, such as kmap, kunmap, kmap_atomic, kunmap_atomic function interface and memory reservation interface for the system.
  • the memory area that is accessed this time may be determined to be the first area or the second area according to the preset access address range of the access memory request.
  • the first area when the preset access address interval belongs to the first area, the first area may be directly accessed according to the mapping relationship of the fixed TLB mapping entry; when the preset access address interval belongs to the second area, the dynamic TLB mapping entry may be The mapping relationship accesses the second zone.
  • the memory area is divided into the first area and the second area, and the fixed TLB mapping entry and the dynamic TLB entry are set in the TLB entry, and only the TLB dynamic entry is replaced when the page table is dynamically loaded.
  • the access can be directly accessed according to the fixed TLB entry, thereby reducing the probability of occurrence of the TLB miss exception, and avoiding constantly loading new TLB entries from the page table, thereby improving the system's memory access performance and reducing the system performance. CPU usage.
  • the method further includes:
  • Step S40 When the accessed memory address is not in the TLB entry, reload the preset page table to replace the dynamic TLB mapping entry.
  • Step S50 re-accessing the memory area of the second area according to the replaced dynamic TLB mapping entry. site.
  • the memory address of the second area is accessed according to the memory access request, if the address is not found, a TLB miss exception is generated, and the TLB miss is abnormal according to the request. Reloading the preset page table to replace the dynamic TLB mapping entry to update the dynamic TLB mapping entry, ensuring that the corresponding memory address can be accessed according to the access memory request.
  • the access memory request type corresponding to the foregoing first area and the second area can be set according to actual needs.
  • the access address range of the interface function corresponding to the access memory request with a relatively low memory access frequency is limited to the second area, and the access address interval of the interface function corresponding to the memory access request with a relatively high memory access frequency is selected. Limited to the first zone.
  • the memory access processing method further includes:
  • Step S60 Presetting the correspondence between the preset interface function and the access address interval, so that the first interface function and the second area of the preset interface function whose memory access frequency is less than the first preset value
  • the access address interval corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
  • the memory access processing method further includes:
  • Step S70 Presetting the correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second area, and the preset interface
  • the second interface function of the non-first interface function in the function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the memory amount corresponding to the access memory request is greater than The second preset value.
  • the access speed is fast because it is independent of the page table.
  • Some functions with low frequency are used to access the memory area, and the TLB miss exception is generated.
  • the content of the page table is loaded into the TLB by loading the dynamic TLB mapping entry, and the virtual real address translation is completed. Since the low-frequency access interface is modified according to the statistics of the kernel operation, The low frequency access interface has a low frequency of actual use and has little impact on the overall performance of the computer.
  • the embodiment of the present invention further provides a memory access processing apparatus.
  • the memory access processing apparatus includes: a region dividing module 10, an item establishing module 20, and a processing module 30. .
  • the area dividing module 10 is configured to divide the memory area into the first area and the second area according to a preset rule
  • the memory access processing device provided by the embodiment of the present invention can be applied to a computer system for controlling memory address access.
  • the above memory partitioning method can be set according to actual needs.
  • the preset rule may be a dividing rule of a memory address.
  • the memory area includes a DMA area (ZONE_DMA) and a NORMAL area (ZONE_NORMAL).
  • the address space of the DMA area can range from 0 to 512 M.
  • the address space of the NORMAL area can be 512 M or more.
  • the memory can be divided into the first area and the second area according to the address. For example, when the system memory is initialized, a part of the NORMAL area of the memory area is divided into a second area; the remaining part of the NORMAL area that is not divided into the second area and the DMA area are set as the first area. . Since the second area is a part of the original NORMAL area, the addressing requirements of the 32-bit DMA device can be balanced. It should be noted that the starting address of the second zone can be determined based on actual memory and TLB mapping entries in the system.
  • the entry establishing module 20 is configured to establish, in the transport backup buffer TLB entry, a fixed TLB mapping entry corresponding to the first region and a dynamic TLB mapping entry corresponding to the second region; the dynamic TLB mapping entry is used according to The preset page table is replaced by a mapping relationship;
  • TLB mapping entries exist in the TLB entry, and are used to access the memory area according to the TLB mapping entry when the preset interface function performs memory access.
  • the TLB mapping entry includes a fixed TLB mapping entry and a dynamic TLB mapping entry, wherein the fixed TLB mapping entry is used for linear fixed mapping of the first region of the high frequency access, and the mapping relationship is not replaced; the dynamic TLB mapping entry is set to the low frequency The second zone entry of the degree access is dynamically replaced and loaded.
  • Fixed TLB mapping entries and dynamic TLB mapping entries complete the mapping of the entire memory space.
  • the above preset page table can be the kernel page table swapper_pg_dir.
  • Dynamic TLB mapping entries can continuously load new TLB entries (ie, TLB mapping entries) from the page table to complete virtual and real address translation.
  • TLB mapping entries ie, TLB mapping entries
  • the space of the related address may be divided in the following manner:
  • the processing module 30 is configured to receive an access memory request of the preset interface function, and access the memory address of the first area according to the fixed TLB mapping entry if the accessed memory request requests access to the first area, In the case that the access memory request requests access to the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  • the foregoing processing module 30 includes:
  • the determining unit 31 is configured to: when receiving the memory access request of the preset interface function, determine, according to the preset access address range of the access memory request, whether the memory area accessed this time is the first area or the second area;
  • the processing unit 32 is configured to: when the memory area of the current access is the first area, access the memory address of the first area according to the fixed TLB mapping entry; when the memory area of the current access is the second area, according to the The dynamic TLB map entry accesses the memory address of the second zone.
  • the related functions involving memory access in the kernel can be modified. Fix the high frequency access interface to the first area of physical memory.
  • the kernel is similar to kmalloc, kfree, get_free_page and other related interfaces.
  • the kernel is used frequently and the application memory size is relatively small. It can be set in the first area.
  • the second area needs to be operated.
  • kmap, kunmap, kmap_atomic, kunmap_atomic function interfaces related to file mapping and reading and writing, and memory access interfaces reserved for the system.
  • the memory area that is accessed this time may be determined to be the first area or the second area according to the preset access address range of the access memory request. For example, when the preset access address interval belongs to the first area, the first area may be directly accessed according to the mapping relationship of the fixed TLB mapping entry; when the preset access address interval belongs to the second area, the dynamic TLB mapping entry may be The mapping relationship accesses the second zone.
  • the memory area is divided into the first area and the second area, and the fixed TLB mapping entry and the dynamic TLB entry are set in the TLB entry, and only the TLB dynamic entry is replaced when the page table is dynamically loaded.
  • the first zone you can directly access the fixed TLB entry, thus reducing the TLB
  • the probability of miss exceptions avoids the constant loading of new TLB entries from the page table, which improves the system's memory access performance and reduces CPU usage.
  • the memory access processing device further includes:
  • the loading module 40 is configured to reload the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
  • the processing module 30 is further configured to re-access the memory address of the second area according to the replaced dynamic TLB mapping entry.
  • the memory address of the second area is accessed according to the memory access request, if the address is not found, a TLB miss exception is generated, and the TLB miss is abnormal according to the request. Reloading the preset page table to replace the dynamic TLB mapping entry to update the dynamic TLB mapping entry, ensuring that the corresponding memory address can be accessed according to the access memory request.
  • the access memory request type corresponding to the first area and the second area may be set according to actual needs.
  • the access address range of the interface function corresponding to the access memory request with a relatively low memory access frequency is limited to the second area, and the access address interval of the interface function corresponding to the memory access request with a relatively high memory access frequency is selected. Limited to the first zone.
  • the memory access processing device further includes:
  • the first preset module 50 is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function in which the memory access frequency in the preset interface function is less than the first preset value is The access address interval of the second area corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
  • the memory access processing device further includes:
  • the second preset module 60 is configured to preset a correspondence between the preset interface function and the access address interval, so that the memory access frequency in the preset interface function is less than the first preset value and accessing the memory request pair
  • the first interface function corresponding to the second preset value corresponds to the access address interval of the second area
  • the second interface function of the non-first interface function in the preset interface function is the first interface function
  • the access address range of the area corresponds.
  • the access speed is fast because it is independent of the page table. Some functions that use less frequent access to the memory area will pass the TLB miss exception. Finally, the contents of the page table are loaded into the TLB by loading the dynamic TLB mapping entry, and the virtual and real address translation is completed. Since the low-frequency access interface is modified according to the statistics of the kernel operation, the actual frequency of the low-frequency access interface is low, which has little impact on the overall performance of the computer.
  • the embodiment of the invention further provides a computer storage medium storing computer executable instructions, the computer executable instructions being configured to perform any of the above memory access processing methods.
  • the present invention can be implemented by software and necessary general hardware, and of course can also be implemented by hardware.
  • the technical solution of the embodiment of the present invention may be embodied in the form of a software product, which may be stored in a computer readable storage medium, such as a computer floppy disk or a read-only memory (Read-Only Memory, ROM). ), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the practice of the present invention The method described in the example.
  • the included units and modules are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be implemented;
  • the names of the units are also for convenience of distinguishing from each other and do not limit the scope of protection of the present invention.
  • the embodiment of the invention further provides a hardware structure diagram of a device for executing a memory access processing method.
  • the device includes:
  • One or more processors 70, one processor 70 is taken as an example in FIG. 11;
  • the apparatus may also include an input device 72 and an output device 73.
  • the processor 70, the memory 71, the input device 72, and the output device 73 in the device may be connected by a bus or other means, as exemplified by a bus connection in FIG.
  • the memory 71 is a computer readable storage medium and can be used for storing software programs and computers. Executing a program, such as a program instruction/module corresponding to the memory access processing method in the embodiment of the present invention.
  • the processor 70 executes the function application and data processing of the server by running the software program, the instruction and the module stored in the memory 71, that is, the memory access processing method in the above method embodiment.
  • the memory 71 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to usage of the terminal device, and the like. Further, the memory 71 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other nonvolatile solid state storage device. In some examples, memory 71 can include memory remotely located relative to processor 70, which can be connected to the terminal device over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • Input device 72 can be arranged to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the terminal.
  • the output device 73 may include a display device such as a display screen.
  • the one or more modules are stored in the memory 71, and when executed by the one or more processors 70, perform the following operations:
  • Receiving an access memory request of the preset interface function in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory
  • the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  • the method further includes:
  • the method further includes:
  • the memory address of the second area is re-accessed according to the replaced dynamic TLB mapping entry.
  • the dividing the memory area into the first area and the second area according to the preset rule includes:
  • a part of the NORMAL area preset in the memory area is divided into the second area; the DMA area and the NORMAL area preset in the memory area are not set to the first The portion of the second zone is set to the first zone.
  • the memory access processing method further includes:
  • the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
  • the method further includes:
  • the second interface function of the first interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the required memory amount is greater than the second preset value.
  • the embodiment of the invention improves the memory access performance of the system and reduces the occupancy rate of the CPU.

Landscapes

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

Abstract

A memory access processing method, comprising: dividing, according to a preset rule, a memory area into a first area and a second area; establishing, in a translation lookaside buffer (TLB) entry, a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area, the dynamic TLB mapping entry being configured to replace, according to a preset page table, a mapping relationship; receiving a memory access request of a preset interface function, and if the memory access request requests to access the first area, accessing a memory address of the first area according to the fixed TLB mapping entry, and if the memory access request requests to access the second area, accessing a memory address of the second area according to the dynamic TLB mapping entry. Also disclosed in an embodiment of the present invention are a memory access processing device and storage medium.

Description

内存访问处理方法、装置和存储介质Memory access processing method, device and storage medium 技术领域Technical field
本申请涉及计算机技术领域,例如涉及内存访问处理方法、装置和存储介质。The present application relates to the field of computer technology, for example, to a memory access processing method, apparatus, and storage medium.
背景技术Background technique
众所周知,在64位计算机系统中,CPU支持的内存理论上最大可以达到2^64字节,然而作为实际页表缓存的TLB(Translation Lookaside Buffer,传输后备缓冲)映射条目却相对较少。因此内核在访问整个内存区的物理地址时,由于不同模块对内存大小需求不同,地址访问会随机地分布在整个内存空间。这样在实际运行中,将不可避免的会发生大量的TLB miss异常,需要不断从页表中加载新的TLB表项完成虚实地址转换,从而导致内存访问的性能降低,且CPU的占用率较高。As is known, in a 64-bit computer system, the memory supported by the CPU can theoretically reach up to 2^64 bytes. However, the TLB (Translation Lookaside Buffer) mapping entry as the actual page table cache is relatively small. Therefore, when the kernel accesses the physical address of the entire memory area, the address access is randomly distributed in the entire memory space due to different memory size requirements of different modules. In this way, in actual operation, a large number of TLB miss exceptions will inevitably occur. It is necessary to continuously load new TLB entries from the page table to complete virtual and real address translation, resulting in lower memory access performance and higher CPU usage. .
上述内容仅用于辅助理解本发明实施例的技术方案,并不代表承认上述内容是现有技术。The above content is only used to assist in understanding the technical solutions of the embodiments of the present invention, and does not represent that the above is prior art.
发明内容Summary of the invention
本发明实施例提供一种内存访问处理方法、装置、存储介质和设备,可以提高系统的内存访问性能,减少CPU的占用率。The embodiment of the invention provides a memory access processing method, device, storage medium and device, which can improve the memory access performance of the system and reduce the occupancy rate of the CPU.
本发明实施例提供的一种内存访问处理方法,包括:A memory access processing method provided by an embodiment of the present invention includes:
按照预置规则将内存区划分为第一区和第二区;Dividing the memory area into the first area and the second area according to a preset rule;
在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;Establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset page table Mapping relationship replacement;
接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。Receiving an access memory request of the preset interface function, in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory In the case where the requested access is the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
可选地,所述方法包括: Optionally, the method includes:
根据所述访问内存请求的预设访问地址区间判断请求访问的内存区是第一区还是第二区。Determining, according to the preset access address range of the access memory request, whether the memory area requested to be accessed is the first area or the second area.
可选地,所述方法在所述根据所述动态TLB映射条目访问所述第二区的内存地址之后还包括:Optionally, after the accessing the memory address of the second area according to the dynamic TLB mapping entry, the method further includes:
当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;Reloading the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The memory address of the second area is re-accessed according to the replaced dynamic TLB mapping entry.
可选地,所述按照预置规则将内存区划分为第一区和第二区包括:Optionally, the dividing the memory area into the first area and the second area according to the preset rule includes:
在系统内存初始化时,将从所述内存区中预先设置的NORMAL区中划分一部分出来设定为所述第二区;将所述内存区中预先设置的DMA区和NORMAL区未设定为第二区的部分设定为所述第一区。When the system memory is initialized, a part of the NORMAL area preset in the memory area is divided into the second area; the DMA area and the NORMAL area preset in the memory area are not set to the first The portion of the second zone is set to the first zone.
可选地,所述方法还包括:Optionally, the method further includes:
预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function whose memory access frequency is less than the first preset value and the access address interval of the second area in the preset interface function Correspondingly, the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
可选地,所述内存访问处理方法还包括:Optionally, the memory access processing method further includes:
预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且所需内存量大于第二预设值。Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second area, and the preset interface function is not The second interface function of the first interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the required memory amount is greater than the second preset value.
此外,本发明实施例还提供一种内存访问处理装置,包括:In addition, an embodiment of the present invention further provides a memory access processing apparatus, including:
区域划分模块,设置为按照预置规则将内存区划分为第一区和第二区;The area dividing module is configured to divide the memory area into the first area and the second area according to the preset rule;
条目建立模块,设置为在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;An entry establishing module, configured to establish, in a transport backup buffer TLB entry, a fixed TLB mapping entry corresponding to the first region and a dynamic TLB mapping entry corresponding to the second region; the dynamic TLB mapping entry is used according to The preset page table is replaced by a mapping relationship;
处理模块,设置为接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。 a processing module, configured to receive an access memory request of the preset interface function, and accessing the memory address of the first area according to the fixed TLB mapping entry, where the access memory request requests access to the first area, In the case that the access memory request requests access to the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
可选地,所述装置还包括:Optionally, the device further includes:
加载模块,设置为当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;Loading a module, configured to reload the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
所述处理模块,还设置为根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The processing module is further configured to re-access the memory address of the second area according to the replaced dynamic TLB mapping entry.
可选地,所述装置还包括:Optionally, the device further includes:
第一预置模块,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。The first preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function and the memory access frequency in the preset interface function are less than the first preset value The access address interval of the second area corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address range of the first area.
可选地,所述还包括:Optionally, the method further includes:
第二预置模块,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且访问内存请求对应的内存量大于第二预设值。The second preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second region, and The second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and accesses the memory request The corresponding amount of memory is greater than the second preset value.
本发明实施例还提供一种计算机存储介质,存储有计算机可执行指令,所述计算机可执行指令设置为执行上述方法。Embodiments of the present invention also provide a computer storage medium storing computer executable instructions, the computer executable instructions being configured to perform the above method.
本发明实施例还提供一种设备,该设备包括:The embodiment of the invention further provides a device, the device comprising:
一个或多个处理器;One or more processors;
存储器;Memory
一个或多个程序,所述一个或多个程序存储在所述存储器中,当被所述一个或多个处理器执行时,进行如下操作:One or more programs, the one or more programs being stored in the memory, and when executed by the one or more processors, do the following:
按照预置规则将内存区划分为第一区和第二区;Dividing the memory area into the first area and the second area according to a preset rule;
在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;Establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset page table Mapping relationship replacement;
接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条 目访问所述第二区的内存地址。Receiving an access memory request of the preset interface function, in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory In case the request is requested to access the second zone, according to the dynamic TLB mapping bar The memory address of the second area is accessed.
本发明实施例中,在进行页表动态加载时仅替换TLB动态条目,在访问第一区时,可以直接根据固定TLB条目进行访问,从而减少TLB miss异常的发生概率,无需避免了不断从页表中加载新的TLB表项,进而提高了系统的内存访问性能,减少了CPU的占用率。In the embodiment of the present invention, only the TLB dynamic entry is replaced when the page table is dynamically loaded, and when the first region is accessed, the access can be directly performed according to the fixed TLB entry, thereby reducing the probability of occurrence of the TLB miss exception, without avoiding continuous page interruption. The new TLB entries are loaded in the table, which improves the memory access performance of the system and reduces the CPU usage.
附图说明DRAWINGS
图1为本发明内存访问处理方法第一实施例的流程示意图;1 is a schematic flowchart of a first embodiment of a memory access processing method according to the present invention;
图2为本发明内存访问处理方法一实施例中访问内存的细化流程示意图;2 is a schematic diagram of a refinement process of accessing a memory in an embodiment of a memory access processing method according to the present invention;
图3为本发明内存访问处理方法第二实施例的流程示意图;3 is a schematic flowchart of a second embodiment of a memory access processing method according to the present invention;
图4为本发明内存访问处理方法第三实施例的流程示意图;4 is a schematic flowchart of a third embodiment of a memory access processing method according to the present invention;
图5为本发明内存访问处理方法第四实施例的流程示意图;FIG. 5 is a schematic flowchart diagram of a fourth embodiment of a memory access processing method according to the present invention; FIG.
图6为本发明内存访问处理装置第一实施例的功能模块示意图;6 is a schematic diagram of functional modules of a first embodiment of a memory access processing apparatus according to the present invention;
图7为图6中处理模块的细化功能结构示意图;7 is a schematic structural diagram of a refinement function of the processing module of FIG. 6;
图8为本发明内存访问处理装置第二实施例的功能模块示意图;FIG. 8 is a schematic diagram of functional modules of a second embodiment of a memory access processing apparatus according to the present invention; FIG.
图9为本发明内存访问处理装置第三实施例的功能模块示意图;9 is a schematic diagram of functional modules of a third embodiment of a memory access processing apparatus according to the present invention;
图10为本发明内存访问处理装置第四实施例的功能模块示意图;10 is a schematic diagram of functional modules of a fourth embodiment of a memory access processing apparatus according to the present invention;
图11为本发明实施例的执行内存访问处理方法的设备的硬件结构示意图。FIG. 11 is a schematic structural diagram of hardware of a device for performing a memory access processing method according to an embodiment of the present invention.
实施方式Implementation
本发明实施例提供一种内存访问处理方法,参照图1,在本发明内存访问处理方法第一实施例中,该内存访问处理方法包括以下步骤:The embodiment of the present invention provides a memory access processing method. Referring to FIG. 1, in the first embodiment of the memory access processing method of the present invention, the memory access processing method includes the following steps:
步骤S10,按照预置规则将内存区划分为第一区和第二区;Step S10, dividing the memory area into the first area and the second area according to a preset rule;
本发明实施例提供的内存访问处理方法可以应用于计算机系统中,可以用于对内存地址访问进行控制。上述内存划分的方式可以根据实际需要进行设置。The memory access processing method provided by the embodiment of the present invention can be applied to a computer system, and can be used to control memory address access. The above memory partitioning method can be set according to actual needs.
其中,所述预置规则可以是内存地址的划分规则,在64位LINUX操作系统中,内存区包括DMA区(ZONE_DMA)和NORMAL区(ZONE_NORMAL)。DMA区的地址空间范围可以是0-512M,相应的,NORMAL区的地址空间范围为可以是512M以上。本实施例中,可以根据地址将内存区分为第一区和第二区。 例如,在系统内存初始化时,将从所述内存区的NORMAL区中划分出一部分设定为第二区;将NORMAL区中未划分为第二区的剩余部分以及DMA区设定为第一区。由于第二区是在原有NORMAL区中划分出的一部分,因此可以兼顾32位DMA设备寻址需求。应当说明的是,第二区的起始地址可以根据系统中的实际内存和TLB映射条目确定。The preset rule may be a dividing rule of a memory address. In the 64-bit LINUX operating system, the memory area includes a DMA area (ZONE_DMA) and a NORMAL area (ZONE_NORMAL). The address space of the DMA area may range from 0 to 512 M. Correspondingly, the address space of the NORMAL area may be 512 M or more. In this embodiment, the memory can be divided into the first area and the second area according to the address. For example, when the system memory is initialized, a part of the NORMAL area of the memory area is divided into a second area; the remaining part of the NORMAL area that is not divided into the second area and the DMA area are set as the first area. . Since the second area is a part of the original NORMAL area, the addressing requirements of the 32-bit DMA device can be balanced. It should be noted that the starting address of the second zone can be determined based on actual memory and TLB mapping entries in the system.
步骤S20,在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;Step S20, establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset The page table is replaced by a mapping relationship;
在本实施例中,TLB表项中存在多个TLB映射条目,用于在预设接口函数进行内存访问时,根据TLB映射条目访问内存区。该TLB映射条目包括固定TLB映射条目和动态TLB映射条目,其中固定TLB映射条目用于对高频度访问的第一区做线性固定映射,映射关系不做替换;动态TLB映射条目用于对低频度访问的第二区的表项做动态替换加载。固定TLB映射条目和动态TLB映射条目完成了对整个内存空间的映射。上述预设的页表可以为内核页表swapper_pg_dir。动态TLB映射条目可以不断从页表中加载新的TLB表项(即TLB映射条目),以完成虚实地址转换。在本实施例中为了综合考虑CPU实际的动态位宽,相关地址的空间可以采用以下方式进行划分:In this embodiment, multiple TLB mapping entries exist in the TLB entry, and are used to access the memory area according to the TLB mapping entry when the preset interface function performs memory access. The TLB mapping entry includes a fixed TLB mapping entry and a dynamic TLB mapping entry, wherein the fixed TLB mapping entry is used for linear fixed mapping of the first region of the high frequency access, and the mapping relationship is not replaced; the dynamic TLB mapping entry is used for the low frequency The second zone entry of the degree access is dynamically replaced and loaded. Fixed TLB mapping entries and dynamic TLB mapping entries complete the mapping of the entire memory space. The above preset page table can be the kernel page table swapper_pg_dir. Dynamic TLB mapping entries can continuously load new TLB entries (ie, TLB mapping entries) from the page table to complete virtual and real address translation. In this embodiment, in order to comprehensively consider the actual dynamic bit width of the CPU, the space of the related address may be divided in the following manner:
综合考虑CPU实际的动态位宽,相关地址空间安排如下:Considering the actual dynamic bit width of the CPU, the relevant address space is arranged as follows:
第一区内存起始地址(物理地址):FIRST_START=0x200000000First area memory start address (physical address): FIRST_START=0x200000000
第二区内存起始地址(物理地址):SECOND_START=0x300000000Second area memory start address (physical address): SECOND_START=0x300000000
内核线性起始地址(虚拟地址):MAP_BASE=0xc000000000000000Kernel linear start address (virtual address): MAP_BASE=0xc000000000000000
内核临时映射起始地址(虚拟地址):FIXADDR_START=0xc00000fffd7bc000,Kernel temporary map start address (virtual address): FIXADDR_START=0xc00000fffd7bc000,
内核永久映射起始地址(虚拟地址):PKMAP_BASE=0xc000008000000000。The kernel permanently maps the starting address (virtual address): PKMAP_BASE=0xc000008000000000.
步骤S30,接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB 映射条目访问所述第二区的内存地址。Step S30, receiving an access memory request of the preset interface function, and accessing the memory address of the first area according to the fixed TLB mapping entry, where the access memory request requests access to the first area, In the case where the access memory request requests access to the second zone, according to the dynamic TLB The mapping entry accesses the memory address of the second zone.
本实施例中的第一区可以称为低端区,第二区可以称为高端区。The first zone in this embodiment may be referred to as a low end zone, and the second zone may be referred to as a high end zone.
参照图2,本实施例中,上述步骤S30包括Referring to FIG. 2, in the embodiment, the foregoing step S30 includes
步骤S31,在接收到预设接口函数访问内存请求的情况下,根据所述访问内存请求的预设访问地址区间判断本次访问的内存区是第一区还是第二区;Step S31, in the case that the preset interface function is accessed to access the memory request, determining whether the memory area accessed this time is the first area or the second area according to the preset access address range of the access memory request;
步骤S32,判断本次访问的内存区是第一区,执行步骤S34;Step S32, determining that the memory area of the current access is the first area, performing step S34;
步骤S33,判断本次访问的内存区不是第一区,判断本次访问的内存区是第二区,执行步骤S35;Step S33, determining that the memory area of the current access is not the first area, determining that the memory area of the current access is the second area, performing step S35;
步骤S34,根据固定TLB映射条目访问所述第一区的内存地址;Step S34, accessing the memory address of the first area according to the fixed TLB mapping entry;
步骤S35,根据动态TLB映射条目访问所述第二区的内存地址。Step S35, accessing the memory address of the second area according to the dynamic TLB mapping entry.
本实施例中,可以修改内核中涉及内存访问的相关函数。把高频度访问接口固定在物理内存的第一区。内核中类似于kmalloc,kfree,get_free_page等相关的接口,内核使用频繁而且申请内存大小相对较少,可以设置在第一区操作。而对于内存访问频度较低但是内存需要大的接口需要通过第二区进行操作,例如与文件映射和读写相关kmap,kunmap,kmap_atomic,kunmap_atomic函数接口以及对系统保留内存访问接口。在接收到预设接口函数访问内存请求时,可以根据所述访问内存请求的预设访问地址区间判断本次访问的内存区是第一区还是第二区。例如当上述预设访问地址区间属于第一区时,则可以直接根据固定TLB映射条目的映射关系访问第一区;当上述预设访问地址区间属于第二区时,则可以根据动态TLB映射条目的映射关系访问第二区。In this embodiment, the related functions involving memory access in the kernel can be modified. Fix the high frequency access interface to the first area of physical memory. The kernel is similar to kmalloc, kfree, get_free_page and other related interfaces. The kernel is used frequently and the application memory size is relatively small. It can be set in the first area. For interfaces with low memory access frequency but large memory requirements, operations need to be performed through the second area, such as kmap, kunmap, kmap_atomic, kunmap_atomic function interface and memory reservation interface for the system. When receiving the preset interface function to access the memory request, the memory area that is accessed this time may be determined to be the first area or the second area according to the preset access address range of the access memory request. For example, when the preset access address interval belongs to the first area, the first area may be directly accessed according to the mapping relationship of the fixed TLB mapping entry; when the preset access address interval belongs to the second area, the dynamic TLB mapping entry may be The mapping relationship accesses the second zone.
本发明实施例通过将内存区划分为第一区和第二区,并且将TLB表项中设置固定TLB映射条目和动态TLB条目,在进行页表动态加载时仅替换TLB动态条目。在访问第一区时,可以直接根据固定TLB条目进行访问,从而减少TLB miss异常的发生概率,避免了不断从页表中加载新的TLB表项,进而提高了系统的内存访问性能,减少了CPU的占用率。In the embodiment of the present invention, the memory area is divided into the first area and the second area, and the fixed TLB mapping entry and the dynamic TLB entry are set in the TLB entry, and only the TLB dynamic entry is replaced when the page table is dynamically loaded. When accessing the first area, the access can be directly accessed according to the fixed TLB entry, thereby reducing the probability of occurrence of the TLB miss exception, and avoiding constantly loading new TLB entries from the page table, thereby improving the system's memory access performance and reducing the system performance. CPU usage.
参照图3,基于本发明内存访问处理方法第一实施例,在本发明内存访问处理方法第二实施例中,步骤S34之后还包括:Referring to FIG. 3, based on the first embodiment of the memory access processing method of the present invention, in the second embodiment of the memory access processing method of the present invention, after step S34, the method further includes:
步骤S40,当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;Step S40: When the accessed memory address is not in the TLB entry, reload the preset page table to replace the dynamic TLB mapping entry.
步骤S50,根据替换后的动态TLB映射条目重新访问所述第二区的内存地 址。Step S50, re-accessing the memory area of the second area according to the replaced dynamic TLB mapping entry. site.
在本实施例中,在接收到上述访问内存请求后,根据该内存访问请求访问第二区的内存地址时,若发现不存在该地址,将产生TLB miss异常,此时将根据该TLB miss异常重新加载所述预设的页表以替换所述动态TLB映射条目,以对动态TLB映射条目进行更新,保证可以根据上述访问内存请求访问到对应的内存地址。In this embodiment, after receiving the access memory request, if the memory address of the second area is accessed according to the memory access request, if the address is not found, a TLB miss exception is generated, and the TLB miss is abnormal according to the request. Reloading the preset page table to replace the dynamic TLB mapping entry to update the dynamic TLB mapping entry, ensuring that the corresponding memory address can be accessed according to the access memory request.
可以理解的是,上述第一区和第二区对应的访问内存请求类型可以根据实际需要进行设置。可选地,可以将内存访问频度比较低的访问内存请求对应的接口函数的访问地址区间限定在第二区内,将内存访问频度比较高的访问内存请求对应的接口函数的访问地址区间限定在第一区内。It can be understood that the access memory request type corresponding to the foregoing first area and the second area can be set according to actual needs. Optionally, the access address range of the interface function corresponding to the access memory request with a relatively low memory access frequency is limited to the second area, and the access address interval of the interface function corresponding to the memory access request with a relatively high memory access frequency is selected. Limited to the first zone.
如图4所示,在本发明内存访问处理方法第三实施例中,上述内存访问处理方法还包括:As shown in FIG. 4, in the third embodiment of the memory access processing method of the present invention, the memory access processing method further includes:
步骤S60,预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。Step S60: Presetting the correspondence between the preset interface function and the access address interval, so that the first interface function and the second area of the preset interface function whose memory access frequency is less than the first preset value The access address interval corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
在内存充足的情况下还可以考虑访问内存请求对应的内存量,将缓存容量较小的接口函数的访问地址区间可以设置在第一区内。在本发明内存访问处理方法第四实施例中,与本发明内存访问处理方法第三实施例的区别在于上述步骤S60可以替换为步骤S70。如图5所示,在本发明内存访问处理方法第四实施例中,上述内存访问处理方法还包括:In the case of sufficient memory, the amount of memory corresponding to the memory request may be considered, and the access address range of the interface function with a smaller buffer capacity may be set in the first area. In the fourth embodiment of the memory access processing method of the present invention, the difference from the third embodiment of the memory access processing method of the present invention is that the above step S60 can be replaced with step S70. As shown in FIG. 5, in the fourth embodiment of the memory access processing method of the present invention, the memory access processing method further includes:
步骤S70,预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且访问内存请求对应的内存量大于第二预设值。Step S70: Presetting the correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second area, and the preset interface The second interface function of the non-first interface function in the function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the memory amount corresponding to the access memory request is greater than The second preset value.
本实施例中,在处理最频繁访问内存空间接口函数时,由于与页表无关,访问速度很快。而一些使用频度比较低的函数在访问内存区域时,会通过TLB miss异常,最终通过加载动态TLB映射条目把页表内容加载到TLB中,完成虚实地址转换。由于低频度访问接口是根据内核运行情况统计后做出的修改,而 低频度访问接口的实际使用频度低,对计算机整体性能影响很小。In this embodiment, when processing the most frequently accessed memory space interface function, the access speed is fast because it is independent of the page table. Some functions with low frequency are used to access the memory area, and the TLB miss exception is generated. Finally, the content of the page table is loaded into the TLB by loading the dynamic TLB mapping entry, and the virtual real address translation is completed. Since the low-frequency access interface is modified according to the statistics of the kernel operation, The low frequency access interface has a low frequency of actual use and has little impact on the overall performance of the computer.
本发明实施例还提供一种内存访问处理装置,参照图6,在本发明内存访问处理装置第一实施例中,该内存访问处理装置包括:区域划分模块10、条目建立模块20以及处理模块30。The embodiment of the present invention further provides a memory access processing apparatus. Referring to FIG. 6, in the first embodiment of the memory access processing apparatus of the present invention, the memory access processing apparatus includes: a region dividing module 10, an item establishing module 20, and a processing module 30. .
区域划分模块10设置为按照预置规则将内存区划分为第一区和第二区;The area dividing module 10 is configured to divide the memory area into the first area and the second area according to a preset rule;
本发明实施例提供的内存访问处理装置可以应用于计算机系统中,用于对内存地址访问进行控制。上述内存划分的方式可以根据实际需要进行设置。The memory access processing device provided by the embodiment of the present invention can be applied to a computer system for controlling memory address access. The above memory partitioning method can be set according to actual needs.
其中,所述预置规则可以是内存地址的划分规则,在64位LINUX操作系统中,内存区包括DMA区(ZONE_DMA)和NORMAL区(ZONE_NORMAL)。DMA区的地址空间范围可以为0-512M,相应的,NORMAL区的地址空间范围可以为512M以上。本实施例中,可以根据地址将内存区分为第一区和第二区。例如,在系统内存初始化时,将从所述内存区的NORMAL区中划分出一部分设定为第二区;将NORMAL区中未划分为第二区的剩余部分以及DMA区设定为第一区。由于第二区是在原有NORMAL区中划分出的一部分,因此可以兼顾32位DMA设备寻址需求。应当说明的是,第二区的起始地址可以根据系统中的实际内存和TLB映射条目确定。The preset rule may be a dividing rule of a memory address. In the 64-bit LINUX operating system, the memory area includes a DMA area (ZONE_DMA) and a NORMAL area (ZONE_NORMAL). The address space of the DMA area can range from 0 to 512 M. Correspondingly, the address space of the NORMAL area can be 512 M or more. In this embodiment, the memory can be divided into the first area and the second area according to the address. For example, when the system memory is initialized, a part of the NORMAL area of the memory area is divided into a second area; the remaining part of the NORMAL area that is not divided into the second area and the DMA area are set as the first area. . Since the second area is a part of the original NORMAL area, the addressing requirements of the 32-bit DMA device can be balanced. It should be noted that the starting address of the second zone can be determined based on actual memory and TLB mapping entries in the system.
条目建立模块20设置为在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;The entry establishing module 20 is configured to establish, in the transport backup buffer TLB entry, a fixed TLB mapping entry corresponding to the first region and a dynamic TLB mapping entry corresponding to the second region; the dynamic TLB mapping entry is used according to The preset page table is replaced by a mapping relationship;
在本实施例中,TLB表项中存在多个TLB映射条目,用于在预设接口函数进行内存访问时,根据TLB映射条目访问内存区。该TLB映射条目包括固定TLB映射条目和动态TLB映射条目,其中固定TLB映射条目用于对高频度访问的第一区做线性固定映射,映射关系不做替换;动态TLB映射条目设置为对低频度访问的第二区的表项做动态替换加载。固定TLB映射条目和动态TLB映射条目完成了对整个内存空间的映射。上述预设的页表可以为内核页表swapper_pg_dir。动态TLB映射条目可以不断从页表中加载新的TLB表项(即TLB映射条目),以完成虚实地址转换。在本实施例中为了综合考虑CPU实际的动态位宽,相关地址的空间可以采用以下方式进行划分:In this embodiment, multiple TLB mapping entries exist in the TLB entry, and are used to access the memory area according to the TLB mapping entry when the preset interface function performs memory access. The TLB mapping entry includes a fixed TLB mapping entry and a dynamic TLB mapping entry, wherein the fixed TLB mapping entry is used for linear fixed mapping of the first region of the high frequency access, and the mapping relationship is not replaced; the dynamic TLB mapping entry is set to the low frequency The second zone entry of the degree access is dynamically replaced and loaded. Fixed TLB mapping entries and dynamic TLB mapping entries complete the mapping of the entire memory space. The above preset page table can be the kernel page table swapper_pg_dir. Dynamic TLB mapping entries can continuously load new TLB entries (ie, TLB mapping entries) from the page table to complete virtual and real address translation. In this embodiment, in order to comprehensively consider the actual dynamic bit width of the CPU, the space of the related address may be divided in the following manner:
综合考虑CPU实际的动态位宽,相关地址空间安排如下:Considering the actual dynamic bit width of the CPU, the relevant address space is arranged as follows:
第一区内存起始地址(物理地址):FIRST_START=0x200000000 First area memory start address (physical address): FIRST_START=0x200000000
第二区内存起始地址(物理地址):SECOND_START=0x300000000Second area memory start address (physical address): SECOND_START=0x300000000
内核线性起始地址(虚拟地址):MAP_BASE=0xc000000000000000Kernel linear start address (virtual address): MAP_BASE=0xc000000000000000
内核临时映射起始地址(虚拟地址):FIXADDR_START=0xc00000fffd7bc000,Kernel temporary map start address (virtual address): FIXADDR_START=0xc00000fffd7bc000,
内核永久映射起始地址(虚拟地址):PKMAP_BASE=0xc000008000000000。The kernel permanently maps the starting address (virtual address): PKMAP_BASE=0xc000008000000000.
处理模块30设置为接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。The processing module 30 is configured to receive an access memory request of the preset interface function, and access the memory address of the first area according to the fixed TLB mapping entry if the accessed memory request requests access to the first area, In the case that the access memory request requests access to the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
参照图7,上述处理模块30包括:Referring to FIG. 7, the foregoing processing module 30 includes:
判断单元31,设置为接收到预设接口函数的访问内存请求时,根据所述访问内存请求的预设访问地址区间判断本次访问的内存区是第一区还是第二区;The determining unit 31 is configured to: when receiving the memory access request of the preset interface function, determine, according to the preset access address range of the access memory request, whether the memory area accessed this time is the first area or the second area;
处理单元32,设置为当本次访问的内存区为第一区时,根据固定TLB映射条目访问所述第一区的内存地址;当本次访问的内存区为第二区时,根据所述动态TLB映射条目访问所述第二区的内存地址。The processing unit 32 is configured to: when the memory area of the current access is the first area, access the memory address of the first area according to the fixed TLB mapping entry; when the memory area of the current access is the second area, according to the The dynamic TLB map entry accesses the memory address of the second zone.
本实施例中,可以修改内核中涉及内存访问的相关函数。把高频度访问接口固定在物理内存的第一区。内核中类似于kmalloc,kfree,get_free_page等相关的接口,内核使用频繁而且申请内存大小相对较少,可以设置在第一区操作。而对于内存访问频度较低但是内存需要大的接口需要通过第二区进行操作。例如与文件映射和读写相关的kmap,kunmap,kmap_atomic,kunmap_atomic函数接口以及对系统保留内存访问接口。在接收到预设接口函数访问内存请求时,可以根据所述访问内存请求的预设访问地址区间判断本次访问的内存区是第一区还是第二区。例如当上述预设访问地址区间属于第一区时,则可以直接根据固定TLB映射条目的映射关系访问第一区;当上述预设访问地址区间属于第二区时,则可以根据动态TLB映射条目的映射关系访问第二区。In this embodiment, the related functions involving memory access in the kernel can be modified. Fix the high frequency access interface to the first area of physical memory. The kernel is similar to kmalloc, kfree, get_free_page and other related interfaces. The kernel is used frequently and the application memory size is relatively small. It can be set in the first area. For an interface with a low memory access frequency but a large memory requirement, the second area needs to be operated. For example, kmap, kunmap, kmap_atomic, kunmap_atomic function interfaces related to file mapping and reading and writing, and memory access interfaces reserved for the system. When receiving the preset interface function to access the memory request, the memory area that is accessed this time may be determined to be the first area or the second area according to the preset access address range of the access memory request. For example, when the preset access address interval belongs to the first area, the first area may be directly accessed according to the mapping relationship of the fixed TLB mapping entry; when the preset access address interval belongs to the second area, the dynamic TLB mapping entry may be The mapping relationship accesses the second zone.
本发明实施例通过将内存区划分为第一区和第二区,并且将TLB表项中设置固定TLB映射条目和动态TLB条目,在进行页表动态加载时仅替换TLB动态条目。在访问第一区时,可以直接根据固定TLB条目进行访问,从而减少TLB miss异常的发生概率,避免了不断从页表中加载新的TLB表项,进而提高了系统的内存访问性能,减少CPU的占用率。In the embodiment of the present invention, the memory area is divided into the first area and the second area, and the fixed TLB mapping entry and the dynamic TLB entry are set in the TLB entry, and only the TLB dynamic entry is replaced when the page table is dynamically loaded. When accessing the first zone, you can directly access the fixed TLB entry, thus reducing the TLB The probability of miss exceptions avoids the constant loading of new TLB entries from the page table, which improves the system's memory access performance and reduces CPU usage.
参照图8,基于本发明内存访问处理装置第一实施例,在本发明内存访问处理装置第二实施例中,所述内存访问处理装置还包括:Referring to FIG. 8, in a second embodiment of the memory access processing device of the present invention, the memory access processing device further includes:
加载模块40,设置为当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;The loading module 40 is configured to reload the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
所述处理模块30,还设置为根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The processing module 30 is further configured to re-access the memory address of the second area according to the replaced dynamic TLB mapping entry.
在本实施例中,在接收到上述访问内存请求后,根据该内存访问请求访问第二区的内存地址时,若发现不存在该地址,将产生TLB miss异常,此时将根据该TLB miss异常重新加载所述预设的页表以替换所述动态TLB映射条目,以对动态TLB映射条目进行更新,保证可以根据上述访问内存请求访问到对应的内存地址。In this embodiment, after receiving the access memory request, if the memory address of the second area is accessed according to the memory access request, if the address is not found, a TLB miss exception is generated, and the TLB miss is abnormal according to the request. Reloading the preset page table to replace the dynamic TLB mapping entry to update the dynamic TLB mapping entry, ensuring that the corresponding memory address can be accessed according to the access memory request.
上述第一区和第二区对应的访问内存请求类型可以根据实际需要进行设置。可选地,可以将内存访问频度比较低的访问内存请求对应的接口函数的访问地址区间限定在第二区内,将内存访问频度比较高的访问内存请求对应的接口函数的访问地址区间限定在第一区内。The access memory request type corresponding to the first area and the second area may be set according to actual needs. Optionally, the access address range of the interface function corresponding to the access memory request with a relatively low memory access frequency is limited to the second area, and the access address interval of the interface function corresponding to the memory access request with a relatively high memory access frequency is selected. Limited to the first zone.
如图9所示,在本发明内存访问处理装置第三实施例中,上述内存访问处理装置还包括:As shown in FIG. 9, in the third embodiment of the memory access processing device of the present invention, the memory access processing device further includes:
第一预置模块50,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。The first preset module 50 is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function in which the memory access frequency in the preset interface function is less than the first preset value is The access address interval of the second area corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
在内存充足的情况下还可以考虑访问内存请求对应的内存量,将缓存容量较小的接口函数的访问地址区间可以设置在第一区内。参照图10,在本发明内存访问处理装置第四实施例中,上述内存访问处理装置还包括:In the case of sufficient memory, the amount of memory corresponding to the memory request may be considered, and the access address range of the interface function with a smaller buffer capacity may be set in the first area. Referring to FIG. 10, in the fourth embodiment of the memory access processing device of the present invention, the memory access processing device further includes:
第二预置模块60,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值且访问内存请求对 应的内存量大于第二预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。The second preset module 60 is configured to preset a correspondence between the preset interface function and the access address interval, so that the memory access frequency in the preset interface function is less than the first preset value and accessing the memory request pair The first interface function corresponding to the second preset value corresponds to the access address interval of the second area, and the second interface function of the non-first interface function in the preset interface function is the first interface function The access address range of the area corresponds.
本实施例中,在处理最频繁访问内存空间接口函数时,由于与页表无关,访问速度很快。而一些使用频度比较低的函数访问内存区域时,会通过TLB miss异常,最终通过加载动态TLB映射条目把页表内容加载到TLB中,完成虚实地址转换。由于低频度访问接口是根据内核运行情况统计后做出的修改,而低频度访问接口的实际使用频度低,对计算机整体性能影响很小。In this embodiment, when processing the most frequently accessed memory space interface function, the access speed is fast because it is independent of the page table. Some functions that use less frequent access to the memory area will pass the TLB miss exception. Finally, the contents of the page table are loaded into the TLB by loading the dynamic TLB mapping entry, and the virtual and real address translation is completed. Since the low-frequency access interface is modified according to the statistics of the kernel operation, the actual frequency of the low-frequency access interface is low, which has little impact on the overall performance of the computer.
本发明实施例还提供一种计算机存储介质,存储有计算机可执行指令,所述计算机可执行指令设置为执行上述任一项内存访问处理方法。The embodiment of the invention further provides a computer storage medium storing computer executable instructions, the computer executable instructions being configured to perform any of the above memory access processing methods.
通过以上关于实施方式的描述,所属领域的技术人员可以清楚地了解到,本发明可借助软件及必需的通用硬件来实现,当然也可以通过硬件实现。基于这样的理解,本发明实施例的技术方案可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如计算机的软盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、闪存(FLASH)、硬盘或光盘等,包括指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明实施例所述的方法。From the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by software and necessary general hardware, and of course can also be implemented by hardware. Based on the understanding, the technical solution of the embodiment of the present invention may be embodied in the form of a software product, which may be stored in a computer readable storage medium, such as a computer floppy disk or a read-only memory (Read-Only Memory, ROM). ), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the practice of the present invention The method described in the example.
值得注意的是,上述内存访问处理装置的实施例中,所包括的单元和模块只是按照功能逻辑进行划分的,但并不局限于上述的划分,只要能够实现相应的功能即可;另外,功能单元的名称也只是为了便于相互区分,并不限制本发明的保护范围。It should be noted that, in the embodiment of the foregoing memory access processing device, the included units and modules are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be implemented; The names of the units are also for convenience of distinguishing from each other and do not limit the scope of protection of the present invention.
本发明实施例还提供了一种执行内存访问处理方法的设备的硬件结构示意图。参见图11,该设备包括:The embodiment of the invention further provides a hardware structure diagram of a device for executing a memory access processing method. Referring to Figure 11, the device includes:
一个或者多个处理器70,图11中以一个处理器70为例;One or more processors 70, one processor 70 is taken as an example in FIG. 11;
存储器71。 Memory 71.
所述设备还可以包括:输入装置72和输出装置73。所述设备中的处理器70、存储器71、输入装置72和输出装置73可以通过总线或其他方式连接,图11中以通过总线连接为例。The apparatus may also include an input device 72 and an output device 73. The processor 70, the memory 71, the input device 72, and the output device 73 in the device may be connected by a bus or other means, as exemplified by a bus connection in FIG.
存储器71作为一种计算机可读存储介质,可用于存储软件程序、计算机可 执行程序,如本发明实施例中的内存访问处理方法对应的程序指令/模块。处理器70通过运行存储在存储器71中的软件程序、指令以及模块,从而执行服务器的功能应用以及数据处理,即实现上述方法实施例中的内存访问处理方法。The memory 71 is a computer readable storage medium and can be used for storing software programs and computers. Executing a program, such as a program instruction/module corresponding to the memory access processing method in the embodiment of the present invention. The processor 70 executes the function application and data processing of the server by running the software program, the instruction and the module stored in the memory 71, that is, the memory access processing method in the above method embodiment.
存储器71可包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序;存储数据区可存储根据终端设备的使用所创建的数据等。此外,存储器71可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实例中,存储器71可包括相对于处理器70远程设置的存储器,这些远程存储器可以通过网络连接至终端设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 71 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to usage of the terminal device, and the like. Further, the memory 71 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other nonvolatile solid state storage device. In some examples, memory 71 can include memory remotely located relative to processor 70, which can be connected to the terminal device over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
输入装置72可设置为接收输入的数字或字符信息,以及产生与终端的用户设置以及功能控制有关的键信号输入。输出装置73可包括显示屏等显示设备。Input device 72 can be arranged to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the terminal. The output device 73 may include a display device such as a display screen.
所述一个或者多个模块存储在所述存储器71中,当被所述一个或者多个处理器70执行时,执行如下操作:The one or more modules are stored in the memory 71, and when executed by the one or more processors 70, perform the following operations:
按照预置规则将内存区划分为第一区和第二区;Dividing the memory area into the first area and the second area according to a preset rule;
在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;Establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset page table Mapping relationship replacement;
接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。Receiving an access memory request of the preset interface function, in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory In the case where the requested access is the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
可选的,所述方法还包括:Optionally, the method further includes:
根据所述访问内存请求的预设访问地址区间判断请求访问的内存区是第一区还是第二区。Determining, according to the preset access address range of the access memory request, whether the memory area requested to be accessed is the first area or the second area.
可选地,所述方法在所述根据所述动态TLB映射条目访问所述第二区的内存地址之后还包括:Optionally, after the accessing the memory address of the second area according to the dynamic TLB mapping entry, the method further includes:
当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目; Reloading the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The memory address of the second area is re-accessed according to the replaced dynamic TLB mapping entry.
可选地,所述按照预置规则将内存区划分为第一区和第二区包括:Optionally, the dividing the memory area into the first area and the second area according to the preset rule includes:
在系统内存初始化时,将从所述内存区中预先设置的NORMAL区中划分一部分出来设定为所述第二区;将所述内存区中预先设置的DMA区和NORMAL区未设定为第二区的部分设定为所述第一区。When the system memory is initialized, a part of the NORMAL area preset in the memory area is divided into the second area; the DMA area and the NORMAL area preset in the memory area are not set to the first The portion of the second zone is set to the first zone.
可选地,所述内存访问处理方法还包括:Optionally, the memory access processing method further includes:
预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function whose memory access frequency is less than the first preset value and the access address interval of the second area in the preset interface function Correspondingly, the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
可选地,所述方法还包括:Optionally, the method further includes:
预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且所需内存量大于第二预设值。Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second area, and the preset interface function is not The second interface function of the first interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the required memory amount is greater than the second preset value.
以上仅为本发明的可选实施例,并非因此限制本发明的专利范围。The above are only optional embodiments of the present invention and are not intended to limit the scope of the invention.
工业实用性Industrial applicability
本发明实施例提高了系统的内存访问性能,减少了CPU的占用率。 The embodiment of the invention improves the memory access performance of the system and reduces the occupancy rate of the CPU.

Claims (11)

  1. 一种内存访问处理方法,包括:A memory access processing method, including:
    按照预置规则将内存区划分为第一区和第二区;Dividing the memory area into the first area and the second area according to a preset rule;
    在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;Establishing a fixed TLB mapping entry corresponding to the first area and a dynamic TLB mapping entry corresponding to the second area in a transport backup buffer TLB entry; the dynamic TLB mapping entry is used according to a preset page table Mapping relationship replacement;
    接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。Receiving an access memory request of the preset interface function, in a case where the access memory request requests access to the first area, accessing the memory address of the first area according to the fixed TLB mapping entry, in the access memory In the case where the requested access is the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  2. 如权利要求1所述的内存访问处理方法,还包括:The memory access processing method of claim 1, further comprising:
    根据所述访问内存请求的预设访问地址区间判断请求访问的内存区是第一区还是第二区。Determining, according to the preset access address range of the access memory request, whether the memory area requested to be accessed is the first area or the second area.
  3. 如权利要求2所述的内存访问处理方法,所述方法在所述根据所述动态TLB映射条目访问所述第二区的内存地址之后还包括:The memory access processing method of claim 2, after the accessing the memory address of the second area according to the dynamic TLB mapping entry, the method further comprises:
    当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;Reloading the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
    根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The memory address of the second area is re-accessed according to the replaced dynamic TLB mapping entry.
  4. 如权利要求1所述的内存访问处理方法,其中,所述按照预置规则将内存区划分为第一区和第二区包括:The memory access processing method according to claim 1, wherein the dividing the memory area into the first area and the second area according to the preset rule comprises:
    在系统内存初始化时,将从所述内存区中预先设置的NORMAL区中划分一部分出来设定为所述第二区;将所述内存区中预先设置的DMA区和NORMAL区未设定为第二区的部分设定为所述第一区。When the system memory is initialized, a part of the NORMAL area preset in the memory area is divided into the second area; the DMA area and the NORMAL area preset in the memory area are not set to the first The portion of the second zone is set to the first zone.
  5. 如权利要求1至4任一项所述的内存访问处理方法,所述方法还包括:The memory access processing method according to any one of claims 1 to 4, further comprising:
    预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。 Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function whose memory access frequency is less than the first preset value and the access address interval of the second area in the preset interface function Correspondingly, the second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area.
  6. 如权利要求1至4任一项所述的内存访问处理方法,所述方法还包括:The memory access processing method according to any one of claims 1 to 4, further comprising:
    预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且所需内存量大于第二预设值。Presetting a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second area, and the preset interface function is not The second interface function of the first interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and the required memory amount is greater than the second preset value.
  7. 一种内存访问处理装置,包括:A memory access processing device includes:
    区域划分模块,设置为按照预置规则将内存区划分为第一区和第二区;The area dividing module is configured to divide the memory area into the first area and the second area according to the preset rule;
    条目建立模块,设置为在传输后备缓冲TLB表项中建立与所述第一区对应的固定TLB映射条目和与所述第二区对应的动态TLB映射条目;所述动态TLB映射条目用于根据预设的页表进行映射关系替换;An entry establishing module, configured to establish, in a transport backup buffer TLB entry, a fixed TLB mapping entry corresponding to the first region and a dynamic TLB mapping entry corresponding to the second region; the dynamic TLB mapping entry is used according to The preset page table is replaced by a mapping relationship;
    处理模块,设置为接收预设接口函数的访问内存请求,在所述访问内存请求所请求访问的是第一区的情况下,根据所述固定TLB映射条目访问所述第一区的内存地址,在所述访问内存请求所请求访问的是第二区的情况下,根据所述动态TLB映射条目访问所述第二区的内存地址。a processing module, configured to receive an access memory request of the preset interface function, and accessing the memory address of the first area according to the fixed TLB mapping entry, where the access memory request requests access to the first area, In the case that the access memory request requests access to the second zone, the memory address of the second zone is accessed according to the dynamic TLB mapping entry.
  8. 如权利要求7所述的内存访问处理装置,还包括:The memory access processing device of claim 7, further comprising:
    加载模块,设置为当访问的内存地址不在所述TLB表项中时,重新加载所述预设的页表以替换所述动态TLB映射条目;Loading a module, configured to reload the preset page table to replace the dynamic TLB mapping entry when the accessed memory address is not in the TLB entry;
    所述处理模块,还设置为根据替换后的动态TLB映射条目重新访问所述第二区的内存地址。The processing module is further configured to re-access the memory address of the second area according to the replaced dynamic TLB mapping entry.
  9. 如权利要求7至8任一项所述的内存访问处理装置,还包括:The memory access processing device according to any one of claims 7 to 8, further comprising:
    第一预置模块,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中内存访问频度小于第一预设值的第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应。The first preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function and the memory access frequency in the preset interface function are less than the first preset value The access address interval of the second area corresponds to, and the second interface function of the non-first interface function in the preset interface function corresponds to the access address range of the first area.
  10. 如权利要求7至9任一项所述的内存访问处理装置,其特征在于,还包括: The memory access processing device according to any one of claims 7 to 9, further comprising:
    第二预置模块,设置为预置所述预设接口函数与访问地址区间的对应关系,以使所述预设接口函数中第一接口函数与所述第二区的访问地址区间对应,且所述预设接口函数中非第一接口函数的第二接口函数与所述第一区的访问地址区间对应;所述第一接口函数的内存访问频度小于第一预设值且访问内存请求对应的内存量大于第二预设值。The second preset module is configured to preset a correspondence between the preset interface function and the access address interval, so that the first interface function in the preset interface function corresponds to the access address interval of the second region, and The second interface function of the non-first interface function in the preset interface function corresponds to the access address interval of the first area; the memory access frequency of the first interface function is less than the first preset value and accesses the memory request The corresponding amount of memory is greater than the second preset value.
  11. 一种计算机存储介质,存储有计算机可执行指令,所述计算机可执行指令设置为执行权利要求1-6任一项的方法。 A computer storage medium storing computer executable instructions arranged to perform the method of any of claims 1-6.
PCT/CN2016/077238 2015-06-26 2016-03-24 Memory access processing method and device, and storage medium WO2016206421A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510366369.9A CN106326150B (en) 2015-06-26 2015-06-26 Memory access processing method and device
CN201510366369.9 2015-06-26

Publications (1)

Publication Number Publication Date
WO2016206421A1 true WO2016206421A1 (en) 2016-12-29

Family

ID=57586102

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/077238 WO2016206421A1 (en) 2015-06-26 2016-03-24 Memory access processing method and device, and storage medium

Country Status (2)

Country Link
CN (1) CN106326150B (en)
WO (1) WO2016206421A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115168247A (en) * 2022-09-02 2022-10-11 北京登临科技有限公司 Method for dynamically sharing memory space in parallel processor and corresponding processor

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109753241B (en) * 2018-12-05 2022-04-08 新华三技术有限公司合肥分公司 Data writing method and device for solid state disk and computer readable storage medium
CN109815192B (en) * 2019-01-31 2024-06-11 深兰机器人(上海)有限公司 Method and device for managing embedded system memory

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470667A (en) * 2007-12-28 2009-07-01 英业达股份有限公司 Method for physical internal memory allocation in assigned address range on Linux system platform
CN102906721A (en) * 2010-06-23 2013-01-30 国际商业机器公司 Resizing address spaces concurrent to accessing the address spaces
CN103793332A (en) * 2014-02-28 2014-05-14 中国科学院微电子研究所 Data storage method and device based on memory, processor and electronic equipment
WO2014143055A1 (en) * 2013-03-15 2014-09-18 Intel Corporation Mechanism for facilitating dynamic and efficient management of translation buffer prefetching in software programs at computing systems
CN104272279A (en) * 2012-05-10 2015-01-07 Arm有限公司 Data processing apparatus having cache and translation lookaside buffer

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7089396B2 (en) * 2002-10-10 2006-08-08 International Business Machines Corporation Method and profiling cache for management of virtual memory
US7426626B2 (en) * 2005-08-23 2008-09-16 Qualcomm Incorporated TLB lock indicator
JP5702808B2 (en) * 2011-01-12 2015-04-15 パナソニック株式会社 Program execution device and compiler system
DE202011005136U1 (en) * 2011-04-11 2012-11-07 Bernd Burgmaier System in a terminal for collecting and processing data for determining the tax obligations of a person providing the service
CN104572313B (en) * 2013-10-22 2018-03-13 华为技术有限公司 Communication means and device between a kind of process

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470667A (en) * 2007-12-28 2009-07-01 英业达股份有限公司 Method for physical internal memory allocation in assigned address range on Linux system platform
CN102906721A (en) * 2010-06-23 2013-01-30 国际商业机器公司 Resizing address spaces concurrent to accessing the address spaces
CN104272279A (en) * 2012-05-10 2015-01-07 Arm有限公司 Data processing apparatus having cache and translation lookaside buffer
WO2014143055A1 (en) * 2013-03-15 2014-09-18 Intel Corporation Mechanism for facilitating dynamic and efficient management of translation buffer prefetching in software programs at computing systems
CN103793332A (en) * 2014-02-28 2014-05-14 中国科学院微电子研究所 Data storage method and device based on memory, processor and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115168247A (en) * 2022-09-02 2022-10-11 北京登临科技有限公司 Method for dynamically sharing memory space in parallel processor and corresponding processor
CN115168247B (en) * 2022-09-02 2022-12-02 北京登临科技有限公司 Method for dynamically sharing memory space in parallel processor and corresponding processor

Also Published As

Publication number Publication date
CN106326150A (en) 2017-01-11
CN106326150B (en) 2020-09-15

Similar Documents

Publication Publication Date Title
US10545672B2 (en) Method for accessing extended memory, device, and system
US9720846B2 (en) Memory swap for direct memory access by a device assigned to a guest operating system
US9772962B2 (en) Memory sharing for direct memory access by a device assigned to a guest operating system
US8359443B2 (en) Secure memory access system and method
US9880871B2 (en) Protection from guest interrupts in a virtual machine function
US8738890B2 (en) Coupled symbiotic operating system
US10108553B2 (en) Memory management method and device and memory controller
US20190004800A1 (en) Smart memory data store or load method and apparatus
US20170004101A1 (en) Data copying method, direct memory access controller, and computer system
US20160224383A1 (en) Protected virtual machine function access
WO2015180598A1 (en) Method, apparatus and system for processing access information of storage device
CN113900966B (en) Access method and device based on Cache
CN104885063A (en) Overlap checking for a translation lookaside buffer (TLB)
WO2016206421A1 (en) Memory access processing method and device, and storage medium
WO2012163017A1 (en) Method for processing access exception of distributed virtual machine and virtual machine monitor
US8751724B2 (en) Dynamic memory reconfiguration to delay performance overhead
US8490207B2 (en) Performing zero-copy sends in a networked file system with cryptographic signing
US8417903B2 (en) Preselect list using hidden pages
US9921979B2 (en) Position dependent code in virtual machine functions
US9507724B2 (en) Memory access processing method and information processing device
JP2024510127A (en) Randomize address space placement with page remapping and rotation to increase entropy
US11249914B2 (en) System and methods of an efficient cache algorithm in a hierarchical storage system
CN107038121B (en) Memory address allocation method and device for virtual machine
US9798479B2 (en) Relocatable and resizable tables in a computing device
CN116680210A (en) Storage space access method, device, equipment and storage medium

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: 16813537

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16813537

Country of ref document: EP

Kind code of ref document: A1