Hotfix Function Jump via Hash Table Indexing
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current hotfix methods, such as function jump-based solutions in Linux kernels, suffer from increased performance overhead due to the lengthening of single linked lists as the number of hotfix functions increases, leading to longer traversal times and function jump delays.
Innovation Solution
Implementing a method that uses hash tables to store and manage the addresses of multiple old functions, allowing for direct access and reducing the time required for function jumps by decoupling the livepatch module from the ftrace module, thereby shortening the linked list and improving system performance.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a single linked list is used to manage hotfixed old functions, then the system can maintain all hotfix functions, but the traversal time increases as the number of hotfix functions increases
Solution Approach 1:
The patent changes the data structure parameter from a single linked list to a hash table. This parameter change transforms the time complexity from O(N) linear traversal to O(1) average case direct access, resolving the contradiction between maintaining hotfix functions and reducing traversal time.
Solution Approach 2:
The patent substitutes the mechanical linked list traversal mechanism with a hash table indexing mechanism. Instead of sequentially traversing nodes in a linked list, the system uses hash function computation to directly locate the target node, dramatically reducing the time required as the number of hotfix functions increases.
2Adaptability or versatility
If the number of hotfix functions increases, then more defects can be fixed, but the function jump time increases due to longer linked list traversal
Solution Approach 1:
The patent applies parameter change by transitioning from linked list to hash table data structure. This allows the system to accommodate an increasing number of hotfix functions (improving adaptability) while maintaining constant-time access (preserving productivity), as hash table lookup time does not scale with the number of elements.
Solution Approach 2:
The hash table structure provides a universal solution that handles any number of hotfix functions efficiently. The same hash table mechanism works whether there are a few or many hotfix functions, making the system scalable without sacrificing performance.
3Device complexity
If a single linked list stores all hotfix function information, then all functions can be managed in one structure, but the structure becomes increasingly complex and slower to search
Solution Approach 1:
The patent segments the single linked list into multiple hash buckets. Each bucket contains a subset of the hotfix function entries, organized by hash function results. This segmentation transforms the single long traversal into multiple short traversals or direct accesses, reducing both the effective complexity and search time.
Solution Approach 2:
The patent changes the organizational parameter from sequential linked list structure to hash-based distributed structure. This parameter change fundamentally alters how data is accessed, replacing linear search with constant-time hash-based retrieval, thereby resolving the contradiction between structure management and search efficiency.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
This application provides a method and an apparatus for implementing a function jump, and a computer-readable storage medium. The method includes: when a first function is called, searching a first data structure in which addresses of a plurality of functions are stored for an address of the first function, where when the address of the first function is found, it indicates that there is a patch function used to replace the first function; searching a second data structure for an address of the patch function of the first function based on the address of the first function, where correspondences between a plurality of functions and patch functions of the plurality of functions are stored in the second data structure; and jumping from the first function to the patch function of the first function based on the address of the patch function of the first function, and executing the patch function of the first function to respond to the call to the first function. In this application, addresses of a plurality of old functions are stored in one struct, thereby reducing time consumed in a function jump phase in a hotfix mechanism.