[go: up one dir, main page]

CN107145399A - A kind of shared-memory management method and shared-memory management equipment - Google Patents

A kind of shared-memory management method and shared-memory management equipment Download PDF

Info

Publication number
CN107145399A
CN107145399A CN201710268053.5A CN201710268053A CN107145399A CN 107145399 A CN107145399 A CN 107145399A CN 201710268053 A CN201710268053 A CN 201710268053A CN 107145399 A CN107145399 A CN 107145399A
Authority
CN
China
Prior art keywords
memory
pbuf
app
read
write operation
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201710268053.5A
Other languages
Chinese (zh)
Other versions
CN107145399B (en
Inventor
张伟
李清清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XFusion Digital Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201710268053.5A priority Critical patent/CN107145399B/en
Publication of CN107145399A publication Critical patent/CN107145399A/en
Application granted granted Critical
Publication of CN107145399B publication Critical patent/CN107145399B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明实施例公开了一种共享内存管理方法及共享内存管理设备,该方法应用于报文零拷贝系统中,该报文零拷贝系统运行于操作系统,该报文零拷贝系统包括至少两个应用程序APPs,APPs共享第一包缓存pbuf内存,该方法包括:APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作保护属性在当前时刻为只读;若所述APP接收到所述操作系统发送的pbuf内存误操作通知消息,则获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息;基于所述pbuf内存误操作现场信息确定内存误操作现场。从而在APP对共享pbuf内存进行误操作时,准确定位产生误操作的问题现场,保障系统可靠性。

The embodiment of the present invention discloses a shared memory management method and a shared memory management device. The method is applied to a message zero-copy system. The message zero-copy system runs on an operating system. The message zero-copy system includes at least two Application program APPs, APPs share the first packet cache pbuf memory, the method includes: any application program APP in the APPs sets the read-write operation protection attribute of the APP to the first pbuf memory to be read-only at the current moment; if The APP receives the pbuf memory misoperation notification message sent by the operating system, then obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message; determines the memory misoperation based on the pbuf memory misoperation site information on site. Therefore, when the APP misuses the shared pbuf memory, it can accurately locate the problem site where the misoperation occurs and ensure system reliability.

Description

一种共享内存管理方法及共享内存管理设备A shared memory management method and shared memory management device

技术领域technical field

本发明涉及通信领域,具体涉及一种共享内存管理方法及共享内存管理设备。The invention relates to the communication field, in particular to a shared memory management method and a shared memory management device.

背景技术Background technique

网络功能虚拟化(英文:Network Function Virtualization,NFV)系统通过软硬件解耦及功能抽象,使网络设备功能不再依赖于专用硬件,资源可以充分灵活共享,实现新业务的快速开发和部署。NFV技术的基础包含云计算技术和虚拟化技术,通用的计算、存储、网络等硬件设备通过虚拟化技术可以分解为多种虚拟资源,以供上层各种应用程序使用。Network Function Virtualization (English: Network Function Virtualization, NFV) system decouples software and hardware and abstracts functions, so that network device functions no longer depend on dedicated hardware, resources can be fully and flexibly shared, and rapid development and deployment of new services are realized. The basis of NFV technology includes cloud computing technology and virtualization technology. General-purpose computing, storage, network and other hardware devices can be decomposed into various virtual resources through virtualization technology for use by various upper-level applications.

当在NFV系统上运行多个应用程序(英文:Application,APP)时,为了实现在不同的应用进程之间进行报文转发,可以采用共享内存机制的零拷贝技术,也即不同的应用程序共享同一包缓存(英文:packet buffer,pbuf)内存,从而可以避免在不同应用程序之间进行拷贝操作,提升系统的性能。但同时使用共享内存机制时,由于各应用程序共享同一pbuf内存,所以破坏了应用程序间的隔离性,导致当出现pbuf内存误操作问题时,无法准确定位内存问题现场。When running multiple applications (English: Application, APP) on the NFV system, in order to realize message forwarding between different application processes, the zero-copy technology of the shared memory mechanism can be used, that is, different application programs share The same packet cache (English: packet buffer, pbuf) memory can avoid copying operations between different applications and improve system performance. However, when the shared memory mechanism is used at the same time, since each application program shares the same pbuf memory, the isolation between applications is destroyed. As a result, when a pbuf memory misuse problem occurs, it is impossible to accurately locate the memory problem site.

发明内容Contents of the invention

本发明实施例提供了一种共享内存管理方法及共享内存管理设备,以在APP对共享pbuf内存进行误操作时,准确定位产生误操作的问题现场。Embodiments of the present invention provide a shared memory management method and a shared memory management device, so as to accurately locate the problem site where the misoperation occurs when an APP misuses the shared pbuf memory.

第一方面,本发明实施例提供一种共享内存管理方法,该方法应用于报文零拷贝系统中,该报文零拷贝系统运行于操作系统上,该报文零拷贝系统包括至少两个应用程序APPs,该APPs的共享内存第一pbuf内存,该方法通过以下步骤进行共享内存管理。首先APPs中的任一应用程序APP设置该APP对第一pbuf内存的读写操作保护属性在当前时刻为只读;然后在APP接收到操作系统发送的pbuf内存误操作通知消息时,获取pbuf内存误操作通知消息中的pbuf内存误操作现场信息,该pbuf内存误操作通知消息用于提醒APP对第一pbuf内存进行写操作以及该写操作的具体位置;最后APP基于pbuf内存误操作现场信息确定APP对第一pbuf内存进行写操作的内存误操作现场。从而实现在多个APP共享同一pbuf内存的情况下,当该共享pbuf内存出现内存误操作时,能快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性。In the first aspect, the embodiment of the present invention provides a shared memory management method, the method is applied to a message zero-copy system, the message zero-copy system runs on an operating system, and the message zero-copy system includes at least two applications For the program APPs, the shared memory of the APPs is first the pbuf memory, and the method performs shared memory management through the following steps. First, any application APP in the APPs sets the protection attribute of the APP to the read and write operation of the first pbuf memory as read-only at the current moment; then, when the APP receives the pbuf memory misoperation notification message sent by the operating system, it obtains the pbuf memory The pbuf memory misuse site information in the misoperation notification message, the pbuf memory misuse notification message is used to remind the APP to write the first pbuf memory and the specific location of the write operation; finally, the APP determines based on the pbuf memory misuse site information The memory misoperation scene where the APP writes to the first pbuf memory. In this way, when multiple APPs share the same pbuf memory, when a memory misoperation occurs in the shared pbuf memory, the APP and the specific location that caused the pbuf memory misoperation can be quickly and accurately located, that is, the pbuf memory misoperation site can be determined , to ensure system reliability.

在一个可能的设计中,该操作系统包括Linux操作系统,该Linux操作系统包括mprotect内存管理接口,该mprotect内存管理接口用于被调用以设置第一pbuf内存的读写操作属性;从而APP通过调用该mprotect内存管理接口设置APP对第一pbuf内存的读写操作属性在当前时刻为只读。从而通过调用Linux操作系统的mprotect内存管理接口可以方便地在Linux操作系统下对第一pbuf内存的读写操作属性进行设置。In a possible design, the operating system includes a Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called to set the read and write operation attributes of the first pbuf memory; thus the APP calls The mprotect memory management interface sets the APP's read and write operation attribute to the first pbuf memory as read-only at the current moment. Therefore, by calling the mprotect memory management interface of the Linux operating system, the read and write operation attributes of the first pbuf memory can be conveniently set under the Linux operating system.

在一个可能的设计中,mprotect内存管理接口用于被APP调用以基于一个或多个页表设置APP对第一pbuf内存的读写操作属性。从而使得基于页表管理的mprotect内存读写操作管理机制可独立对该第一pbuf内存进行控制。In a possible design, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the APP to the first pbuf memory based on one or more page tables. Therefore, the mprotect memory read and write operation management mechanism based on page table management can independently control the first pbuf memory.

在一个可能的设计中,该报文零拷贝系统还包括第二pbuf内存,APPs的共享内存还包括该第二pbuf内存,其中,该第一pbuf内存为小页内存,该第二pbuf内存为大页内存,该第一pbuf内存与一个或多个页表存在唯一对应关系。APP在预设时刻确定第一pbuf内存为APPs的共享内存,APP在预设时刻之外确定第二pbuf内存为APPs的共享内存。当该预设时刻的频率越小时,则说明进行pbuf内存监控的频率越小,所以此时系统可靠性相对较小,而此时使用大页内存第二pbuf内存进行填充的相对次数多,系统的性能提升较大;而预设时刻的频率越大,则说明进行pbuf内存监控的频率越大,所以此时系统的可靠性相对较大,而此时使用大页内存第二pbuf内存进行填充的相对次数小,系统的性能提升较小。故可以根据需求,权衡系统的性能提升与可靠性设置该预设时刻。In a possible design, the message zero-copy system also includes a second pbuf memory, and the shared memory of APPs also includes the second pbuf memory, wherein the first pbuf memory is a small page memory, and the second pbuf memory is Huge page memory, the first pbuf memory has a unique correspondence with one or more page tables. The APP determines that the first pbuf memory is the shared memory of the APPs at a preset time, and the APP determines that the second pbuf memory is the shared memory of the APPs outside the preset time. When the frequency of the preset time is smaller, it means that the frequency of pbuf memory monitoring is smaller, so the reliability of the system is relatively low at this time, and at this time, the relative times of filling the second pbuf memory with the large page memory is more, the system The performance improvement is greater; the higher the frequency at the preset time, the greater the frequency of pbuf memory monitoring, so the reliability of the system is relatively high at this time, and at this time, use the second pbuf memory of the large page memory to fill The relative number of times is small, and the performance improvement of the system is small. Therefore, the preset time can be set according to the requirements and by weighing the performance improvement and reliability of the system.

在一个可能的设计中,该第一pbuf内存还用于缓存轨迹标识,APP还通过该轨迹标识记录第一pbuf内存的轨迹点信息,该轨迹点信息包括所应用程序标识、应用程序当前进程标识以及当前时刻。通过在第一pbuf的轨迹点信息确定的第一pbuf的轨迹,来进一步确定该第一pbuf所经过的上游APP,从而在确定APP对第一pbuf内存进行写操作的内存误操作现场后,可进一步通过该APP的上游APP来进行pbuf内存问题排查,以进一步提高系统可靠性。In a possible design, the first pbuf memory is also used to cache the track ID, and the APP also records the track point information of the first pbuf memory through the track ID, and the track point information includes the application program ID and the current process ID of the application program and the current moment. Through the trajectory of the first pbuf determined by the trajectory point information of the first pbuf, the upstream APP passed by the first pbuf is further determined, so that after determining the memory misoperation site where the APP performs a write operation on the memory of the first pbuf, you can Further use the upstream APP of this APP to troubleshoot pbuf memory problems to further improve system reliability.

第一方面,本发明实施例提供一种共享内存管理方法,该方法应用于操作系统,该操作系统上运行有报文零拷贝系统,该报文零拷贝系统包括至少两个应用程序APPs,APPs包括第一报文缓存pbuf内存,该方法通过以下步骤实现共享内存管理。首先操作系统根据APPs中的任一应用程序APP对第一pbuf内存的读写操作属性设置指示记录APP对第一pbuf内存的读写操作属性为只读;从而当操作系统监控到APP对第一pbuf内存进行写操作,操作系统向APP发送pbuf内存误操作通知消息,该pbuf内存误操作通知消息用于提醒APP对第一pbuf内存进行写操作以及该写操作的具体位置。从而实现在多个APP共享同一pbuf内存的情况下,当该共享pbuf内存出现内存误操作时,能快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性的同时能提高系统性能。In the first aspect, the embodiment of the present invention provides a shared memory management method, the method is applied to the operating system, the message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, APPs Including the first message cache pbuf memory, the method implements shared memory management through the following steps. First, the operating system sets an instruction to record that the read-write operation attribute of the APP to the first pbuf memory is read-only according to any application program APP in the APPs. The pbuf memory performs a write operation, and the operating system sends a pbuf memory misoperation notification message to the APP. The pbuf memory misoperation notification message is used to remind the APP to perform a write operation on the first pbuf memory and the specific location of the write operation. In this way, when multiple APPs share the same pbuf memory, when a memory misoperation occurs in the shared pbuf memory, the APP and the specific location that caused the pbuf memory misoperation can be quickly and accurately located, that is, the pbuf memory misoperation site can be determined , to improve system performance while ensuring system reliability.

在一个可能的设计中,该操作系统包括Linux操作系统,该Linux操作系统包括mprotect内存管理接口,该mprotect内存管理接口用于被APP调用以设置该APP对第一pbuf内存的读写操作属性;在APP通过调用mprotect内存管理接口设置APP对第一pbuf内存的读写操作属性在当前时刻为只读时,Linux操作系统记录APP对第一pbuf内存的读写操作属性。从而通过调用Linux操作系统的mprotect内存管理接口可以方便地在Linux操作系统下对第一pbuf内存的读写操作属性进行设置。In a possible design, the operating system includes a Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called by the APP to set the APP's read and write operation attributes to the first pbuf memory; When the APP sets the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment by calling the mprotect memory management interface, the Linux operating system records the read-write operation attribute of the APP to the first pbuf memory. Therefore, by calling the mprotect memory management interface of the Linux operating system, the read and write operation attributes of the first pbuf memory can be conveniently set under the Linux operating system.

在一个可能的设计中,所述mprotect内存管理接口用于被APP调用以基于一个或多个页表设置APP对第一pbuf内存的读写操作属性。从而使得基于页表管理的mprotect内存读写操作管理机制可独立对该第一pbuf内存进行控制。In a possible design, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the APP to the first pbuf memory based on one or more page tables. Therefore, the mprotect memory read and write operation management mechanism based on page table management can independently control the first pbuf memory.

在一个可能的设计中,该页表包括读写操作属性标识,操作系统通过该页表上的读写操作属性标识记录APP对第一pbuf内存的读写操作属性为只读。从而使得基于页表管理的mprotect内存读写操作管理机制可独立对该第一pbuf内存进行控制。In a possible design, the page table includes a read-write operation attribute identifier, and the operating system records that the read-write operation attribute of the APP to the first pbuf memory is read-only through the read-write operation attribute identifier on the page table. Therefore, the mprotect memory read and write operation management mechanism based on page table management can independently control the first pbuf memory.

第三方面,本发明实施例提供一种应用程序APP,该应用程序APP具有实现上述第一方面的方法的功能,所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。In a third aspect, an embodiment of the present invention provides an application program APP, which has a function of implementing the method in the first aspect above, and the function may be implemented by hardware, or may be implemented by executing corresponding software on the hardware. The hardware or software includes one or more modules corresponding to the above functions.

第四方面,本发明实施例提供一种计算机存储介质,用于储存为上述用于第三方面所述的应用程序APP所用的计算机软件指令,其包含用于执行上述第一方面的方法的程序。In a fourth aspect, an embodiment of the present invention provides a computer storage medium for storing computer software instructions for the above-mentioned application program APP described in the third aspect, which includes a program for executing the method of the first aspect above .

第五方面,本发明实施例提供一种操作系统,该操作系统具有实现上述第二方面的方法的功能,所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。In a fifth aspect, an embodiment of the present invention provides an operating system. The operating system has the function of implementing the method of the second aspect above. The function may be implemented by hardware, or by executing corresponding software on the hardware. The hardware or software includes one or more modules corresponding to the above functions.

第六方面,本发明实施例提供一种计算机存储介质,用于储存为上述用于第五方面所述的操作系统所用的计算机软件指令,其包含用于执行上述第二方面的方法的程序。In a sixth aspect, an embodiment of the present invention provides a computer storage medium for storing computer software instructions for the above-mentioned operating system in the fifth aspect, which includes a program for executing the method in the second aspect above.

第七方面,本发明实施例提供一种共享内存管理装置,该共享内存管理装置包括存储有可执行程序代码的存储器,以及与所述存储器耦合的处理器;所述处理器上运行有应用程序APP与操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP,所述APP用于执行本发明第一方面的方法流程。In a seventh aspect, an embodiment of the present invention provides a shared memory management device, the shared memory management device includes a memory storing executable program codes, and a processor coupled to the memory; an application program runs on the processor APP and operating system, the operating system has a message zero-copy system running on it, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first packet cache pbuf memory, and the APP is the Any APP among APPs, the APP is used to execute the method flow of the first aspect of the present invention.

第八方面,本发明实施例提供一种共享内存管理装置,该共享内存管理装置包括存储有可执行程序代码的存储器,以及与所述存储器耦合的处理器;所述处理器上运行有应用程序APP和操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一报文缓存pbuf内存,所述APP为所述APPs中的任一APP,所述操作系统用于执行本发明第二方面的方法流程。In an eighth aspect, an embodiment of the present invention provides a shared memory management device, the shared memory management device includes a memory storing executable program codes, and a processor coupled to the memory; an application program runs on the processor APP and an operating system, the operating system runs a message zero-copy system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first message cache pbuf memory, and the APP is all Any one of the above APPs, the operating system is used to execute the method flow of the second aspect of the present invention.

第九方面,本发明实施例提供一种共享内存管理设备,该共享内存管理设备包括处理器和存储器。该处理器上运行第三方面的应用程序APP和第五方面的操作系统,该处理器被配置为支持应用程序APP以及操作系统执行本发明实施例所提供的共享内存管理方法。该存储器用于与处理器耦合,用于存储应用程序APP必要的程序代码和数据,以及用于存储操作系统必要的程序代码和数据。In a ninth aspect, an embodiment of the present invention provides a shared memory management device, where the shared memory management device includes a processor and a memory. The application program APP of the third aspect and the operating system of the fifth aspect run on the processor, and the processor is configured to support the application program APP and the operating system to execute the shared memory management method provided by the embodiment of the present invention. The memory is used for coupling with the processor, for storing necessary program codes and data of the application program APP, and for storing necessary program codes and data of the operating system.

相较于现有技术,本发明实施例的方案中在多个APP共享同一pbuf内存的情况下,通过设置APP对第一pbuf内存的读写操作属性为只读,从而在操作系统监控到APP对第一pbuf进行写操作时,操作系统向APP发送pbuf内存误操作通知消息,以使APP基于该pbuf内存误操作通知消息快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性。Compared with the prior art, in the solution of the embodiment of the present invention, when multiple APPs share the same pbuf memory, by setting the read-write operation attribute of the APP to the first pbuf memory as read-only, the APP can be monitored by the operating system. When performing a write operation on the first pbuf, the operating system sends a pbuf memory misoperation notification message to the APP, so that the APP can quickly and accurately locate the APP and the specific location that caused the pbuf memory misoperation based on the pbuf memory misoperation notification message, that is, Determine the pbuf memory misuse site to ensure system reliability.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings that are required in the description of the embodiments or the prior art.

图1是本发明实施例提供的一种网络功能虚拟化系统的架构示意图;FIG. 1 is a schematic diagram of the architecture of a network function virtualization system provided by an embodiment of the present invention;

图2是本发明实施例提供的另一种NFV系统的架构示意图;FIG. 2 is a schematic structural diagram of another NFV system provided by an embodiment of the present invention;

图3是本发明实施例提供的又一种NFV系统的架构示意图;FIG. 3 is a schematic diagram of the architecture of another NFV system provided by an embodiment of the present invention;

图4是本发明实施例提供的一种报文零拷贝系统的架构示意图;FIG. 4 is a schematic diagram of the architecture of a message zero-copy system provided by an embodiment of the present invention;

图5是本发明实施例提供的一种共享内存管理方法的流程示意图;FIG. 5 is a schematic flowchart of a shared memory management method provided by an embodiment of the present invention;

图6是本发明实施例提供的一种APP进程间第一pbuf内存管理流程示意图;FIG. 6 is a schematic diagram of a first pbuf memory management process between APP processes provided by an embodiment of the present invention;

图7是本发明实施例提供的一种报文零拷贝流程以及第一pbuf内存管理流程示意图;7 is a schematic diagram of a message zero-copy process and a first pbuf memory management process provided by an embodiment of the present invention;

图8-a是本发明实施例提供的另一种报文零拷贝系统的架构示意图;Fig. 8-a is a schematic diagram of another message zero-copy system provided by an embodiment of the present invention;

图8-b是本发明实施例提供的另一种报文零拷贝流程以及pbuf内存管理流程示意图;Figure 8-b is a schematic diagram of another message zero-copy process and pbuf memory management process provided by the embodiment of the present invention;

图9是本发明实施例提供的一种应用程序APP的结构示意图;FIG. 9 is a schematic structural diagram of an application program APP provided by an embodiment of the present invention;

图10是本发明实施例提供的一种操作系统的结构示意图;FIG. 10 is a schematic structural diagram of an operating system provided by an embodiment of the present invention;

图11为本发明实施例提供的一种共享内存管理装置的结构示意图;FIG. 11 is a schematic structural diagram of a shared memory management device provided by an embodiment of the present invention;

图12为本发明实施例提供的另一种共享内存管理装置的结构示意图;FIG. 12 is a schematic structural diagram of another shared memory management device provided by an embodiment of the present invention;

图13为本发明实施例提供的一种共享内存管理设备的结构示意图。FIG. 13 is a schematic structural diagram of a shared memory management device provided by an embodiment of the present invention.

具体实施方式detailed description

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention.

为了更好地理解本发明技术方案,下面首先对本发明实施例所基于的应用场景进行说明。In order to better understand the technical solutions of the present invention, the application scenarios based on the embodiments of the present invention will be firstly described below.

首先参见图1,图1是本发明实施例提供的一种网络功能虚拟化系统NFV100的架构示意图。如图1所示,该NFV系统包括硬件层110,管理程序(英文:Hyperviser)层120,操作系统(英文:OperSystem,OS)层130、应用程序(英文:application,APP)层140,其中,操作系统层130和各个应用程序构成虚拟机(英文:Virtual Machine,VM)。Referring first to FIG. 1 , FIG. 1 is a schematic diagram of an architecture of a network function virtualization system NFV100 provided by an embodiment of the present invention. As shown in Figure 1, the NFV system includes a hardware layer 110, a management program (English: Hyperviser) layer 120, an operating system (English: OperSystem, OS) layer 130, and an application program (English: application, APP) layer 140, wherein, The operating system layer 130 and various application programs constitute a virtual machine (English: Virtual Machine, VM).

其中,硬件层110为虚拟化环境运行的硬件平台,该硬件层110可以由一台或多台服务器组成;管理程序120直接安装在硬件计算资源上,用于管理和调用硬件资源,不需要底层操作系统,也即可以理解管理程序为一个很薄的操作系统;操作系统层130包括一个或多个操作系统,是运行在管理程序上的访问操作系统(英文:Guest OS),在本发明实施例中,该操作系统可以为Linux操作系统或其它操作系统;应用程序层140包括一个或多个应用程序模块,是运行在访问操作系统上的应用,为客户提供服务。Among them, the hardware layer 110 is a hardware platform running in a virtualized environment, and the hardware layer 110 can be composed of one or more servers; the hypervisor 120 is directly installed on the hardware computing resources, and is used to manage and invoke hardware resources, without the need for a bottom layer Operating system, that is, it can be understood that the hypervisor is a very thin operating system; the operating system layer 130 includes one or more operating systems, which are access operating systems (English: Guest OS) running on the hypervisor. In an example, the operating system may be a Linux operating system or other operating systems; the application layer 140 includes one or more application program modules, which are applications running on the access operating system to provide services for clients.

参见图2,图2是本发明实施例提供的另一种NFV系统的架构示意图。如图2所示,该NFV系统包括硬件层210,宿主机(英文:host)层220,管理程序层230,访问操作系统(英文:guest)240、APP层250。其中,图2所示的NFV系统架构与图1所示的网络功能虚拟化系统架构不同之处在于,在图2所示的网络功能虚拟化系统架构中,通过增加host层220,该host层可用于安装基础操作系统,从而使管理程序层230运行在基础操作系统上,构建出一整套虚拟硬件平台,使用者根据需要在guest层上安装新的操作系统和应用软件,host层和guest层上的操作系统可以完全无关。在本发明实施例中,该host层的操作系统可以为Windos操作,该guest层上的操作系统可以为Linux操作系统。Referring to FIG. 2, FIG. 2 is a schematic structural diagram of another NFV system provided by an embodiment of the present invention. As shown in FIG. 2 , the NFV system includes a hardware layer 210 , a host (English: host) layer 220 , a hypervisor layer 230 , an access operating system (English: guest) 240 , and an APP layer 250 . Wherein, the difference between the NFV system architecture shown in FIG. 2 and the network function virtualization system architecture shown in FIG. 1 is that, in the network function virtualization system architecture shown in FIG. It can be used to install the basic operating system, so that the hypervisor layer 230 runs on the basic operating system and builds a complete set of virtual hardware platform. Users can install new operating systems and application software, host layer and guest layer on the guest layer as needed. The operating system on can be completely irrelevant. In the embodiment of the present invention, the operating system of the host layer may be Windows, and the operating system of the guest layer may be a Linux operating system.

参见图3,图3是本发明实施例提供的又一种NFV系统的架构示意图。在图3所示的网络功能虚拟化系统中,包括网络功能虚拟化基础设施层(英文:NFV Infrastructure,NFVI)310、虚拟网络功能(英文:Virtual Network Functions,VNFS)320、操作/业务支持系统(英文:Operation Support System/Business Support System,OSS/BSS)330以及网络功能虚拟化管理和编排系统(英文:NFV Management and Orchestration,NFV MANO)340。Referring to FIG. 3 , FIG. 3 is a schematic structural diagram of another NFV system provided by an embodiment of the present invention. The network function virtualization system shown in FIG. 3 includes a network function virtualization infrastructure layer (English: NFV Infrastructure, NFVI) 310, a virtual network function (English: Virtual Network Functions, VNFS) 320, and an operation/service support system (English: Operation Support System/Business Support System, OSS/BSS) 330 and network function virtualization management and orchestration system (English: NFV Management and Orchestration, NFV MANO) 340 .

其中,虚拟化基础设施层310包括硬件资源层,虚拟化层以及虚拟资源层,VNFS320包括多个VNF以及多个网元管理器(英文:Element Manager,EM),可以为用户提供不同的虚拟网络功能。相对于图1或图2所示的架构,可以认为图1或图2中的APP部署于图3中的VNF。Among them, the virtualization infrastructure layer 310 includes a hardware resource layer, a virtualization layer, and a virtual resource layer, and the VNFS 320 includes multiple VNFs and multiple network element managers (English: Element Manager, EM), which can provide users with different virtual network Function. Compared with the architecture shown in FIG. 1 or FIG. 2 , it can be considered that the APP in FIG. 1 or FIG. 2 is deployed on the VNF in FIG. 3 .

其中,NFV MANO包括网络功能虚拟化编排器(英文:NFV Orchestrator,NFVO)、一个或多个虚拟化网络功能管理器(英文:VNF Manager,VNFM)和虚拟化基础设施管理器(英文:Virtualized Infrastructure Manager,VIM),网络服务目录(英文:Network ServiceCatalogue,NS Catalogue),用于负责对整个NFVI资源的管理和编排,负责业务网络和NFVI资源的映射和关联,负责OSS业务资源流程的实施等,MANO通过解析产品提供的虚拟网络功能描述符(英文:VNF Descriptor,VNFD)文件实现虚拟机的创建、网元的安装、亲和及反亲和的配置、系统扩缩容等操作。Among them, NFV MANO includes a network function virtualization orchestrator (English: NFV Orchestrator, NFVO), one or more virtualized network function managers (English: VNF Manager, VNFM) and a virtualized infrastructure manager (English: Virtualized Infrastructure Manager). Manager, VIM), Network Service Catalog (English: Network Service Catalog, NS Catalog), which is responsible for the management and arrangement of the entire NFVI resources, responsible for the mapping and association of business networks and NFVI resources, and responsible for the implementation of OSS business resource processes, etc. MANO implements virtual machine creation, network element installation, affinity and anti-affinity configuration, and system expansion and contraction by analyzing the virtual network function descriptor (English: VNF Descriptor, VNFD) file provided by the product.

参见图4,图4是本发明实施例提供的一种报文零拷贝系统400的架构示意图,如图4所示,该报文零拷贝系统400包括N个APP,也即包括APPs,分别为APP1,APP2,···APPn,第一网卡和第一网卡队列,第二网卡和第二网卡队列,以及一个报文缓存pbuf内存。其中,不同的APP属于不同的业务进程,该pbuf内存由N个APP共享。Referring to FIG. 4, FIG. 4 is a schematic diagram of the architecture of a message zero-copy system 400 provided by an embodiment of the present invention. As shown in FIG. 4, the message zero-copy system 400 includes N APPs, that is, APPs, respectively APP1, APP2, ... APPn, the first network card and the first network card queue, the second network card and the second network card queue, and a message cache pbuf memory. Wherein, different APPs belong to different business processes, and the pbuf memory is shared by N APPs.

在本发明实施例中,该N个APP可以为上述图1和图2中运行于同一个VM的APP,也可以为图3中的VNF,也可以为运行于物理计算机中的不同应用程序。In the embodiment of the present invention, the N APPs can be the APPs running on the same VM in FIG. 1 and FIG. 2 , or they can be the VNFs in FIG. 3 , or they can be different application programs running on the physical computer.

在本发明实施例中,该报文零拷贝系统可运行于物理计算机上的操作系统上,也可以运行于NFV系统中的操作系统上。In the embodiment of the present invention, the message zero-copy system may run on an operating system on a physical computer, or on an operating system in an NFV system.

值得说明的是,该APP可以为一个独立的功能模块,用于执行特征的功能,例如,可以为用于执行传输层处理功能的APP、或用于执行应用层处理功能的APP,或也可以为一个独立函数编写的功能模块。It is worth noting that the APP can be an independent functional module for performing characteristic functions, for example, it can be an APP for performing transport layer processing functions, or an APP for performing application layer processing functions, or it can also be A function module written for a single function.

可选地,在本发明的一个实施例中,该多个APP可以为不同的进程;也可以为同一个进程中的不同线程。不管该多个APP处于不同的进程,还是处于同一个进程中的不同线程,只要该多个APP共享同一pbuf内存,并利用该pbuf内存在该多个APP之间进行报文转发的场景均为本发明实施例所提供的应用场景。Optionally, in an embodiment of the present invention, the multiple APPs may be different processes; they may also be different threads in the same process. Regardless of whether the multiple APPs are in different processes or different threads in the same process, as long as the multiple APPs share the same pbuf memory and use the pbuf memory to forward packets among the multiple APPs, The application scenarios provided by the embodiments of the present invention.

在本发明实施例中,上述第一网卡和第二网卡可以为虚拟网卡(英文:virtualnetwork card,VNIC),也可以为物理网卡。In the embodiment of the present invention, the above-mentioned first network card and the second network card may be virtual network cards (English: virtual network card, VNIC), or may be physical network cards.

在本发明实施例中,当利用该报文零拷贝系统进行零拷贝报文转发时,首先APP1进程往第一网卡队列中填充pbuf内存的直接内存存储(英文:Direct Memory Access,DMA)地址后,第一网卡往该pbuf内存地址中填充报文,然后APP1从第一网卡队列中收包该报文至pbuf内存,并将该报文依次经过多个APP进程进行处理,最后APPn处理完毕后,第二网卡再往第二网卡队列中填充该pbuf内存地址,APPn将该报文填充至第二网卡队列的pbuf内存地址,然后第二网卡从该第二网卡队列中回收该报文并发送出去。当第二网卡发送报文后,APPn收回该pbuf内存至内存池。可以看出,该报文零拷贝系统通过pbuf内存共享内存,实现在不同的APP之间的报文转发,从而实现报文零拷贝。In the embodiment of the present invention, when the message zero-copy system is used for zero-copy message forwarding, first the APP1 process fills the direct memory storage (English: Direct Memory Access, DMA) address of the pbuf memory in the first network card queue , the first network card fills the message into the pbuf memory address, then APP1 receives the message from the queue of the first network card to the pbuf memory, and processes the message through multiple APP processes in turn, and finally APPn finishes processing , the second network card fills the pbuf memory address in the second network card queue, APPn fills the message into the pbuf memory address of the second network card queue, and then the second network card retrieves the message from the second network card queue and sends it go out. After the second network card sends the message, APPn reclaims the pbuf memory to the memory pool. It can be seen that the message zero-copy system realizes message forwarding between different APPs through pbuf memory shared memory, thereby realizing message zero-copy.

但同时,基于该报文零拷贝系统,由于不同的APP共享同一个pbuf内存,所以破坏了不同的APP进程间的隔离性,当跨进程操作时出现pbuf内存问题时,无法找到出现pbuf内存问题所在的APP与具体位置(例如,当pbuf内存出现问题时,无法确定是n个APP中具体哪个APP发生误操作问题),也即无法定位问题第一现场,导致业务恢复周期长。But at the same time, based on the message zero-copy system, since different APPs share the same pbuf memory, the isolation between different APP processes is destroyed. When pbuf memory problems occur during cross-process operations, pbuf memory problems cannot be found. The APP and the specific location (for example, when there is a problem with the pbuf memory, it is impossible to determine which APP among the n APPs has the misoperation problem), that is, it is impossible to locate the first site of the problem, resulting in a long service recovery period.

为了解决上述问题,本发明实施例提出了一种共享内存管理方法,通过设置pbuf内存的读写操作属性,以在pbuf内存发生误操作时,获取到产生该pbuf内存误操作的内存误操作现场,增强报文零拷贝系统可靠性。In order to solve the above problems, the embodiment of the present invention proposes a shared memory management method. By setting the read and write operation attributes of the pbuf memory, when a misoperation occurs in the pbuf memory, the memory misoperation site where the pbuf memory misoperation occurs can be obtained. , to enhance the reliability of the message zero-copy system.

下面对本发明实施例进行详细说明。参见图5,图5是本发明实施例提供的一种共享内存管理方法的流程示意图,该共享内存管理方法应用于图4所示的零拷贝系统,该报文零拷贝系统运行于操作系统,如图5所示,该方法可以包括以下步骤:The embodiments of the present invention will be described in detail below. Referring to FIG. 5, FIG. 5 is a schematic flowchart of a shared memory management method provided by an embodiment of the present invention. The shared memory management method is applied to the zero-copy system shown in FIG. 4, and the message zero-copy system runs on the operating system. As shown in Figure 5, the method may include the following steps:

S501、APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读,所述操作系统记录所述APP对所述第一pbuf内存的读写操作属性。S501, any application program APP in the APPs sets the read and write operation attribute of the APP to the first pbuf memory to be read-only at the current moment, and the operating system records the reading of the APP to the first pbuf memory Write operation attributes.

在本发明实施例中,该至少两个应用程序为图4所示的APPs,该至少两个应用程序中的任一应用程序APP可以为APP1至APPn间的任一应用程序,例如,APP1,APP2,APPn。In the embodiment of the present invention, the at least two application programs are APPs shown in FIG. 4 , and any application program APP in the at least two application programs can be any application program between APP1 to APPn, for example, APP1, APP2, APPn.

其中,第一pbuf内存的读写操作属性是指为了对共享内存第一pbuf进行管理,防止多个应用程序同时对第一pbuf进行写操作而产生内存问题,由各APP所设置的该APP对第一pbuf在某时刻所应当执行的读写操作,从而当APP对第一pbuf内存执行了读写操作属性以外的操作时,操作系统则认为是内存误操作。Among them, the read and write operation attribute of the first pbuf memory means that in order to manage the first pbuf of the shared memory and prevent multiple applications from writing the first pbuf at the same time to cause memory problems, the APP set by each APP The read and write operations that the first pbuf should perform at a certain moment, so when the APP performs operations other than the read and write operation attributes on the first pbuf memory, the operating system considers it a memory misoperation.

在本发明实施例中,该读写操作属性包括只读、读写、以及只写。当设置APP对第一pbuf内存的读写操作属性为只读时,而此时APP对第一pbuf内存执行了写操作,此时操作系统认为APP对第一pbuf内存误操作;当设置APP对第一pbuf内存为读写时,也即此时APP对第一pbuf内存执行读操作或者写操作,操作系统均不会监控为内存误操作;当设置APP对第一pbuf内存为只写时,从而此时当APP对第一pbuf内存执行了读操作,操作系统认为APP对第一pbuf内存误操作。值得说明的是,对于读写操作属性为读写时,也可进一步在APP对第一pbuf内存执行读操作的情况下,确定此时的读写操作属性为只读,在APP对第一pbuf内存执行写操作的情况下,确定此时的读写操作属性为只写。In the embodiment of the present invention, the read and write operation attributes include read only, read and write, and write only. When the read and write operation attribute of the APP to the first pbuf memory is set to read-only, and the APP performs a write operation on the first pbuf memory at this time, the operating system thinks that the APP misoperated the first pbuf memory; when setting the APP to the first pbuf memory When the first pbuf memory is read and written, that is, the APP performs a read or write operation on the first pbuf memory at this time, the operating system will not monitor it as a memory misoperation; when setting the APP to the first pbuf memory as write-only, Therefore, at this time, when the APP performs a read operation on the first pbuf memory, the operating system thinks that the APP misoperated on the first pbuf memory. It is worth noting that when the attribute of the read and write operation is read and write, it can also be determined that the attribute of the read and write operation at this time is read-only when the APP performs a read operation on the first pbuf memory. When the memory performs a write operation, it is determined that the attribute of the read and write operation at this time is write-only.

可选地,在本发明的一个实施例中,当APP通过第一pbuf内存接收到报文并进行处理时,此时该APP设置对第一pbuf内存的读写操作属性为读写,而在其它时刻APP对该第一pbuf内存的读写操作属性为只读,例如,当APP未接收到报文时,或者当APP将报文处理完毕并发送至其它APP后,APP对该第一pbuf内存的读写操作属性均为只读。Optionally, in one embodiment of the present invention, when the APP receives and processes the message through the first pbuf memory, the APP sets the read and write operation attribute of the first pbuf memory to read and write, and in At other times, the APP's read and write operation attribute of the first pbuf memory is read-only. The attributes of read and write operations of the memory are read-only.

具体地,在本发明的一个实施例中,当APP通过第一pbuf内存接收到预设报文并处理时,此时该APP将对该第一pbuf内存的读写操作属性设置为读写,而其它APP对该第一pbuf内存的读写操作属性为只读,当APP将该预设报文发送给其它APP后,此时将收回该写操作属性,也即此时APP对该预设报文的读写操作属性将重设置为只读。当各APP设置好对第一pbuf内存的读写操作属性后,后续该零拷贝系统所运行的操作系统监控到存在APP对第一pbuf内存的误操作时,将发出pbuf内存误用通知消息,以提示用户第一pbuf内存出现问题,从而通过该方式可以实现对第一pbuf内存的管理。Specifically, in one embodiment of the present invention, when the APP receives and processes the preset message through the first pbuf memory, the APP sets the read and write operation attribute of the first pbuf memory to read and write. However, the read and write operation attribute of other APPs to the first pbuf memory is read-only. When the APP sends the preset message to other APPs, the write operation attribute will be withdrawn at this time, that is, the APP will take back the preset message at this time. The read and write operation attribute of the message will be reset to read only. After each APP has set the read and write operation attributes for the first pbuf memory, and the operating system running on the zero-copy system monitors the misoperation of the first pbuf memory by the APP, it will send a pbuf memory misuse notification message. To prompt the user that there is a problem with the first pbuf memory, so that the management of the first pbuf memory can be realized in this way.

举例说明,在本发明的一个示例中,具体参见图6,图6是本发明实施例提供的一种APP进程间第一pbuf内存管理流程示意图。在报文在APP1、APP2以及APP3之间进行转发的情况下,当APP1在时刻1通过第一pbuf内存接收到报文并进行处理,此时APP1对第一pbuf内存的读写操作属性设置为读写;当APP1将报文发送至APP2进程后,APP2在时刻2接收到该报文,此时APP2对第一pbuf内存的读写操作属性将设置为读写,而此时APP1将收回第一pbuf内存的写操作,也即此时APP1对第一pbuf内存的读写操作属性将为只读。在这两个时刻,APP3未对报文进行处理,所以APP3对该第一pbuf内存的读写操作属性一直设置为只读。For example, in an example of the present invention, please refer to FIG. 6 for details. FIG. 6 is a schematic diagram of a first pbuf memory management process between APP processes provided by an embodiment of the present invention. In the case that the message is forwarded between APP1, APP2 and APP3, when APP1 receives the message through the first pbuf memory at time 1 and processes it, the read and write operation attribute of APP1 to the first pbuf memory is set to Read and write; when APP1 sends the message to the APP2 process, APP2 receives the message at time 2, at this time APP2 will set the read and write operation attribute of the first pbuf memory to read and write, and at this time APP1 will withdraw the first pbuf memory A write operation of the pbuf memory, that is, at this time, the read and write operation attribute of APP1 to the first pbuf memory will be read-only. At these two moments, APP3 does not process the message, so APP3 always sets the read and write operation attribute of the first pbuf memory as read-only.

更进一步地,参见图7,图7是本发明实施例提供的一种报文零拷贝流程以及第一pbuf内存管理流程示意图。当利用该报文零拷贝系统进行零拷贝报文转发时,首先APP1、APP2和APP3将对第一pbuf内存的读写操作属性均设置为只读。APP1往第一网卡队列填充DMA地址,也即第一pbuf内存地址,第一网卡将报文收包之后将该报文写入第一网卡队列中,然后APP1使用第一pbuf内存从第一网卡队列中收包该报文,此时APP1将对该第一pbuf内存的读写操作属性设置为读写;当APP1对第一pbuf内存中的报文处理完毕后,将该报文发送至APP2,此时APP1收回该第一pbuf内存的写操作属性,也即此时APP1进程对该第一pbuf内存的读写操作属性为只读,而此时APP2将设置对该第一pbuf内存的读写操作属性为读写;当APP2对该报文处理完毕后,再依次发往下一个APP,各APP的第一pbuf内存的读写操作属性设置方式同上步骤。当报文转发到APPn后,APPn对第一pbuf内存的读写操作属性为读写,当APPn对报文进行处理后,APPn将该报文发送给APP1,并收回写操作属性。此时APP1接收到该报文后,APP1重新设置对第一pbuf内存的读写操作属性为读写,最后APP1将报文发送至第二网卡队列,然后第二网卡将报文第二网卡队列中取出,完成整个网卡收发包流程。需要说明的是,在图7所示的流程中,由APP1统一管理网卡的收发包。Further, referring to FIG. 7 , FIG. 7 is a schematic diagram of a message zero-copy process and a first pbuf memory management process provided by an embodiment of the present invention. When the message zero-copy system is used for zero-copy message forwarding, first APP1, APP2 and APP3 set the read and write operation attributes of the first pbuf memory as read-only. APP1 fills the DMA address to the first network card queue, that is, the first pbuf memory address, and the first network card writes the message into the first network card queue after receiving the packet, and then APP1 uses the first pbuf memory from the first network card The message is received in the queue, at this time APP1 will set the read and write operation attribute of the first pbuf memory to read and write; when APP1 finishes processing the message in the first pbuf memory, send the message to APP2 At this time, APP1 takes back the write operation attribute of the first pbuf memory, that is, the read and write operation attribute of the APP1 process to the first pbuf memory is read-only at this time, and at this time APP2 will set the read and write operation attribute of the first pbuf memory The write operation attribute is read and write; after APP2 finishes processing the message, it will send it to the next APP in turn, and the setting method of the read and write operation attribute of the first pbuf memory of each APP is the same as the above steps. After the message is forwarded to APPn, the read and write operation attribute of APPn to the first pbuf memory is read and write. After APPn processes the message, APPn sends the message to APP1 and withdraws the write operation attribute. At this time, after APP1 receives the message, APP1 resets the read and write operation attribute of the first pbuf memory to read and write, and finally APP1 sends the message to the second network card queue, and then the second network card sends the message to the second network card queue Take it out to complete the entire network card sending and receiving packet process. It should be noted that, in the process shown in FIG. 7 , APP1 uniformly manages sending and receiving packets of the network card.

具体地,在本发明的一个实施例中,当各APP运行在Linux操作系统时,Linux操作系统包括mprotect内存管理接口,该mprotect内存管理接口用于设置所述第一pbuf内存的读写操作属性,也即当APP在处理第一pbuf内存报文时,APP通过调用mprotect内存管理接口设置APP对该第一pbuf内存的读写操作属性为读写,其它APP则通过调用mprotect内存管理接口设置对该第一pbuf的读写操作属性为只读,此时Linux操作系统将记录APP对第一pbuf内存的读写操作属性。一旦读写操作属性为只读的APP对第一pbuf内存进行写操作时,Linux系统可以立即侦听到该内存误操作,然后Linux操作系统产生段错误信号segmentfault,用于提示APP对第一pbuf的内存进行了误操作了,然后该APP即可通过该错误信息提示打印出调用栈信息来确定异常的上下文第一现场。可以理解,通过调用Linux操作系统的mprotect内存管理接口可以方便地在Linux操作系统下对第一pbuf内存的读写操作属性进行设置。Specifically, in one embodiment of the present invention, when each APP runs on the Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to set the read and write operation attributes of the first pbuf memory , that is, when the APP is processing the first pbuf memory message, the APP sets the read and write operation attribute of the APP to the first pbuf memory as read and write by calling the mprotect memory management interface, and other APPs call the mprotect memory management interface to set the right The read and write operation attribute of the first pbuf is read-only, and at this time, the Linux operating system will record the read and write operation attribute of the APP to the memory of the first pbuf. Once an APP whose read-write operation attribute is read-only writes to the first pbuf memory, the Linux system can immediately detect the misoperation of the memory, and then the Linux operating system generates a segment fault signal segmentfault, which is used to prompt the APP to write to the first pbuf If the memory of the device is misoperated, then the APP can prompt and print out the call stack information through the error message to determine the first scene of the abnormal context. It can be understood that by calling the mprotect memory management interface of the Linux operating system, the read and write operation attributes of the first pbuf memory can be conveniently set under the Linux operating system.

可选地,在本发明的一个实施例中,由于mprotect内存管理接口是基于页表进行管理的,也即同一页表上所对应内存的读写操作属性将同时进行设置,具体地,各页表包括读写操作属性标识,从而操作系统记录APP对第一pbuf内存的读写操作属性为只读时,可以通过在该页表上的读写操作属性标识上记录APP对第一pbuf内存的读写操作属性为只读。由于各页表对应一个读写操作属性标识,也即各页表通过该读写操作属性标识来统一设置该页表所对应pbuf内存的读写操作属性。故当基于mprotect内存读写操作管理机制进行内存读写操作管理时,为了使在由mprotect内存读写操作管理机制对第一pbuf内存的读写操作属性进行设置时,不至于干扰到该页表上的其它内存的读写操作属性,所以需要使该页表与第一pbuf内存存在唯一的对应关系,也即该第一pbuf内存对应的一个页表或多个页表由mprotect内存读写操作管理机制独立进行控制,此时与该第一pbuf内存对应的一个或多个页表的读写操作属性标识将同时进行设置为只读或者读写。Optionally, in one embodiment of the present invention, since the mprotect memory management interface is managed based on the page table, that is, the read and write operation attributes of the corresponding memory on the same page table will be set at the same time, specifically, each page The table includes the read and write operation attribute identification, so that when the operating system records that the APP's read and write operation attribute of the first pbuf memory is read-only, it can record the APP's operation of the first pbuf memory on the read and write operation attribute identification on the page table. The read and write operation attribute is read-only. Since each page table corresponds to a read and write operation attribute identifier, that is, each page table uniformly sets the read and write operation attributes of the pbuf memory corresponding to the page table through the read and write operation attribute identifier. Therefore, when the memory read and write operation management is performed based on the mprotect memory read and write operation management mechanism, in order not to interfere with the page table when the mprotect memory read and write operation management mechanism sets the read and write operation attributes of the first pbuf memory The read and write operation attributes of other memory on the network, so it is necessary to have a unique correspondence between the page table and the first pbuf memory, that is, a page table or multiple page tables corresponding to the first pbuf memory are read and written by mprotect memory The management mechanism controls independently. At this time, the read and write operation attribute identifiers of one or more page tables corresponding to the first pbuf memory will be set to read-only or read-write at the same time.

可选地,在本发明的一个实施例中,该页表可以为普通的4K比特的页表,例如第一pbuf内存大小为4K比特以内大小时,该第一pbuf内存对应一个页表,此时mprotect内存读写操作管理机制通过独立设置控制该页表以对第一pbuf内存的读写操作属性进行独立控制,具体地,可以通过设置该页表的读写操作属性标识来设置各APP对该第一pbuf的读写操作属性,或者如果第一pbuf内存大小为8K比特时,该第一pbuf内存对应连续两个页表,此时mprotect内存读写操作管理机制可通过同时控制该两个页表以对第一pbuf内存的读写操作属性进行独立控制,具体地,可以通过同时设置该2个页表的读写操作属性标识为相同(同时为只读或者同时为读写)来独立控制第一pbuf内存的读写操作属性。可以理解,通过使得第一pbuf内存独立于其它pbuf内存与页表唯一对应,使得基于页表管理的mprotect内存读写操作管理机制可独立对该第一pbuf内存进行控制。Optionally, in one embodiment of the present invention, the page table can be a common 4K-bit page table. For example, when the size of the first pbuf memory is within 4K bits, the first pbuf memory corresponds to a page table. When the mprotect memory read and write operation management mechanism independently controls the page table to independently control the read and write operation attributes of the first pbuf memory, specifically, each APP pair can be set by setting the read and write operation attribute identifier of the page table. The read and write operation attributes of the first pbuf, or if the size of the first pbuf memory is 8K bits, the first pbuf memory corresponds to two consecutive page tables. At this time, the mprotect memory read and write operation management mechanism can control the two pages at the same time. The page table is used to independently control the read and write operation attributes of the first pbuf memory. Specifically, the read and write operation attributes of the two page tables can be marked as the same (read-only or read-write at the same time) to independently control the two page tables. Controls the read and write operation properties of the first pbuf memory. It can be understood that by making the first pbuf memory independent from other pbuf memories and uniquely corresponding to the page table, the mprotect memory read and write operation management mechanism based on page table management can independently control the first pbuf memory.

可选地,在本发明的一个实施例中,所述报文零拷贝系统还包括第二pbuf内存,所述APPs的共享内存还包括第二pbuf内存,报文零拷贝系统在使用共享内存进行零拷贝时,APP可在预设时刻确定所述第一pbuf内存为所述APPs的所述共享内存,所述APP在预设时刻之外确定所述第二pbuf内存为所述APPs的共享内存,所述第一pbuf内存为小页内存,所述第二pbuf内存为大页内存,所述第一pbuf内存与所述一个或多个页表存在唯一对应关系。Optionally, in one embodiment of the present invention, the message zero-copy system also includes a second pbuf memory, and the shared memory of APPs also includes a second pbuf memory, and the message zero-copy system uses the shared memory to perform In the case of zero copy, the APP may determine the first pbuf memory as the shared memory of the APPs at a preset time, and the APP determines the second pbuf memory as the shared memory of the APPs outside the preset time , the first pbuf memory is a small page memory, the second pbuf memory is a large page memory, and there is a unique correspondence between the first pbuf memory and the one or more page tables.

其中,大页内存是指通过增加页表大小来减少页表数量,提高系统性能,在大页内存下,每个页表大小可以1G比特或更大,而如果APPs的共享内存大小仅4K比特时,此时每个页表将对应多个pbuf内存。小页内存是与大页内存相对的概念,小页内存下,每个页表的大小可为普通4K比特大小的页表或8K比特大小的页表。Among them, large page memory refers to reducing the number of page tables and improving system performance by increasing the size of page tables. Under large page memory, the size of each page table can be 1G bits or larger, and if the shared memory size of APPs is only 4K bits At this time, each page table will correspond to multiple pbuf memories. Small page memory is a concept opposite to large page memory. Under small page memory, the size of each page table can be a normal 4K-bit page table or an 8K-bit page table.

可选地,在本发明的一个实施例中,预设时刻是指APP基于预设规则确定的,例如,可以是基于预设采样周期确定的,从而APP在预设采样周期对应的预设时刻使用第一pbuf内存,在预设采样周期之外的时刻使用第二pbuf内存;又例如,也可以是在报文零拷贝系统即将处理的报文的类型是预设类型时,使用第一pbuf内存保存该报文(即确定当前时刻为预设时刻),在报文零拷贝系统即将处理的报文的类型是其它类型时,使用第二pbuf内存保存该报文(即确定当前时刻为预设时刻之外),从而可基于报文零拷贝系统当前将处理的报文类型确定预设时刻。Optionally, in one embodiment of the present invention, the preset time means that the APP determines based on a preset rule, for example, it may be determined based on a preset sampling period, so that the APP at the preset time corresponding to the preset sampling period Use the first pbuf memory, and use the second pbuf memory at a time other than the preset sampling period; for another example, when the type of the message to be processed by the message zero-copy system is the preset type, use the first pbuf The memory saves the message (that is, it is determined that the current time is the preset time), and when the type of the message to be processed by the message zero-copy system is other types, the second pbuf memory is used to save the message (that is, it is determined that the current time is the preset time). In addition to setting the time), the preset time can be determined based on the type of message that the message zero-copy system will currently process.

具体地,在本发明的一个实施例中,由于在4K比特页表下,系统性能比较低,而如果将该pbuf内存设置为大页内存,此时将存在多个pbuf内存对应同一个页表的情况,如果对当前的pbuf内存的读写操作进行管理时,将错误地管理到同一页表的其它pbuf内存,造成系统功能异常。所以,在保证系统性能与防止系统功能异常的情况下,可以通过增加第二pbuf内存,设置该第二pbuf内存为大页内存,从而APP可通过第一pbuf内存或第二pbuf内存接收并处理预设报文,提升系统性能。例如可参见图8-a,图8-a是本发明实施例提供的另一种报文零拷贝系统的架构示意图。但由于第二pbuf内存为大页内存,Linux操作系统并不对该第二pbuf内存进行读写操作管理,只对第一pbuf内存进行读写操作管理。可设置第一pbuf内存的预设采样周期,APP进程在预设采样周期对应的采样时刻填充第一pbuf内存,然后通过对该第一pbuf内存进行读写操作管理,保证系统可靠性。例如,在设置第一pbuf内存的预设采样周期为1000的情况下,每填充999个第二pbuf内存,填充一个第一pbuf内存,Linux对该第一pbuf内存进行读写操作管理以保证系统可靠性,同时由于在1000个pbuf内存中有999个采用的是大页内存的第二pbuf内存,所以可保证系统的高性能。Specifically, in one embodiment of the present invention, since the system performance is relatively low under the 4K-bit page table, if the pbuf memory is set as a large page memory, there will be multiple pbuf memories corresponding to the same page table In some cases, if the read and write operations of the current pbuf memory are managed, other pbuf memories in the same page table will be managed by mistake, resulting in abnormal system functions. Therefore, in the case of ensuring system performance and preventing abnormal system functions, you can increase the second pbuf memory and set the second pbuf memory as large page memory, so that APP can receive and process through the first pbuf memory or the second pbuf memory Preset messages to improve system performance. For example, refer to FIG. 8-a, which is a schematic structural diagram of another packet zero-copy system provided by an embodiment of the present invention. However, since the second pbuf memory is a large page memory, the Linux operating system does not manage read and write operations on the second pbuf memory, but only manages read and write operations on the first pbuf memory. The preset sampling period of the first pbuf memory can be set, and the APP process fills the first pbuf memory at the sampling time corresponding to the preset sampling period, and then manages the read and write operations of the first pbuf memory to ensure system reliability. For example, when the preset sampling period of the first pbuf memory is set to 1000, every time 999 second pbuf memories are filled, one first pbuf memory is filled, and Linux performs read and write operation management on the first pbuf memory to ensure that the system Reliability, at the same time, because 999 of the 1000 pbuf memories use the second pbuf memory of the large page memory, the high performance of the system can be guaranteed.

值得说明的是,通过设置APP使用第一pbuf内存的预设时刻,当该预设时刻的频率越小时,则说明进行pbuf内存监控的频率越小,所以此时系统可靠性相对较小,而此时使用大页内存第二pbuf内存进行填充的相对次数多,系统的性能提升较大;而预设时刻的频率越大,则说明进行pbuf内存监控的频率越大,所以此时系统的可靠性相对较大,而此时使用大页内存第二pbuf内存进行填充的相对次数小,系统的性能提升较小。故可以根据需求,权衡系统的性能提升与可靠性设置该预设时刻。It is worth noting that by setting the preset time when the APP uses the first pbuf memory, the lower the frequency of the preset time is, the lower the frequency of pbuf memory monitoring is, so the system reliability is relatively low at this time, and At this time, the relative frequency of using the large page memory and the second pbuf memory for filling is relatively large, and the performance of the system is greatly improved; and the higher the frequency of the preset time, the greater the frequency of pbuf memory monitoring, so the reliability of the system at this time The performance is relatively large, and at this time, the relative times of filling with the second pbuf memory of the huge page memory is small, and the performance improvement of the system is small. Therefore, the preset time can be set according to the requirements and by weighing the performance improvement and reliability of the system.

更进一步地,参见图8-b,图8-b是本发明实施例提供的另一种报文零拷贝流程以及pbuf内存管理流程示意图。图8-b所示的流程为基于图8-a所示的零报文拷贝系统执行的,也即包括两个pbuf内存:第一pbuf内存与第二pbuf内存。由于第一pbuf内存与页表一一对应,第二pbuf内存为大页内存,所以设置预设采样周期对第一pbuf内存进行采样填充,并仅使用mprotect内存读写操作管理机制对第一pbuf内存进行读写操作管理,对于第二pbuf内存则不进行内存读写操作管理。并且图8-b所示的流程由APP1统一管理网卡的收发包。如图8-b所示,首先APP1、APP2和APP3将第一pbuf内存的读写操作属性均设置为只读。APP1往第一网卡队列中填充DAM地址时,当不为预设采样周期时,使用第二pbuf内存的DMA地址填充第一网卡队列,从而后续APP1通过第二pbuf内存从第一网卡队列读取报文并处理;当为预设采样周期时,使用第一pbuf内存的DMA地址填充第一网卡队列,从而当APP1通过第一pbuf内存从第一网卡队列读取报文后,由于第一pbuf内存为需要进行读写操作属性设置的采样pbuf内存,所以APP1设置第一pbuf内存的读写操作属性为读写,并处理报文,当处理完报文后,APP1收回第一pbuf内存的写操作属性,并将该报文发往APP2。Further, referring to FIG. 8-b, FIG. 8-b is a schematic diagram of another packet zero-copy process and pbuf memory management process provided by the embodiment of the present invention. The process shown in Figure 8-b is executed based on the zero packet copy system shown in Figure 8-a, that is, it includes two pbuf memories: the first pbuf memory and the second pbuf memory. Since the first pbuf memory has a one-to-one correspondence with the page table, and the second pbuf memory is a large page memory, the preset sampling cycle is set to sample and fill the first pbuf memory, and only the mprotect memory read and write operation management mechanism is used to control the first pbuf The memory performs read and write operation management, and the second pbuf memory does not perform memory read and write operation management. And in the process shown in Figure 8-b, APP1 uniformly manages sending and receiving packets of the network card. As shown in Figure 8-b, first APP1, APP2 and APP3 set the read and write operation attributes of the first pbuf memory to read-only. When APP1 fills the DAM address in the first network card queue, when it is not the preset sampling period, use the DMA address of the second pbuf memory to fill the first network card queue, so that subsequent APP1 reads from the first network card queue through the second pbuf memory Messages are processed together; when the sampling period is preset, use the DMA address of the first pbuf memory to fill the first network card queue, so that when APP1 reads the message from the first network card queue through the first pbuf memory, due to the first pbuf The memory is the sampling pbuf memory that needs to be set for read and write operation attributes, so APP1 sets the read and write operation attribute of the first pbuf memory to read and write, and processes the message. After processing the message, APP1 takes back the write of the first pbuf memory Manipulate the attributes and send the message to APP2.

APP2收到APP1发送的报文时,判断该pbuf内存是否为采样第一pbuf内存,在判断为否的情况下,不进行读写操作属性设置直接处理,在判断为是的情况下,设置该第一pbuf内存的读写操作属性为读写,并处理报文,当处理完报文后,APP2收回第一pbuf内存的写操作属性,并将该报文发往APP3。When APP2 receives the message sent by APP1, it judges whether the pbuf memory is the first pbuf memory for sampling. The read and write operation attribute of the first pbuf memory is read and write, and the message is processed. After the message is processed, APP2 takes back the write operation attribute of the first pbuf memory, and sends the message to APP3.

APP3收到APP2发送的报文时,判断该pbuf内存是否为采样第一pbuf内存,在判断为否的情况下,不进行读写操作属性设置直接处理,在判断为是的情况下,设置该第一pbuf内存的读写操作属性为读写,并处理报文,当处理完报文后,APP3收回第一pbuf内存的读操作属性,并将该报文发往APP1。When APP3 receives the message sent by APP2, it judges whether the pbuf memory is the first pbuf memory for sampling. The read and write operation attribute of the first pbuf memory is read and write, and the message is processed. After processing the message, APP3 takes back the read operation attribute of the first pbuf memory, and sends the message to APP1.

APP1收到该报文后,在判断为第二pbuf内存的情况下,此时不进行读写操作属性设置,处理完报文后将报文发送至第二网卡队列并回收该第二pbuf内存至pbuf内存池。在判断为第一pbuf内存的情况下,此时设置该第一pbuf内存的读写操作属性为读写,并处理报文,然后再将报文发送到第二网卡队列,以及从第二网卡队列中回收该第一pbuf内存至pbuf内存池,同时收回第一pbuf内存的写操作属性。从而完成整个报文零拷贝过程。After APP1 receives the message, if it is judged to be the second pbuf memory, it does not set the read and write operation attributes at this time. After processing the message, it sends the message to the second network card queue and reclaims the second pbuf memory To the pbuf memory pool. In the case of judging that it is the first pbuf memory, set the read and write operation attribute of the first pbuf memory to read and write at this time, and process the message, and then send the message to the second network card queue, and from the second network card Reclaim the first pbuf memory in the queue to the pbuf memory pool, and reclaim the write operation attribute of the first pbuf memory at the same time. In this way, the entire message zero-copy process is completed.

S502、在操作系统监控到APP对第一pbuf内存进行写操作的情况下,操作系统向APP发送pbuf内存误操作通知消息,此时APP接收到操作系统发送的pbuf内存误操作通知消息,并获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息,所述pbuf内存误操作通知消息用于指示所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。S502. When the operating system monitors that the APP performs a write operation on the first pbuf memory, the operating system sends a pbuf memory misoperation notification message to the APP. At this time, the APP receives the pbuf memory misoperation notification message sent by the operating system, and obtains The pbuf memory misoperation site information in the pbuf memory misoperation notification message, the pbuf memory misoperation notification message is used to instruct the APP to perform a write operation on the first pbuf memory and the specific location of the write operation.

可选地,在本发明的一个实施例中,该pbuf内存误操作现场信息包括调用栈信息。Optionally, in an embodiment of the present invention, the pbuf memory misoperation context information includes call stack information.

具体地,在本发明的一个实施例中,当操作系统监测到第一pbuf内存为只读时,APP对该第一pbuf内存进行了写操作,然后操作系统将向该APP发送pbuf内存误操作通知消息,例如,该pbuf内存误操作通知消息可为段错误信号segment fault,然后APP通过该段错误信号segmentfault打印出来调用栈信息,从而进一步地,该APP可以根据该调用栈信息确定导致内存错误的具体位置,以及使得APP可以根据该具体位置修复导致内存错误的问题。Specifically, in one embodiment of the present invention, when the operating system detects that the first pbuf memory is read-only, the APP writes to the first pbuf memory, and then the operating system will send a pbuf memory misoperation to the APP Notification message, for example, the pbuf memory misoperation notification message can be a segment fault signal segment fault, and then the APP prints out the call stack information through the segment fault signal segment fault, so that further, the APP can determine that the memory error is caused according to the call stack information The specific location, and the APP can fix the problem that causes the memory error according to the specific location.

可选地,在本发明的一个实施例中,所述第一pbuf内存还用于缓存轨迹标识,所述APP接收到pbuf内存误操作通知消息后,APP还可以通过该第一pbuf内存的轨迹标识记录第一pbuf内存的轨迹点信息,该轨迹点信息包括应用程序APP标识、应用程序当前进程标识以及当前时刻,其中,APP标识用于指示在某个时刻使用该第一pbuf内存的APP,应用程序当前进程标识指示在某个时刻使用该第一pbuf内存的APP进程。Optionally, in an embodiment of the present invention, the first pbuf memory is also used to cache the trace identifier, and after the APP receives the pbuf memory misoperation notification message, the APP can also pass the trace of the first pbuf memory Identify and record the track point information of the first pbuf memory, the track point information includes the application program APP identification, the application program current process identification and the current time, wherein the APP identification is used to indicate the APP that uses the first pbuf memory at a certain time, The current process identifier of the application program indicates the APP process using the first pbuf memory at a certain moment.

在本发明实施例中,轨迹点信息是指使用该第一pbuf内存的APP的相关信息,从而将使用该第一pbuf的APP的相关信息按时间顺序衔接则构成第一pbuf内存的轨迹点信息。In the embodiment of the present invention, the track point information refers to the relevant information of the APP using the first pbuf memory, so that the relevant information of the APP using the first pbuf is connected in chronological order to form the track point information of the first pbuf memory .

具体地,在本发明实施例中,可以通过轨迹标识来记录轨迹点信息,其中,该轨迹标识可以是指第一pbuf内存中用于保存报文的内存空间,从而可以利用该剩余内存空间来记录第一pbuf的轨迹点信息。Specifically, in the embodiment of the present invention, the track point information can be recorded through the track mark, wherein the track mark can refer to the memory space used to save the message in the first pbuf memory, so that the remaining memory space can be used to Record the track point information of the first pbuf.

举例说明,在本发明的一个示例中,参见图4。当APP1进程在第一时刻接收并处理第一pbuf内存报文时,APP1进程在第一pbuf内存的剩余内存空间中记录此时的轨迹点信息,也即APP1标识、APP2进程标识以及第一时刻;然后当APP1将第一内存报文发送至APP2后,APP2进程在第二时刻接收并处理第一pbuf内存报文时,APP2进程再更一步在该第一pbuf内存的剩余空间中记录此时的轨迹点信息,也即APP2标识、APP2进程标识以及第二时刻;依次记录第一pbuf内存所经过的所有的轨迹点信息,从而在APPn当中将包括第一pbuf内存从APP1到APPn的所有轨迹点信息,将该所有轨迹点信息根据时间先后即可得到第一pbuf内存所经过的轨迹。更进一步地,还可以记录零拷贝系统中的第一pbuf内存经过第一网卡队列以及第二网卡队列的轨迹。For illustration, see FIG. 4 in one example of the present invention. When the APP1 process receives and processes the first pbuf memory message at the first moment, the APP1 process records the track point information at this time in the remaining memory space of the first pbuf memory, that is, the APP1 ID, the APP2 process ID, and the first moment ; Then after APP1 sends the first memory message to APP2, when the APP2 process receives and processes the first pbuf memory message at the second moment, the APP2 process takes another step to record this time in the remaining space of the first pbuf memory track point information, that is, APP2 ID, APP2 process ID, and the second moment; record all the track point information of the first pbuf memory in turn, so that all tracks of the first pbuf memory from APP1 to APPn will be included in APPn Point information, all the track point information can be obtained according to the time sequence of the track of the first pbuf memory. Furthermore, the track of the first pbuf memory passing through the first network card queue and the second network card queue in the zero-copy system can also be recorded.

可以理解,当记录到第一pbuf的轨迹点信息后,则可以当在某个APP发生误用写操作时,可以通过在第一pbuf的轨迹点信息确定的第一pbuf的轨迹,来进一步确定该第一pbuf所经过的上游APP,以进一步提高系统可靠性。It can be understood that after the track point information of the first pbuf is recorded, when a write operation is misused in an APP, the track of the first pbuf determined by the track point information of the first pbuf can be further determined The upstream APP that the first pbuf passes through to further improve system reliability.

S503、APP基于所述pbuf内存误操作现场信息确定所述APP对所述pbuf内存进行写操作的内存误操作现场。S503. The APP determines a memory misoperation site where the APP performs a write operation on the pbuf memory based on the pbuf memory misoperation site information.

更进一步地,在本发明的一个实施例中,可以基于该内存误操作现场进行业务恢复。Furthermore, in an embodiment of the present invention, service recovery can be performed on-site based on the memory misoperation.

举例说明,在本发明的一个示例中,在报文零拷贝系统工作时,并且第一pbuf内存发送至APP3,此时APP2通过调用mprotect内存管理接口设置APP2对第一pbuf内存的读写操作属性为只读,APP2将接收到系统发送的pbuf内存误操作通知消息,例如段错误信号,然后APP2基于该段错误信号打印调用栈信息,并由APP2基于该调用栈信息确定产生对第一pbuf进行写操作的位置,也即产生误写操作的代码位置,从而可使得APP基于该位置修复该问题,防止后续APP2对第一pbuf内存进行误写操作。通过设置各APP对第一pbuf内存的读写操作属性,从而在第一pbuf内存运行至APP3时,在APP2对该第一pbuf内存进行了写操作的情况下,系统能通过pbuf内存误操作通知消息提醒APP2,以使得APP2可以及时定位并修改该第一pbuf内存问题,保证系统可靠性,并且也使得此刻正操作第一pbuf内存的APP3不至于浪费资源去进行pbuf内存问题排查,也进一步提高了系统性能。For example, in an example of the present invention, when the message zero-copy system is working, and the first pbuf memory is sent to APP3, at this time APP2 sets the read and write operation attributes of APP2 to the first pbuf memory by calling the mprotect memory management interface It is read-only, APP2 will receive the pbuf memory misoperation notification message sent by the system, such as a segment error signal, and then APP2 will print the call stack information based on the segment error signal, and APP2 will determine the first pbuf based on the call stack information. The location of the write operation, that is, the code location where the erroneous write operation occurs, so that the APP can repair the problem based on this location, and prevent the subsequent APP2 from performing an erroneous write operation on the first pbuf memory. By setting the read and write operation attributes of each APP to the first pbuf memory, when the first pbuf memory runs to APP3, in the case that APP2 performs a write operation on the first pbuf memory, the system can notify through pbuf memory misoperation The message reminds APP2 so that APP2 can locate and modify the first pbuf memory problem in time to ensure system reliability, and also prevent APP3, which is operating the first pbuf memory at the moment, from wasting resources to troubleshoot pbuf memory problems, and further improve system performance.

更进一步地,APP可在对第一pbuf内存进行误写操作时,记录下APP对第一pbuf内存进行写操作之前该第一pbuf内存相应位置所存储的数值,从而当APP对第一pbuf内存进行误写时,可将该第一pbuf内存相应位置的数值恢复至误写之前的数值,以进一步提高系统可靠性与系统性能,也提高了系统鲁棒性。Furthermore, when the APP performs a wrong write operation on the first pbuf memory, it can record the value stored in the corresponding position of the first pbuf memory before the APP writes to the first pbuf memory, so that when the APP writes to the first pbuf memory When writing by mistake, the value of the corresponding position of the first pbuf memory can be restored to the value before the wrong write, so as to further improve system reliability and system performance, and also improve system robustness.

更进一步地,通过记录第一pbuf内存的轨迹点信息,在确定APP对第一pbuf内存进行写操作的内存误操作现场后,可进一步通过该APP的上游APP来进行pbuf内存问题排查,进一步提高系统可靠性。Furthermore, by recording the track point information of the first pbuf memory, after determining the memory misoperation site where the APP writes to the first pbuf memory, you can further troubleshoot the pbuf memory problem through the upstream APP of the APP to further improve System reliability.

值得说明的是,上述方法实施例不仅可用于当APP对第一pbuf内存的读写操作属性设置为只读时,对第一pbuf内存进行内存误操作的监控。当APP对第一pbuf内存的读写操作属性设置为只写,以及当APP对第一pbuf内存的读写操作属性设置为读写时的读状态以及写状态时,同样可使用上述方式对第一pbuf内存进行内存误操作的监控,具体地,可根据读写操作属性所对应的操作范围对上述方法的使用进行适应调整。It is worth noting that the above method embodiment can not only be used to monitor the memory misoperation of the first pbuf memory when the read and write operation attribute of the APP to the first pbuf memory is set to read-only. When the APP's read and write operation attribute of the first pbuf memory is set to write-only, and when the APP's read and write operation attribute of the first pbuf memory is set to the read state and write state when reading and writing, the above method can also be used for the first pbuf memory A pbuf memory is used to monitor memory misoperations. Specifically, the use of the above method can be adapted and adjusted according to the operation range corresponding to the read and write operation attributes.

值得说明的是,上述步骤S501、步骤S502和步骤S503在实际执行时也可以同步并行执行,本发明实施例并不对其执行顺序进行严格限制。It is worth noting that the above step S501, step S502 and step S503 may also be executed synchronously and in parallel during actual execution, and the embodiment of the present invention does not strictly limit the execution order thereof.

可以看出,本发明实施例的方案中,当运行于操作系统的零拷贝系统中由APPs共享第一pbuf内存时,该APPs中的任一APP设置该APP对第一pbuf内存的读写操作属性在当前时刻为只读时,操作系统记录该APP对第一pbuf内存的读写操作属性;然后在操作系统监控到该APP对第一pbuf内存进行写操作时,操作系统向该APP发送pbuf内存误操作通知消息,该APP接收到操作系统发送的pbuf内存误操作通知消息后,获取该pbuf内存误操作通知消息中的pbuf内存误操作现场信息,该pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作以及该写操作的具体位置;最后该APP再基于该pbuf内存误操作现场信息确定APP对第一pbuf内存进行写操作的内存误操作现场。从而实现在多个APP共享同一pbuf内存的情况下,当该共享pbuf内存出现内存误操作时,能快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性的同时能提高系统性能。It can be seen that, in the solution of the embodiment of the present invention, when the first pbuf memory is shared by APPs in the zero-copy system running on the operating system, any APP in the APPs sets the APP to read and write operations to the first pbuf memory When the attribute is read-only at the current moment, the operating system records the read and write operation attributes of the APP to the first pbuf memory; then when the operating system monitors that the APP performs a write operation on the first pbuf memory, the operating system sends the pbuf to the APP Memory misoperation notification message. After receiving the pbuf memory misoperation notification message sent by the operating system, the APP obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message. The pbuf memory misoperation notification message is used to remind all The APP performs a write operation on the first pbuf memory, the write operation, and the specific location of the write operation; finally, the APP determines the memory error of the APP’s write operation on the first pbuf memory based on the site information of the pbuf memory misoperation. Operation site. In this way, when multiple APPs share the same pbuf memory, when a memory misoperation occurs in the shared pbuf memory, the APP and the specific location that caused the pbuf memory misoperation can be quickly and accurately located, that is, the pbuf memory misoperation site can be determined , to improve system performance while ensuring system reliability.

更进一步地,可以基于该pbuf内存误操作现场进行业务恢复,更一步保障系统可靠性。Furthermore, service recovery can be performed on-site based on the misoperation of the pbuf memory, further ensuring system reliability.

参见图9,图9是本发明实施例提供的一种应用程序APP的结构示意图,用于实现本发明实施例公开的共享内存管理方法。其中,该APP应用于报文零拷贝系统中,所述报文零拷贝系统运行于操作系统上,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP。如图9所示,本发明实施例提供的一种APP包括:Referring to FIG. 9 , FIG. 9 is a schematic structural diagram of an application program APP provided by an embodiment of the present invention, which is used to implement the shared memory management method disclosed in the embodiment of the present invention. Wherein, the APP is applied in a message zero-copy system, and the message zero-copy system runs on an operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first packet cache pbuf Memory, the APP is any APP in the APPs. As shown in Figure 9, an APP provided by an embodiment of the present invention includes:

设置模块910、获取模块920以及确定模块930。A setting module 910 , an obtaining module 920 and a determining module 930 .

设置模块910,用于设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读。The setting module 910 is configured to set the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment.

获取模块920,用于在接收到所述操作系统发送的pbuf内存误操作通知消息的情况下,获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。The acquiring module 920 is configured to acquire the pbuf memory misuse site information in the pbuf memory misuse notification message in the case of receiving the pbuf memory misuse notification message sent by the operating system, the pbuf memory misuse notification message The message is used to remind the APP to perform a write operation on the first pbuf memory and a specific location of the write operation.

确定模块930,用于基于所述pbuf内存误操作现场信息确定所述APP对所述第一pbuf内存进行写操作的内存误操作现场。The determining module 930 is configured to determine a memory misoperation site where the APP performs a write operation on the first pbuf memory based on the pbuf memory misuse site information.

可选地,在本发明的一个实施例中,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被调用以设置所述第一pbuf内存的读写操作属性;所述设置模块910具体用于:Optionally, in an embodiment of the present invention, the operating system includes a Linux operating system, and the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called to set the first pbuf The read and write operation attributes of the memory; the setting module 910 is specifically used for:

通过调用所述mprotect内存管理接口设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读。Setting the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment by calling the mprotect memory management interface.

可选地,在本发明的一个实施例中,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the APP to the first pbuf memory based on one or more page tables .

可选地,在本发明的一个实施例中,所述报文零拷贝系统还包括第二pbuf内存,所述APPs共享所述第二pbuf内存,所述APP配置为在预设采样周期对应的采样时刻采样所述第一pbuf内存,所述APP配置为在所述采样时刻之外采样所述第二pbuf内存。Optionally, in an embodiment of the present invention, the message zero-copy system further includes a second pbuf memory, the APPs share the second pbuf memory, and the APP is configured to correspond to the preset sampling period The first pbuf memory is sampled at a sampling time, and the APP is configured to sample the second pbuf memory outside of the sampling time.

可选地,在本发明的一个实施例中,所述报文零拷贝系统还包括第二pbuf内存,所述APPs的共享内存包括所述第二pbuf内存,所述确定模块930还用于所述APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读息之前,在预设时刻确定所述第一pbuf内存为所述APPs的所述共享内存,所述APP在预设时刻之外确定所述第二pbuf内存为所述APPs的共享内存,所述第一pbuf内存为小页内存,所述第二pbuf内存为大页内存,所述第一pbuf内存与所述一个或多个页表存在唯一对应关系。Optionally, in an embodiment of the present invention, the message zero-copy system further includes a second pbuf memory, the shared memory of APPs includes the second pbuf memory, and the determination module 930 is also used for all Before any application program APP in the APPs sets the read and write operation attribute of the APP to the first pbuf memory as read-only information at the current moment, determine the first pbuf memory as the APPs at the preset time The shared memory, the APP determines that the second pbuf memory is the shared memory of the APPs outside the preset time, the first pbuf memory is a small page memory, and the second pbuf memory is a large page memory , there is a unique correspondence between the first pbuf memory and the one or more page tables.

可选地,在本发明的一个实施例中,APP900还包括记录模块940,用于通过所述轨迹标识记录所述第一pbuf内存的轨迹点信息,所述轨迹点信息包括所述应用程序标识、所述应用程序当前进程标识以及所述当前时刻。Optionally, in one embodiment of the present invention, the APP900 further includes a recording module 940, configured to record the track point information of the first pbuf memory through the track ID, the track point information including the application program ID , the current process identifier of the application program and the current time.

可以看出,本发明实施例的方案中,当运行于操作系统的零拷贝系统中由APPs共享第一pbuf内存时,该APPs中的任一APP设置该APP对第一pbuf内存的读写操作属性在当前时刻为只读时,操作系统记录该APP对第一pbuf内存的读写操作属性;然后在操作系统监控到该APP对第一pbuf内存进行写操作时,操作系统向该APP发送pbuf内存误操作通知消息,该APP接收到操作系统发送的pbuf内存误操作通知消息后,获取该pbuf内存误操作通知消息中的pbuf内存误操作现场信息,该pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作以及该写操作的具体位置;最后该APP再基于该pbuf内存误操作现场信息确定APP对第一pbuf内存进行写操作的内存误操作现场。从而实现在多个APP共享同一pbuf内存的情况下,当该共享pbuf内存出现内存误操作时,能快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性的同时能提高系统性能。It can be seen that, in the solution of the embodiment of the present invention, when the first pbuf memory is shared by APPs in the zero-copy system running on the operating system, any APP in the APPs sets the APP to read and write operations to the first pbuf memory When the attribute is read-only at the current moment, the operating system records the read and write operation attributes of the APP to the first pbuf memory; then when the operating system monitors that the APP performs a write operation on the first pbuf memory, the operating system sends the pbuf to the APP Memory misoperation notification message. After receiving the pbuf memory misoperation notification message sent by the operating system, the APP obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message. The pbuf memory misoperation notification message is used to remind all The APP performs a write operation on the first pbuf memory, the write operation, and the specific location of the write operation; finally, the APP determines the memory error of the APP’s write operation on the first pbuf memory based on the site information of the pbuf memory misoperation. Operation site. In this way, when multiple APPs share the same pbuf memory, when a memory misoperation occurs in the shared pbuf memory, the APP and the specific location that caused the pbuf memory misoperation can be quickly and accurately located, that is, the pbuf memory misoperation site can be determined , to improve system performance while ensuring system reliability.

更进一步地,可以基于该pbuf内存误操作现场进行业务恢复,更一步保障系统可靠性。Furthermore, service recovery can be performed on-site based on the misoperation of the pbuf memory, further ensuring system reliability.

在本实施例中,应用程序APP900是以模块的形式来呈现。这里的“模块”可以指特定应用集成电路(application-specific integrated circuit,ASIC),执行一个或多个软件或固件程序的处理器和存储器,集成逻辑电路,和/或其他可以提供上述功能的器件。In this embodiment, the application program APP900 is presented in the form of modules. The "module" here may refer to an application-specific integrated circuit (ASIC), a processor and memory executing one or more software or firmware programs, an integrated logic circuit, and/or other devices that can provide the above functions .

可以理解的是,本实施例的应用程序APP900的各功能单元的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional unit of the application program APP900 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

参见图10,图10是本发明实施例提供的一种操作系统的结构示意图,用于实现本发明实施例公开的共享内存管理方法。其中,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一报文缓存pbuf内存,如图10所示,本发明实施例提供的一种操作系统1000包括:Referring to FIG. 10 , FIG. 10 is a schematic structural diagram of an operating system provided by an embodiment of the present invention, which is used to implement the shared memory management method disclosed in the embodiment of the present invention. Wherein, a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first message cache pbuf memory, as shown in Figure 10, the present invention An operating system 1000 provided in an embodiment includes:

记录模块1010以及发送模块1020。A recording module 1010 and a sending module 1020 .

其中,记录模块1010,用于根据所述APPs中的任一应用程序APP对所述第一pbuf内存的读写操作属性设置指示记录所述APP对所述第一pbuf内存的读写操作属性为只读;Wherein, the recording module 1010 is used to set an instruction to record the read and write operation attribute of the APP to the first pbuf memory according to any application program APP in the APPs to the read and write operation attribute of the first pbuf memory. read only;

发送模块1020,用于在所述操作系统监控到所述APP对所述第一pbuf内存进行写操作的情况下,所述操作系统向所述APP发送pbuf内存误操作通知消息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。The sending module 1020 is configured to send a pbuf memory misoperation notification message to the APP when the operating system monitors that the APP performs a write operation on the first pbuf memory, and the pbuf memory The misoperation notification message is used to remind the APP to perform a write operation on the first pbuf memory and a specific location of the write operation.

可选地,在本发明的一个实施例中,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被所述APP调用以设置所述APP对所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the operating system includes a Linux operating system, and the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called by the APP to set the The attributes of the APP's read and write operations on the first pbuf memory.

可选地,在本发明的一个实施例中,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the APP to the first pbuf memory based on one or more page tables .

可选地,在本发明的一个实施例中,所述页表包括读写操作属性标识,所述记录模块1010记录所述APP对所述第一pbuf内存的读写操作属性为只读包括:Optionally, in an embodiment of the present invention, the page table includes a read-write operation attribute identifier, and the recording module 1010 records that the APP's read-write operation attribute of the first pbuf memory is read-only includes:

通过所述读写操作属性标识记录所述APP对所述第一pbuf内存的读写操作属性只读。The read-write operation attribute of the APP to the first pbuf memory is read-only recorded through the read-write operation attribute identification.

可以看出,本发明实施例的方案中,当运行于操作系统的零拷贝系统中由APPs共享第一pbuf内存时,该APPs中的任一APP设置该APP对第一pbuf内存的读写操作属性在当前时刻为只读时,操作系统记录该APP对第一pbuf内存的读写操作属性;然后在操作系统监控到该APP对第一pbuf内存进行写操作时,操作系统向该APP发送pbuf内存误操作通知消息,该APP接收到操作系统发送的pbuf内存误操作通知消息后,获取该pbuf内存误操作通知消息中的pbuf内存误操作现场信息,该pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作以及该写操作的具体位置;最后该APP再基于该pbuf内存误操作现场信息确定APP对第一pbuf内存进行写操作的内存误操作现场。从而实现在多个APP共享同一pbuf内存的情况下,当该共享pbuf内存出现内存误操作时,能快速并准确地定位产生该pbuf内存误操作的APP以及具体位置,即确定pbuf内存误操作现场,保障系统可靠性的同时能提高系统性能。It can be seen that, in the solution of the embodiment of the present invention, when the first pbuf memory is shared by APPs in the zero-copy system running on the operating system, any APP in the APPs sets the APP to read and write operations to the first pbuf memory When the attribute is read-only at the current moment, the operating system records the read and write operation attributes of the APP to the first pbuf memory; then when the operating system monitors that the APP performs a write operation on the first pbuf memory, the operating system sends the pbuf to the APP Memory misoperation notification message. After receiving the pbuf memory misoperation notification message sent by the operating system, the APP obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message. The pbuf memory misoperation notification message is used to remind all The APP performs a write operation on the first pbuf memory, the write operation, and the specific location of the write operation; finally, the APP determines the memory error of the APP’s write operation on the first pbuf memory based on the site information of the pbuf memory misoperation. Operation site. In this way, when multiple APPs share the same pbuf memory, when a memory misoperation occurs in the shared pbuf memory, the APP and the specific location that caused the pbuf memory misoperation can be quickly and accurately located, that is, the pbuf memory misoperation site can be determined , to improve system performance while ensuring system reliability.

更进一步地,可以基于该pbuf内存误操作现场进行业务恢复,更一步保障系统可靠性。Furthermore, service recovery can be performed on-site based on the misoperation of the pbuf memory, further ensuring system reliability.

在本实施例中,操作系统1000是以模块的形式来呈现。这里的“模块”可以指特定应用集成电路(application-specific integrated circuit,ASIC),执行一个或多个软件或固件程序的处理器和存储器,集成逻辑电路,和/或其他可以提供上述功能的器件。In this embodiment, the operating system 1000 is presented in the form of modules. The "module" here may refer to an application-specific integrated circuit (ASIC), a processor and memory executing one or more software or firmware programs, an integrated logic circuit, and/or other devices that can provide the above functions .

可以理解的是,本实施例的操作系统1000的各功能单元的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional unit of the operating system 1000 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

参见图11,图11为本发明实施例提供的一种共享内存管理装置的结构示意图,如图11所示,该共享内存管理设备1100包括:Referring to FIG. 11, FIG. 11 is a schematic structural diagram of a shared memory management device provided by an embodiment of the present invention. As shown in FIG. 11, the shared memory management device 1100 includes:

存储有可执行程序代码的存储器1101与所述存储器耦合的处理器1102。该存储器1101可以独立存在,通过总线与处理器1102相连接。存储器1101也可以和处理器1102集成在一起。其中,所述处理器1102可以为中央处理器(Central Processing Unit,CPU),所述处理器1102上运行有应用程序APP与操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP。A memory 1101 storing executable program codes and a processor 1102 coupled to the memory. The memory 1101 may exist independently and be connected to the processor 1102 through a bus. The memory 1101 may also be integrated with the processor 1102 . Wherein, the processor 1102 may be a central processing unit (Central Processing Unit, CPU), and an application program APP and an operating system run on the processor 1102, and a message zero-copy system runs on the operating system, and the The message zero-copy system includes at least two application programs APPs, the APPs share the memory of the first packet cache pbuf, and the APPs are any APPs in the APPs.

所述APP用于:设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读;在所述APP接收到所述操作系统发送的pbuf内存误操作通知消息的情况下,获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置;基于所述pbuf内存误操作现场信息确定所述APP对所述第一pbuf内存进行写操作的内存误操作现场。The APP is used to: set the read-write operation attribute of the APP to the first pbuf memory to be read-only at the current moment; when the APP receives the pbuf memory misoperation notification message sent by the operating system Obtaining the pbuf memory misoperation site information in the pbuf memory misoperation notification message, the pbuf memory misoperation notification message is used to remind the APP to perform a write operation on the first pbuf memory and the details of the write operation Location: determine the memory misuse site where the APP performs a write operation on the first pbuf memory based on the pbuf memory misuse site information.

可选地,在本发明的一个实施例中,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被调用以设置所述第一pbuf内存的读写操作属性;Optionally, in an embodiment of the present invention, the operating system includes a Linux operating system, and the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called to set the first pbuf The read and write operation properties of the memory;

所述设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读,包括:The setting of the read-write operation attribute of the APP to the first pbuf memory is read-only at the current moment, including:

通过调用所述mprotect内存管理接口设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读。Setting the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment by calling the mprotect memory management interface.

可选地,在本发明的一个实施例中,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the APP to the first pbuf memory based on one or more page tables .

可选地,在本发明的一个实施例中,在所述设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读之前,所述APP还用于:Optionally, in an embodiment of the present invention, before setting the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment, the APP is further used to:

在预设时刻确定所述第一pbuf内存为所述APPs的所述共享内存,在预设时刻之外确定所述第二pbuf内存为所述APPs的共享内存,所述第一pbuf内存为小页内存,所述第二pbuf内存为大页内存,所述第一pbuf内存与所述一个或多个页表存在唯一对应关系。Determine that the first pbuf memory is the shared memory of the APPs at a preset time, determine that the second pbuf memory is a shared memory of the APPs outside the preset time, and the first pbuf memory is small page memory, the second pbuf memory is a large page memory, and there is a unique correspondence between the first pbuf memory and the one or more page tables.

可选地,在本发明的一个实施例中,所述第一pbuf内存还用于缓存轨迹标识,所述APP还用于:通过所述轨迹标识记录所述第一pbuf内存的轨迹点信息,所述轨迹点信息包括所述应用程序标识、所述应用程序当前进程标识以及所述当前时刻。Optionally, in an embodiment of the present invention, the first pbuf memory is also used for caching track identifiers, and the APP is also used for: recording track point information of the first pbuf memory through the track identifiers, The track point information includes the application identifier, the current process identifier of the application, and the current time.

值得说明的是,图11仅仅示出了共享内存管理设备1100的简化设计。在实际应用中,共享内存管理设备1100可以包含任意数量处理器和存储器等,而所有可以实现本发明实施例的共享内存管理设备都在本发明实施例的保护范围之内。It should be noted that FIG. 11 only shows a simplified design of the shared memory management device 1100 . In practical applications, the shared memory management device 1100 may include any number of processors and memories, and all shared memory management devices that can implement the embodiments of the present invention are within the protection scope of the embodiments of the present invention.

参见图12,图12为本发明实施例提供的另一种共享内存管理装置的结构示意图,如图12所示,该共享内存管理设备1200包括:Referring to FIG. 12, FIG. 12 is a schematic structural diagram of another shared memory management device provided by an embodiment of the present invention. As shown in FIG. 12, the shared memory management device 1200 includes:

存储有可执行程序代码的存储器1201与所述存储器耦合的处理器1202。该存储器1201可以独立存在,通过总线与处理器1202相连接。存储器1201也可以和处理器1202集成在一起。其中,所述处理器1202可以为中央处理器CPU,所述处理器1202上运行有应用程序APP与操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP。A memory 1201 storing executable program codes and a processor 1202 coupled to the memory. The memory 1201 can exist independently, and is connected to the processor 1202 through a bus. The memory 1201 can also be integrated with the processor 1202 . Wherein, the processor 1202 can be a central processing unit CPU, an application program APP and an operating system run on the processor 1202, a message zero-copy system runs on the operating system, and the message zero-copy system includes At least two application programs APPs, the APPs share the first packet cache pbuf memory, and the APP is any APP in the APPs.

所述操作系统用于:根据所述APPs中的任一应用程序APP对所述第一pbuf内存的读写操作属性设置指示记录所述APP对所述第一pbuf内存的读写操作属性为只读;在所述操作系统监控到所述APP对所述第一pbuf内存进行写操作的情况下,向所述APP发送pbuf内存误操作通知消息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。The operating system is used for: according to any application program APP in the APPs, the read and write operation attribute of the first pbuf memory is set to indicate that the read and write operation attribute of the APP to the first pbuf memory is set as only Read; when the operating system monitors that the APP performs a write operation on the first pbuf memory, send a pbuf memory misuse notification message to the APP, and the pbuf memory misuse notification message is used to remind all The APP performs a write operation on the first pbuf memory and the specific location of the write operation.

可选地,在本发明的一个实施例中,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被所述APP调用以设置所述APP对所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the operating system includes a Linux operating system, and the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called by the APP to set the The attributes of the APP's read and write operations on the first pbuf memory.

可选地,在本发明的一个实施例中,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述第一pbuf内存的读写操作属性。Optionally, in an embodiment of the present invention, the mprotect memory management interface is used to be called by the APP to set the read and write operation attributes of the first pbuf memory based on one or more page tables.

可选地,在本发明的一个实施例中,所述页表包括读写操作属性标识,所述记录模块记录所述APP对所述第一pbuf内存的读写操作属性为只读包括:Optionally, in an embodiment of the present invention, the page table includes a read-write operation attribute identifier, and the recording module records that the APP's read-write operation attribute of the first pbuf memory is read-only includes:

通过所述读写操作属性标识记录所述APP对所述第一pbuf内存的读写操作属性为只读。The read-write operation attribute of the APP to the first pbuf memory is marked and recorded as read-only.

值得说明的是,图12仅仅示出了共享内存管理设备1200的简化设计。在实际应用中,共享内存管理设备1200可以包含任意数量处理器和存储器等,而所有可以实现本发明实施例的共享内存管理设备都在本发明实施例的保护范围之内。It should be noted that FIG. 12 only shows a simplified design of the shared memory management device 1200 . In practical applications, the shared memory management device 1200 may include any number of processors and memories, and all shared memory management devices that can implement the embodiments of the present invention are within the protection scope of the embodiments of the present invention.

参见图13,图13为本发明实施例提供的一种共享内存管理设备的结构示意图,如图13所示,该共享内存管理设备1300包括:Referring to FIG. 13, FIG. 13 is a schematic structural diagram of a shared memory management device provided by an embodiment of the present invention. As shown in FIG. 13, the shared memory management device 1300 includes:

存储有可执行程序代码的存储器1301与所述存储器耦合的处理器1302。其中,处理器1101可以为中央处理器(Central Processing Unit,CPU),该处理器上可以运行如图5所示方法实施例中的APP和操作系统、或者如图9所示装置实施例中的APP和如图10所示装置实施例中的操作系统、或者如图11所示装置实施例中的APP和图12所示装置实施例中的操作系统,以用于执行本发明实施例所提供的共享内存管理方法。其中,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP。该存储器1301用于存储APP的程序代码和数据,以及用于存储操作系统的程序代码和数据。该存储器1301可以独立存在,通过总线与处理器1302相连接。存储器1301也可以和处理器1302集成在一起。A memory 1301 storing executable program codes and a processor 1302 coupled to the memory. Wherein, the processor 1101 may be a central processing unit (Central Processing Unit, CPU), and the APP and the operating system in the method embodiment shown in FIG. 5 may be run on the processor, or the APP and the operating system in the device embodiment shown in FIG. The APP and the operating system in the device embodiment shown in FIG. 10, or the APP in the device embodiment shown in FIG. 11 and the operating system in the device embodiment shown in FIG. 12 are used to execute the Shared memory management method. Wherein, a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first packet cache pbuf memory, and the APPs are the ones in the APPs Any APP. The memory 1301 is used for storing APP program codes and data, and for storing operating system program codes and data. The memory 1301 may exist independently and be connected to the processor 1302 through a bus. The memory 1301 can also be integrated with the processor 1302 .

可以理解的是,图13仅仅示出了共享内存管理设备1300的简化设计。在实际应用中,共享内存管理设备1300可以包含任意数量处理器和存储器等,而所有可以实现本发明实施例的共享内存管理设备都在本发明实施例的保护范围之内。It can be understood that FIG. 13 only shows a simplified design of the shared memory management device 1300 . In practical applications, the shared memory management device 1300 may include any number of processors and memories, and all shared memory management devices that can implement the embodiments of the present invention are within the protection scope of the embodiments of the present invention.

本发明实施例还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时可以实现包括上述方法实施例中记载的任何共享内存管理方法的部分或全部步骤。前述的存储介质包括:U盘、只读存储器(英文:read-only memory)、随机存取存储器(英文:random access memory,RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。An embodiment of the present invention also provides a computer storage medium, wherein the computer storage medium can store a program, and when the program is executed, some or all steps including any shared memory management method described in the above method embodiments can be implemented. The aforementioned storage medium includes: U disk, read-only memory (English: read-only memory), random access memory (English: random access memory, RAM), mobile hard disk, magnetic disk or optical disk, etc., which can store program codes. medium.

需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. Because of the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the foregoing embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

以上所述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still understand the foregoing The technical solutions recorded in each embodiment are modified, or some of the technical features are replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (19)

1.一种共享内存管理方法,其特征在于,所述方法应用于报文零拷贝系统中,所述报文零拷贝系统运行于操作系统上,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs的共享内存包括第一包缓存pbuf内存,所述方法包括:1. A shared memory management method, characterized in that, the method is applied in a message zero-copy system, the message zero-copy system runs on an operating system, and the message zero-copy system includes at least two applications Program APPs, the shared memory of the APPs includes the first packet cache pbuf memory, and the method includes: 所述APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读;Any application program APP in the APPs sets the read-write operation attribute of the APP to the first pbuf memory to be read-only at the current moment; 在所述APP接收到所述操作系统发送的pbuf内存误操作通知消息的情况下,获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置;When the APP receives the pbuf memory misoperation notification message sent by the operating system, it obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message, and the pbuf memory misoperation notification message is used for Reminding the APP to perform a write operation on the first pbuf memory and the specific location of the write operation; 基于所述pbuf内存误操作现场信息确定所述APP对所述第一pbuf内存进行写操作的内存误操作现场。Based on the pbuf memory misoperation site information, determine a memory misoperation site where the APP performs a write operation on the first pbuf memory. 2.根据权利要求1所述的方法,其特征在于,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被调用以设置所述第一pbuf内存的读写操作属性;2. The method according to claim 1, wherein the operating system includes a Linux operating system, and the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called to set the first A read and write operation attribute of pbuf memory; 所述APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读,包括:Any application program APP in the APPs sets the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment, including: 所述APP通过调用所述mprotect内存管理接口设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读。The APP sets the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment by calling the mprotect memory management interface. 3.根据权利要求2所述的方法,其特征在于,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。3. The method according to claim 2, wherein the mprotect memory management interface is used to be called by the APP to set the reading and writing of the first pbuf memory by the APP based on one or more page tables Action properties. 4.根据权利要求3所述的方法,其特征在于,所述报文零拷贝系统还包括第二pbuf内存,所述APPs的共享内存包括所述第二pbuf内存,在所述APPs中的任一应用程序APP设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读之前,所述方法还包括:4. The method according to claim 3, wherein the message zero-copy system also includes a second pbuf memory, and the shared memory of the APPs includes the second pbuf memory, any of the APPs Before an application program APP sets the read and write operation attribute of the APP to the first pbuf memory as read-only at the current moment, the method also includes: 所述APP在预设时刻确定所述第一pbuf内存为所述APPs的所述共享内存,所述APP在预设时刻之外确定所述第二pbuf内存为所述APPs的共享内存,所述第一pbuf内存为小页内存,所述第二pbuf内存为大页内存,所述第一pbuf内存与所述一个或多个页表存在唯一对应关系。The APP determines that the first pbuf memory is the shared memory of the APPs at a preset time, and the APP determines that the second pbuf memory is the shared memory of the APPs outside the preset time, and the APP determines that the second pbuf memory is the shared memory of the APPs. The first pbuf memory is a small page memory, the second pbuf memory is a large page memory, and there is a unique correspondence between the first pbuf memory and the one or more page tables. 5.根据权利要求1至4任一项所述的方法,其特征在于,所述第一pbuf内存还用于缓存轨迹标识,所述方法还包括:5. The method according to any one of claims 1 to 4, wherein the first pbuf memory is also used to cache track identification, and the method further comprises: 所述APP通过所述轨迹标识记录所述第一pbuf内存的轨迹点信息,所述轨迹点信息包括所述应用程序标识、所述应用程序当前进程标识以及所述当前时刻。The APP records track point information in the first pbuf memory through the track ID, and the track point information includes the application ID, the current process ID of the application, and the current time. 6.一种共享内存管理方法,其特征在于,所述方法应用于操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs的共享内存包括第一包缓存pbuf内存,所述方法包括:6. A shared memory management method, characterized in that, the method is applied to an operating system, and a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, so The shared memory of APPs includes the first packet cache pbuf memory, and the method includes: 所述操作系统根据所述APPs中的任一应用程序APP对所述第一pbuf内存的读写操作属性设置指示记录所述APP对所述第一pbuf内存的读写操作属性为只读;The operating system sets an instruction to record the APP's read-write operation attribute to the first pbuf memory according to any application program APP in the APPs to the read-write operation attribute of the first pbuf memory; 在所述操作系统监控到所述APP对所述第一pbuf内存进行写操作的情况下,所述操作系统向所述APP发送pbuf内存误操作通知消息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。When the operating system monitors that the APP performs a write operation on the first pbuf memory, the operating system sends a pbuf memory misoperation notification message to the APP, and the pbuf memory misoperation notification message is used for Reminding the APP to perform a write operation on the first pbuf memory and a specific location of the write operation. 7.根据权利要求6所述的方法,其特征在于,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被所述APP调用以设置所述APP对所述第一pbuf内存的读写操作属性。7. The method according to claim 6, wherein the operating system includes a Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called by the APP to set The attributes of the APP's read and write operations on the first pbuf memory. 8.根据权利要求7所述的方法,其特征在于,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。8. The method according to claim 7, wherein the mprotect memory management interface is used to be called by the APP to set the reading and writing of the first pbuf memory by the APP based on one or more page tables Action properties. 9.根据权利要求8所述的方法,其特征在于,所述页表包括读写操作属性标识,所述操作系统记录所述APP对所述第一pbuf内存的读写操作属性为只读包括:9. The method according to claim 8, wherein the page table includes a read-write operation attribute identifier, and the operating system records that the APP read-write operation attribute of the first pbuf memory is read-only and includes : 所述操作系统通过所述读写操作属性标识记录所述APP对所述第一pbuf内存的读写操作属性为只读。The operating system marks and records the read-write operation attribute of the APP on the first pbuf memory as read-only through the read-write operation attribute. 10.一种共享内存管理装置,其特征在于,所述设备包括:10. A shared memory management device, characterized in that the device comprises: 存储有可执行程序代码的存储器;a memory storing executable program code; 与所述存储器耦合的处理器;a processor coupled to the memory; 所述处理器上运行有应用程序APP与操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一包缓存pbuf内存,所述APP为所述APPs中的任一APP,所述APP用于:An application program APP and an operating system run on the processor, a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first packet cache pbuf memory, the APP is any APP in the APPs, and the APP is used for: 设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读;Setting the read and write operation attribute of the APP to the first pbuf memory is read-only at the current moment; 在所述APP接收到所述操作系统发送的pbuf内存误操作通知消息的情况下,获取所述pbuf内存误操作通知消息中的pbuf内存误操作现场信息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置;When the APP receives the pbuf memory misoperation notification message sent by the operating system, it obtains the pbuf memory misoperation site information in the pbuf memory misoperation notification message, and the pbuf memory misoperation notification message is used for Reminding the APP to perform a write operation on the first pbuf memory and the specific location of the write operation; 基于所述pbuf内存误操作现场信息确定所述APP对所述第一pbuf内存进行写操作的内存误操作现场。Based on the pbuf memory misoperation site information, determine a memory misoperation site where the APP performs a write operation on the first pbuf memory. 11.根据权利要求10所述的共享内存管理设备,其特征在于,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被调用以设置所述第一pbuf内存的读写操作属性;11. The shared memory management device according to claim 10, wherein the operating system includes a Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be called to set The read and write operation attributes of the first pbuf memory; 所述设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读,包括:The setting of the read-write operation attribute of the APP to the first pbuf memory is read-only at the current moment, including: 通过调用所述mprotect内存管理接口设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读。Setting the read-write operation attribute of the APP to the first pbuf memory as read-only at the current moment by calling the mprotect memory management interface. 12.根据权利要求11所述的共享内存管理设备,其特征在于,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述APP对所述第一pbuf内存的读写操作属性。12. The shared memory management device according to claim 11, wherein the mprotect memory management interface is used to be called by the APP to set the first pbuf memory of the APP based on one or more page tables The read and write operation properties. 13.根据权利要求12所述的共享内存管理设备,其特征在于,在所述设置所述APP对所述第一pbuf内存的读写操作属性在当前时刻为只读之前,所述APP还用于:13. The shared memory management device according to claim 12, wherein, before the setting of the read-write operation attribute of the APP to the first pbuf memory is read-only at the current moment, the APP also uses At: 在预设时刻确定所述第一pbuf内存为所述APPs的所述共享内存,在预设时刻之外确定所述第二pbuf内存为所述APPs的共享内存,所述第一pbuf内存为小页内存,所述第二pbuf内存为大页内存,所述第一pbuf内存与所述一个或多个页表存在唯一对应关系。Determine that the first pbuf memory is the shared memory of the APPs at a preset time, determine that the second pbuf memory is a shared memory of the APPs outside the preset time, and the first pbuf memory is small page memory, the second pbuf memory is a large page memory, and there is a unique correspondence between the first pbuf memory and the one or more page tables. 14.根据权利要求10至13任一项所述的共享内存管理设备,其特征在于,所述第一pbuf内存还用于缓存轨迹标识,所述APP还用于:14. The shared memory management device according to any one of claims 10 to 13, wherein the first pbuf memory is also used for caching trace identification, and the APP is also used for: 通过所述轨迹标识记录所述第一pbuf内存的轨迹点信息,所述轨迹点信息包括所述应用程序标识、所述应用程序当前进程标识以及所述当前时刻。The track point information of the first pbuf memory is recorded through the track ID, and the track point information includes the application program ID, the current process ID of the application program, and the current time. 15.一种共享内存管理装置,其特征在于,所述设备包括:15. A shared memory management device, characterized in that the device comprises: 存储有可执行程序代码的存储器;a memory storing executable program code; 与所述存储器耦合的处理器;a processor coupled to the memory; 所述处理器上运行有应用程序APP和操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一报文缓存pbuf内存,所述APP为所述APPs中的任一APP,所述操作系统用于:An application program APP and an operating system run on the processor, a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first message Cache the pbuf memory, the APP is any APP in the APPs, and the operating system is used for: 根据所述APPs中的任一应用程序APP对所述第一pbuf内存的读写操作属性设置指示记录所述APP对所述第一pbuf内存的读写操作属性为只读;According to any application program APP in the APPs, the read-write operation attribute of the first pbuf memory is set to indicate that the APP is read-only to the read-write operation attribute of the first pbuf memory; 在所述操作系统监控到所述APP对所述第一pbuf内存进行写操作的情况下,向所述APP发送pbuf内存误操作通知消息,所述pbuf内存误操作通知消息用于提醒所述APP对所述第一pbuf内存进行写操作以及所述写操作的具体位置。When the operating system monitors that the APP performs a write operation on the first pbuf memory, it sends a pbuf memory misoperation notification message to the APP, and the pbuf memory misoperation notification message is used to remind the APP Perform a write operation on the first pbuf memory and a specific location of the write operation. 16.根据权利要求15所述的共享内存管理设备,其特征在于,所述操作系统包括Linux操作系统,所述Linux操作系统包括mprotect内存管理接口,所述mprotect内存管理接口用于被所述APP调用以设置所述APP对所述第一pbuf内存的读写操作属性。16. The shared memory management device according to claim 15, wherein the operating system includes a Linux operating system, the Linux operating system includes an mprotect memory management interface, and the mprotect memory management interface is used to be used by the APP Called to set the attributes of the APP's read and write operations on the first pbuf memory. 17.根据权利要求16所述的共享内存管理设备,其特征在于,所述mprotect内存管理接口用于被所述APP调用以基于一个或多个页表设置所述第一pbuf内存的读写操作属性。17. The shared memory management device according to claim 16, wherein the mprotect memory management interface is used to be called by the APP to set the read and write operations of the first pbuf memory based on one or more page tables Attributes. 18.根据权利要求17所述的共享内存管理设备,其特征在于,所述页表包括读写操作属性标识,所述记录模块记录所述APP对所述第一pbuf内存的读写操作属性为只读包括:18. The shared memory management device according to claim 17, wherein the page table includes a read-write operation attribute identifier, and the recording module records the read-write operation attribute of the APP to the first pbuf memory as Read-only includes: 通过所述读写操作属性标识记录所述APP对所述第一pbuf内存的读写操作属性为只读。The read-write operation attribute of the APP to the first pbuf memory is marked and recorded as read-only. 19.一种共享内存管理设备,其特征在于,所述共享内存管理设备包括:19. A shared memory management device, characterized in that the shared memory management device comprises: 存储有可执行程序代码的存储器;a memory storing executable program code; 与所述存储器耦合的处理器;a processor coupled to the memory; 所述处理器上运行有应用程序APP和操作系统,所述操作系统上运行有报文零拷贝系统,所述报文零拷贝系统包括至少两个应用程序APPs,所述APPs共享第一报文缓存pbuf内存,所述APP为所述APPs中的任一APP;An application program APP and an operating system run on the processor, a message zero-copy system runs on the operating system, and the message zero-copy system includes at least two application programs APPs, and the APPs share the first message Cache the pbuf memory, and the APP is any APP in the APPs; 所述APP用于执行权利要求1至5任一项所述共享内存管理方法;The APP is used to execute the shared memory management method described in any one of claims 1 to 5; 所述操作系统用于执行权利要求6至9任一项所述的共享内存管理方法。The operating system is used to execute the shared memory management method described in any one of claims 6-9.
CN201710268053.5A 2017-04-22 2017-04-22 A shared memory management method and shared memory management device Active CN107145399B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710268053.5A CN107145399B (en) 2017-04-22 2017-04-22 A shared memory management method and shared memory management device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710268053.5A CN107145399B (en) 2017-04-22 2017-04-22 A shared memory management method and shared memory management device

Publications (2)

Publication Number Publication Date
CN107145399A true CN107145399A (en) 2017-09-08
CN107145399B CN107145399B (en) 2021-03-02

Family

ID=59775251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710268053.5A Active CN107145399B (en) 2017-04-22 2017-04-22 A shared memory management method and shared memory management device

Country Status (1)

Country Link
CN (1) CN107145399B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109361693A (en) * 2018-11-21 2019-02-19 南京中孚信息技术有限公司 Virtual unit communication means and device
CN111488123A (en) * 2020-04-07 2020-08-04 Tcl移动通信科技(宁波)有限公司 Storage space management method and device, storage medium and mobile terminal
CN111736533A (en) * 2020-06-04 2020-10-02 佛山智能装备技术研究院 Data synchronization method and device based on control and drive integrated robot
CN115220936A (en) * 2022-09-20 2022-10-21 之江实验室 Method and device for zero copying of multi-class sensor data in controller

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102006241A (en) * 2010-12-17 2011-04-06 天津曙光计算机产业有限公司 Method for receiving message through buffer area shared by multiple applications
CN102164177A (en) * 2011-03-11 2011-08-24 浪潮(北京)电子信息产业有限公司 Method, device and system for sharing storage pool by cluster
CN102831069A (en) * 2012-06-30 2012-12-19 华为技术有限公司 Memory processing method and memory management equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102006241A (en) * 2010-12-17 2011-04-06 天津曙光计算机产业有限公司 Method for receiving message through buffer area shared by multiple applications
CN102164177A (en) * 2011-03-11 2011-08-24 浪潮(北京)电子信息产业有限公司 Method, device and system for sharing storage pool by cluster
CN102831069A (en) * 2012-06-30 2012-12-19 华为技术有限公司 Memory processing method and memory management equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
沈剑光: "浅析 Linux 中的共享内存机制", 《中国科技信息》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109361693A (en) * 2018-11-21 2019-02-19 南京中孚信息技术有限公司 Virtual unit communication means and device
CN109361693B (en) * 2018-11-21 2020-11-24 南京中孚信息技术有限公司 Virtual device communication method and device
CN111488123A (en) * 2020-04-07 2020-08-04 Tcl移动通信科技(宁波)有限公司 Storage space management method and device, storage medium and mobile terminal
CN111488123B (en) * 2020-04-07 2022-11-04 Tcl移动通信科技(宁波)有限公司 Storage space management method and device, storage medium and mobile terminal
CN111736533A (en) * 2020-06-04 2020-10-02 佛山智能装备技术研究院 Data synchronization method and device based on control and drive integrated robot
CN115220936A (en) * 2022-09-20 2022-10-21 之江实验室 Method and device for zero copying of multi-class sensor data in controller

Also Published As

Publication number Publication date
CN107145399B (en) 2021-03-02

Similar Documents

Publication Publication Date Title
US10198377B2 (en) Virtual machine state replication using DMA write records
US10067692B2 (en) Method and apparatus for backing up and restoring cross-virtual machine application
US8910172B2 (en) Application resource switchover systems and methods
US8146082B2 (en) Migrating virtual machines configured with pass-through devices
US10530837B2 (en) Always-on monitoring in the cloud
CN107209705B (en) Activity rollback for a computing environment
US9652326B1 (en) Instance migration for rapid recovery from correlated failures
US10656877B2 (en) Virtual storage controller
US8195619B2 (en) Extent reference count update system and method
US8578214B2 (en) Error handling in a virtualized operating system
CN112256393B (en) Resource management method and equipment for bare metal server
JP7483054B2 (en) Live migration of virtual machines to target hosts in the event of a fatal memory error
CN106030548A (en) Multi-Node Backbone for Trusted Computing
US11449388B1 (en) Synthesized network block devices for recovery of image backups
US20190332461A1 (en) Embedding forensic and triage data in memory dumps
CN107145399A (en) A kind of shared-memory management method and shared-memory management equipment
CN109347899B (en) Method of writing log data in distributed storage system
CN117472632A (en) Processing method and device for memory faults of virtual machine and electronic equipment
US10402252B1 (en) Alternative event reporting for peripheral devices
CN109154963B (en) Equipment and method for preventing memory data from being leaked
CN103713952A (en) Virtual disk distributed-memory method based on UFS (Universal Flash Storage)
US12436818B2 (en) Disabling a processor facility on a new processor generation without breaking binary compatibility
US12008413B2 (en) Vector processing employing buffer summary groups
US12210634B2 (en) Featureless machine enhancement discovery and verification
CN117076105B (en) Dirty page determining method and computing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20211223

Address after: 450046 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu wisdom Island, Zhengdong New Area, Zhengzhou City, Henan Province

Patentee after: xFusion Digital Technologies Co., Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd.