A session migration method based on a shared big page memory region and an electronic device
Patent Information
- Application Number
- CN202611155566.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-11-17
Smart Images

Figure CN123114786A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtual forwarding, and more specifically, to a session migration method and electronic device based on a shared big page memory region. Background Technology
[0002] In high-performance network forwarding services such as virtual switches and virtual network elements, a session is used to record the state information of a connection, such as the Transmission Control Protocol / Internet Protocol (TCP / IP) 5-tuple, so that subsequent traffic can be correctly identified and processed. With the rapid development of cloud computing and software-defined networking (SDN), these forwarding services require frequent service upgrades, process restarts, or hot migrations.
[0003] However, traditional session management solutions typically rely on process memory, and this session data is released when the process exits, resulting in session loss and subsequent business interruption. Summary of the Invention
[0004] This application addresses the shortcomings by providing a session migration method and electronic device based on a shared large page memory region.
[0005] In a first aspect, a session migration method based on a shared large page memory region is provided, comprising: obtaining a newly created first process, wherein the first process is a new process; mapping the shared large page memory region of an already running second process to the virtual space of the first process, wherein the second process is an already running old process, and the session object data information of the second process includes second management metadata and content metadata, wherein the second management metadata is used to manage the session forwarding service of the second process, and the content metadata is used to indicate the session content information of the second process, and the shared large page memory region of the second process stores the content metadata; obtaining the content metadata, and constructing first management metadata of the first process based on the content metadata, and retaining the second management metadata, wherein the first management metadata is used to manage the session forwarding service information of the first process; and determining, based on the first management metadata and the content metadata, that the first process replaces the second process in handling traffic.
[0006] This scheme eliminates the need for reallocating session data or synchronizing session information from the old process line by line via inter-process communication when a new process starts. Instead, it directly maps the shared big page memory region of the old process into its own virtual space, inheriting the existing session's content metadata. This ensures that existing communication sessions are not lost during service hot upgrades or process restarts, and user traffic can seamlessly switch after the new process starts without re-establishing connections. Furthermore, session object data is divided into two parts: management metadata and content metadata. Management metadata is unique to each process, while content metadata is shared between processes. During hot upgrades, the new process only modifies its own management metadata, without modifying the old process's management metadata or the shared content metadata.
[0007] In conjunction with the first aspect, in a possible implementation of the first aspect, determining whether the first process will replace the second process in handling traffic based on the first management metadata and the content metadata includes: if the first process starts normally, switching the traffic of the second process to the first process based on the first management metadata and the content metadata, stopping the second process and destroying the second management metadata; if the first process fails to start, exits abnormally, or terminates, stopping the first process, and determining whether the second process will continue to handle traffic based on the retained second management metadata and the content metadata.
[0008] This solution enables a seamless traffic switch between the old and new processes upon successful hot upgrade, while halting the new process in case of failure, and leaving the old process's management metadata and session content metadata unmodified. Consequently, the old process can continue operating normally, achieving a lossless rollback after a hot upgrade failure.
[0009] In conjunction with the first aspect, in a possible implementation of the first aspect, the second management metadata includes node pointer information of the second process's session in a hash table or pointer information pointing to the next session, and the content metadata includes the 5-tuple information of the TCP session.
[0010] This scheme clearly defines the content of management metadata and content metadata. Management metadata is used to associate the data structures of the session objects managed by different forwarding services, while content metadata uniformly represents the core connection information of the session, making it easier for forwarding services with different architectures to share session content data.
[0011] In conjunction with the first aspect, in a possible implementation of the first aspect, mapping the shared large page memory region of the running second process to the virtual space of the first process includes: obtaining index data created by the second process, wherein the elements of the index data correspond one-to-one with the memory pages in the shared large page memory region of the second process, wherein the index data is used to manage the shared large page memory region; and mapping the shared large page memory region to the virtual space of the first process by associating the index data with the first process.
[0012] This scheme uses an index array where each element points to a shared massive page memory region, enabling unified management of multiple shared massive page memory regions without the need for separate management of each region. Furthermore, the new and old processes do not need to map shared memory to the same virtual address, avoiding upgrade failures due to pre-occupation of virtual address space and improving the success rate of hot upgrades.
[0013] In conjunction with the first aspect, in a possible implementation of the first aspect, a session object allocator is included in the shared large page memory region, and obtaining the content metadata includes: searching for the session object allocator in the shared large page memory region by the first process to obtain the content metadata.
[0014] With this scheme, all data information of the session object allocator is concentrated in a shared massive page memory area. When a new process connects to the shared massive page memory area of an old process, it is equivalent to sharing the same session object allocator, which improves migration efficiency.
[0015] In conjunction with the first aspect, in a possible implementation of the first aspect, the shared large page memory region is mapped to the virtual space of the first process by associating the index data with the first process, including: obtaining the shared memory identifier information in the startup parameters of the first process; determining that the shared memory identifier information is not empty and the loaded shared file is valid, and then creating the index data corresponding to the first process and attaching the shared file; mapping the shared large page memory region to the index data corresponding to the first process, so as to map the shared large page memory region to the virtual space of the first process.
[0016] This scheme allows the first process to associate the shared massive memory region created by the second process with the shared memory identifier information in the startup parameters, thus realizing inter-process sharing of massive memory without master-slave dependency, without relying on the master-slave process model.
[0017] In conjunction with the first aspect, in a possible implementation of the first aspect, the data information of the session object allocator includes the metadata information of the session object allocator, the content metadata, and the lock-free allocation queue, wherein the lock-free allocation queue is used to allocate a target index for each session object when requesting a session object, and is used to reclaim the target index when releasing a session object.
[0018] This scheme assigns a unique index to each session object using a lock-free allocation queue. Both requesting and releasing session objects are accomplished by manipulating the index, enabling fast allocation and recycling of session objects.
[0019] In conjunction with the first aspect, in a possible implementation of the first aspect, the lock-free allocation queue is implemented through a compare-and-swap (CAS) lock-free programming approach.
[0020] This scheme leverages the atomicity of hardware-supported CAS operations to avoid thread blocking and context switching overhead caused by traditional locking mechanisms, thereby improving the efficiency of the session object allocator in allocating and recycling objects in high-concurrency scenarios.
[0021] In conjunction with the first aspect, in a possible implementation of the first aspect, the shared massive page memory region comprises multiple massive pages of the same size.
[0022] This scheme uses large page memory (such as 2MB, 512MB or 1GB) to form a shared memory region. Compared with the traditional 4KB small page memory, it reduces the number of page table entries, improves the translation lookaside buffer (TLB) hit rate, reduces memory access latency, and improves the overall packet forwarding throughput.
[0023] In a second aspect, an electronic device is provided, including one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs including instructions that, when executed by the one or more processors, cause the method as described in the first aspect or any possible implementation thereof to be performed.
[0024] Thirdly, a computer-readable storage medium is provided that stores computer instructions that, when executed on a computer, cause the method described in the first aspect or any possible implementation thereof to be performed.
[0025] Fourthly, a computer program product is provided that, when run on a computer, causes the computer to perform the method described in the first aspect or any possible implementation thereof. Attached Figure Description
[0026] Figure 1 A schematic flowchart of a session migration method based on a shared big page memory region provided in an embodiment of this application is shown; Figure 2 This illustration shows the overall shared massive page memory architecture provided in an embodiment of this application; Figure 3 This paper illustrates a flowchart of a shared large page memory region initialization design provided in an embodiment of this application. Figure 4 A schematic diagram of a session object allocator provided in an embodiment of this application is shown; Figure 5 This illustration shows a schematic diagram of session object data information provided in an embodiment of this application; Figure 6 This illustration shows a schematic diagram of multiple processes sharing session content according to an embodiment of this application; Figure 7 A flowchart illustrating a session migration method provided in an embodiment of this application is shown; Figure 8 This is a structural schematic diagram of a device provided in an embodiment of this application; Figure 9 This is a structural schematic diagram of a system on a chip (SoC) provided in an embodiment of this application. Detailed Implementation
[0027] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0028] The terminology used in the following embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to also include expressions such as “one or more,” unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, “at least one” and “one or more” refer to one, two, or more than two. The term “and / or” is used to describe the relationship between related objects, indicating that three relationships may exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship.
[0029] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0030] As mentioned earlier, traditional session management solutions typically rely on process memory. This session data is released when the process exits, leading to session loss and subsequent business interruption.
[0031] For example, in an operating system, each process has its own independent virtual memory space. When a process exits normally or crashes abnormally, the operating system kernel reclaims all memory resources occupied by that process, including session data stored therein. While this memory management mechanism ensures isolation between processes and system stability, it also means that data in a process's memory lacks cross-process persistence. When a version update or configuration change of the virtual forwarding service is required, or when a process crashes and terminates, the process typically needs to be restarted. The traditional restart method is to stop the old process first and then start the new process; the session data in the old process's memory is released when it stops. If the session data is not shared or persisted between processes, session loss can still occur during the switchover process.
[0032] Furthermore, while traditional shared memory allows data to be shared among multiple processes, in high-concurrency scenarios, inefficient TLB access due to small page memory (e.g., 4KB) can easily create performance bottlenecks. Additionally, dynamic memory allocation increases lock contention and fragmentation, further reducing performance.
[0033] Hugepages are an optimization scheme that allows the allocation of larger memory pages, thereby improving TLB hit rate and reducing memory access latency. Specifically, hugepages are a memory management approach that allows the use of larger memory page sizes (such as 2MB or 1GB) to reduce TLB access overhead and improve memory access performance. Hugepages are widely used in high-performance computing applications such as the Linux kernel and the Data Plane Development Kit (DPDK). The advantages of hugepages are mainly: reduced TLB hit rate decline: compared to 4KB small pages, using 2MB or 1GB pages reduces the number of page table entries, improving TLB hit rate and thus improving CPU access efficiency; reduced page table management overhead: the system needs to maintain fewer page table entries, reducing latency caused by page walks; and increased data throughput: in network forwarding and high-performance computing, hugepages reduce address translation latency and improve overall throughput.
[0034] DPDK is a high-speed user-space packet processing framework that bypasses the Linux kernel protocol stack, enabling direct user-space polling mode for packet processing. DPDK can interact directly with network interface card (NIC) hardware, leveraging hardware acceleration to improve performance. It also supports multi-core processing, allowing parallel packet processing on multi-core processors to increase overall throughput. It is widely used in software switches, software routers, and load balancers.
[0035] However, at present, there is no optimization for high-performance session management, which leads to session loss during service upgrades and fails to meet the high availability requirements of network forwarding services.
[0036] To address the aforementioned issues, this application proposes a session migration method 100 based on a shared large page memory region. Figure 1 A schematic flowchart of a session migration method 100 based on a shared large page memory region provided in an embodiment of this application is shown. Figure 1 As shown, the method 100 includes steps S110 to S140.
[0037] In this method 100, when a new process starts, there is no need to reallocate session data or synchronize session information from the old process one by one via inter-process communication. Instead, the shared large page memory region of the old process is directly mapped to its own virtual space, inheriting the existing session's content metadata. This ensures that existing communication sessions are not lost during service hot upgrades or process restarts, and user traffic can seamlessly switch after the new process starts without re-establishing connections. Furthermore, the session object data is divided into two parts: management metadata and content metadata. Management metadata is unique to each process, while content metadata is shared between processes. Consequently, during a hot upgrade, the new process only modifies its own management metadata without modifying the old process's management metadata or the shared content metadata, thus achieving a lossless rollback after a hot upgrade failure.
[0038] S110: Obtain the first process of the newly created process.
[0039] Specifically, the first process is a new process. In the embodiments of this application, a process may refer to a running virtual forwarding service instance, such as a virtual switch process or a virtual network element process. In high-performance forwarding scenarios, these processes can run based on DPDK to process data packets and achieve high throughput and low latency forwarding performance.
[0040] For example, in a high-performance virtual forwarding service scenario, when a hot upgrade of a running second process is required or a restart is needed due to a failure, the system creates a new process, namely the first process. This first process is used to replace the second process to continue handling network forwarding traffic. In some embodiments of this application, the system can obtain the process identifier and process handle of the newly created first process through the process management interface, so as to subsequently perform shared memory mapping and session data inheritance operations.
[0041] S120: Map the shared massive page memory region of the running second process to the virtual space of the first process.
[0042] Specifically, unlike the newly created first process, this second process is an existing, running process, such as a virtual forwarding service process that was already running and processing user traffic before the first process was created. Furthermore, the session object data information of this second process includes second management metadata and content metadata. The second management metadata is unique to the second process and is used to manage the session forwarding service of this second process, while the content metadata indicates the session content information of the second process. This content metadata is stored in the shared large page memory area of the second process.
[0043] Furthermore, in this embodiment, memory mapping technology can be used to associate the shared large page memory region already created by the second process with the address space of the first process, enabling the first process to directly access the data stored in the shared large page memory region of the second process. This shared large page memory region can be requested by the second process during initialization through the large page memory allocation interface and is specifically used to store the content metadata of the session object.
[0044] Optionally, in step S120, in the embodiments of this application, the shared large page memory region may include multiple large page memory units of the same size. For example, the shared large page memory region is composed of multiple large page memory units of the same size, and the size of the large page memory unit can be 2MB, 512MB, or 1GB. When creating the shared large page memory region, the system can calculate the total amount of memory required based on the estimated number of sessions and the size of the session objects, and then apply for the corresponding number of large page memory units, combining these contiguous or non-contiguous large page memory units into a unified shared large page memory region. By using large page memory to replace the traditional 4KB small page memory, the number of page table entries is reduced, the TLB hit rate is improved, the memory access latency is reduced, and the overall packet forwarding throughput is improved.
[0045] Optionally, embodiments of this application can uniformly manage the shared large page memory region through index data, and allow new and old processes to map the same shared physical memory with different virtual addresses. Specifically, the process of mapping the shared large page memory region of the running second process to the virtual space of the first process includes: obtaining index data created by the second process, wherein the elements of the index data correspond one-to-one with the memory pages in the shared large page memory region of the second process, wherein the index data is used to manage the shared large page memory region; and mapping the shared large page memory region to the virtual space of the first process by associating the index data with the first process.
[0046] For example, in the embodiments of this application, the index data can refer to an `rte_fbarray` index array, where each element points to a shared large page memory region. Furthermore, this array enables centralized management and fast lookup of multiple shared large page memory regions. For instance, during initialization, the second process creates an `rte_fbarray` index array containing three elements, each pointing to a different shared large page memory region. When the first process starts, it reads the shared files left by the second process to obtain the name and identification information of the index array. Then, the first process creates the corresponding index array structure in its own virtual space and appends the shared files to the index array, thereby mapping the shared large page memory region of the second process to the virtual space of the first process. Through the above scheme, this application achieves inter-process large page memory sharing without master-slave dependency, improving the success rate of hot upgrades.
[0047] Optionally, in embodiments of this application, shared memory identification information can also be passed through startup parameters, enabling the new process to perform corresponding initialization or association operations based on the parameter status. Specifically, the process of mapping the shared large page memory region to the virtual space of the first process by associating the index data with the first process includes: obtaining the shared memory identification information in the startup parameters of the first process; determining that the shared memory identification information is not empty and the loaded shared file is valid, thereby creating the index data corresponding to the first process and attaching the shared file; mapping the shared large page memory region to the index data corresponding to the first process, so as to map the shared large page memory region to the virtual space of the first process.
[0048] Optionally, in embodiments of this application, management metadata can refer to data structure information used by various forwarding services to manage session objects, such as node pointer information of a session in a hash table or pointer information pointing to the next session. Management metadata is a data structure unique to each process, and different processes can have different management metadata formats and management algorithms. Content metadata can refer to the core connection information carried in the session. The information carried varies depending on the protocol. For example, the content metadata of a TCP session includes a five-tuple of information: source MAC address, destination MAC address, source IP address, destination IP address, source port information, and destination port information. Content metadata is a data structure shared between processes, and all processes accessing this shared memory area obtain the same content metadata.
[0049] S130: Obtain the content metadata, and based on the content metadata, construct the first management metadata of the first process, and retain the second management metadata.
[0050] Specifically, the first management metadata is used to manage the session forwarding service of the first process. After completing the mapping of the shared big page memory region, the first process reads the content metadata of all session objects from this region. The content metadata contains the core connection information of each session. Based on this information, the first process constructs its own management metadata, i.e., the first management metadata. Meanwhile, the second process's original second management metadata remains in the second process's memory space and is not modified or deleted by the first process.
[0051] Optionally, embodiments of this application can centralize all data information of the session object allocator in a shared large page memory region, and achieve efficient allocation and reclamation of session objects through a lock-free allocation queue. Specifically, the shared large page memory region includes the session object allocator, and the process of obtaining the content metadata includes: searching for the session object allocator in the shared large page memory region through the first process, and obtaining the content metadata.
[0052] The data information of the session object allocator includes the allocator's metadata, the content metadata, and a lock-free allocation queue. The lock-free allocation queue is used to allocate a target index for each session object when it is requested, and to reclaim the target index when a session object is released. It should be understood that, in the embodiments of this application, the session object allocator can refer to a functional module for managing the request and release of session objects, with all its data information centrally stored in a shared large page memory area. The lock-free allocation queue can be implemented using lock-free programming techniques and is used to allocate and reclaim the index values of session objects, with each index value uniquely corresponding to the storage space of a session object.
[0053] For example, in the embodiments of this application, the target index can refer to the position number of the session object in the shared big page memory region. This number allows for quick location of the corresponding session content metadata. When the second process needs to create a new session, it retrieves an index from the head of the lock-free allocation queue, for example, index 100, and then writes the five-tuple information of the session at offset 100 in the content metadata region. After the first process maps the shared big page memory region, it finds the starting address of the session object allocator in the shared region and then directly reads all allocated session information from the allocator's content metadata region, without needing to receive each item individually. When the first process needs to request a new session object, it also retrieves an available index through the same lock-free allocation queue, achieving rapid allocation of the session object. Through the above scheme, this application achieves seamless sharing of the session object allocator between processes, avoiding complex session synchronization communication between new and old processes and improving session migration efficiency.
[0054] Optionally, embodiments of this application can implement a lock-free allocation queue using compare-and-swap (CAS) lock-free programming. Specifically, CAS can refer to a hardware-supported atomic operation instruction that can safely update the value of shared variables without locking in a multi-threaded environment. Furthermore, when multiple threads simultaneously request session object indexes from the lock-free allocation queue, each thread attempts to update the queue's head pointer from its current value to the next value using a CAS operation. The CAS operation atomically checks whether the current value of the head pointer matches the expected value read by the thread. If they match, the update is performed and success is returned; otherwise, failure is returned and the process is retried. Through this scheme, this application minimizes thread waiting time and improves the throughput of session allocation and reclamation while ensuring concurrency safety for multiple producers and consumers.
[0055] S140: Based on the first management metadata and the content metadata, determine that the first process will replace the second process in handling traffic.
[0056] Specifically, after the first process completes the construction of its management metadata and confirms that it is ready to handle forwarded traffic, the system switches network traffic from the second process to the first process. The first process then uses its constructed first management metadata and shared content metadata to handle subsequent network forwarding traffic. Furthermore, when the first process receives a data packet, it quickly locates the corresponding session using the data structure information in its first management metadata and performs correct forwarding processing by combining the five-tuple information in the content metadata, thereby completing session migration and traffic switching.
[0057] Optionally, in embodiments of this application, corresponding switching or rollback operations can also be performed based on the startup status of the first process. Specifically, determining whether the first process will replace the second process in handling traffic based on the first management metadata and the content metadata includes: if the first process starts normally, switching the traffic of the second process to the first process based on the first management metadata and the content metadata, stopping the second process, and destroying the second management metadata; if the first process fails to start, exits abnormally, or terminates, stopping the first process, and determining whether the second process will continue to handle traffic based on the retained second management metadata and the content metadata.
[0058] Furthermore, upon successful hot upgrade, the system completes the traffic switch between the old and new processes, and the management metadata of the old process is destroyed to release resources. Upon failure of hot upgrade, the new process stops running, while the management metadata and session content metadata of the old process remain unchanged, allowing the old process to continue operating normally, thus achieving a lossless rollback after a hot upgrade failure.
[0059] For example, in the aforementioned hot upgrade scenario for network element services, after completing the mapping of the shared big page memory region and the construction of the first management metadata, the first process performs a health check to confirm that all its functional modules have been initialized normally and can begin processing network traffic. Subsequently, the system performs a traffic switching operation, switching all forwarding traffic originally handled by the second process to the first process. After the switch is completed, the second process no longer receives new traffic and is safely stopped after processing its existing data packets. The second management metadata of the second process is destroyed to release private memory resources. Throughout the switching process, the five-tuple information of existing sessions is always stored in the shared big page memory region, and the user's communication connection is not interrupted. Suppose that the first process encounters insufficient memory and exits abnormally while constructing the first management metadata. After detecting the failure to start the first process, the system automatically stops and cleans up the resources occupied by the first process. At the same time, it confirms that the second management metadata of the second process has not been modified, and the content metadata in the shared big page memory region is also intact. Therefore, the system determines that the second process should continue to process all traffic. Since the second process is running throughout the entire process and its management metadata and shared content metadata are not contaminated, traffic processing is not affected in any way, and the user is completely unaware of the upgrade failure.
[0060] In method 100, when the new process starts, there is no need to reallocate session data or synchronize session information from the old process one by one through inter-process communication. Instead, the shared large page memory area of the old process is directly mapped into its own virtual space to inherit the content metadata of the existing session. Therefore, existing communication sessions are not lost during service hot upgrades or process restarts, and user traffic can seamlessly switch after the new process starts without re-establishing connections. Furthermore, this application also achieves a lossless rollback where the traffic switch between the old and new processes is completed when the hot upgrade is successful, and the old process can continue to operate normally when the hot upgrade fails.
[0061] The following describes a detailed embodiment of method 100 with reference to the accompanying drawings.
[0062] In the embodiments of this application, an index array is first used as a shared bigpage memory management mechanism to provide object allocation capabilities for multiple independent processes and support inter-process sharing without master-slave dependencies. Then, by creating an index array and allocating bigpage memory in process A, it acts as an object allocator to manage data objects, enabling multiple processes to access the same memory pool. Next, when the newly created process B starts, it inherits the management state of the object allocator by associating existing index data with the bigpage memory, thus achieving no session loss during service upgrades. Finally, after process B completes initialization, it replaces process A to continue processing traffic, avoiding latency caused by data reallocation and ensuring uninterrupted service during the upgrade process.
[0063] During shared memory management, metadata for object allocation is maintained through index data, and thread-safe allocation and release mechanisms are provided to ensure consistency across multiple processes. Furthermore, this approach enables seamless upgrades to high-performance virtual forwarding services, improves resource reuse, and ensures data integrity and business continuity.
[0064] Figure 2 This diagram illustrates the overall shared massive page memory architecture provided in an embodiment of this application. Figure 2 As shown, the index array (rte_fbarray) manages the shared huge page memory. Each element in the index array points to a shared huge page memory region (shared_memzone). Each shared memory region consists of several huge pages of the same size; for example, three 1GB huge pages can form a 3GB shared memory region, and 100 2MB huge pages can form a 200MB memory region. When an object needs to use shared huge page memory, a corresponding shared memory region needs to be created. In high-performance forwarding scenarios, when the allocator creates a session object, it needs to calculate the memory size, request the corresponding size of shared huge page memory, and associate it with an element in the index array for easy management and release later.
[0065] Furthermore, when a session is seamlessly migrated between multiple processes, the new process first needs to map to an index array, then obtain the shared big page memory information corresponding to each element in the array, and then map the shared big page memory to its own virtual space. Finally, it can seamlessly use the session created by the previous process, and similarly, it can seamlessly pass its own session to the next process.
[0066] To ensure seamless migration of sessions across multiple processes, later-started processes need to load the shared massive memory region of the previous process. In this embodiment, shared massive page management is implemented through index data, where each element represents a shared massive page, which can be created and deleted as needed. Furthermore, shared massive pages do not depend on the master-slave relationship between the two processes, nor do they require the two processes to map shared memory to the same starting address. This approach is suitable for hot process upgrade scenarios and also for streaming log scenarios (i.e., using a separate process to read session packet statistics and report them to the log system).
[0067] For example, Figure 3 This illustration shows a flowchart of a shared massive page memory region initialization design provided in an embodiment of this application. Figure 3As shown, the process first retrieves the startup parameters for shared memory. If the parameters are empty, a new shared memory index array is created and initialized, and shared memory is created. If the parameters are not empty, the shared file corresponding to the startup parameters is loaded. If the shared file does not exist or has expired, a new shared memory index array is created and initialized, and shared memory is created. If the shared file is valid, a shared memory index array is created, and the shared memory information of the previous process is synchronized to the index array of the new process.
[0068] The above approach allows processes to create multiple shared huge page regions and then manage the shared memory uniformly, eliminating the need for separate management of each shared huge page. Furthermore, processes without a master-slave relationship can also share huge page memory. New and old processes do not need to use the same virtual addresses to map shared huge page memory, ensuring a high success rate for hot upgrades and preventing upgrade failures caused by the new process's virtual addresses being pre-occupied.
[0069] The design of the session object allocator in this embodiment is described below. The session object allocator is primarily used to manage the allocation and release of session objects. Users initialize the session object allocator by setting the number of session objects to be allocated and the size of each object session as needed. Each object allocator corresponds to a shared large page memory region, and the size of the memory region is calculated based on the information from the object allocator. Figure 4 A schematic diagram of a session object allocator provided in an embodiment of this application is shown.
[0070] like Figure 4 As shown, the session object allocator consists of three parts: the object allocator's metadata, session content metadata, and a lock-free allocation queue. By centralizing all the data information of the object allocator in a shared memory region, when a new process connects to the shared big page region of an older process, it is equivalent to the new process and the older process sharing an object allocator, avoiding unnecessary session communication between the new and old processes.
[0071] Once a session object allocator is initialized, the lock-free queue assigns an index to each session object. Requesting an object involves retrieving an index from the lock-free queue, after which the service process can use the session memory corresponding to that index. Releasing an object involves placing the previously requested index back into the lock-free queue; the released index can then be requested again. This process utilizes the lock-free queue to ensure both lock-free operation and support for a multi-producer, multi-consumer model.
[0072] In high-performance forwarding services, the communication session object is crucial for ensuring normal user connectivity, and different service architectures have their own session management algorithms. Some use hash tables, while others use linked lists or arrays. Therefore, in order to apply the design to different forwarding services such as virtual switches and virtual network elements, Figure 5 A schematic diagram illustrating session object data information provided in an embodiment of this application is shown. For example... Figure 5 As shown in the embodiment of this application, the content of the session object is divided into two parts: management metadata and content metadata.
[0073] Management metadata refers to the data used by various forwarding services to manage this object, such as the node pointer information of the session in the hash table or a pointer to the next session. Content metadata represents the content information carried in this session, which varies depending on the protocol. For example, a TCP session requires the source MAC address, destination MAC address, source IP address, destination IP address, source port information, and destination port information.
[0074] By separating management metadata and content metadata, management metadata belongs to a unique data structure for each process, while content metadata belongs to a shared data structure. During a hot upgrade, the new process needs to create its own management metadata based on the content metadata. Furthermore, during a hot upgrade, two processes can share a session object allocator, where each process stores its own management metadata information and is also connected to the shared session's content metadata. Figure 6 This illustration shows a schematic diagram of multiple processes sharing session content according to an embodiment of this application. For example... Figure 6 As shown, process A and process B share session content in the content metadata, and each stores management metadata such as a hash table.
[0075] Furthermore, in the embodiments of this application, a rollback can be implemented after a hot upgrade fails. During the upgrade process, the new process modifies its own session management metadata, without modifying the session management metadata of the old process. Even if the new process encounters a problem and stops running during the upgrade process, the session management metadata of the old process is not contaminated, the session content metadata is not modified, and the old process can continue to operate normally.
[0076] Furthermore, it enables upgrades between forwarding services with different architectures. During the evolution of a forwarding service, the architecture may be replaced, or the session management method may evolve. Because the management metadata is unique to each process—for example, an OVS-based forwarding service uses cmap to manage sessions, while a VPP-based forwarding service uses cuckoo hash—and the session's content metadata remains unchanged as 5-tuples, it is possible to upgrade an OVS-based forwarding service to a VPP-based forwarding service.
[0077] Figure 7 A flowchart illustrating a session migration method provided in an embodiment of this application is shown. Figure 7 As shown, the hot upgrade process basically involves the new process first mapping shared memory, such as through... Figure 3 The process shown locates the shared file. Then, the shared large pages in the shared file are mapped into the address space of the new process. Next, this embodiment of the application can locate the allocator of the session object, and finally, the new process creates its own management metadata based on the existing session. Ultimately, if the new process starts normally, the traffic of the old process can be switched to the new process. Even if the new process encounters problems and stops running during the upgrade process, the session management metadata of the old process is not contaminated, the content metadata of the session is not modified, and the old process can continue to operate normally.
[0078] The above embodiments ensure that when services are upgraded or processes are restarted, the new process can directly map the shared bigpage region of the original process, inherit existing session information, and does not need to re-establish a connection, thus ensuring uninterrupted sessions and achieving seamless migration. Furthermore, this application's embodiments do not rely on a master-slave process-dependent bigpage memory sharing scheme and employ index data management to achieve master-slave process-independent shared bigpage management capabilities, meeting the needs of services like virtual machine switches and virtual network elements that require high network data processing performance. In addition, the object allocator is implemented using CAS lock-free programming. CAS operations, through hardware-supported atomicity, avoid the thread blocking and context switching overhead of traditional locking mechanisms, improving the efficiency of object allocator allocation and deallocation.
[0079] This application provides a computer program product that, when run on an electronic device, causes the electronic device to execute the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar to those of the related embodiments described above, and will not be repeated here.
[0080] This application provides a readable storage medium containing instructions that, when executed by an electronic device, cause the electronic device to perform the technical solution described in the above embodiments. The implementation principle and technical effects are similar and will not be repeated here.
[0081] This application provides a chip for executing instructions. When the chip is running, it executes the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0082] The hardware module of this application is described below, which can be used to implement the aforementioned method 100 and Figures 2 to 7 The content shown.
[0083] Now for reference Figure 8The diagram shows a block diagram of a device 800 according to one embodiment of this application. Device 800 may include one or more processors 801 coupled to a controller hub 803. In at least one embodiment, the controller hub 803 communicates with the processor 801 via a multi-branch bus such as a front side bus (FSB), a point-to-point interface such as a quickpath interconnect (QPI), or a similar connection 810. The processor 801 executes instructions controlling general types of data processing operations. In one embodiment, the controller hub 803 includes, but is not limited to, a graphics memory controller hub (GMCH) (not shown) and an input / output hub (IOH) (which may be on a separate chip) (not shown), wherein the GMCH includes memory and a graphics controller and is coupled to the IOH.
[0084] Device 800 may also include a coprocessor 802 and a memory 804 coupled to a controller hub 803. Alternatively, one or both of the memory and the GMCH may be integrated within the processor, with memory 804 and coprocessor 802 directly coupled to processor 801 and controller hub 803, which resides on a single chip with IOH. Memory 804 may be, for example, dynamic random access memory (DRAM), phase change memory (PCM), or a combination of both. In one embodiment, coprocessor 802 is a dedicated processor, such as, for example, a high-throughput MIC processor (many integrated core, MIC), a network or communication processor, a compression engine, a graphics processor, a general-purpose computing on GPU (GPGPU), or an embedded processor, etc. Optional properties of coprocessor 802 are indicated by dashed lines. Figure 8 middle.
[0085] As a computer-readable storage medium, memory 804 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. For example, memory 804 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device such as one or more hard-disk drives (HDD(s)), one or more compact disc (CD) drives, and / or one or more digital versatile disc (DVD) drives.
[0086] In one embodiment, device 800 may further include a network interface controller (NIC) 806. NIC 806 may include a transceiver for providing a radio interface to device 800, thereby enabling communication with any other suitable device (such as a front-end module, antenna, etc.). In various embodiments, NIC 806 may be integrated with other components of device 800. NIC 806 can implement the functionality of the communication unit in the above embodiments.
[0087] Device 800 may further include input / output (I / O) device 805. I / O 805 may include: a user interface designed to enable a user to interact with device 800; a peripheral component interface designed to enable peripheral components to also interact with device 800; and / or sensors designed to determine environmental conditions and / or location information related to device 800.
[0088] It is worth noting that, Figure 8 This is merely an example. That is, although... Figure 8 The diagram shows that device 800 includes multiple devices such as processor 801, controller hub 803, and memory 804. However, in actual applications, devices using the methods of this application may include only a portion of the devices in device 800. For example, it may include only processor 801 and NIC 806. Figure 7 The properties of the optional devices are shown in dashed lines. According to some embodiments of this application, the memory 704, which is a computer-readable storage medium, stores instructions that, when executed on a computer, cause the device 700 to perform the methods according to the above embodiments. Specific details can be found in the methods of the above embodiments, and will not be repeated here.
[0089] Now for reference Figure 9 The diagram shown is a block diagram of a system-on-chip (SoC) 900 according to an embodiment of this application. Figure 9In the diagram, similar components share the same reference numerals. Additionally, dashed boxes are an optional feature for more advanced SoCs. Figure 9 In this SoC 900, the following are included: an interconnect unit 950 coupled to an application processor 910; a system proxy unit 980; a bus controller unit 990; an integrated memory controller unit 940; a group or one or more coprocessors 920, which may include integrated graphics logic, an image processor, an audio processor, and a video processor; a static random access memory (SRAM) unit 930; and a direct memory access (DMA) unit 960. In one embodiment, the coprocessor 920 includes a dedicated processor, such as, for example, a network or communication processor, a compression engine, a GPGPU, a high-throughput MIC processor, or an embedded processor.
[0090] The static random-access memory (SRAM) cell 930 may include one or more computer-readable media for storing data and / or instructions. The computer-readable storage medium may store instructions, specifically, temporary and permanent copies of those instructions. These instructions may include, when executed by at least one unit in the processor, causing the SoC 900 to perform the method according to the above embodiments, as detailed in the methods described above, which will not be repeated here.
[0091] Various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or combinations of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0092] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.
[0093] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0094] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, CD-ROMs, compact disc read-only memory (CD-ROMs), magneto-optical disks, read-only memory (ROM), random-access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagated signals. Therefore, machine-readable media includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0095] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the accompanying drawings. Furthermore, including structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.
[0096] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.
[0097] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0098] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art should understand that various changes in form and detail may be made thereto without departing from the spirit and scope of this application.
Claims
1. A session migration method based on a shared massive page memory region, characterized in that, include: Get the newly created first process; the first process is the new process. The shared large page memory region of the running second process is mapped to the virtual space of the first process. The second process is an old process that has been running. The session object data information of the second process includes second management metadata and content metadata. The second management metadata is used to manage the session forwarding service of the second process. The content metadata is used to indicate the session content information of the second process. The shared large page memory region of the second process stores the content metadata. The content metadata is obtained, and based on the content metadata, the first management metadata of the first process is constructed, and the second management metadata is retained, wherein the first management metadata is used to manage the session forwarding service information of the first process; Based on the first management metadata and the content metadata, it is determined that the first process will replace the second process in handling traffic.
2. The method according to claim 1, characterized in that, Based on the first management metadata and the content metadata, determining that the first process replaces the second process in handling traffic includes: If the first process starts normally, based on the first management metadata and the content metadata, switch the traffic of the second process to the first process, stop the second process and destroy the second management metadata; In the event that the first process fails to start, exits abnormally, or terminates, the first process is stopped, and the second process is determined to continue processing traffic based on the retained second management metadata and the content metadata.
3. The method according to claim 1 or 2, characterized in that, The second management metadata includes node pointer information of the second process's session in the hash table or pointer information pointing to the next session, and the content metadata includes the five-tuple information of the TCP session.
4. The method according to claim 1 or 2, characterized in that, The step of mapping the shared massive page memory region of the running second process to the virtual space of the first process includes: Obtain the index data created by the second process, wherein each element of the index data corresponds one-to-one with the large page memory in the shared large page memory region of the second process, and wherein the index data is used to manage the shared large page memory region; By associating the index data with the first process, the shared large page memory region is mapped to the virtual space of the first process.
5. The method according to claim 4, characterized in that, The shared big page memory region includes a session object allocator, and obtaining the content metadata includes: The first process locates the session object allocator in the shared large page memory region and obtains the content metadata.
6. The method according to claim 4, characterized in that, The step of associating the index data through the first process and mapping the shared large page memory region to the virtual space of the first process includes: Obtain the shared memory identifier information from the startup parameters of the first process; Once it is determined that the shared memory identifier information is not empty and the loaded shared file is valid, index data corresponding to the first process is created and the shared file is appended. The shared massive page memory region is mapped to the index data corresponding to the first process, thereby mapping the shared massive page memory region to the virtual space of the first process.
7. The method according to claim 5, characterized in that, The data information of the session object allocator includes the metadata information of the session object allocator, the content metadata, and the lock-free allocation queue. The lock-free allocation queue is used to allocate a target index for each session object when requesting a session object, and to reclaim the target index when releasing a session object.
8. The method according to claim 7, characterized in that, The lock-free allocation queue is implemented using a compare-and-swap (CAS) lock-free programming approach.
9. The method according to claim 1 or 2, characterized in that, The shared large page memory region includes multiple large pages of the same size.
10. An electronic device, characterized in that, It includes one or more processors; one or more memories; said one or more memories storing one or more computer programs, said one or more computer programs including instructions that, when executed by said one or more processors, cause the method of any one of claims 1 to 9 to be performed.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the method as described in any one of claims 1 to 9 to be performed.
12. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 9.
