Kernel code processing method, kernel code access method, computer system and computing equipment

By dividing the kernel code into multiple kernel code segments and distributing and storing them to multiple system nodes, and generating kernel page tables, the performance imbalance caused by centralized storage of kernel code in NUMA architecture is solved, and the performance improvement of each system node in execution of kernel code is achieved balanced.

CN119440801APending Publication Date: 2025-02-14PHYTIUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411288071.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the NUMA architecture, the centralized storage of kernel code on a certain node causes poor performance in other nodes to execute kernel code, resulting in an overall performance imbalance.

Method used

The kernel code is divided into multiple kernel code segments and distributed and stored in multiple system nodes. A kernel page table is generated to record the correspondence between the virtual address and the physical storage address, so that each system node can load and run kernel code evenly.

Benefits of technology

By dispersing the kernel code to multiple system nodes, the performance imbalance caused by centralized storage of kernel code is solved, making the performance of each system node more balanced when executing kernel code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440801A_ABST
    Figure CN119440801A_ABST
Patent Text Reader

Abstract

The invention provides a kernel code processing method, an access method, a computer system and computing equipment, the kernel code processing method is applied to the computer system, and the computer system comprises a plurality of system nodes; the method comprises the following steps: a first system node in a plurality of system nodes divides a kernel code into a plurality of kernel code segments, and distributes and stores the kernel code segments into the system nodes; the first system node generates a kernel page table based on the storage position of each kernel code segment in the plurality of system nodes; the kernel page table is used for recording the corresponding relation between the virtual address and the physical storage address of the kernel code segment; and the first system node stores the kernel page table to a set storage position, so that the plurality of system nodes access the kernel page table from the set storage position and load and run the kernel code by accessing the kernel page table. By means of the method, the kernel code execution performance of all the system nodes in the computer system of the NUMA architecture can be more balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a kernel code processing method, an access method, a computer system and a computing device. Background Art

[0002] NUMA (Non Uniform Memory Access) technology allows many servers to operate like a single system while retaining the advantages of small systems that are easy to program and manage. In the NUMA architecture, each NUMA node corresponds to its own memory controller and memory. Any NUMA node can access its own memory and the memory of any other node in the architecture.

[0003] Kernel code is the core code that ensures the basic functions of the processor. In existing applications, kernel code is centrally stored on a numa node (usually node 0) in the NUMA architecture, but threads that need to execute kernel code may be distributed on any NUMA node in the NUMA architecture. This causes threads on the same node as the kernel code to exhibit better performance, while threads on a different node from the kernel code always need to fetch instructions from memory across nodes, exhibiting poor performance, leading to performance imbalance of the entire NUMA architecture. Summary of the invention

[0004] Based on the above technical problems, the present application proposes a kernel code processing method, access method, computer system and computing device, which can make the performance of kernel code execution of each system node in a NUMA architecture computer system more balanced.

[0005] In a first aspect, the present application provides a kernel code processing method, which is applied to a computer system, wherein the computer system includes a plurality of system nodes; the method includes:

[0006] A first system node among the plurality of system nodes divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes; wherein each of the system nodes stores at least one kernel code segment;

[0007] The first system node generates a kernel page table based on the storage location of each kernel code segment in the plurality of system nodes; the kernel page table is used to record the correspondence between the virtual address of the kernel code segment and the physical storage address of the kernel code segment in the system node;

[0008] The first system node stores the kernel page table in a set storage location, so that the multiple system nodes access the kernel page table from the set storage location and load and run kernel code by accessing the kernel page table.

[0009] In some implementations, the first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including:

[0010] The first system node evenly divides the kernel code into a first number of kernel code segments, the first number being the same as the number of the plurality of system nodes;

[0011] The first system node stores the first number of kernel code segments in the multiple system nodes in a one-to-one correspondence.

[0012] In some implementations, the first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including:

[0013] The first system node starts from the start code of the kernel code and stores the kernel code in the i-th memory page table of each system node in sequence according to the execution order of the kernel code;

[0014] When the i-th memory page table of each system node is full of kernel code and the kernel code has not been completely stored, the kernel code is stored in the i+1-th memory page table of each system node in turn until the kernel code is completely stored; i is a positive integer starting from 1.

[0015] In some implementations, the first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including:

[0016] The first system node determines the hot kernel code segment corresponding to each system node according to the historical access records and access frequencies of the kernel code of each system node; wherein the hot kernel code segment corresponding to the system node refers to the kernel code segment with the highest access frequency of the system node;

[0017] The first system node stores hotspot kernel code segments corresponding to each system node in each system node.

[0018] In some implementations, the first system node generates a kernel page table based on storage locations of each kernel code segment in the plurality of system nodes, including:

[0019] The first system node obtains an original kernel page table, where the original kernel page table is used to record a correspondence between a virtual address of the kernel code and a physical storage address of the kernel code in an original system node, where the original system node is any one of the multiple system nodes;

[0020] The first system node determines, based on the original kernel page table, respective virtual addresses of respective kernel code segments stored in respective system nodes;

[0021] A kernel page table is generated based on the virtual addresses of the kernel code segments and the storage locations of the kernel code segments in the plurality of system nodes.

[0022] In some implementations, the method further includes:

[0023] When an update operation on a first kernel code segment is received, the update operation is performed on the first kernel code segment stored in a target system node based on the virtual address of the first kernel code segment and the kernel page table; the target system node is a system node storing the first kernel code segment.

[0024] In some implementations, the first system node stores the kernel page table to a set storage location, so that the multiple system nodes access the kernel page table from the set storage location and load and run kernel code by accessing the kernel page table, including:

[0025] The first system node stores the kernel page table to a set storage location, and stores the starting storage address of the kernel page table at the set storage location to a page table base address register, so that the multiple system nodes determine the starting storage address of the kernel page table at the set storage location by accessing the page table base address register, access the kernel page table according to the starting storage address, and load and run the kernel code by accessing the kernel page table.

[0026] In a second aspect, the present application provides a kernel code access method, which is applied to a computer system, wherein the computer system includes a plurality of system nodes, each of the system nodes stores at least one kernel code segment, and the kernel code segments stored in each of the system nodes are distributed and stored in each of the system nodes by a first system node among the plurality of system nodes executing the kernel code processing method described above; the method includes:

[0027] A second system node among the plurality of system nodes accesses a kernel page table from a set storage location to determine a physical storage address of a kernel code segment to be accessed;

[0028] The second system node loads and runs the kernel code segment to be accessed based on the physical storage address of the kernel code segment to be accessed;

[0029] The kernel page table is obtained by the first system node by executing the above-mentioned kernel code processing method and is stored in the set storage location.

[0030] A third aspect of the present application proposes a computer system, comprising a plurality of system nodes, wherein the computer system is configured to implement the above-mentioned kernel code processing method or kernel code access method.

[0031] A fourth aspect of the present application provides a computing device, comprising the above-mentioned computer system.

[0032] The kernel code processing method proposed in the present application divides the kernel code into multiple kernel code segments, and distributes and stores them in multiple system nodes, and generates a kernel page table based on the storage location of each kernel code segment in the system node, so that each system node accesses the kernel code segment according to the kernel page table. The above scheme stores the kernel code in different system nodes in a dispersed manner, so that each system node in the entire system architecture may load the kernel code from other nodes and load the kernel code from the local, so that the performance of each system node in executing the kernel code is more balanced, and it can solve the problem of unbalanced performance of different system nodes in executing the kernel code caused by centrally storing the kernel code in a certain system node. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0034] Figure 1 A schematic diagram of the structure of a NUMA architecture provided in an embodiment of the present application.

[0035] Figure 2 A flowchart of a kernel code processing method provided in an embodiment of the present application.

[0036] Figure 3 A schematic diagram of a kernel page table provided in an embodiment of the present application.

[0037] Figure 4 A schematic diagram of another kernel page table provided in an embodiment of the present application.

[0038] Figure 5A flowchart of a kernel code access method provided in an embodiment of the present application.

[0039] Figure 6 A schematic diagram of the structure of a computer system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] NUMA (Non-Uniform Memory Access) is a computer architecture that is derived from the development of multi-processor or multi-processor core technology and is used to optimize the processor's access performance to memory.

[0041] In the NUMA architecture, processors or processor cores are divided into multiple NUMA nodes. Each node has its own independent memory space and bus system, and the NUMA nodes are also interconnected through the bus.

[0042] In one implementation, the NUMA architecture includes a processor including multiple processor cores. The multiple processor cores are divided into different groups, each group includes at least one processor core, and each group serves as a NUMA node.

[0043] In another embodiment, if Figure 1 As shown, the NUMA architecture includes multiple processors, each processor includes multiple processor cores, and the processor cores of each processor are divided into different NUMA nodes.

[0044] Regardless of the method used, each NUMA node is also configured with an independent memory controller. The processor cores in the same NUMA node can share the memory controller. At the same time, the corresponding physical memory is configured for each NUMA node. Each NUMA node can access the memory space of its own configured local memory through its corresponding memory controller. At the same time, it can also access the memory space of other NUMA nodes.

[0045] In the NUMA architecture, each NUMA node corresponds to its own memory controller and memory. Any NUMA node can access its own memory, and can also access the memory of any other node in the architecture. According to the relationship between NUMA nodes, NUMA nodes can be divided into local nodes, neighbor nodes, and remote nodes. The speed at which the processor core accesses the memory of different types of nodes is different. The speed of accessing local nodes is the fastest, and the speed of accessing remote nodes is the slowest.

[0046] Kernel code is the core code that ensures the basic functions of the processor. In existing applications, kernel code is centrally stored on a NUMA node (usually node 0) in the NUMA architecture, but threads that need to execute kernel code may be distributed on any NUMA node in the NUMA architecture. The efficiency of a NUMA node accessing the memory of its own node is significantly different from the efficiency of accessing the memory of other nodes. Since any NUMA node inevitably needs to execute kernel code, threads in the same node as the kernel code segment will show better performance, while threads in a different node from the kernel code segment will always need to fetch memory instructions across nodes, showing poor performance, which will lead to an imbalance in the performance of the entire NUMA architecture and affect the overall performance of the NUMA architecture.

[0047] In response to the above technical problems, the present application proposes a kernel code processing solution, and based on the solution, forms a new kernel code access mode in the above NUMA architecture, which can make the performance of kernel code execution of each system node in the entire system architecture more balanced, and can solve the problem of unbalanced performance of kernel code execution of different system nodes caused by storing kernel code in a certain system node.

[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0049] The embodiment of the present application first proposes a kernel code processing method, which can be applied to a computer system including multiple system nodes, that is, a computer system applied to a NUMA architecture, and any system node in the computer system includes memory and a processor (or processor core). The method can be specifically executed by any system node in the computer system, such as by an idle system node in the computer system, or by an idle processor or processor core in the computer system.

[0050] In addition, in order to execute the kernel code processing method proposed in the embodiment of the present application, the embodiment of the present application also designs a kernel module for executing the kernel code processing method.

[0051] Exemplarily, a user may insert the kernel module into the operating system program of a computer system through the insmod command and call the kernel module. In each system node of the computer system, an idle processor core is selected to execute the kernel module, thereby implementing the kernel code processing method proposed in the embodiment of the present application.

[0052] See also Figure 2 As shown, the kernel code processing method proposed in the embodiment of the present application specifically includes:

[0053] S101. A first system node among the multiple system nodes divides a kernel code into multiple kernel code segments, and distributes and stores the multiple kernel code segments into the multiple system nodes.

[0054] Specifically, the first system node is a system node selected from a computer system of multiple system nodes for executing the kernel code processing method proposed in the embodiment of the present application. The first system node can be any system node in the computer system of multiple system nodes, for example, any idle system node.

[0055] The first system node runs the above kernel module, segments the kernel code, and divides the kernel code of the computer system into multiple kernel code segments. The number of kernel code segments divided by the first system node is not less than the number of system nodes in the computer system.

[0056] Then, the first system node distributes and stores the obtained multiple kernel code segments to multiple system nodes, specifically, distributes and stores the obtained multiple kernel code segments to the respective memories of the multiple system nodes, so that at least one kernel code segment is stored in the memory of each system node.

[0057] Exemplarily, when the first system node segments the kernel code, the kernel code can be segmented according to the code content of the kernel code, such as dividing kernel codes with strong correlation into the same kernel code segment, or segmenting the kernel code in units of a set kernel code length, etc.

[0058] In some embodiments, the first system node evenly divides the kernel code into a first number of kernel code segments, wherein the first number is the same as the number of system nodes in the computer system. The first system node then stores the divided first number of kernel code segments in a one-to-one correspondence in multiple system nodes. Through the above process, the first system node evenly distributes the kernel code to each system node for storage, so that the kernel code stored in each system node has the same length.

[0059] In other embodiments, the first system node segments the kernel code according to the capacity of the memory page table of each system node and the content of the kernel code, and stores the kernel code segments to each system node in sequence.

[0060] Specifically, the first system node starts from the start code of the kernel code and stores the kernel code in the i-th memory page table of each system node in sequence according to the execution order of the kernel code. When the i-th memory page table of each system node is full of kernel code and the kernel code is not completely stored, the kernel code is stored in the i+1-th memory page table of each system node in sequence until the kernel code is completely stored; i is a positive integer starting from 1.

[0061] That is, the first system node starts from the starting code of the kernel code and writes the kernel code into the first memory page table of the first system node. When the first memory page table of the first system node is full, the kernel code is written to the first memory page table of the second system node. When the first memory page table of the second system node is full, the kernel code is continued to be written to the first memory page table of the third system node, and so on, until the first memory page table of the last system node is full of kernel code, if there is any remaining kernel code that has not been written, start writing the remaining kernel code to the second memory page table of the first system node. When the second memory page table of the first system node is full, the kernel code is written to the second memory page table of the second system node. When the second memory page table of the second system node is full, the kernel code is continued to be written to the second memory page table of the third system node, and so on, until all the kernel codes are stored in each system node.

[0062] In other embodiments, the first system node segments and distributes the kernel code for storage according to the access frequency of each system node to different kernel internal code contents.

[0063] Specifically, the first system node determines the hot kernel code segments corresponding to each system node according to the historical access records and access frequencies of the kernel code of each system node; wherein the hot kernel code segments corresponding to the system nodes refer to the kernel code segments with the highest access frequency of the system nodes. Then, the first system node stores the hot kernel code segments corresponding to each system node in each system node.

[0064] For example, the first system node uses an open source performance observation tool such as perf to record the access history and frequency of each system node to the kernel code. According to the access history and frequency of each system node to the kernel code, the kernel code segment with the highest access frequency of each system node is determined as the hot kernel code segment corresponding to each system node. Based on the above operation, the first system node stores the hot kernel code segment corresponding to each system node in each system node.

[0065] Through the above processing, the kernel code segments with the highest access frequency are stored locally in the system node, so that the system node can access the kernel code that it frequently accesses more efficiently and quickly. At the same time, through the above processing, more kernel code segments are stored in the system node with a high kernel access frequency, while fewer kernel code segments are stored in the system node with a low kernel access frequency.

[0066] Among them, in the above processing process, the length of the kernel code stored in each system node may be different, but the lower limit and upper limit of the kernel code storage can be set for each system node, so that each system node can store part of the kernel code, or the lower limit and upper limit can be set to avoid excessive differences in the number of kernel code segments stored in different system nodes, so that the number of kernel code segments stored in each system node is balanced.

[0067] S102: The first system node generates a kernel page table based on storage locations of each kernel code segment in the multiple system nodes.

[0068] The kernel page table is used to record the correspondence between the virtual address of the kernel code segment and the physical storage address of the kernel code segment in the system node.

[0069] Specifically, in a computer system with multiple system nodes, a kernel page table is used to record the correspondence between the virtual address of the kernel code and the actual physical storage address of the kernel code.

[0070] In a conventional solution, the kernel code is stored in the system node 0 of the computer system, so the correspondence between the virtual address of the kernel code and the actual physical storage address of the kernel code in the system node 0 is recorded in the kernel page table. Figure 3 As shown, VA0~VA7 represent the virtual addresses of each kernel code segment in the kernel code, PA0~PA7 represent the physical addresses of node 0, and the correspondence between the virtual addresses of each kernel code segment of the kernel code and their actual storage physical addresses in node 0 is recorded in the kernel page table.

[0071] In the embodiment of the present application, since the first system node divides the kernel code into different kernel code segments and distributes and stores them in multiple system nodes, it is necessary to regenerate the kernel page table.

[0072] The first system node determines the physical storage address of the kernel code segment stored in each system node based on the kernel code segment stored in each system node and the memory address of the kernel code segment stored in each system node. Then, based on the virtual address of the kernel code segment stored in each system node, a kernel page table is generated to represent the correspondence between the virtual address of the kernel code segment stored in each system node and the physical storage address of the kernel code segment stored in each system node in the memory.

[0073] The generated kernel page table is as follows Figure 4 As shown. In the kernel page table, VA0 and VA1 represent the virtual address of the kernel code segment stored in node 0, while PA0 and PA1 represent the physical storage address of the kernel code segment stored in node 0 in node 0; VA2 and VA3 represent the virtual address of the kernel code segment stored in node 1, while PA10 and PA11 represent the physical storage address of the kernel code segment stored in node 1 in node 1; VA4 and VA5 represent the virtual address of the kernel code segment stored in node 2, while PA20 and PA21 represent the physical storage address of the kernel code segment stored in node 2 in node 2; VA6 and VA7 represent the virtual address of the kernel code segment stored in node 3, while PA30 and PA31 represent the physical storage address of the kernel code segment stored in node 3 in node 3.

[0074] In some embodiments, the first system node first obtains the original kernel page table, that is, obtains Figure 3 The kernel page table shown in FIG. 1 records the correspondence between the virtual address of the kernel code and the physical storage address of the kernel code in the original system node, and the original system node is any system node in a computer system with multiple system nodes.

[0075] Then, the first system node determines the virtual addresses of the kernel code segments stored in the system nodes based on the original kernel page table by querying the virtual addresses of the kernel code segments from the original kernel page table.

[0076] Finally, the first system node generates a kernel page table for recording the correspondence between the virtual addresses of the kernel code segments stored in each system node and the physical storage addresses of the kernel code segments stored in each system node in the memory based on the virtual addresses of the kernel code segments and the storage locations of the kernel code segments in the multiple system nodes.

[0077] S103: The first system node stores the kernel page table to a set storage location, so that the multiple system nodes access the kernel page table from the set storage location and load and run kernel code by accessing the kernel page table.

[0078] Specifically, after generating the kernel page table, the first system node stores the kernel page table in a storage location set by the computer system for storing the kernel page table. When the kernel code needs to be accessed, each system node in the computer system accesses the kernel page table from the set storage location, and determines the physical storage address of the kernel code segment to be accessed by accessing the kernel page table, that is, determines which physical address on which system node the kernel code segment to be accessed is stored. Then, the system node loads and runs the kernel code from the physical storage address of the kernel code segment to be accessed.

[0079] In some embodiments, the first system node stores the generated kernel page table to a set storage location in the computer system, and stores the starting storage address of the kernel page table at the set storage location to a page table base register, so that multiple system nodes in the computer system can determine the starting storage address of the kernel page table at the above-mentioned set storage location by accessing the page table base register, access the kernel page table according to the starting storage address, and load and run the kernel code by accessing the kernel page table.

[0080] Specifically, in a computer system with a NUMA architecture, each system node obtains the starting storage address of the kernel page table by accessing the page table base register, and then accesses the kernel page table based on the starting storage address. In order to keep the access method of each system node to the kernel page table unchanged, in an embodiment of the present application, after the first system node generates the kernel page table and stores the kernel page table to a set storage location, it also stores the starting storage address of the kernel page table at the set storage location to the page table base register, so that each system node in the computer system can read the starting storage address of the kernel page table from the page table base register according to the original kernel page table access method, and then access the kernel page table based on the starting storage address, read the physical storage address of the kernel code segment to be accessed from the kernel page table, and load and run the kernel code based on the physical storage address. This processing method can keep the operation logic of the upper layer of the system node unchanged, and avoid the impact on the operation of the upper system due to the regeneration of the kernel page table.

[0081] From the above introduction, it can be seen that the kernel code processing method proposed in the embodiment of the present application divides the kernel code into multiple kernel code segments, and distributes and stores them in multiple system nodes, and generates a kernel page table based on the storage location of each kernel code segment in the system node, so that each system node accesses the kernel code segment according to the kernel page table. The above scheme stores the kernel code in different system nodes in a dispersed manner, so that each system node in the entire system architecture may load the kernel code from other nodes and load the kernel code from the local, so that the performance of each system node in executing the kernel code is more balanced, and it can solve the problem of unbalanced performance of different system nodes in executing the kernel code caused by centrally storing the kernel code in a certain system node.

[0082] In another embodiment of the present application, the above kernel code processing method further includes:

[0083] When an update operation on a first kernel code segment is received, the update operation is performed on the first kernel code segment stored in a target system node based on the virtual address of the first kernel code segment and the kernel page table; the target system node is a system node storing the first kernel code segment.

[0084] Specifically, in actual applications, it may be necessary to update the kernel code, and the operating system only updates the kernel code according to the address mapping relationship recorded in the original kernel page table, and does not synchronously update the memory code segments stored in each NUMA node. Therefore, it is necessary to synchronously update the kernel code segments stored in each NUMA node after updating the kernel code.

[0085] Based on the above requirements, in the kernel code processing method proposed in the embodiment of the present application, the operating system's update operation on the kernel code is monitored in real time. When an update operation on any kernel code segment is detected, the kernel code segment stored in the target system node storing the updated kernel code segment is updated based on the kernel page table generated by the first system node.

[0086] Exemplarily, in order to synchronize the update of the kernel code to the kernel code segment stored in the corresponding NUMA node, the embodiment of the present application uses the kernel's kprobe mechanism to achieve the above update synchronization. The kprobe mechanism can be used to register a callback function, and a kernel function can be specified for the callback function. When the specified kernel function runs, an exception will be triggered, and then the registered callback function will be jumped to execute. After the callback function is executed, it will return to the original kernel function to continue execution. The kprobe mechanism is used to register a callback function for synchronizing the modification of the kernel code to the kernel code segment in the corresponding NUMA node for all functions that may modify the kernel code. This callback function will run when it detects that the kernel code has been modified or updated, and synchronize the modification or update of the kernel code to the NUMA node storing the kernel code.

[0087] As mentioned above, the kernel code is divided into different kernel code segments and copied to each NUMA node respectively. Based on this, the corresponding physical base address PA of the memory page can be found according to the virtual address VA of the modified kernel code using the kernel page table generated by the first system node, and then the page offset offset of the memory page to which it belongs is calculated according to VA. PA plus offset is the physical address of the kernel code of the corresponding NUMA node that needs to be updated. The modification is synchronized to the physical address to complete the corresponding update synchronization operation.

[0088] For example, assuming that the page size is 4KB, there is a mapping relationship between the virtual address VA2 and the physical address PA10 in the newly created kernel page table. Assuming that the virtual address represented by VA2 is 0x1000, the physical address represented by PA10 is 0xA000, and the virtual address of the code to be updated is 0x10FF. When the code is updated, the kprobe mechanism will be triggered to jump to the registered callback function to perform code synchronization operations. In the callback function, the virtual address 0x10FF of the code to be updated is decomposed into two parts, 0x1000 and 0xFF, where 0xFF is the page offset and 0x1000 is used for the page table index. According to the page table index 0x1000 and the mapping relationship between VA2 and PA10, it can be seen that the code with the virtual address 0x10FF exists in the physical page with the base address 0xA000. Because the page offset is 0x0FF, it can be calculated that the physical address mapped by 0x10FF is 0xA0FF, so the code modification can be synchronized to the physical address 0xA0FF.

[0089] Based on the above update synchronization operation, the operating system's update operation on the kernel code can be synchronized in real time to the system node storing the kernel code, thereby ensuring timely update of the kernel code segments stored in each system node.

[0090] Corresponding to the above-mentioned kernel code processing method, another embodiment of the present application also proposes a kernel code access method, which is applied to a computer system including multiple system nodes, wherein the above-mentioned system nodes include processors (or processor cores) and memory, so that kernel code segments can be stored in the memory of each system node, and the processors or processor cores in each system node can run kernel code. The first system node in the computer system divides the kernel code into multiple kernel code segments and distributes and stores them in each system node by executing the kernel code processing method described in any of the above-mentioned embodiments, and each system node stores at least one kernel code segment.

[0091] Based on the above kernel code segment storage method, see Figure 5 As shown, the kernel code access method proposed in the embodiment of the present application includes:

[0092] S201. A second system node among the multiple system nodes accesses a kernel page table from a set storage location to determine a physical storage address of a kernel code segment to be accessed.

[0093] The kernel page table is obtained by the first system node by executing the kernel code processing method described in any of the above embodiments and is stored in the set storage location.

[0094] When the second system node needs to run the kernel code, it first accesses the kernel page table from the above-mentioned set storage location, and queries the physical storage address of the kernel code segment to be accessed from the kernel page table, that is, queries which system node and which physical storage address the kernel code segment to be accessed is stored in.

[0095] In some embodiments, after the first system node generates a kernel page table and stores the kernel page table in a set storage location, the first system node also stores the starting storage address of the kernel page table at the set storage location in a page table base address register. When the second system node needs to run the kernel code, it first accesses the page table base address register, reads the starting storage address of the kernel page table from the page table base address register, and then accesses the kernel page table based on the starting storage address, and reads the physical storage address of the kernel code segment to be accessed from the kernel page table.

[0096] S202: The second system node loads and runs the kernel code segment to be accessed based on the physical storage address of the kernel code segment to be accessed.

[0097] Specifically, after determining the physical storage address of the kernel code segment to be accessed, the second system node loads and runs the kernel code segment to be accessed based on the physical storage address of the kernel code segment to be accessed.

[0098] The kernel code access method proposed in the embodiment of the present application divides the kernel code into multiple kernel code segments, and distributes and stores them in multiple system nodes, and generates a kernel page table based on the storage location of each kernel code segment in the system node. When any system node needs to run the kernel code, the physical storage address of the kernel code segment to be accessed is determined through the kernel page table, and then based on the physical storage address of the kernel code segment to be accessed, the kernel code segment to be accessed is loaded and run. The above scheme stores the kernel code in different system nodes in a dispersed manner, so that each system node in the entire system architecture may load the kernel code from other nodes and load the kernel code from the local, so that the performance of each system node in executing the kernel code is more balanced, and it can solve the problem of unbalanced performance of different system nodes in executing the kernel code caused by storing the kernel code in a certain system node.

[0099] The kernel code access method provided in this embodiment belongs to the same application concept as the kernel code processing method provided in the above embodiment of this application, and the kernel code access method provided in this embodiment is implemented based on the kernel code processing method provided in the above embodiment. For technical details of the kernel code processing method not described in detail in this embodiment, please refer to the specific processing content of the kernel code processing method provided in the above embodiment of this application, which will not be repeated here.

[0100] Another embodiment of the present application also provides a computer system, see Figure 6 As shown, the computer system is a computer system with a NUMA architecture, which includes multiple system nodes. Each system node includes a processor or a processor core and a memory.

[0101] The computer system is configured to implement the kernel code processing method described in any of the above embodiments or the kernel code access method described in any of the above embodiments.

[0102] In another embodiment of the present application, a computing device is also provided, which includes the above-mentioned computer system.

[0103] Exemplarily, the above-mentioned computer device may specifically be a personal computer, a server, a smart terminal, a handheld terminal, a wearable device, and the like.

[0104] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0105] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0106] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0107] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.

[0108] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0109] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0110] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.

[0111] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0112] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0113] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0114] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing kernel code, characterized in that: Applied to a computer system, the computer system includes a plurality of system nodes; the method includes: A first system node among the plurality of system nodes divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes; wherein each of the system nodes stores at least one kernel code segment; The first system node generates a kernel page table based on the storage location of each kernel code segment in the plurality of system nodes; the kernel page table is used to record the correspondence between the virtual address of the kernel code segment and the physical storage address of the kernel code segment in the system node; The first system node stores the kernel page table in a set storage location, so that the multiple system nodes access the kernel page table from the set storage location and load and run kernel code by accessing the kernel page table.

2. The method according to claim 1, characterized in that: The first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including: The first system node evenly divides the kernel code into a first number of kernel code segments, the first number being the same as the number of the plurality of system nodes; The first system node stores the first number of kernel code segments in the multiple system nodes in a one-to-one correspondence.

3. The method according to claim 1, characterized in that: The first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including: The first system node starts from the start code of the kernel code and stores the kernel code in the i-th memory page table of each system node in sequence according to the execution order of the kernel code; When the i-th memory page table of each system node is full of kernel code and the kernel code has not been completely stored, the kernel code is stored in the i+1-th memory page table of each system node in turn until the kernel code is completely stored; i is a positive integer starting from 1.

4. The method according to claim 1, characterized in that: The first system node divides the kernel code into a plurality of kernel code segments, and distributes and stores the plurality of kernel code segments to the plurality of system nodes, including: The first system node determines the hot kernel code segment corresponding to each system node according to the historical access records and access frequencies of the kernel code of each system node; wherein the hot kernel code segment corresponding to the system node refers to the kernel code segment with the highest access frequency of the system node; The first system node stores hotspot kernel code segments corresponding to each system node in each system node.

5. The method according to claim 1, characterized in that The first system node generates a kernel page table based on storage locations of each kernel code segment in the plurality of system nodes, including: The first system node obtains an original kernel page table, where the original kernel page table is used to record a correspondence between a virtual address of the kernel code and a physical storage address of the kernel code in an original system node, where the original system node is any one of the multiple system nodes; The first system node determines, based on the original kernel page table, respective virtual addresses of respective kernel code segments stored in respective system nodes; A kernel page table is generated based on the virtual addresses of the kernel code segments and the storage locations of the kernel code segments in the plurality of system nodes.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: When an update operation on a first kernel code segment is received, the update operation is performed on the first kernel code segment stored in a target system node based on the virtual address of the first kernel code segment and the kernel page table; the target system node is a system node storing the first kernel code segment.

7. The method according to any one of claims 1 to 5, characterized in that The first system node stores the kernel page table to a set storage location, so that the multiple system nodes access the kernel page table from the set storage location and load and run kernel code by accessing the kernel page table, including: The first system node stores the kernel page table to a set storage location, and stores the starting storage address of the kernel page table at the set storage location to a page table base address register, so that the multiple system nodes determine the starting storage address of the kernel page table at the set storage location by accessing the page table base address register, access the kernel page table according to the starting storage address, and load and run the kernel code by accessing the kernel page table.

8. A method for accessing kernel code, characterized in that: The method is applied to a computer system, the computer system comprising a plurality of system nodes, each of the system nodes storing at least one kernel code segment, the kernel code segments stored in each of the system nodes being distributed and stored in each of the system nodes by a first system node among the plurality of system nodes executing the kernel code processing method according to any one of claims 1 to 7; the method comprising: A second system node among the plurality of system nodes accesses a kernel page table from a set storage location to determine a physical storage address of a kernel code segment to be accessed; The second system node loads and runs the kernel code segment to be accessed based on the physical storage address of the kernel code segment to be accessed; The kernel page table is obtained by the first system node by executing the kernel code processing method according to any one of claims 1 to 7 and is stored in the set storage location.

9. A computer system, characterized in that: The computer system comprises a plurality of system nodes, and is configured to implement the method according to any one of claims 1 to 8.

10. A computing device, characterized in that Comprising the computer system as claimed in claim 9.