WO2012062113A1 - Method and system for realizing multi-core hot patching - Google Patents

Method and system for realizing multi-core hot patching Download PDF

Info

Publication number
WO2012062113A1
WO2012062113A1 PCT/CN2011/075972 CN2011075972W WO2012062113A1 WO 2012062113 A1 WO2012062113 A1 WO 2012062113A1 CN 2011075972 W CN2011075972 W CN 2011075972W WO 2012062113 A1 WO2012062113 A1 WO 2012062113A1
Authority
WO
WIPO (PCT)
Prior art keywords
patch
core
core processing
patch operation
processing unit
Prior art date
Application number
PCT/CN2011/075972
Other languages
French (fr)
Chinese (zh)
Inventor
汤时虎
郑国春
赵路
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012062113A1 publication Critical patent/WO2012062113A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running

Definitions

  • the present invention relates to the field of communications, and in particular to a method and system for implementing a multi-core hot patch.
  • AMP Asymmetrical Multi-Processing
  • SMP Symmetrical Multi-Processing
  • AMP Asymmetrical Multi-Processing
  • SMP Symmetrical Multi-Processing
  • the code of the same virtual address between multiple cores is usually mapped to the same physical address for code sharing.
  • Defects and vulnerabilities are inevitable in any software system. 4
  • the methods of software defects are usually: Release a new version or patch. Since the release of the version involves more aspects, when the impact of the defect is small and the number is small, the patching method is usually adopted.
  • the so-called patching that is, using the correct code to correct the defects in the current software version, usually in the form of a patch file, such as the various patches released by the Windows operating system.
  • the system is required to be quickly corrected after a software defect is discovered, and the system is not allowed to be interrupted to avoid unnecessary losses.
  • the approximate flow of the patch operation is as follows: Step 1: Add the patch file patch.c to the existing project and compile the link into a new project. Step 2: Make a patch version. Step 3: The new patch version replaces the original version. Compared with the normal patch operation (cold patch;), the process of completing the patch operation without interrupting the system operation is called hot patch.
  • the hot patch implementation method in the related art is only applicable to a single core system (one CPU), and a hot patch for a multi-core system may cause system instability or even service interruption.
  • a primary object of the present invention is to provide a multi-core hot patch implementation method and system, to at least solve the above-mentioned related art hot patch implementation method only applicable to a single core system (a CPU), and a hot patch for a multi-core system may result in The system is unstable or even the business is interrupted.
  • a method for implementing a multi-core hot patch is provided.
  • the multi-core hot patch according to the present invention includes: one of the plurality of core processing units notifying other core processing units sharing the code before performing the patch operation on the code, and the other core processing units waiting for the patch operation to be executed after receiving the notification
  • the core processing unit that performs the patch operation performs the patch operation; after the patch operation is completed, the core processing unit that performs the patch operation notifies the other core processing unit that the patch operation is completed.
  • One of the plurality of core processing units notifies other core processing units that share the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification, including: a core processing unit that performs the patch operation ⁇ ⁇ tampering global shared variables to notify other core processing units with which they share code, where global shared variables are used for multi-core synchronization; other core processing units modify global variables to ready states to notify the core processing unit that performs the patch operation You are ready to perform the patch operation and wait for the patch operation to complete.
  • the core processing unit performing the patch operation modifies the global shared variable to the patched state to notify other core processing units with which the code is shared; the other core processing units respectively tamper with the global variable to the ready state to notify the core processing of the patch operation.
  • the unit is ready to perform the patch operation and waits for the patch operation to complete in the IDLE task (system idle task).
  • One of the plurality of core processing units notifies other core processing units that share the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification, including: the core processing unit performing the patch operation Other cores distribute inter-core interrupts to notify other core processing units with which they share code; other core processing units wait for the patch operation to complete after receiving the inter-core interrupt; after the patch operation is completed, the core processing unit that performs the patch operation The inter-core interrupt is sent again to notify other core processing unit that the patch operation has been completed. Before performing the patch operation, a fixed memory space is reserved for the patch corresponding to the patch operation. A core processing unit that identifies the shared code by setting a flag bit.
  • the patch corresponding to the patch operation is a patch pair, and the patch pair includes a patched function and a patch function.
  • the MAP file generated after the patch operation and the MAP file generated before the patch operation are consistent except for the reserved patch segment.
  • an implementation system of a multi-core hot patch is provided.
  • the implementation system of the multi-core hot patch includes: a core processing unit that performs a patch operation, comprising: a first notification module configured to notify other core processing units with which the code is shared before performing a patch operation on the code;
  • the execution module is configured to perform a patch operation;
  • the second notification module is configured to notify other core processing unit that the patch operation is completed after the execution of the patch operation is completed;
  • other core processing units including: a waiting module, configured to receive the first After the notification of the notification module, the patch operation is completed.
  • the first notification module includes: a first modification submodule, configured to modify the global shared variable to notify other core processing units with which the code is shared; the waiting module includes: a second modification submodule, configured to modify the global variable to a ready state, The core processing unit that notifies the execution of the patch operation is ready to perform the patch operation; the first waiting sub-module is set to wait for the patch operation to be completed.
  • the first modification submodule is configured to modify the global shared variable to be patched to notify other core processing units with which the code is shared; the second modification submodule is set to modify the global variable to the ready state to notify the core processing of performing the patch operation The unit is ready to perform a patch operation.
  • the first notification module includes: a first distribution sub-module configured to distribute an inter-core interrupt to other cores to notify other core processing units with which the code is shared; the second notification module includes: a second distribution sub-module, configured to be in a patch operation After the execution is completed, the inter-core interrupt is sent again to notify other core processing units that the patch operation is completed.
  • the waiting module includes: a receiving sub-module, configured to receive an inter-core interrupt; and a second waiting sub-module, set to be interrupted after receiving the inter-core Wait for the patch operation to complete.
  • FIG. 1 A plurality of core processing units are used, and the hot patch implementation method in the related art is only applicable to a single core system (one CPU), and the hot patch for the multi-core system may cause the system to be unstable or even interrupted, and further The implementation of the hot patch in the multi-core system avoids the loss caused by the system interruption and achieves the effect of improving the stability of the system.
  • FIG. 1 is a flowchart of a method for implementing a multi-core hot patch according to an embodiment of the present invention
  • FIG. 2 is a structural diagram of a foreground system and a background patch tool according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a hot patch function of a multi-core system according to an embodiment of the present invention
  • FIG. 5 is a flowchart of processing a patch command according to an embodiment of the present invention
  • FIG. 7 is a flow chart of a multi-core synchronization according to an embodiment of the present invention
  • FIG. 8 is a flowchart of an implementation system of a multi-core hot patch according to an embodiment of the present invention
  • Block diagram and FIG.
  • FIG. 9 is a structural block diagram of an implementation system of a multi-core hot patch according to an embodiment of the present invention.
  • BEST MODE FOR CARRYING OUT THE INVENTION Hereinafter, the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
  • FIG. 1 is a flowchart of a hot patch implementation method according to an embodiment of the present invention. As shown in FIG.
  • the method includes: Step 4: S 102: One of the core processing units notifies other core processing units sharing the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification; Step S104: Perform core processing of the patch operation The unit performs a patch operation; Step S106: After the execution of the patch operation is completed, the core processing unit that performs the patch operation notifies the other core processing unit that the patch operation is completed.
  • one of the core processing units of the plurality of shared codes notifies other core processing units sharing the code to wait for the execution of the patch operation thereof before performing the patch operation on the code, and then notifies after the patch operation is performed.
  • step S102 a preferred embodiment of step S102 is described below.
  • the core processing unit 4 performing the patch operation tampers with the global shared variable to notify other core processing units with which the code is shared, wherein the global shared variable is used for multi-core synchronization; the other core processing units respectively tamper with the global variable to the ready state
  • the core processing unit that notifies the execution of the patch operation is ready to perform the patch operation and waits for the patch operation to complete.
  • the core processing unit performing the patch operation tampers the global shared variable to the patched state to notify other core processing units with which the code is shared; the other core processing units respectively tamper with the global variable to the ready state to notify the execution of the patch
  • the core processing unit of the operation is ready to perform the patch operation and wait for the patch operation to complete in the IDLE task.
  • step S102 the interaction of information between multiple cores is implemented by IDLE, which reduces the interruption delay of the hot patch and reduces the impact on the business process.
  • the core processing unit performing the patch operation distributes the inter-core interrupt to other cores to notify other core processing units with which the code is shared; after receiving the interrupt, the other core processing units wait for the patch operation to be completed; after the execution of the patch operation is completed, the execution
  • the core processing unit of the patch operation again sends an inter-core interrupt to notify other core processing unit that the patch operation is completed.
  • the transfer of inter-core information in the hot patch is achieved by distributing inter-core interrupts.
  • a fixed memory space is reserved for the patch corresponding to the patch operation before the patch operation is performed.
  • all memory except the patch file is guaranteed to be unaffected, and the correctness of executing the hot patch is guaranteed.
  • the core processing unit for identifying the shared code is identified by setting a flag bit.
  • all core processing orders can be implemented by a core processing unit identified as a logo sharing code Meta-shared code or part of the core processing unit shared code, which can support both SMP-based and AMP-based systems.
  • the patch corresponding to the patch operation is a patch pair, and the patch pair includes a patched function and a patch function. With the preferred embodiment, the patched function and the patch function are used as patch pairs.
  • Embodiment 1 This embodiment combines the foregoing embodiments and preferred embodiments thereof.
  • a method for implementing a multi-core hot patch is provided. The method includes: Step 1: Marking a core applicable to a patch function Number distribution (patches applicable bitmap).
  • the patch function (the implementation of the error in the original system) and the patch function (the correct implementation for modifying the patched function) are called a pair of patches (Pair).
  • Step 1 2: Reserve patch segments in the original system. To ensure that the original system avoids call exceptions after the patch operation, you must ensure that in addition to the patch segment.
  • Other memory partitions are consistent before and after the patch.
  • a function calls callp FuncOrigText.
  • _FuncOrigText is replaced by a memory address generated by the compilation. If the address of FuncOrigText before and after the patch is divided into 'J 0x1000 and 0x2000, then executing the function call after the patch will not get the correct result.
  • the application is required to reserve a certain memory space (fixed size and fixed address) in advance for the hot patch module.
  • Step 3 Use the background patch tool to create, verify, and distribute the patch package.
  • 2 is an architectural diagram of a foreground system and a background patching tool according to an embodiment of the present invention. As shown in FIG. 2, the background patching tool sends a patch command to the foreground software system, and receives an execution result fed back from the foreground software system.
  • the patch tool provides a user-friendly interface that allows the user to specify various configurations of the patch: such as the version number of the patch pair and the applicable core number of the patch pair.
  • the patch tool extracts information about patch pairs from user-defined MAP files and OUT files: function names, function definitions, binary implementations, and more.
  • the information is written to the patch package according to the defined format patch.
  • the patch tool provides the MAP file school-risk function, that is, the patch tool can determine whether the map file of the original system MAP file and the patch system is in addition to the patch segment. Nothing else is different.
  • the patch tool generates a patch package file.
  • the patch tool opens the TFTP server.
  • FIG. 3 is a flowchart of a patching tool for creating a patch package according to an embodiment of the present invention. As shown in FIG.
  • Step S302 The user inputs various attribute information of the patch package on the patch tool.
  • Step S304 Whether the patch tool school-risk system MAP file is consistent with the new system MAP.
  • Step S306 The patch tool extracts patch segment information from the new system MAP file and the OUT file.
  • Step 4 S308: The patch tool generates a patch package file.
  • the software system hot patch function module processes the patch request. When the software system initializes the hot patch module, it creates a patch processing task to process all commands related to the patch operation. These include: activating patches and uninstalling patches.
  • segment. 4 is a schematic diagram of a hot patch function of a multi-core system according to an embodiment of the present invention. As shown in FIG. 4, the hot patch function management module performs information interaction with a memory storage unit to complete patch command processing, patch version management, and code. . Cache (CACHE) synchronization, multi-core state synchronization and more. Step 5: After multi-core synchronization ⁇ ⁇ 'tamper the jump code at the patched function.
  • CACHE Cache
  • the minimum core modifies the global shared variable and notifies other cores related to this patch operation.
  • Other cores found that the core needs to be patched and enter IDLE. Modify the global shared variable to the ready state, and notify the minimum core that the core has been synchronized. Thereafter, the other cores die in the IDLE task until the minimum core completes the patch operation.
  • the minimum core starts to perform the patch operation.
  • FIG. 5 is a flowchart of processing a patch command according to an embodiment of the present invention, including: Step 4: S502: The patch tool sends a patch request command to a software system. Step S504: The minimum core change global variable notifies other cores to enter the multi-core synchronization state. Step S506: The other core receives the synchronization request, enters the IDLE task, modifies the global variable, and dies. Step S508: The minimum core configures the patch segment after the other cores are synchronized, and modifies the jump code of the patched function.
  • Step S510 The minimum core patch operation is completed, and the other cores are notified to leave the multi-core synchronization state.
  • the synchronization process can also be implemented in the following manner.
  • the primary core is responsible for receiving the patch request and distributing the inter-core interrupt to other cores that need to cooperate.
  • the other cores receive the inter-core interrupt for the first time (the main core is ready to start the hot patch operation) and wait until the primary core is received again. If the inter-core interrupt is sent, the primary core can be considered to have completed the hot patch operation, returning from the interrupt and continuing to execute the business process.
  • the drawback of this method is that it may affect the business process, and the delay of the interruption is relatively large.
  • multi-core synchronization can also be achieved by using a multi-core synchronization mechanism such as inter-core semaphores and inter-core mailboxes.
  • Step 6 The software system manages different patch versions. After the patch is downloaded to the foreground, it is backed up in memory. Different versions of the patch are allowed to exist in the current system at the same time as the memory allows. This feature is an add-on feature that allows users to define multiple fix packs for flexible operation and more comprehensive support for unit and integration testing. It should be noted that the technical solution presented in the foregoing embodiment is implemented in a multi-core DSP system, but the same applies to other single-core systems or multi-core systems, and is not mentioned here.
  • Embodiment 2 This embodiment provides a multi-core hot patch implementation method.
  • the code segment is divided into 3 types: 1) 6 core shared code, called ST; 2) core 0, core 1 shared group code, called G1T; 3) core 2 3, 4, 5 Shared grouping code, called G2T.
  • ST 6 core shared code
  • G1T core 1 shared group code
  • G2T core 2 3, 4, 5 Shared grouping code
  • the corresponding patch functions are ST_Func_Patch, GlT Func Patch and G2T_Func_Patch.
  • the method includes the following steps: Step 1: Implement the patch function, compile the patch project, and generate the patch code.
  • Step 2 Create a patch package file Specifically, connect the software system to the patch tool. The user sets the patch pair (ST_Func, ST Func Patch), (GlT_Func, GlT Func Patch) in turn through the patch tool.
  • Step 3 Send a patch activation or uninstall command.
  • the activation command is used by the software system to download the patch package file from the background host to the memory, and replace the patch function with the patch function in the patch package.
  • the patch function is used to remove the currently running patch package, the system status is restored to the state before the patch, and the backup of the patch package is deleted from the memory.
  • Step 4 The hot patch task processes the patch request. Including step a and step b. Step a: If the patch tool sends an activation to the software system So, the patch tool to open a TFTP server locally, while the IP address of the TFTP server, the local patch storage path, patch version number as an additional command is sent to the reception system parameters.
  • the smallest core that is currently running starts to perform the patch operation.
  • Synchronization of multi-core systems uses global shared variables to flag the state of each core for synchronization. Volatile unsigned int gaudCoresPatchStat[6]; ⁇ flag multi-core synchronization state.
  • Each core of this embodiment corresponds to an index of gaudCoresPatchStat.
  • FIG. 7 is a flowchart of multi-core synchronization according to an embodiment of the present invention. As shown in FIG. 7, the method includes: Step S702: The minimum core modifies the core flag related to the current patch operation to PM SYNC ENTER. Step S704: The minimum core configuration patch segment. Step S706: The minimum core modification patch function jump code. Step S708: Update gtCachetrl (multi-core cache control information variable).
  • Step S710 The minimum core modifies gaudCoresPatchStat (weight synchronization state flag variable) to PM SYNC EXIT.
  • Step S712 feedback the execution result, and exit.
  • Step S714 After the other cores enter the IDLE task, check whether the flag of the core is
  • Step S716 Then die, until the flag of the core is PM_SYNC_EXIT.
  • the minimum core copies the patch code segments, data segments, and constant segments saved in the patch package file to the corresponding physical memory after all the cores are synchronized.
  • ST Func's first instruction should be modified to jmp ST Func Patch, where _ST_Func_Patch should be a specific memory address. It is important to note that after executing the ST Func Patch, the PC pointer should be returned to the address where ST Func is called.
  • Step S718 At the same time, since the code segment may be cacheable, after the minimum core modifies the code of the patched function, the other core should be notified to refresh the cache of the patched function, so that other cores still execute the old code in the cache.
  • the specific implementation scheme is as follows: Define a global structure variable gtCacheCtrl, and save the data related to the patched function in the patch package. After the minimum core performs the patch operation, the information in the patch package is backed up to gtCacheCtrl. Other cores will flush the gtCacheCtrl content to the cache before exiting the IDLE task, completing the synchronization of the memory and the cache.
  • Step S720 After the minimum core completes the above work, the flag of the patch-related core is modified to be PM_SYNC_EXIT. Other cores were able to exit in the IDLE task and continue to execute.
  • Step b If the patch tool sends an uninstall command to the software system, the foreground system performs the following operations: The information of the original patch function of the backup is used to restore the system state before the patch. The synchronization operation in this process is consistent with the above. Then, all the dynamic memory that is applied during the patch activation process is released, and the backup patch file is deleted to avoid the hidden danger of the memory leak in the system.
  • Step 5 Hot patch task feedback processing results.
  • FIG. 8 is a structural block diagram of a system for implementing a multi-core hot patch according to an embodiment of the present invention. As shown in FIG.
  • the core processing unit 2 of the operation comprising: a first notification module 82, configured to notify other core processing units sharing the code with the code before performing the patch operation on the code; the execution module 84 is connected to the first notification module 82, and is set to After the first notification module 82 notifies the other core processing units with which the code is shared, the patch operation is performed; the second notification module 86 is connected to the execution module 84, and is configured to notify other core processing after the execution of the patch operation of the execution module 84 is completed.
  • the unit patch operation is completed; the other core processing unit 4 includes: a waiting module 88, configured to wait for the execution of the patch operation after receiving the notification of the first notification module 82.
  • the first notification module 82 includes: a first modification submodule 822, set to modify the global shared variable to notify other core processing units with which to share the code;
  • the waiting module 88 includes: a second modification sub-module 882, configured to modify the global variable to the ready state to notify the core processing unit that performs the patch operation It is ready to perform the patch operation;
  • the first wait sub-module 884 connected to the second modification sub-module 882, is set to wait for the patch operation to complete.
  • the first modification submodule 822 is configured to modify the global shared variable to be in a state to be synchronized to notify other core processing units with which the code is shared; the second modification submodule 882 is set to modify the global variable to a ready state to notify execution The core processing unit of the patch operation is ready to perform the patch operation.
  • the first notification module 82 includes: a first distribution sub-module 824 configured to distribute inter-core interrupts to other cores to notify other core processing units with which the code is shared; the second notification module 86 includes: a second distribution sub-module 862, setting After the execution of the patch operation is completed, the inter-core interrupt is sent again to notify other core processing unit that the patch operation is completed.
  • the waiting module 88 includes: a receiving submodule 886, configured to receive the inter-core interrupt; and a second waiting sub-module 888, the connection
  • the receiving sub-module 886 is configured to wait for the execution of the patch operation after receiving the inter-core interrupt; and the foregoing embodiment provides a multi-core hot patch implementation method and system, by which the core processing unit of multiple shared codes is provided
  • One of the other core processing units that have shared the code waits for the completion of the patch operation before performing the patch operation on the code, and then notifies the other core processing unit of the shared code that the patch operation is completed after the patch operation is performed, overcoming
  • the hot patch implementation method in the related art only applies Single-core processing unit, multi-core processing units in the system can cause problems in system instability and service interruption, to achieve a hot patches in multi-core systems to achieve the effect of improving the stability of the system.
  • modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device, and in some In this case, the steps shown or described may be performed in an order different from that herein, or they may be separately fabricated into individual integrated circuit modules, or a plurality of the modules or steps may be implemented as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.

Abstract

A method and system for realizing multi-core hot patching are provided. The method comprises: before executing a patching operation to codes, one of multiple core processing units notifies other core processing units which share code with the core processing unit, and the other core processing units wait for the completion of the patching operation after receiving the notice (S102); the core processing unit for executing the patching operation executes the patching operation (S104); and after completing the patching operation, the core processing unit for executing the patching operation notifies other core processing units of the completion of the patching operation (S106). The technical solution improves the stability of the system.

Description

多核热 卜丁的实现方法及系统 技术领域 本发明涉及通信领域,具体而言, 涉及一种多核热补丁的实现方法及系统。 背景技术 随着中央处理器( Central Processing Unit, 简称为 CPU )技术的不断发展, 多核技术已经成为当前的主流。 传统的多核架构有两种: 非对称多处理 ( Asymmetrical Multi-Processing , 简称为 AMP ) 和对称多处理 ( Symmetrical Multi-Processing, 简称为 SMP )。 SMP就是多个内核运行一个操作系统, 它们 共享内存、 总线和其它资源, 任务被均匀分配到各个内核上进行处理。 在 SMP 架构中, 每个内核的地位是相等的。 而 AMP架构中, 各个内核有主有次, 每 个内核均运行一个操作系统, 才艮据分工的不同处理不同类型的任务。 在 AMP 架构下, 为了节省内存, 通常多核之间相同虚拟地址的代码会被映射到相同的 物理地址上, 以实现代码共享。 任何软件系统都不可避免的存在缺陷和漏洞, 4爹正软件缺陷的方法通常 有: 发布新版本或打补丁。 由于版本发布会牵涉较多方面, 因此在缺陷影响小、 数目少时, 通常釆用打补丁的办法。 所谓打补丁, 即用正确的代码来更正当前 软件版本中的缺陷, 通常以补丁文件的形式来完成, 如 Windows操作系统发布 的各个补丁包。 在电信服务中, 要求系统在发现软件缺陷后能迅速地修正, 并 且不允许系统中断运行以避免造成不必要的损失。 补丁操作大致的流程如下所 示: 步骤 1 : 在现有工程中加入补丁文件 patch.c, 编译链接成新的工程。 步骤 2: 制作补丁版本。 步骤 3:新的补丁版本代替原有的版本。相对于普通情况下的补丁操作(冷 补丁;), 不中断系统运行的前提下即完成补丁操作的过程称为热补丁。 相关技术中的热补丁实现方法只适用于单核系统 (一个 CPU ), 对于多核 系统的热补丁可能导致系统不稳-定甚至业务中断。 发明内容 本发明的主要目的在于提供一种多核热补丁实现方法及系统, 以至少解决 上述相关技术中的热补丁实现方法只适用于单核系统 (一个 CPU ), 对于多核 系统的热补丁可能导致系统不稳定甚至业务中断的问题。 为了实现上述目的, 才艮据本发明的一个方面, 提供了一种多核热补丁的实 现方法。 才艮据本发明的多核热补丁包括: 多个核心处理单元中的一个在对代码执行 补丁操作之前, 通知与其共享代码的其他核心处理单元, 其他核心处理单元在 接收到通知后等待补丁操作执行完毕; 执行补丁操作的核心处理单元执行补丁 操作; 在补丁操作执行完毕之后, 执行补丁操作的核心处理单元通知其他核心 处理单元补丁操作执行完毕。 多个核心处理单元中的一个在对代码执行补丁操作之前, 通知与其共享代 码的其他核心处理单元, 其他核心处理单元在接收到通知后等待补丁操作执行 完毕包括: 执行补丁操作的核心处理单元^ ί'爹改全局共享变量, 以通知与其共享 代码的其他核心处理单元, 其中, 全局共享变量用于多核同步; 其他核心处理 单元分别修改全局变量为就绪状态以通知执行补丁操作的核心处理单元其已 经准备执行补丁操作, 并等待补丁操作执行完毕。 执行补丁操作的核心处理单元修改全局共享变量为待补丁状态, 以通知与 其共享代码的其他核心处理单元; 其他核心处理单元分别^ ί'爹改全局变量为就绪 状态以通知执行补丁操作的核心处理单元其已经准备执行补丁操作, 并在 IDLE任务 (系统空闲任务) 中等待补丁操作执行完毕。 多个核心处理单元中的一个在对代码执行补丁操作之前, 通知与其共享代 码的其他核心处理单元, 其他核心处理单元在接收到通知后等待补丁操作执行 完毕包括: 执行补丁操作的核心处理单元向其他核分发核间中断, 以通知与其 共享代码的其他核心处理单元; 其他核心处理单元在接收到核间中断之后, 等 待补丁操作执行完毕; 在补丁操作执行完毕之后, 执行补丁操作的核心处理单 元再次发送核间中断以通知其他核心处理单元补丁操作执行完毕。 在执行补丁操作之前, 为补丁操作对应的补丁预定固定的内存空间。 通过设置标志位用于标识共享代码的核心处理单元。 补丁操作对应的补丁为补丁对, 补丁对包括被补丁函数和补丁函数。 补丁操作后生成的 MAP文件和补丁操作前生成的 MAP文件除预留补丁段 之外保持一致。 根据本发明的另一方面, 提供了一种多核热补丁的实现系统。 才艮据本发明的多核热补丁的实现系统包括: 执行补丁操作的核心处理单 元, 其包括: 第一通知模块, 设置为在对代码执行补丁操作之前, 通知与其共 享代码的其他核心处理单元; 执行模块,设置为执行补丁操作; 第二通知模块, 设置为在补丁操作执行完毕之后, 通知其他核心处理单元补丁操作执行完毕; 其他核心处理单元, 其包括: 等待模块, 设置为在接收到第一通知模块的通知 后等待补丁操作执行完毕。 第一通知模块包括: 第一修改子模块, 设置为修改全局共享变量, 以通知 与其共享代码的其他核心处理单元; 等待模块包括: 第二修改子模块, 设置为 修改全局变量为就绪状态, 以通知执行补丁操作的核心处理单元其已经准备执 行补丁操作; 第一等待子模块, 设置为等待补丁操作执行完毕。 第一修改子模块, 设置为修改全局共享变量为待补丁状态, 以通知与其共 享代码的其他核心处理单元; 第二修改子模块, 设置为修改全局变量为就绪状 态以通知执行补丁操作的核心处理单元其已经准备执行补丁操作。 第一通知模块包括: 第一分发子模块, 设置为向其他核分发核间中断, 以 通知与其共享代码的其他核心处理单元; 第二通知模块包括: 第二分发子模块, 设置为在补丁操作执行完毕之后, 再次发送核间中断以通知其他核心处理单元 补丁操作执行完毕; 等待模块包括: 接收子模块, 设置为接收到核间中断; 第 二等待子模块, 设置为在接收核间中断后等待补丁操作执行完毕。 通过本发明, 釆用多个核心处理单元, 解决了相关技术中的热补丁实现方 法只适用于单核系统 (一个 CPU ), 对于多核系统的热补丁可能导致系统不稳 定甚至中断的问题, 进而实现了在多核系统中实现热补丁, 避免了系统中断造 成的损失, 并达到了提高了系统稳定性的效果。 附图说明 此处所说明的附图用来提供对本发明的进一步理解, 构成本申请的一部 分, 本发明的示意性实施例及其说明用于解释本发明, 并不构成对本发明的不 当限定。 在附图中: 图 1是才艮据本发明实施例的多核热补丁实现方法的流程图; 图 2是 居本发明实施例的前台系统以及后台补丁工具的架构图; 图 3是 居本发明实施例的后台补丁工具制作补丁包的流程图; 图 4是才艮据本发明实施例的多核系统的热补丁功能示意图; 图 5是 居本发明实施例的处理补丁命令的流程图; 图 6是才艮据本发明实施例的多核系统框架图; 图 7是才艮据本发明实施例的多核同步的流程图; 图 8是才艮据本发明实施例的多核热补丁的实现系统的结构框图; 以及 图 9是才艮据本发明实施例的多核热补丁的实现系统的结构框图。 具体实施方式 下文中将参考附图并结合实施例来详细说明本发明。 需要说明的是, 在不 冲突的情况下, 本申请中的实施例及实施例中的特征可以相互组合。 本实施例提供了一种多核热补丁的实现方法, 图 1是才艮据本发明实施例的 热补丁实现方法的流程图, 如图 1所示, 该方法包括: 步 4聚 S 102: 多个核心处理单元中的一个在对代码执行补丁操作之前, 通知 与其共享代码的其他核心处理单元, 其他核心处理单元在接收到通知后等待补 丁操作执行完毕; 步骤 S 104: 执行补丁操作的核心处理单元执行补丁操作; 步骤 S 106: 在补丁操作执行完毕之后, 执行补丁操作的核心处理单元通知 其他核心处理单元补丁操作执行完毕。 通过上述步 4聚, 多个共享代码的核心处理单元中的一个在对代码执行补丁 操作之前, 通知与其共享代码的其他核心处理单元等待其补丁操作执行完毕, 然后在其执行完补丁操作后通知与其共享代码的其他核心处理单元补丁操作 执行完毕, 克服了相关技术中的热补丁实现方法只适用于单核心处理单元, 在 多核心处理单元系统中会造成系统不稳定及业务中断的问题, 实现了在多核系 统中实现热补丁, 达到了提高了系统稳定性的效果。 优选地, 下面对步骤 S 102 中的一个优选的实施方式进行说明。 执行补丁 操作的核心处理单元 4爹改全局共享变量, 以通知与其共享代码的其他核心处理 单元, 其中, 全局共享变量用于多核同步; 其他核心处理单元分别^ ί'爹改全局变 量为就绪状态以通知执行补丁操作的核心处理单元其已经准备执行补丁操作, 并等待补丁操作执行完毕。 通过该优选实施例, 实现了通过修改全局共享变量 用以通知本次补丁操作相关的其他核心处理单元, 以及通过^ ί'爹改全局变量为就 绪状态以通知准备执行补丁操作, 并等待补丁操作执行完毕, 实现了在不影响 业务流程的情况下多核之间的同步。 优选地, 执行补丁操作的核心处理单元^ ί'爹改全局共享变量为待补丁状态, 以通知与其共享代码的其他核心处理单元; 其他核心处理单元分别爹改全局变 量为就绪状态以通知执行补丁操作的核心处理单元其已经准备执行补丁操作, 并在 IDLE任务中等待补丁操作执行完毕。 通过该优选实施例, 通过 IDLE实 现多核之间信息的交互, 降低了热补丁的中断延迟并降低了对业务流程的影 响。 下面对步骤 S 102 的一个优选的实施方式进行说明。 执行补丁操作的核心 处理单元向其他核分发核间中断, 以通知与其共享代码的其他核心处理单元; 其他核心处理单元在接收到中断之后, 等待补丁操作执行完毕; 在补丁操作执 行完毕之后, 执行补丁操作的核心处理单元再次发送核间中断以通知其他核心 处理单元补丁操作执行完毕。 通过该优选实施例, 实现了通过分发核间中断来 实现热补丁中核间信息的传递。 优选地, 在执行补丁操作之前, 为补丁操作对应的补丁预定固定的内存空 间。 通过该优选实施例, 保证了除补丁文件外的其他所有内存不受影响, 及保 证了执行热补丁的正确性。 优选地, 通过设置标志位用于标识共享代码的核心处理单元。 通过该优选 实施例, 通过标识为标志共享代码的核心处理单元, 可以实现所有核心处理单 元共享代码或者部分核心处理单元共享代码, 既可以支持 SMP 架构的系统, 也可以支持 AMP架构的系统。 优选地, 补丁操作对应的补丁为补丁对, 补丁对包括被补丁函数和补丁函 数。 通过该优选实施例, 将被补丁函数和补丁函数作为补丁对, 在补丁操作出 现错误时, 可以执行被补丁函数用以系统还原, 提高了系统的健壮性。 优选地,补丁操作后生成的 MAP文件和补丁操作前生成的 MAP文件除预 留补丁段之外保持一致。 通过该优选实施例, 保证了补丁对文件的准确性。 实施例一 本实施例结合了上述实施例及其中的优选实施方式, 在本实施例中, 提供 了一种多核热补丁的实现方法, 该方法包括: 步骤 1 : 用以标志补丁函数适用的核号分布(补丁适用位图)。 并以被补丁 函数(原有系统中错误的实现) 和补丁函数(用于对被补丁函数进行修改的正 确实现) 为一组称为补丁对(Pair )。 若该对补丁对适用于某核, 其对应比特位 置 1。 所有的补丁对及其它补丁信息 (如补丁函数的二进制码实现、 补丁函数 在补丁段里的分布等) 共同组成一个补丁文件, 称为补丁包 (Patch )。 在复杂的系统 (指 AMP架构的多核系统) 中, 由于功能划分的需要, 可 能既存在多核共享代码, 也存在单核私有代码, 甚至是某几个核共享、 其它核 不能访问的分组代码, 通过步骤 1 , 代码可以用来标识是那几个核共享的。 步 4聚 2: 在原有系统中预留补丁段。 为了保证原系统在补丁操作后避免出现调用异常, 必须保证除了补丁段The present invention relates to the field of communications, and in particular to a method and system for implementing a multi-core hot patch. BACKGROUND With the continuous development of the Central Processing Unit (CPU) technology, multi-core technology has become the mainstream. There are two traditional multi-core architectures: Asymmetrical Multi-Processing (abbreviated as AMP) and Symmetrical Multi-Processing (SMP). SMP is where multiple cores run an operating system that shares memory, bus, and other resources, and tasks are evenly distributed to each core for processing. In the SMP architecture, the status of each core is equal. In the AMP architecture, each core has its own master and time. Each core runs an operating system, and different types of tasks are handled according to the division of labor. In the AMP architecture, in order to save memory, the code of the same virtual address between multiple cores is usually mapped to the same physical address for code sharing. Defects and vulnerabilities are inevitable in any software system. 4 The methods of software defects are usually: Release a new version or patch. Since the release of the version involves more aspects, when the impact of the defect is small and the number is small, the patching method is usually adopted. The so-called patching, that is, using the correct code to correct the defects in the current software version, usually in the form of a patch file, such as the various patches released by the Windows operating system. In telecommunications services, the system is required to be quickly corrected after a software defect is discovered, and the system is not allowed to be interrupted to avoid unnecessary losses. The approximate flow of the patch operation is as follows: Step 1: Add the patch file patch.c to the existing project and compile the link into a new project. Step 2: Make a patch version. Step 3: The new patch version replaces the original version. Compared with the normal patch operation (cold patch;), the process of completing the patch operation without interrupting the system operation is called hot patch. The hot patch implementation method in the related art is only applicable to a single core system (one CPU), and a hot patch for a multi-core system may cause system instability or even service interruption. SUMMARY OF THE INVENTION A primary object of the present invention is to provide a multi-core hot patch implementation method and system, to at least solve the above-mentioned related art hot patch implementation method only applicable to a single core system (a CPU), and a hot patch for a multi-core system may result in The system is unstable or even the business is interrupted. In order to achieve the above object, according to an aspect of the present invention, a method for implementing a multi-core hot patch is provided. The multi-core hot patch according to the present invention includes: one of the plurality of core processing units notifying other core processing units sharing the code before performing the patch operation on the code, and the other core processing units waiting for the patch operation to be executed after receiving the notification The core processing unit that performs the patch operation performs the patch operation; after the patch operation is completed, the core processing unit that performs the patch operation notifies the other core processing unit that the patch operation is completed. One of the plurality of core processing units notifies other core processing units that share the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification, including: a core processing unit that performs the patch operation^爹 爹 tampering global shared variables to notify other core processing units with which they share code, where global shared variables are used for multi-core synchronization; other core processing units modify global variables to ready states to notify the core processing unit that performs the patch operation You are ready to perform the patch operation and wait for the patch operation to complete. The core processing unit performing the patch operation modifies the global shared variable to the patched state to notify other core processing units with which the code is shared; the other core processing units respectively tamper with the global variable to the ready state to notify the core processing of the patch operation. The unit is ready to perform the patch operation and waits for the patch operation to complete in the IDLE task (system idle task). One of the plurality of core processing units notifies other core processing units that share the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification, including: the core processing unit performing the patch operation Other cores distribute inter-core interrupts to notify other core processing units with which they share code; other core processing units wait for the patch operation to complete after receiving the inter-core interrupt; after the patch operation is completed, the core processing unit that performs the patch operation The inter-core interrupt is sent again to notify other core processing unit that the patch operation has been completed. Before performing the patch operation, a fixed memory space is reserved for the patch corresponding to the patch operation. A core processing unit that identifies the shared code by setting a flag bit. The patch corresponding to the patch operation is a patch pair, and the patch pair includes a patched function and a patch function. The MAP file generated after the patch operation and the MAP file generated before the patch operation are consistent except for the reserved patch segment. According to another aspect of the present invention, an implementation system of a multi-core hot patch is provided. The implementation system of the multi-core hot patch according to the present invention includes: a core processing unit that performs a patch operation, comprising: a first notification module configured to notify other core processing units with which the code is shared before performing a patch operation on the code; The execution module is configured to perform a patch operation; the second notification module is configured to notify other core processing unit that the patch operation is completed after the execution of the patch operation is completed; and other core processing units, including: a waiting module, configured to receive the first After the notification of the notification module, the patch operation is completed. The first notification module includes: a first modification submodule, configured to modify the global shared variable to notify other core processing units with which the code is shared; the waiting module includes: a second modification submodule, configured to modify the global variable to a ready state, The core processing unit that notifies the execution of the patch operation is ready to perform the patch operation; the first waiting sub-module is set to wait for the patch operation to be completed. The first modification submodule is configured to modify the global shared variable to be patched to notify other core processing units with which the code is shared; the second modification submodule is set to modify the global variable to the ready state to notify the core processing of performing the patch operation The unit is ready to perform a patch operation. The first notification module includes: a first distribution sub-module configured to distribute an inter-core interrupt to other cores to notify other core processing units with which the code is shared; the second notification module includes: a second distribution sub-module, configured to be in a patch operation After the execution is completed, the inter-core interrupt is sent again to notify other core processing units that the patch operation is completed. The waiting module includes: a receiving sub-module, configured to receive an inter-core interrupt; and a second waiting sub-module, set to be interrupted after receiving the inter-core Wait for the patch operation to complete. Through the present invention, a plurality of core processing units are used, and the hot patch implementation method in the related art is only applicable to a single core system (one CPU), and the hot patch for the multi-core system may cause the system to be unstable or even interrupted, and further The implementation of the hot patch in the multi-core system avoids the loss caused by the system interruption and achieves the effect of improving the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS The accompanying drawings, which are set to illustrate,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, In the drawings: FIG. 1 is a flowchart of a method for implementing a multi-core hot patch according to an embodiment of the present invention; FIG. 2 is a structural diagram of a foreground system and a background patch tool according to an embodiment of the present invention; FIG. 4 is a schematic diagram of a hot patch function of a multi-core system according to an embodiment of the present invention; FIG. 5 is a flowchart of processing a patch command according to an embodiment of the present invention; FIG. 7 is a flow chart of a multi-core synchronization according to an embodiment of the present invention; FIG. 8 is a flowchart of an implementation system of a multi-core hot patch according to an embodiment of the present invention; Block diagram; and FIG. 9 is a structural block diagram of an implementation system of a multi-core hot patch according to an embodiment of the present invention. BEST MODE FOR CARRYING OUT THE INVENTION Hereinafter, the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict. This embodiment provides a method for implementing a multi-core hot patch. FIG. 1 is a flowchart of a hot patch implementation method according to an embodiment of the present invention. As shown in FIG. 1, the method includes: Step 4: S 102: One of the core processing units notifies other core processing units sharing the code before performing the patch operation on the code, and the other core processing units wait for the execution of the patch operation after receiving the notification; Step S104: Perform core processing of the patch operation The unit performs a patch operation; Step S106: After the execution of the patch operation is completed, the core processing unit that performs the patch operation notifies the other core processing unit that the patch operation is completed. Through the above step 4, one of the core processing units of the plurality of shared codes notifies other core processing units sharing the code to wait for the execution of the patch operation thereof before performing the patch operation on the code, and then notifies after the patch operation is performed. The other core processing unit patch operations with the shared code are executed, and the hot patch implementation method in the related art is only applicable to the single core processing unit, which causes system instability and business interruption in the multi-core processing unit system. The implementation of hot patching in a multi-core system has improved the stability of the system. Preferably, a preferred embodiment of step S102 is described below. The core processing unit 4 performing the patch operation tampers with the global shared variable to notify other core processing units with which the code is shared, wherein the global shared variable is used for multi-core synchronization; the other core processing units respectively tamper with the global variable to the ready state The core processing unit that notifies the execution of the patch operation is ready to perform the patch operation and waits for the patch operation to complete. With the preferred embodiment, it is implemented to modify the global shared variable to notify other core processing units related to the patch operation, and to tamper with the global variable to the ready state to notify that the patch operation is ready to be executed, and wait for the patch operation. After the execution is completed, synchronization between multiple cores is achieved without affecting the business process. Preferably, the core processing unit performing the patch operation tampers the global shared variable to the patched state to notify other core processing units with which the code is shared; the other core processing units respectively tamper with the global variable to the ready state to notify the execution of the patch The core processing unit of the operation is ready to perform the patch operation and wait for the patch operation to complete in the IDLE task. Through the preferred embodiment, the interaction of information between multiple cores is implemented by IDLE, which reduces the interruption delay of the hot patch and reduces the impact on the business process. A preferred embodiment of step S102 will now be described. The core processing unit performing the patch operation distributes the inter-core interrupt to other cores to notify other core processing units with which the code is shared; after receiving the interrupt, the other core processing units wait for the patch operation to be completed; after the execution of the patch operation is completed, the execution The core processing unit of the patch operation again sends an inter-core interrupt to notify other core processing unit that the patch operation is completed. With the preferred embodiment, the transfer of inter-core information in the hot patch is achieved by distributing inter-core interrupts. Preferably, a fixed memory space is reserved for the patch corresponding to the patch operation before the patch operation is performed. With the preferred embodiment, all memory except the patch file is guaranteed to be unaffected, and the correctness of executing the hot patch is guaranteed. Preferably, the core processing unit for identifying the shared code is identified by setting a flag bit. With the preferred embodiment, all core processing orders can be implemented by a core processing unit identified as a logo sharing code Meta-shared code or part of the core processing unit shared code, which can support both SMP-based and AMP-based systems. Preferably, the patch corresponding to the patch operation is a patch pair, and the patch pair includes a patched function and a patch function. With the preferred embodiment, the patched function and the patch function are used as patch pairs. When an error occurs in the patch operation, the patched function can be executed for system restoration, thereby improving the robustness of the system. Preferably, the MAP file generated after the patch operation and the MAP file generated before the patch operation are consistent except for the reserved patch segment. With this preferred embodiment, the accuracy of the patch to the file is guaranteed. Embodiment 1 This embodiment combines the foregoing embodiments and preferred embodiments thereof. In this embodiment, a method for implementing a multi-core hot patch is provided. The method includes: Step 1: Marking a core applicable to a patch function Number distribution (patches applicable bitmap). The patch function (the implementation of the error in the original system) and the patch function (the correct implementation for modifying the patched function) are called a pair of patches (Pair). If the pair of patches applies to a core, its corresponding bit position is 1. All patch pairs and other patch information (such as the binary implementation of the patch function, the distribution of the patch function in the patch segment, etc.) together form a patch file called a patch. In a complex system (referring to the AMP-architecture multi-core system), due to the need for functional partitioning, there may be multiple core shared code, single-core private code, or even a few core shared, other cores can not access the packet code, Through step 1, the code can be used to identify which cores are shared. Step 4: 2: Reserve patch segments in the original system. To ensure that the original system avoids call exceptions after the patch operation, you must ensure that in addition to the patch segment.
(数据段、 代码段和常量段等) 外的其它内存划分在补丁前后是一致的。 如: 在原有系统中有一函数调用 callp FuncOrigText, 在链接后生成的二进制代码 中, _FuncOrigText 被编译生成的一个内存地址所替换。 支如补丁前后 FuncOrigText的地址分另' J 0x1000和 0x2000, 那么补丁后执行该函数调用将无 法得到正确的结果。 为此, 要求应用程序提前给热补丁模块预留一定的内存空 间 (大小固定、 地址固定), 补丁时增加的文件中定义的全局变量、 代码、 常 量等必须指定到补丁段中, 从而能够保证除了补丁文件外的其它所有内存都不 受影响。 步骤 3: 通过后台补丁工具来实现补丁包的制作、 校验、 分发。 图 2是才艮据本发明实施例的前台系统以及后台补丁工具的架构图, 如图 2 所示, 后台补丁工具向前台软件系统发送补丁命令, 并接收来自前台软件系统 反馈的执行结果。 补丁工具向用户提供友好的界面, 允许用户指定补丁的各种 配置: 如补丁对的版本号、 补丁对适用的核号。 补丁工具从用户定义的 MAP 文件和 OUT文件中提取补丁对的信息: 函数名、 函数定义、 二进制代码实现 等。 并按照定义的格式补丁对信息写入补丁包中。 在制作补丁包之前, 为了确 保步骤 2中的内存一致性, 补丁工具提供了 MAP文件校 -险的功能, 即补丁工 具可判断原有系统的 MAP文件与补丁系统的 map文件是否除了补丁段外再无 其它不同。当校 -险一致后,补丁工具生成补丁包文件。同时,补丁工具开启 TFTP 服务器。 具体地, 图 3是根据本发明实施例的后台补丁工具制作补丁包的流程 图, 如图 3所示, 包括: 步骤 S302: 用户在补丁工具上输入补丁包的各种属性信息。 步骤 S304: 补丁工具校 -险原系统 MAP文件与新系统 MAP是否一致。 步骤 S306: 补丁工具从新系统 MAP文件、 OUT文件中提取补丁段信息。 步 4聚 S308: 补丁工具生成补丁包文件。 步骤 4: 软件系统热补丁功能模块处理补丁请求。 软件系统初始化热补丁 模块时, 创建补丁处理任务来处理一切艮补丁操作相关的命令。 包括: 激活补 丁、 卸载补丁。 当现有补丁需要补丁操作时, 补丁工具发送命令到前台软件, 前台热补丁模块处理命令请求, 发起 TFTP请求补丁包文件的下载, 并对补丁 包进行解析, 才艮据补丁包的内容配置补丁段。 图 4是才艮据本发明实施例的多核 系统的热补丁功能示意图, 如图 4所示, 热补丁功能管理模块与内存存储单元 进行信息交互, 用以完成补丁命令处理、 补丁版本管理、 代码。 緩存(CACHE ) 同步、 多核状态同步等功能。 步骤 5: 多核同步后^ ί'爹改被补丁函数处的跳转代码。 在多核系统中存在有共享代码, 其中一个核在修_?丈被补丁函数时, 其它核 不能执行该函数。 优选地, 所有多核的补丁操作可以由核号最小的核来完成, 其它核只负责 与该核进行配合。 多核同步的具体过程如下: 最小核修改全局共享变量, 通知 本次补丁操作相关的其它核。 其它核发现本核需要补丁操作后, 进入 IDLE任 务中修改全局共享变量为就绪状态, 通知最小核本核已经同步完毕。 此后其它 核在 IDLE任务里死等, 直至最小核完成补丁操作为止。 当所有核均同步完毕, 最小核即开始执行补丁操作, 完成后修改全局变量为退出状态通知其它核退出 同步。 具体地, 图 5是根据本发明实施例的处理补丁命令的流程图, 包括: 步 4聚 S502: 补丁工具向软件系统发送补丁请求命令。 步骤 S504: 最小核更改全局变量通知其他核进入多核同步状态。 步骤 S506: 其他核收到同步请求, 进入 IDLE任务, 修改全局变量, 并死 等。 步骤 S508: 最小核在其他核同步完成后配置补丁段、修改被补丁函数的跳 转代码。 步骤 S510: 最小核补丁操作完成, 通知其他核离开多核同步状态。 优选地, 同步过程还可以通过以下方式实现。 主核负责接收补丁请求, 并 向需要进行配合的其他核分发核间中断, 其他核第一次收到核间中断 (主核准 备开始执行热补丁操作)后死等直到再一次收到主核发送的核间中断, 则可认 为主核完成了热补丁操作, 从中断中返回并继续执行业务流程。 但这种方式的 缺陷是可能影响业务流程, 且中断的延迟比较大。 此外, 多核同步亦可釆用核 间信号量、 核间邮箱等多核间同步机制来实现。 步骤 6: 软件系统管理不同的补丁版本。 补丁包在下载到前台后, 随即被备份在内存中。 在内存允许的情况下, 不 同版本的补丁允许同时存在于当前系统中。 本特征作为一项辅助功能, 允许用 户定义多个补丁包, 进行灵活的操作, 并对单元测试和集成测试提供更全面的 支持。 需要说明的是, 上述实施例给出的技术方案以多核 DSP 系统中的具体实 现, 但其同样适用在其它的单核系统或多核系统, 在此不再赞述。 实施例二 本实施例提供了一种多核热补丁实现方法, 本实施例所处的系统环境为多 核的 AMP系统, 口图 6所示, n = 5。 其中, 代码段分为 3 中类型: 1 ) 6核 共享的代码, 称为 ST; 2 )核 0、 核 1共享的分组代码, 称为 G1T; 3 )核 2、 3、 4、 5 共享的分组代码, 称为 G2T。 假设原软件系统中分别有 3 个函数: ST_Func、 GlT_Func、 G2T Func, 现发现这 3个函数有错误, 故欲对其进行补 丁操作, 对应的补丁函数分别为 ST_Func_Patch、 GlT Func Patch 和 G2T_Func_Patch„ 该方法包括如下步 4聚: 步骤 1 : 实现补丁函数, 编译补丁工程, 生成补丁代码。 具体地, 将 ST_Func_Patch、 GlT Func Patch和 G2T_Func_Patch的实现 写入 Patch.c 中, 并在原系统的工程中加入 Patch.c, 使用编译环境或 Makefile 编译补丁工程, 生成新的 map文件和 out文件。 应注意的是, 编译器为了优化 起见, 未被调用的函数可能不被链接到新的 out文件中, 应釆取措施确保补丁 函数被链接。 步骤 2: 制作补丁包文件。 具体地, 将软件系统与补丁工具相连接。 用户通过补丁工具依次设置补丁 对(ST_Func、 ST Func Patch )、 ( GlT_Func、 GlT Func Patch )、 ( G2T_Func、 G2T_Func_Patch ) 的属性: 版本号、 适用的核号。 并指定补丁工程生成的 map 文件和 out文件, 同时指定原系统的 map文件。 补丁工具首先比较 2个 map文 件的差异, 只有所有的差异都在补丁段的预留内存里时, 2个 map文件才被认 为是匹配的。 若 map文件不能匹配, 则不能继续进行下一步操作。 然后, 补丁 工具从新的 map文件中找到补丁对的函数地址, 并从 out文件中提取整个补丁 段内容, 最后按照约定的格式封装成补丁包。 步骤 3: 发送补丁激活或卸载命令。 具体地, 激活命令用于软件系统从后台主机上下载补丁包文件到内存, 并 用补丁包中的补丁函数来替换被补丁函数。 卸载命令则用于将当前正在运行的 补丁包去除, 系统状态回复到被补丁前的状态, 同时将补丁包的备份从内存中 删除。 步骤 4: 热补丁任务处理补丁请求。 处理过程包括步骤 a和步骤 b。 步骤 a: 若补丁工具向软件系统发送的是激活命令, 则补丁工具在本地开 启一个 TFTP服务器, 同时 TFTP服务器的 IP地址、补丁包在本地的存储路径、 补丁包的版本号作为命令的附加参数被发送到前台系统。 前台则根据这些参数 向本地主机下载补丁包, 然后从内存中申请动态内存来备份补丁包和被补丁函 数的代码。 当备份工作完成后, 当前处于运行状态的最小核开始执行补丁操作。 多核 系统的同步使用全局共享变量来标志各核的状态, 从而实现同步。 volatile unsigned int gaudCoresPatchStat[6]; 〃标志多核的同步 态。 本 实 施 例 的 每 个核 对应 gaudCoresPatchStat 的 一 个 索 引 。 gaudCoresPatchStat 可 能 的 状 态 有 3 个 : PM SYNC ENTER 、 PM SYNC READY、 PM SYNC EXIT。 PM SYNC ENTER表示该核目前需 要进入同步状态, 但尚未完成同步。 PM_SYNC_READY表示该核已进入同步 状态。 PM_SYNC_EXIT表示该核可以退出同步状态。 图 7是 居本发明实施例的多核同步的流程图, 如图 7所示, 包括: 步骤 S702: 最小核将本次补丁操作相 关的核标志修改为 PM SYNC ENTER。 步骤 S704: 最小核配置补丁段。 步骤 S706: 最小核修改补丁函数跳转代码。 步骤 S708: 更新 gtCachetrl (多核緩存控制信息变量)。 步骤 S710: 最小核修改 gaudCoresPatchStat (权值同步状态标志变量) 为 PM SYNC EXIT。 步骤 S712: 反馈执行结果, 并退出。 步骤 S714 : 其它核在进入 IDLE 任务后查询本核的标志是否为Other memory partitions (data segments, code segments, constant segments, etc.) are consistent before and after the patch. For example: In the original system, a function calls callp FuncOrigText. In the binary code generated after the link, _FuncOrigText is replaced by a memory address generated by the compilation. If the address of FuncOrigText before and after the patch is divided into 'J 0x1000 and 0x2000, then executing the function call after the patch will not get the correct result. To this end, the application is required to reserve a certain memory space (fixed size and fixed address) in advance for the hot patch module. The global variables, codes, constants, etc. defined in the file added during the patch must be specified in the patch segment, thereby ensuring All memory except the patch file is unaffected. Step 3: Use the background patch tool to create, verify, and distribute the patch package. 2 is an architectural diagram of a foreground system and a background patching tool according to an embodiment of the present invention. As shown in FIG. 2, the background patching tool sends a patch command to the foreground software system, and receives an execution result fed back from the foreground software system. The patch tool provides a user-friendly interface that allows the user to specify various configurations of the patch: such as the version number of the patch pair and the applicable core number of the patch pair. The patch tool extracts information about patch pairs from user-defined MAP files and OUT files: function names, function definitions, binary implementations, and more. The information is written to the patch package according to the defined format patch. Before making the patch package, in order to ensure the memory consistency in step 2, the patch tool provides the MAP file school-risk function, that is, the patch tool can determine whether the map file of the original system MAP file and the patch system is in addition to the patch segment. Nothing else is different. When the school-risk is consistent, the patch tool generates a patch package file. At the same time, the patch tool opens the TFTP server. Specifically, FIG. 3 is a flowchart of a patching tool for creating a patch package according to an embodiment of the present invention. As shown in FIG. 3, the method includes: Step S302: The user inputs various attribute information of the patch package on the patch tool. Step S304: Whether the patch tool school-risk system MAP file is consistent with the new system MAP. Step S306: The patch tool extracts patch segment information from the new system MAP file and the OUT file. Step 4: S308: The patch tool generates a patch package file. Step 4: The software system hot patch function module processes the patch request. When the software system initializes the hot patch module, it creates a patch processing task to process all commands related to the patch operation. These include: activating patches and uninstalling patches. When an existing patch requires a patch operation, the patch tool sends a command to the foreground software, the foreground hot patch module processes the command request, initiates the download of the TFTP request patch package file, and parses the patch package, and then configures the patch according to the content of the patch package. segment. 4 is a schematic diagram of a hot patch function of a multi-core system according to an embodiment of the present invention. As shown in FIG. 4, the hot patch function management module performs information interaction with a memory storage unit to complete patch command processing, patch version management, and code. . Cache (CACHE) synchronization, multi-core state synchronization and more. Step 5: After multi-core synchronization ^ ί 'tamper the jump code at the patched function. There is shared code in a multi-core system, one of which is under repair? When the patch is patched, other cores cannot execute the function. Preferably, all multi-core patch operations can be performed by the core with the smallest core number, and other cores are only responsible for cooperation with the core. The specific process of multi-core synchronization is as follows: The minimum core modifies the global shared variable and notifies other cores related to this patch operation. Other cores found that the core needs to be patched and enter IDLE. Modify the global shared variable to the ready state, and notify the minimum core that the core has been synchronized. Thereafter, the other cores die in the IDLE task until the minimum core completes the patch operation. When all the cores are synchronized, the minimum core starts to perform the patch operation. After the completion, the global variable is modified to the exit status to notify other cores to exit the synchronization. Specifically, FIG. 5 is a flowchart of processing a patch command according to an embodiment of the present invention, including: Step 4: S502: The patch tool sends a patch request command to a software system. Step S504: The minimum core change global variable notifies other cores to enter the multi-core synchronization state. Step S506: The other core receives the synchronization request, enters the IDLE task, modifies the global variable, and dies. Step S508: The minimum core configures the patch segment after the other cores are synchronized, and modifies the jump code of the patched function. Step S510: The minimum core patch operation is completed, and the other cores are notified to leave the multi-core synchronization state. Preferably, the synchronization process can also be implemented in the following manner. The primary core is responsible for receiving the patch request and distributing the inter-core interrupt to other cores that need to cooperate. The other cores receive the inter-core interrupt for the first time (the main core is ready to start the hot patch operation) and wait until the primary core is received again. If the inter-core interrupt is sent, the primary core can be considered to have completed the hot patch operation, returning from the interrupt and continuing to execute the business process. However, the drawback of this method is that it may affect the business process, and the delay of the interruption is relatively large. In addition, multi-core synchronization can also be achieved by using a multi-core synchronization mechanism such as inter-core semaphores and inter-core mailboxes. Step 6: The software system manages different patch versions. After the patch is downloaded to the foreground, it is backed up in memory. Different versions of the patch are allowed to exist in the current system at the same time as the memory allows. This feature is an add-on feature that allows users to define multiple fix packs for flexible operation and more comprehensive support for unit and integration testing. It should be noted that the technical solution presented in the foregoing embodiment is implemented in a multi-core DSP system, but the same applies to other single-core systems or multi-core systems, and is not mentioned here. Embodiment 2 This embodiment provides a multi-core hot patch implementation method. The system environment in this embodiment is a multi-core AMP system, as shown in FIG. 6, n=5. Among them, the code segment is divided into 3 types: 1) 6 core shared code, called ST; 2) core 0, core 1 shared group code, called G1T; 3) core 2 3, 4, 5 Shared grouping code, called G2T. Suppose there are 3 functions in the original software system: ST_Func, GlT_Func, G2T Func. Now we find that these three functions have errors, so we want to patch them. The corresponding patch functions are ST_Func_Patch, GlT Func Patch and G2T_Func_Patch. The method includes the following steps: Step 1: Implement the patch function, compile the patch project, and generate the patch code. Specifically, write the implementation of ST_Func_Patch, GlT Func Patch, and G2T_Func_Patch into Patch.c, and add a patch to the original system project. .c, compile the patch project using the build environment or Makefile to generate new map files and out files. It should be noted that for the sake of optimization, the uncalled function may not be linked to the new out file. Take steps to ensure that the patch function is linked. Step 2: Create a patch package file Specifically, connect the software system to the patch tool. The user sets the patch pair (ST_Func, ST Func Patch), (GlT_Func, GlT Func Patch) in turn through the patch tool. ), ( G2T_Func, G2T_Func_Patch ) attributes: version number, applicable And specify the map file and out file generated by the patch project, and specify the map file of the original system. The patch tool first compares the difference between the two map files, only when all the differences are in the reserved memory of the patch segment, 2 The map file is considered to be a match. If the map file does not match, the next step cannot be continued. Then, the patch tool finds the function address of the patch pair from the new map file, and extracts the entire patch segment content from the out file. Finally, it is packaged into a patch package according to the agreed format. Step 3: Send a patch activation or uninstall command. Specifically, the activation command is used by the software system to download the patch package file from the background host to the memory, and replace the patch function with the patch function in the patch package. The patch function is used to remove the currently running patch package, the system status is restored to the state before the patch, and the backup of the patch package is deleted from the memory. Step 4: The hot patch task processes the patch request. Including step a and step b. Step a: If the patch tool sends an activation to the software system So, the patch tool to open a TFTP server locally, while the IP address of the TFTP server, the local patch storage path, patch version number as an additional command is sent to the reception system parameters. The parameters of the reception Download the patch package to the local host, and then apply dynamic memory from the memory to back up the patch package and the code of the patched function. When the backup job is completed, the smallest core that is currently running starts to perform the patch operation. Synchronization of multi-core systems uses global shared variables to flag the state of each core for synchronization. Volatile unsigned int gaudCoresPatchStat[6]; 〃 flag multi-core synchronization state. Each core of this embodiment corresponds to an index of gaudCoresPatchStat. There are three possible states for gaudCoresPatchStat: PM SYNC ENTER , PM SYNC READY, PM SYNC EXIT. PM SYNC ENTER indicates that the core currently needs to enter the synchronization state, but the synchronization has not yet been completed. PM_SYNC_READY indicates that the core has entered the synchronization state. PM_SYNC_EXIT indicates that the core can exit the synchronization state. FIG. 7 is a flowchart of multi-core synchronization according to an embodiment of the present invention. As shown in FIG. 7, the method includes: Step S702: The minimum core modifies the core flag related to the current patch operation to PM SYNC ENTER. Step S704: The minimum core configuration patch segment. Step S706: The minimum core modification patch function jump code. Step S708: Update gtCachetrl (multi-core cache control information variable). Step S710: The minimum core modifies gaudCoresPatchStat (weight synchronization state flag variable) to PM SYNC EXIT. Step S712: feedback the execution result, and exit. Step S714: After the other cores enter the IDLE task, check whether the flag of the core is
PM SYNC ENTER, 若是, 则将本核的标志爹改为 PM_SYNC_READY。 步骤 S716: 然后死等, 直至本核的标志为 PM_SYNC_EXIT。 最小核在所 有核均完成同步后, 将补丁包文件中保存的补丁代码段、 数据段和常量段依次 拷贝到相应的物理内存处。 然后依次修改被补丁函数的第一条指令, 将其改为 其补丁函数的入口地址。 如: ST Func 的第一条指令应修改为 jmp ST Func Patch, 其中 _ST_Func_Patch应为具体的内存地址。 需要特别说明的 是,执行完 ST Func Patch补丁后, 应将 PC指针返回到调用 ST Func的地址。 步骤 S718: 同时, 由于代码段可能是 cacheable的, 因此最小核在修改了 被补丁函数的代码后, 应通知其它核刷新被补丁函数的 cache, 避免其它核仍 然执行的是 cache 里的旧代码。 具体实现方案如下: 定义全局结构体变量 gtCacheCtrl, 保存补丁包中与被补丁函数相关的数据。 最小核在执行补丁操作 后, 将补丁包中的信息备份到 gtCacheCtrl 中。 其它核在退出 IDLE任务前将 gtCacheCtrl内容刷到 cache里, 完成内存与 cache的同步。 步骤 S720 : 最小核完成以上工作后, 修改本次补丁相关核的标志为 PM_SYNC_EXIT。 其它核在 IDLE任务中得以退出, 并继续执行。 步骤 b: 若补丁工具向软件系统发送的是卸载命令, 则前台系统执行以下 操作: 使用备份的原补丁函数的信息来恢复到补丁前的系统状态。 此过程中的 同步操作与上文所述一致。然后,将补丁激活过程中申请的动态内存全部释放, 将备份的补丁文件删除, 以避免系统存在内存泄露的隐患。 步骤 5: 热补丁任务反馈处理结果。 前台系统最后处理的结果以错误码的形式反馈到后台补丁工具。 本实施例提供了一种多核热补丁的实现系统, 图 8是根据本发明实施例的 多核热补丁的实现系统的结构框图, 如图 8所示, 下面对上述结构进行详细描 述: 执行补丁操作的核心处理单元 2 , 其包括: 第一通知模块 82 , 设置为在对代码执行补丁操作之前, 通知与其共享代码 的其他核心处理单元; 执行模块 84 , 连接至第一通知模块 82 , 设置为在第一通知模块 82通知与 其共享代码的其他核心处理单元之后, 执行补丁操作; 第二通知模块 86 , 连接至执行模块 84 , 设置为在执行模块 84的补丁操作 执行完毕之后, 通知其他核心处理单元补丁操作执行完毕; 其他核心处理单元 4 , 包括: 等待模块 88 , 设置为在接收到第一通知模块 82的通知后等待补丁操作执 行完毕。 图 9是才艮据本发明实施例的多核热补丁的实现系统的优选的结构框图, 如 图 9所示, 下面对上述结构进行详细描述: 第一通知模块 82包括: 第一修改子模块 822 , 设置为修改全局共享变量, 以通知与其共享代码的其他核心处理单元; 等待模块 88包括:第二修改子模块 882 ,设置为修改全局变量为就绪状态, 以通知执行补丁操作的核心处理单元其已经准备执行补丁操作; 第一等待子模 块 884 , 连接至第二修改子模块 882 , 设置为等待补丁操作执行完毕。 优选地, 第一修改子模块 822 , 设置为修改全局共享变量为待同步状态, 以通知与其共享代码的其他核心处理单元; 第二修改子模块 882 , 设置为修改全局变量为就绪状态以通知执行补丁操 作的核心处理单元其已经准备执行补丁操作。 第一通知模块 82包括: 第一分发子模块 824 , 设置为向其他核分发核间中 断, 以通知与其共享代码的其他核心处理单元; 第二通知模块 86包括: 第二分发子模块 862 , 设置为在补丁操作执行完毕 之后, 再次发送核间中断以通知其他核心处理单元补丁操作执行完毕; 等待模块 88包括: 接收子模块 886 , 设置为接收到核间中断; 第二等待子 模块 888 , 连接至接收子模块 886 , 设置为在接收到核间中断后等待补丁操作 执行完毕; 通过上述实施例, 提供了一种多核热补丁实现方法及系统, 通过该方法, 多个共享代码的核心处理单元中的一个在对代码执行补丁操作之前, 通知与其 共享代码的其他核心处理单元等待其补丁操作执行完毕, 然后在其执行完补丁 操作后通知与其共享代码的其他核心处理单元补丁操作执行完毕, 克服了相关 技术中的热补丁实现方法只适用于单核心处理单元, 在多核心处理单元系统中 会造成系统不稳定及业务中断的问题, 实现了在多核系统中实现热补丁, 达到 了提高了系统稳定性的效果。 显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可以 用通用的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多 个计算装置所组成的网络上, 可选地, 它们可以用计算装置可执行的程序代码 来实现, 从而, 可以将它们存储在存储装置中由计算装置来执行, 并且在某些 情况下, 可以以不同于此处的顺序执行所示出或描述的步骤, 或者将它们分别 制作成各个集成电路模块, 或者将它们中的多个模块或步骤制作成单个集成电 路模块来实现。 这样, 本发明不限制于任何特定的硬件和软件结合。 以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本领 域的技术人员来说, 本发明可以有各种更改和变化。 凡在本发明的 ^"神和原则 之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之 内。 PM SYNC ENTER, if yes, change the flag of this core to PM_SYNC_READY. Step S716: Then die, until the flag of the core is PM_SYNC_EXIT. The minimum core copies the patch code segments, data segments, and constant segments saved in the patch package file to the corresponding physical memory after all the cores are synchronized. Then modify the first instruction of the patched function in turn, and change it to the entry address of its patch function. For example: ST Func's first instruction should be modified to jmp ST Func Patch, where _ST_Func_Patch should be a specific memory address. It is important to note that after executing the ST Func Patch, the PC pointer should be returned to the address where ST Func is called. Step S718: At the same time, since the code segment may be cacheable, after the minimum core modifies the code of the patched function, the other core should be notified to refresh the cache of the patched function, so that other cores still execute the old code in the cache. The specific implementation scheme is as follows: Define a global structure variable gtCacheCtrl, and save the data related to the patched function in the patch package. After the minimum core performs the patch operation, the information in the patch package is backed up to gtCacheCtrl. Other cores will flush the gtCacheCtrl content to the cache before exiting the IDLE task, completing the synchronization of the memory and the cache. Step S720: After the minimum core completes the above work, the flag of the patch-related core is modified to be PM_SYNC_EXIT. Other cores were able to exit in the IDLE task and continue to execute. Step b: If the patch tool sends an uninstall command to the software system, the foreground system performs the following operations: The information of the original patch function of the backup is used to restore the system state before the patch. The synchronization operation in this process is consistent with the above. Then, all the dynamic memory that is applied during the patch activation process is released, and the backup patch file is deleted to avoid the hidden danger of the memory leak in the system. Step 5: Hot patch task feedback processing results. The result of the final processing of the foreground system is fed back to the background patch tool in the form of an error code. This embodiment provides a system for implementing a multi-core hot patch. FIG. 8 is a structural block diagram of a system for implementing a multi-core hot patch according to an embodiment of the present invention. As shown in FIG. 8, the foregoing structure is described in detail: The core processing unit 2 of the operation, comprising: a first notification module 82, configured to notify other core processing units sharing the code with the code before performing the patch operation on the code; the execution module 84 is connected to the first notification module 82, and is set to After the first notification module 82 notifies the other core processing units with which the code is shared, the patch operation is performed; the second notification module 86 is connected to the execution module 84, and is configured to notify other core processing after the execution of the patch operation of the execution module 84 is completed. The unit patch operation is completed; the other core processing unit 4 includes: a waiting module 88, configured to wait for the execution of the patch operation after receiving the notification of the first notification module 82. FIG. 9 is a block diagram showing a preferred structure of an implementation system of a multi-core hot patch according to an embodiment of the present invention. As shown in FIG. 9, the foregoing structure is described in detail. The first notification module 82 includes: a first modification submodule 822, set to modify the global shared variable to notify other core processing units with which to share the code; the waiting module 88 includes: a second modification sub-module 882, configured to modify the global variable to the ready state to notify the core processing unit that performs the patch operation It is ready to perform the patch operation; the first wait sub-module 884, connected to the second modification sub-module 882, is set to wait for the patch operation to complete. Preferably, the first modification submodule 822 is configured to modify the global shared variable to be in a state to be synchronized to notify other core processing units with which the code is shared; the second modification submodule 882 is set to modify the global variable to a ready state to notify execution The core processing unit of the patch operation is ready to perform the patch operation. The first notification module 82 includes: a first distribution sub-module 824 configured to distribute inter-core interrupts to other cores to notify other core processing units with which the code is shared; the second notification module 86 includes: a second distribution sub-module 862, setting After the execution of the patch operation is completed, the inter-core interrupt is sent again to notify other core processing unit that the patch operation is completed. The waiting module 88 includes: a receiving submodule 886, configured to receive the inter-core interrupt; and a second waiting sub-module 888, the connection The receiving sub-module 886 is configured to wait for the execution of the patch operation after receiving the inter-core interrupt; and the foregoing embodiment provides a multi-core hot patch implementation method and system, by which the core processing unit of multiple shared codes is provided One of the other core processing units that have shared the code waits for the completion of the patch operation before performing the patch operation on the code, and then notifies the other core processing unit of the shared code that the patch operation is completed after the patch operation is performed, overcoming The hot patch implementation method in the related art only applies Single-core processing unit, multi-core processing units in the system can cause problems in system instability and service interruption, to achieve a hot patches in multi-core systems to achieve the effect of improving the stability of the system. Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device, and in some In this case, the steps shown or described may be performed in an order different from that herein, or they may be separately fabricated into individual integrated circuit modules, or a plurality of the modules or steps may be implemented as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software. The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the scope of the present invention are intended to be included within the scope of the present invention.

Claims

权 利 要 求 书 Claims
1. 一种多核热补丁的实现方法, 包括: 1. A method for implementing a multi-core hot patch, comprising:
多个核心处理单元中的一个在对代码执行补丁操作之前, 通知与其 共享所述代码的其他核心处理单元, 所述其他核心处理单元在接收到所 述通知后等待所述补丁操作执行完毕;  One of the plurality of core processing units notifies other core processing units with which the code is shared before performing the patching operation on the code, the other core processing unit waiting for the execution of the patch operation after receiving the notification;
执行所述补丁操作的核心处理单元执行所述补丁操作; 在所述补丁操作执行完毕之后, 执行所述补丁操作的核心处理单元 通知所述其他核心处理单元所述补丁操作执行完毕。  The core processing unit that performs the patch operation performs the patch operation. After the patch operation is completed, the core processing unit that executes the patch operation notifies the other core processing unit that the patch operation is completed.
2. 才艮据权利要求 1所述的方法, 其中, 多个核心处理单元中的一个在对代 码执行补丁操作之前, 通知与其共享所述代码的其他核心处理单元, 所 述其他核心处理单元在接收到所述通知后等待所述补丁操作执行完毕包 括: 2. The method of claim 1 wherein one of the plurality of core processing units notifies other core processing units with which the code is shared prior to performing a patch operation on the code, the other core processing unit being Waiting for the execution of the patch operation after receiving the notification includes:
执行所述补丁操作的核心处理单元^ ί'爹改全局共享变量, 以通知与其 共享所述代码的其他核心处理单元, 其中, 所述全局共享变量用于多核 同步;  The core processing unit executing the patch operation tampers with the global shared variable to notify other core processing units with which the code is shared, wherein the global shared variable is used for multi-core synchronization;
所述其他核心处理单元分别修改所述全局变量为就绪状态以通知执 行所述补丁操作的核心处理单元其已经准备执行补丁操作, 并等待所述 补丁操作执行完毕。  The other core processing unit respectively modifies the global variable to a ready state to notify the core processing unit that performs the patch operation that it is ready to perform a patch operation, and waits for the patch operation to be completed.
3. 根据权利要求 2所述的方法, 其中: 3. The method of claim 2, wherein:
执行所述补丁操作的核心处理单元 4爹改所述全局共享变量为待补丁 态, 以通知与其共享所述代码的其他核心处理单元;  The core processing unit 4 executing the patch operation tampers the global shared variable into a to-be-patched state to notify other core processing units with which the code is shared;
所述其他核心处理单元分别修改所述全局变量为就绪状态以通知执 行所述补丁操作的核心处理单元其已经准备执行补丁操作, 并在空闲 IDLE任务中等待所述补丁操作执行完毕。  The other core processing unit respectively modifies the global variable to a ready state to notify the core processing unit that performs the patch operation that it is ready to perform a patch operation, and waits for the patch operation to be completed in the idle IDLE task.
4. 才艮据权利要求 1所述的方法, 其中, 多个核心处理单元中的一个在对代 码执行补丁操作之前, 通知与其共享所述代码的其他核心处理单元, 所 述其他核心处理单元在接收到所述通知后等待所述补丁操作执行完毕包 括: 执行所述补丁操作的核心处理单元向所述其他核分发核间中断, 以 通知与其共享所述代码的其他核心处理单元; 所述其他核心处理单元在接收到所述核间中断之后, 等待所述补丁 操作执行完毕; 4. The method of claim 1, wherein one of the plurality of core processing units notifies other core processing units with which the code is shared prior to performing a patch operation on the code, the other core processing unit being Waiting for the execution of the patch operation after receiving the notification includes: A core processing unit performing the patch operation distributes an inter-core interrupt to the other core to notify other core processing units with which the code is shared; the other core processing unit waits after receiving the inter-core interrupt The patch operation is completed;
在所述补丁操作执行完毕之后, 执行所述补丁操作的核心处理单元 再次发送核间中断以通知所述其他核心处理单元所述补丁操作执行完 毕。  After the execution of the patch operation is completed, the core processing unit that performs the patch operation transmits an inter-core interrupt again to notify the other core processing unit that the patch operation is completed.
5. 根据权利要求 1至 4中任一项所述的方法, 其中, 在执行所述补丁操作 之前, 为所述补丁操作对应的补丁预定固定的内存空间。 The method according to any one of claims 1 to 4, wherein a fixed memory space is reserved for a patch corresponding to the patch operation before the patch operation is performed.
6. 根据权利要求 1至 4中任一项所述的方法, 其中, 通过设置标志位用于 标识共享所述代码的核心处理单元。 The method according to any one of claims 1 to 4, wherein the flag is used to identify a core processing unit that shares the code.
7. 根据权利要求 1至 4中任一项所述的方法, 其中, 所述补丁操作对应的 补丁为补丁对, 所述补丁对包括被补丁函数和补丁函数。 The method according to any one of claims 1 to 4, wherein the patch corresponding to the patch operation is a patch pair, and the patch pair includes a patched function and a patch function.
8. 居权利要求 7所述的方法, 其中, 所述补丁操作后生成的 MAP文件 和所述补丁操作前生成的 MAP文件除预留补丁段之外保持一致。 8. The method of claim 7, wherein the MAP file generated after the patch operation and the MAP file generated before the patch operation are consistent except for the reserved patch segment.
9. 一种多核热补丁的实现系统, 包括: 9. A system for implementing a multi-core hot patch, comprising:
执行补丁操作的核心处理单元, 其包括:  A core processing unit that performs a patch operation, which includes:
第一通知模块, 设置为在对代码执行补丁操作之前, 通知与其共享 所述代码的其他核心处理单元;  a first notification module, configured to notify other core processing units with which the code is shared before performing a patch operation on the code;
执行模块, 设置为执行所述补丁操作;  An execution module, configured to perform the patch operation;
第二通知模块, 设置为在所述补丁操作执行完毕之后, 通知所述其 他核心处理单元所述补丁操作执行完毕;  a second notification module, configured to notify the other core processing unit that the patch operation is completed after the execution of the patch operation is completed;
所述其他核心处理单元, 其包括:  The other core processing unit includes:
等待模块, 设置为在接收到所述第一通知模块的通知后等待所述补 丁操作执行完毕。 根据权利要求 9所述的系统,  The waiting module is configured to wait for the completion of the patch operation after receiving the notification of the first notification module. The system of claim 9
所述第一通知模块包括: 第一修改子模块, 设置为修改全局共享变量, 以通知与其共享所述 代码的其他核心处理单元; The first notification module includes: a first modification submodule, configured to modify the global shared variable to notify other core processing units with which the code is shared;
所述等待模块包括:  The waiting module includes:
第二修改子模块, 设置为修改全局变量为就绪状态, 以通知执行所 述补丁操作的核心处理单元其已经准备执行补丁操作;  a second modification submodule, configured to modify the global variable to a ready state to notify the core processing unit that performs the patch operation that it is ready to perform a patch operation;
第一等待子模块, 设置为等待所述补丁操作执行完毕。  The first waiting sub-module is set to wait for the patch operation to be completed.
11. 根据权利要求 10所述的系统, 其中: 11. The system of claim 10, wherein:
所述第一修改子模块, 设置为修改全局共享变量为待补丁状态, 以 通知与其共享所述代码的其他核心处理单元; 所述第二修改子模块, 设置为修改全局变量为就绪状态以通知执行 所述补丁操作的核心处理单元其已经准备执行补丁操作。  The first modifying submodule is configured to modify the global shared variable to be in a patched state to notify other core processing units with which the code is shared; and the second modified submodule is configured to modify the global variable to a ready state to notify The core processing unit that performs the patch operation is ready to perform a patch operation.
12. 根据权利要求 9所述的系统, 其中, 12. The system according to claim 9, wherein
所述第一通知模块包括:  The first notification module includes:
第一分发子模块, 设置为向所述其他核分发核间中断, 以通知与其 共享所述代码的其他核心处理单元;  a first distribution sub-module configured to distribute an inter-core interrupt to the other core to notify other core processing units with which the code is shared;
所述第二通知模块包括:  The second notification module includes:
第二分发子模块, 设置为在所述补丁操作执行完毕之后, 再次发送 核间中断以通知所述其他核心处理单元所述补丁操作执行完毕;  a second distribution sub-module, configured to: after the execution of the patch operation is completed, send an inter-core interrupt to notify the other core processing unit that the patch operation is completed;
所述等待模块包括:  The waiting module includes:
接收子模块, 设置为接收到所述核间中断;  Receiving a submodule, configured to receive the inter-core interrupt;
第二等待子模块, 设置为在接收到所述核间中断后等待所述补丁操 作执行完毕。  The second waiting sub-module is arranged to wait for the execution of the patch operation after receiving the inter-core interrupt.
PCT/CN2011/075972 2010-11-12 2011-06-20 Method and system for realizing multi-core hot patching WO2012062113A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010543020.5 2010-11-12
CN2010105430205A CN102467394A (en) 2010-11-12 2010-11-12 Method and system for realizing multi-core hot patching

Publications (1)

Publication Number Publication Date
WO2012062113A1 true WO2012062113A1 (en) 2012-05-18

Family

ID=46050367

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/075972 WO2012062113A1 (en) 2010-11-12 2011-06-20 Method and system for realizing multi-core hot patching

Country Status (2)

Country Link
CN (1) CN102467394A (en)
WO (1) WO2012062113A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2843546A3 (en) * 2013-08-28 2018-05-02 VIA Technologies, Inc. Propagation of microcode patches to multiple cores in multicore microprocessor
US10649763B2 (en) * 2018-06-15 2020-05-12 Microsoft Technology Licensing, Llc Resource efficient deployment of multiple hot patches

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105988798B (en) * 2015-02-12 2020-07-31 南京中兴软件有限责任公司 Patch processing method and device
CN105159738A (en) * 2015-08-20 2015-12-16 上海斐讯数据通信技术有限公司 Hot patch implementation method and system
CN106775732B (en) * 2016-12-23 2019-02-12 优刻得科技股份有限公司 A kind of hot patch loading method and device
CN112015491B (en) 2019-05-30 2022-08-09 华为技术有限公司 Method, device and computer storage medium for realizing function jump

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6075938A (en) * 1997-06-10 2000-06-13 The Board Of Trustees Of The Leland Stanford Junior University Virtual machine monitors for scalable multiprocessors
US7149843B1 (en) * 2001-12-10 2006-12-12 Vmware, Inc. System and method for detecting access to shared structures and for maintaining coherence of derived structures in virtualized multiprocessor systems
CN101178672A (en) * 2007-11-29 2008-05-14 上海华为技术有限公司 Multi-nucleus processor sharing code segment patching method and apparatus
CN101561764A (en) * 2009-05-18 2009-10-21 华为技术有限公司 Patching method and patching device under multi-core environment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6075938A (en) * 1997-06-10 2000-06-13 The Board Of Trustees Of The Leland Stanford Junior University Virtual machine monitors for scalable multiprocessors
US7149843B1 (en) * 2001-12-10 2006-12-12 Vmware, Inc. System and method for detecting access to shared structures and for maintaining coherence of derived structures in virtualized multiprocessor systems
CN101178672A (en) * 2007-11-29 2008-05-14 上海华为技术有限公司 Multi-nucleus processor sharing code segment patching method and apparatus
CN101561764A (en) * 2009-05-18 2009-10-21 华为技术有限公司 Patching method and patching device under multi-core environment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2843546A3 (en) * 2013-08-28 2018-05-02 VIA Technologies, Inc. Propagation of microcode patches to multiple cores in multicore microprocessor
US10649763B2 (en) * 2018-06-15 2020-05-12 Microsoft Technology Licensing, Llc Resource efficient deployment of multiple hot patches

Also Published As

Publication number Publication date
CN102467394A (en) 2012-05-23

Similar Documents

Publication Publication Date Title
US9244676B2 (en) Virtual machine based controller and upgrade mechanism
AU2006297144B2 (en) Application of virtual servers to high availability and disaster recovery solutions
WO2019144761A1 (en) Data synchronization method, distributed system and device
WO2012062113A1 (en) Method and system for realizing multi-core hot patching
CN108089913B (en) Virtual machine deployment method of super-fusion system
JP2006107500A (en) Updating software during its execution
CA2724532C (en) Enhanced upgrade path
WO2012054160A2 (en) High availability of machines during patching
CN111552496A (en) System and method for realizing seamless upgrade of sidecar based on temporary container addition
WO2015078166A1 (en) Load processing method and device for system application installation package, and terminal
WO2014127628A1 (en) Firmware upgrade method and system
WO2009117921A1 (en) Distributed network management system, network management server and method
CN107707687A (en) A kind of method and apparatus of virtual machine IP address configuration
CN108319492B (en) Method, device and system for resetting physical machine
JP4770242B2 (en) Software update information distribution system and software update information distribution method
WO2015018302A1 (en) Hot patching method and device
CN107465709B (en) Distributed mirror image construction task method, device and system
US20220326940A1 (en) Service Upgrade Method, Apparatus, and System
CN111427608A (en) Gray scale publishing method for bank core system
WO2016074460A1 (en) Data processing method and device
WO2023000672A1 (en) Network switching method and apparatus, electronic device, and storage medium
CN112328429A (en) Hard disk snapshot method and device based on Openstack
WO2023050947A1 (en) Network upgrade method, electronic device and storage medium
CN117667132A (en) Operating system updating method, device and storage medium
CN114090339A (en) Database stream copying method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11839178

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11839178

Country of ref document: EP

Kind code of ref document: A1