Affinity scheduling method, multiprocessor system and computer program product
By obtaining affinity scheduling information in the NUMA architecture and utilizing the modified execve system call, dynamic link libraries are loaded into specified NUMA nodes, thus resolving the system jitter and performance degradation issues caused by cross-node access and improving task execution efficiency.
Patent Information
- Application Number
- CN202510772481.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-11-07
AI Technical Summary
Under the NUMA architecture, despite affinity scheduling and binding, cross-NUMA node access is still unavoidable, affecting service response speed and causing system jitter, especially when frequently accessing dynamic link libraries.
By obtaining affinity scheduling information when starting the target computation task, binding the task to a specified NUMA node using NUMA node parameters, and calling the modified execve system call to load the dynamic link library into that node, the task is ensured to be executed locally.
It reduces access across NUMA nodes, lowers system jitter and performance degradation, and improves the execution efficiency of computing tasks, especially in scenarios with frequent access to dynamic link libraries.
Smart Images

Figure CN120909754A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the chip technical field, in particular, to the scheduling technology in the chip technical field, more particularly, to an affinity scheduling method, a multi-processor system and a computer program product. BACKGROUND
[0002] With the increase of the number of processor cores, the NUMA (Non-Uniform Memory Access) architecture is widely used in high-performance computing and server fields. Under the NUMA architecture, the CPU and the memory are divided into multiple NUMA nodes, and each NUMA node contains a plurality of CPU cores and local memory. Within the same NUMA node, the CPU can quickly access the local memory, thereby optimizing the local memory access performance.
[0003] Generally, in order to better provide services, affinity scheduling needs to be performed at the start of the service or thereafter, and the service is bound to a specified NUMA node. In this way, the service can be provided only by using the bound NUMA node. However, even if the NUMA node is bound through affinity scheduling, cross- NUMA node access will still inevitably occur when processing some tasks, thereby affecting the response speed of the service, and even causing system jitter. SUMMARY
[0004] To solve the above technical problems, the present application provides an affinity scheduling method, a multi-processor system and a computer program product, to achieve the purpose of reducing cross- NUMA node access through affinity scheduling.
[0005] To achieve the above technical purpose, the embodiments of the present application provide the following technical solutions:
[0006] In a first aspect, the embodiments of the present application provide an affinity scheduling method applied to a multi-processor system of a NUMA architecture, the multi-processor system comprising a plurality of NUMA nodes, and the method comprising:
[0007] When a target computing task is started in the multi-processor system, affinity scheduling information of the target computing task is obtained, wherein the affinity scheduling information comprises a NUMA node parameter and a computing task start parameter;
[0008] Based on the NUMA node parameter, the target computing task is bound to a first NUMA node, wherein the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter;
[0009] Based on the computing task startup parameter, a modified execve system call in the kernel is invoked to load a dynamic link library relied by the target computing task to the first NUMA node and execute the target computing task in a current process.
[0010] In a second aspect, the embodiments of the present application provide a multi-processor system, the multi-processor system adopts a NUMA architecture, and the multi-processor system comprises a plurality of NUMA nodes.
[0011] The multi-processor system is configured to acquire affinity scheduling information of a target computing task when starting the target computing task, wherein the affinity scheduling information comprises a NUMA node parameter and a computing task startup parameter.
[0012] The multi-processor system is further configured to bind the target computing task to a first NUMA node based on the NUMA node parameter, wherein the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter.
[0013] The multi-processor system is further configured to invoke a modified execve system call in the kernel based on the computing task startup parameter, load a dynamic link library relied by the target computing task to the first NUMA node, and execute the target computing task in a current process.
[0014] In a third aspect, the embodiments of the present application provide a computing device comprising the multi-processor system of the second aspect.
[0015] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is run by a processor to implement the affinity scheduling method of the first aspect.
[0016] In a fifth aspect, the embodiments of the present application provide a computer program product, and the computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps of the affinity scheduling method of the first aspect.
[0017] The affinity scheduling method provided by the embodiment of the present application is applied to a multi-processor system of NUMA architecture, and the multi-processor system comprises a plurality of NUMA nodes. At the beginning of starting a target computing task, affinity scheduling is carried out by using obtained affinity scheduling information. The target computing task is bound to a first NUMA node by using a NUMA node parameter in the affinity scheduling information, so that the target computing task can be executed by using the first NUMA node subsequently. Then, a modified execve system call in a kernel is called by using a computing task starting parameter in the affinity scheduling information, a dynamic link library relied on by the target computing task is loaded to the first NUMA node, and the target computing task is executed in the current process. Since the dynamic link library relied on by the target computing task is directly loaded to the first NUMA node, the corresponding dynamic link library can be accessed without crossing NUMA nodes when the computing task is executed in the first NUMA node. Even if there is a globally shared dynamic link library on other NUMA nodes in the multi-processor system, the execution of the target computing task will not be affected, and the cross- NUMA node access is reduced. Especially for the scene of frequently accessing the dynamic link library, the system jitter and performance decline can be reduced. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the provided drawings.
[0019] FIG. 1 A structure schematic diagram of a multi-processor system of NUMA architecture is shown in FIG. 1.
[0020] FIG. 2 A flowchart of an affinity scheduling method provided by the embodiment of the present application is shown in FIG. 2.
[0021] FIG. 3 A flowchart of an affinity scheduling method provided by the embodiment of the present application is shown in FIG. 2. DETAILED DESCRIPTION
[0022] Unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be understood as the general meaning understood by those skilled in the art to which the embodiments of the present application belong. The terms "first", "second" and the like used in the embodiments of the present application do not represent any order, quantity or importance, but are only set to avoid confusion of the constituent elements.
[0023] Unless otherwise required by context, "plurality" means "at least two" in the specification, "include" is to be construed as open, inclusive, meaning "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiment", "example", "specific example" or "some examples" are intended to mean that a particular feature, structure, material or characteristic included in at least one embodiment or example of the specification. The illustrative representation of the above terms does not necessarily mean the same embodiment or example. In addition, the embodiments in the following description can be understood as implementation manners.
[0024] The technical solutions in the embodiments of the specification will be described clearly and completely in the specification below in combination with the drawings in the embodiments of the specification. Obviously, the described embodiments are only part of the embodiments of the specification, not all. Based on the embodiments in the specification, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the specification.
[0025] SUMMARY
[0026] As described in the background, the NUMA architecture is widely used in many technical fields due to its excellent performance. When a multi-processor system adopts the NUMA architecture, the processors or processor cores are divided into multiple NUMA nodes. For example, each NUMA node contains a group of processor cores, local memory and a bus for communication between NUMA nodes.
[0027] In one embodiment, the NUMA architecture includes a processor, which includes multiple processor cores, and the multiple processor cores are divided into different groups, each group including at least one processor core, and each group is a NUMA node.
[0028] In another embodiment, the NUMA architecture includes multiple processors, each processor including multiple processor cores, and the processor cores of each processor are divided into different NUMA nodes.
[0029] Regardless of which of the above embodiments is adopted, for each NUMA node, a physical memory is also configured, and each NUMA node can access the memory space of the physical memory (local memory) configured by itself, and can also access the memory space of other NUMA nodes. As shown in the figure, the multi-processor system can include four NUMA nodes (not limited to four) FIG. 1 As shown in the figure, the multi-processor system can include four NUMA nodes (not limited to four) FIG. 1 Only four are taken as an example, but not limited to four), each NUMA node includes a group of processor cores and memory; in the same NUMA node, the processor cores and the memory communicate through a bus, and different NUMA nodes communicate through a bus.
[0030] In the above NUMA architecture, in order to make its performance be utilized to the maximum extent, it is usually required to perform affinity scheduling on the services or computing tasks running thereon. For example, the numactl utility tool can be used to bind the services or computing tasks to the specified NUMA node at the time of starting. For another example, the taskset tool can be used to bind the processes of the services or computing tasks to the specified NUMA node after the processes are started.
[0031] No matter which affinity scheduling manner is adopted, during the running of the services, cross- NUMA node access will inevitably occur, thereby affecting the response speed of the services, and even causing system jitter. For example, the dynamic link library (Dynamic Link Library or Dynamic-link Library, referred to as DLL) relied on by the service process is usually managed by the operating system, i.e. shared by the whole system. Since there is only one shared library of the dynamic link library, which is located at a certain NUMA node, when other NUMA nodes access the dynamic link library during the execution of the computing tasks, cross- NUMA node access will inevitably occur.
[0032] In view of the above technical status, the present application inventors propose that, due to the inherent mechanism of a computer system, a shared dynamic link library cannot be copied multiple times and stored in each NUMA node. However, by means of an execve system call, the dynamic link library relied on by a computing task can be loaded into a corresponding NUMA node when the computing task is started by modifying the system call. In this way, without destroying the inherent mechanism of the computer system, the dynamic link library can be accessed locally in the NUMA node, and the cross- NUMA node access situation is reduced. For this purpose, an affinity scheduling method is proposed in the embodiments of the present application. At the beginning of starting a target computing task, affinity scheduling is carried out by using the obtained affinity scheduling information. The target computing task is bound to a first NUMA node by using the NUMA node parameter in the affinity scheduling information, so that the target computing task can be executed by using the first NUMA node subsequently. Then, the dynamic link library relied on by the target computing task is loaded into the first NUMA node by using the computing task start parameter in the affinity scheduling information, and the target computing task is executed in the current process by using the modified execve system call in the kernel. Since the dynamic link library relied on by the target computing task is directly loaded into the first NUMA node, the corresponding dynamic link library can be accessed without crossing the NUMA node when the computing task is executed in the first NUMA node. Even if there is a globally shared dynamic link library in other NUMA nodes in the multiprocessor system, the execution of the target computing task will not be affected, and the cross- NUMA node access situation is reduced. Especially for scenarios that need to frequently access the dynamic link library, the system jitter and performance degradation can be reduced.
[0033] Exemplary method
[0034] The affinity scheduling method provided in the embodiments of the present application is applied to a multiprocessor system adopting a NUMA architecture. As shown in the above embodiments and FIG. 1 The multiprocessor system adopting the NUMA architecture can include a plurality of NUMA nodes, and each NUMA node has a local memory and one or more processors or processor cores.
[0035] The affinity scheduling method proposed in the embodiments of the present application is executed by the above-mentioned multiprocessor system adopting the NUMA architecture, and can be executed by an operating system running on the multiprocessor system or by a specific application program running on the multiprocessor system.
[0036] The specific processing flow of the affinity scheduling method proposed in the present application will be introduced below.
[0037] As shown in FIG. 2 The affinity scheduling method can include:
[0038] S201: When starting a target computing task in a multiprocessor system, obtaining affinity scheduling information of the target computing task.
[0039] In this step, as to the multiprocessor system, refer to the above description, which will not be repeated here. The target computing task includes any computing task, service or application program that can run in the multiprocessor system.
[0040] In some embodiments, the target computing task includes a pre-configured computing task. For example, a plurality of computing tasks are pre-configured in the multiprocessor system, and the plurality of computing tasks are determined as the target computing task.
[0041] In some embodiments, the target computing task includes a computing task that may occur cross- NUMA node access under the inherent mechanism of the computer system. For example, the target computing task includes a computing task whose dependent dynamic link library is a shared library. In some embodiments, the target computing task includes a computing task that may occur frequent cross- NUMA node access under the inherent mechanism of the computer system. For example, the target computing task includes a MySQL database service, which usually accesses the shared dynamic link library frequently and thus occurs frequent cross- NUMA node access in the process of providing the MySQL database service by the multiprocessor system. The above inherent mechanism includes the sharing mechanism of the dynamic link library.
[0042] The affinity scheduling information of the target computing task is used to specify the NUMA node to which the target computing task needs to be bound, and to provide the necessary parameters required for starting the target computing task. In this embodiment, the affinity scheduling information includes a NUMA node parameter and a computing task starting parameter. The NUMA node parameter includes a parameter of a specified NUMA node, which is used to bind the target computing task to the specified NUMA node. The specific content of the NUMA node parameter is not limited here. For example, the NUMA node parameter can include an identifier of the specified NUMA node.
[0043] The computing task starting parameter includes a parameter required for starting the target computing task on the multiprocessor system. It can be understood that in the process of starting a computing task on the multiprocessor system, a process will be generated accordingly. Therefore, in some embodiments, the computing task starting parameter can be a parameter required for the multiprocessor system to generate a process corresponding to the target computing task.
[0044] S202: Bind the target computing task to the first NUMA node based on the NUMA node parameter.
[0045] In this step, the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter. By binding the target computing task to the first NUMA node, the target computing task can be executed on the first NUMA node subsequently. That is, the processor or processor core in the first NUMA node and the memory in the first NUMA node are used to process the target computing task.
[0046] S203: Based on the computing task start parameter, the modified execve system call in the kernel is called to load the dynamic link library relied on by the target computing task to the first NUMA node, and execute the target computing task in the current process.
[0047] Wherein, the execve system call can also be represented as execve(), which is a function in the Linux operating system call sequence, used to create a new process and load a new executable file, so as to execute a new program. Usually, the computing task (ELF format file) is located in the hard disk, and the execve system call is needed to build the Linex execution body, i.e. process, to start the computing task.
[0048] The system call in this step is the modified execve system call, which adds the function logic of loading the dynamic link library to the specified NUMA node on the basis of the original function logic. Therefore, by calling the modified execve system call, not only can the process of the target computing task be built to execute the target computing task, but also the dynamic link library relied on by the target computing task can be loaded to the specified NUMA node (the first NUMA node in this embodiment), so that when the target computing task process runs on the first NUMA node and needs to access the dynamic link library, the access will be performed in the first NUMA node, and cross- NUMA node access will not occur.
[0049] In some embodiments, the shared library sharing mechanism of the computer system can be preserved in the multiprocessor system. Before starting a target computing task, a shared dynamic link library can be loaded in a certain NUMA node for access by other NUMA nodes. When a certain computing task is started, if the dependent dynamic link library is loaded in the NUMA node to which the computing task is bound, when the computing task is run, the dynamic link library in the NUMA node to which the computing task is bound can be preferentially accessed. If the dependent dynamic link library is not loaded in the NUMA node to which the computing task is bound, when the computing task is run, the shared dynamic link library can be accessed. Therefore, before S201, the method further includes: loading a dynamic link library shared by each computing task in the multiprocessor system to a second NUMA node, wherein the second NUMA node is any one of the plurality of NUMA nodes except the first NUMA node. The dynamic link library shared by each computing task is the shared dynamic link library, which includes the dynamic link libraries relied on by all computing tasks.
[0050] In the embodiments of the present application, at the beginning of starting the target computing task, affinity scheduling is carried out by using the obtained affinity scheduling information. The target computing task is bound to the first NUMA node by using the NUMA node parameter in the affinity scheduling information, so that the target computing task can be executed by using the first NUMA node subsequently. Then, the dynamic link library relied on by the target computing task is loaded to the first NUMA node and the target computing task is executed in the current process by using the computing task starting parameter in the affinity scheduling information and calling the modified execve system call in the kernel. Since the dynamic link library relied on by the target computing task is directly loaded to the first NUMA node, when the computing task is executed in the first NUMA node, the corresponding dynamic link library can be accessed without crossing the NUMA node. Even if the global shared dynamic link library exists on other NUMA nodes in the multiprocessor system, the execution of the target computing task will not be affected, and the situation of crossing the NUMA node is reduced. Especially for the scene of frequently accessing the dynamic link library, the system jitter and performance decline can be reduced.
[0051] To avoid that the dynamic link library occupies a large memory space in the first NUMA node, in some embodiments of the present application, based on the computing task starting parameter, the modified execve system call in the kernel is called to load the dynamic link library relied on by the target computing task to the first NUMA node, including:
[0052] Based on the computing task starting parameter, the modified execve system call in the kernel is called to parse the executable file of the target computing task;
[0053] The dynamic link library relied on by the target computing task is determined through the executable file;
[0054] mapping the dynamic link library relied by the target computing task to the address space of the current process.
[0055] It should be noted that the executable file of the target computing task can be a common ELF (Executable and Linkable Format) file. The executable file of the target computing task contains the dynamic link library relied by the target computing task during execution.
[0056] Mapping the dynamic link library relied by the target computing task to the address space of the current process, that is, loading the dynamic link library relied by the target computing task into the first NUMA node. The current process can be a process corresponding to the target computing task, and the address space corresponding to the current process can be a virtual address space corresponding to the current process.
[0057] In some embodiments, in the case where the executable file of the target computing task is an ELF file, the following code logic can be added on the basis of the original execve system call, so as to obtain a modified execve system call.
[0058] 1. Analyze the header of the ELF file to find the.dynamic segment.
[0059] List all required shared libraries (dynamic link libraries) through DT_NEEDED.
[0060] Specify the path for searching the shared library (dynamic link library) through DT_RPATH or DT_RUNPATH.
[0061] Parse the symbols through DT_STRTAB, DT_SYMTAB, etc.
[0062] 2. Map the dynamic link library required by the ELF file to the virtual address space of the process through the vm_mmap function of the kernel.
[0063] In the embodiments of the present application, only the dynamic link library relied by the target computing task can be loaded into the memory of the first NUMA node. Compared with loading all dynamic link libraries relied by the computing tasks, the present application will occupy a smaller memory space in the first NUMA node.
[0064] In some embodiments of the present application, loading the dynamic link library relied by the target computing task into the first NUMA node includes:
[0065] Finding the dynamic link library shared by the computing tasks in the multi-processor system;
[0066] Loading the dynamic link library shared by the computing tasks into the first NUMA node.
[0067] It should be noted that the computing tasks in the multi-processor system can include a plurality of specified computing tasks, and the plurality of specified computing tasks include the target computing task. The computing tasks in the multi-processor system can also include all computing tasks in the multi-processor system. It can be understood that the dynamic link libraries relied on by different computing tasks are different. When considering loading the dynamic link library relied on by the target computing task to the first NUMA node, in order to simplify the loading process, the dynamic link libraries relied on by the plurality of computing tasks including the target computing task can be loaded to the first NUMA node together. For example, the dynamic link libraries relied on by all computing tasks in the multi-processor system can be loaded to the first NUMA node together.
[0068] In some embodiments, when the shared dynamic link library has been loaded to a certain NUMA node of the multi-processor system, the dynamic link library required by the target computing task can be searched according to the path of the shared dynamic link library, and then the searched dynamic link library can be loaded to the first NUMA node.
[0069] In the embodiments of the present application, the dynamic link libraries shared by the computing tasks in the multi-processor system can be loaded to the first NUMA node together, so that the loading process can be simplified and the modification range of the execve system call can be reduced.
[0070] In order to reduce the waste of memory space in each NUMA node, in some embodiments of the present application, based on the computing task start parameter, the modified execve system call in the kernel is called to load the dynamic link library relied on by the target computing task to the first NUMA node, and before executing the target computing task in the current process, the method further includes:
[0071] determining the shared library identifier of the target computing task, wherein the shared library identifier includes a first identifier indicating separate loading and a second identifier indicating sharing;
[0072] in the case where the shared library identifier is the first identifier, performing the step of calling the modified execve system call in the kernel based on the computing task start parameter to load the dynamic link library relied on by the target computing task to the first NUMA node, and executing the target computing task in the current process;
[0073] in the case where the shared library identifier is the second identifier, setting the dynamic link library access strategy of the target computing task to access the dynamic link library shared by the multi-processor system, and executing the target computing task in the current process.
[0074] It should be noted that in the embodiments, the shared library identifier is used to determine whether the dynamic link library relied on by the computing task needs to be loaded to the NUMA node bound to the computing task.
[0075] The shared library identifier can be at least one of a number, a letter, and a special symbol. The first identifier is different from the second identifier. For example, when a number is used as the shared library identifier, the first identifier can be 1 and the second identifier can be 0. For another example, when a letter is used as the shared library identifier, the first identifier can be a and the second identifier can be b.
[0076] If the dynamic link library relied on by the computing task needs to be loaded to the NUMA node to which the computing task is bound, the dynamic link library can be loaded to the first NUMA node in the manner provided in the above embodiments.
[0077] If the dynamic link library relied on by the computing task does not need to be loaded to the NUMA node to which the computing task is bound, it means that the dynamic link library shared by the multiprocessor system can be used to complete the processing or running of the target computing task. For example, if the shared library identifier is the second identifier, the dynamic link library does not need to be loaded. In the process of running the target computing task, the dynamic link library shared by the second NUMA node in the above embodiments can be accessed across nodes.
[0078] For ease of understanding, the process of the modified execve system call in the calling kernel and the manner of processing based on the shared library identifier in the process are described below with a specific example.
[0079] Step 1, parameter checking. Verify whether the file path parameter, the new environment variable parameter, and the like are valid, and check whether the ELF format executable file exists and has the permission.
[0080] Step 2, loading the ELF format executable file. First, read the file header to determine whether the file format is the ELF format or the script format. Then, call the corresponding record to parse the ELF format executable file.
[0081] Step 3, cleaning the old process image and releasing the memory space (such as the code segment, the data segment, and the stack) of the current process.
[0082] Step 4, setting the new process image. Load the code and data of the new program into the memory. Determine whether the dynamic link library needs to be loaded based on the shared library identifier. For example, set the f_load_dynamic_lib flag as the shared library identifier. If the flag is 1, it means that the dynamic link library needs to be loaded, and the required dynamic link library is loaded to the specified NUMA node (for example, the dynamic link library relied on by the target computing task is loaded to the first NUMA node). If the flag is 0, it means that the dynamic link library does not need to be loaded. Initialize the stack and set the program counter to the entry point of the new program.
[0083] Step 5, returning to the user mode. Return from the kernel mode, and the process starts to execute the new program.
[0084] In the embodiments of the present application, whether the dynamic link library needs to be loaded in the specified NUMA node is selected based on the shared library identifier, which is not only flexible and convenient, but also can avoid the waste of resources caused by loading the dynamic link library in each NUMA node to some extent.
[0085] In some embodiments of the present application, the shared library identifier of the target computing task is determined, comprising:
[0086] The target computing task is evaluated by using a preset evaluation strategy to obtain an evaluation result;
[0087] The shared library identifier is determined to be the first identifier or the second identifier based on the evaluation result.
[0088] It should be noted that different contents of the shared library identifier will result in two different situations. Situation one, when the shared library identifier is the first identifier, the dynamic link library needs to be loaded in the specified NUMA node. In this way, while reducing cross-node access, the memory space of the specified NUMA node will also be occupied. Situation two, when the shared library identifier is the second identifier, the dynamic link library does not need to be loaded in the specified NUMA node. In this way, cross-node access to the shared dynamic link library on other NUMA nodes is required, but the memory space of the specified NUMA node is saved. Therefore, regardless of which identifier the shared library identifier is, the final implementation scheme has its own advantages and disadvantages.
[0089] To balance the above two situations, the specific situation of the computing task needs to be analyzed. In the embodiments, the computing task is analyzed in detail by using a preset evaluation strategy to determine whether the memory space of the NUMA node should be sacrificed for faster access to the dynamic link library, or the access speed of the dynamic link library should be sacrificed for the saving of the memory space in the NUMA node.
[0090] The specific content of the preset evaluation strategy is not limited here. Business personnel can configure the evaluation strategy according to the actual situation of different computing tasks. For example, frequent cross-node access can easily cause system jitter and system performance degradation. In some embodiments, the evaluation strategy can be determined based on the frequency of accessing the dynamic link library within a certain time period during the execution of the computing task. The configured preset evaluation strategy can include: whether the frequency of accessing the dynamic dependent library within the target time period during the execution of the computing task exceeds the frequency threshold. If yes, the evaluation result of needing to load the dynamic link library is obtained. If no, the evaluation result of not needing to load the dynamic link library is obtained.
[0091] Specifically, the evaluation result includes: a first evaluation result that meets a target condition and a second evaluation result that does not meet the target condition, and the target condition includes: the frequency of accessing the dynamic dependent library within the target time period during the execution of the target computing task exceeds the frequency threshold;
[0092] The determining the shared library identifier as the first identifier or the second identifier based on the evaluation result comprises: in a case where the evaluation result is the first evaluation result, determining the shared library identifier as the first identifier; and in a case where the evaluation result is the second evaluation result, determining the shared library identifier as the second identifier.
[0093] In the embodiments of the present application, the evaluation strategy can be flexibly set, so as to automatically determine whether the dynamic link library relied on by the computing task needs to be loaded to the specified NUMA node or directly use the shared dynamic link library in other NUMA nodes, without human intervention.
[0094] In some embodiments of the present application, the affinity scheduling information further comprises: a shared library identifier.
[0095] It should be noted that by flexibly setting the evaluation strategy, it can be automatically determined whether the dynamic link library relied on by the computing task needs to be loaded to the specified NUMA node or directly use the shared dynamic link library in other NUMA nodes. Although it can be achieved without human intervention, the evaluation strategy needs to be maintained in real time.
[0096] Therefore, in the embodiments of the present application, it can be determined by human whether the dynamic link library relied on by the computing task needs to be loaded to the specified NUMA node or directly use the shared dynamic link library in other NUMA nodes. Then, after determining the determination result, the corresponding shared library identifier is set in the affinity scheduling information based on the determination result.
[0097] The standard of human determination can be the same as or different from the evaluation strategy in the above embodiments.
[0098] For example, if it is determined by human that the first computing task only occasionally accesses the dynamic link library, it indicates that it is more appropriate to access the shared dynamic link library during the execution of the first computing task. At this time, the shared library identifier in the affinity scheduling information of the first computing task can be set as the second identifier.
[0099] If it is determined that the first computing task accesses the dynamic link library temporarily and frequently, it indicates that it is more appropriate to access the dynamic link library in the NUMA node bound to the first computing task during the execution of the first computing task. At this time, the shared library identifier in the affinity scheduling information of the first computing task can be set as the first identifier.
[0100] For another example, it is determined by human that the second computing task is a computing task with a very high importance level, which indicates that it is necessary to try to ensure the smooth execution of the second computing task. During the execution of the second computing task, accessing the dynamic link library in the NUMA node bound to the second computing task makes the system response faster, and thus it is more appropriate. At this time, the shared library identifier in the affinity scheduling information of the second computing task can be set as the first identifier.
[0101] If the second computing task is determined to be a very low importance level computing task by the artificial judgment, it indicates that the second computing task does not need to be excessively ensured to be executed successfully. In the process of executing the second computing task, the shared dynamic link library can be accessed, so that the memory space in the NUMA node to which the second computing task is bound can be saved, and it is more appropriate. At this time, the shared library identifier in the affinity scheduling information of the second computing task can be set as the second identifier.
[0102] In the embodiments of the present application, it can be determined by artificial judgment whether the dynamic link library relied on by the computing task needs to be loaded into the specified NUMA node or directly use the shared dynamic link library in other NUMA node. Then the judgment result can be embodied in the affinity scheduling information, and there is no need to set the evaluation strategy for analyzing the computing task.
[0103] In some embodiments, the NUMA node parameter includes a processor affinity policy and a memory affinity policy; the processor affinity policy includes information of the first NUMA node and information of the target processor in the first NUMA node; the memory affinity policy includes information of the first NUMA node and information of the target memory in the first NUMA node; and the target computing task is bound to the first NUMA node based on the NUMA node parameter, including:
[0104] The target computing task is bound to the target processor in the first NUMA node according to the processor affinity policy;
[0105] The target computing task is bound to the target memory in the first NUMA node according to the memory affinity policy.
[0106] Through the above binding process, when the target computing task is executed in the first NUMA node, the target computing task is processed by using the target processor and the target memory.
[0107] For the convenience of understanding, the affinity scheduling method provided by the present embodiment will be described below with a specific example. As shown in the figure, the process includes: FIG. 3
[0108] S301: The command line parameters are parsed by using a utility tool to obtain a processor affinity policy, a memory affinity policy, and a computing task command line parameter. The computing task command line parameter is a command line parameter for starting a computing task, and different computing tasks have different specific contents, which will not be described here. For example, the utility program is foo; the computing task is: / usr / bin / mysqld, and the parameter of the computing task is -f / etc / mysql / my.conf. Then the command line parameter for starting the computing task is: `foo –cpubind=0
[0109] -membind=0 / usr / bin / mysqld-f / etc / mysql / my.conf.
[0110] S302: processor affinity setting based on processor affinity policy.
[0111] S303: memory affinity setting based on memory affinity policy. Continue to take the example in S301, cpubind / membind can represent which NUMA node and which CPU and memory of the NUMA node the computing task wants to run on.
[0112] S304: call the modified execve system call to pass the f_load_dynamic_lib flag, and replace the current process with the computing task image. The process is the same as the process of steps 1-5 in the above embodiment, and will not be repeated here.
[0113] S305: control is transferred to the computing task, so that the computing task can be executed.
[0114] In the embodiments of the present application, a utility tool can be constructed, and the utility tool is used to parse command line parameters to obtain processor affinity policy, memory affinity policy, and computing task command line parameters. The execve system call is modified in the Linux kernel, and the f_load_dynamic_lib flag is added to make it load the dynamic link library dependent on the computing task immediately when loading a new ELF executable file (when f_load_dynamic_lib is 1).
[0115] Before the modified execve system call, the process has set the memory allocation policy to be limited on the specified NUMA node. Therefore, the dynamic link library loaded by the modified execve system call will all reside in the memory of the specified NUMA node, thereby minimizing the cross- NUMA node access during the running of the computing task, improving the access efficiency, and keeping completely transparent to the application, thereby improving the overall system performance.
[0116] Exemplary system
[0117] Corresponding to the affinity scheduling method described above, the embodiments of the present application also propose a multi-processor system. The multi-processor system adopts a NUMA architecture, and the multi-processor system includes a plurality of NUMA nodes. The structure of the multi-processor system can be seen from FIG. 1 .
[0118] The multi-processor system is used to obtain affinity scheduling information of a target computing task when starting the target computing task, wherein the affinity scheduling information includes a NUMA node parameter and a computing task starting parameter.
[0119] The multi-processor system is further configured to bind the target computing task to the first NUMA node based on the NUMA node parameter, wherein the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter.
[0120] The multi-processor system is further configured to, based on the computing task start parameter, call the modified execve system call in the kernel to load the dynamic link library relied on by the target computing task to the first NUMA node and execute the target computing task in the current process.
[0121] In some embodiments, the multi-processor system, based on the computing task start parameter, calls the modified execve system call in the kernel to load the dynamic link library relied on by the target computing task to the first NUMA node, comprises:
[0122] Based on the computing task start parameter, calling the modified execve system call in the kernel to parse the executable file of the target computing task; determining the dynamic link library relied on by the target computing task through the executable file; and mapping the dynamic link library relied on by the target computing task to the address space of the current process.
[0123] In some embodiments, the multi-processor system, based on the computing task start parameter, calls the modified execve system call in the kernel to load the dynamic link library relied on by the target computing task to the first NUMA node and execute the target computing task in the current process, is further configured to:
[0124] determining the shared library identifier of the target computing task, wherein the shared library identifier comprises a first identifier indicating separate loading and a second identifier indicating sharing; in the case that the shared library identifier is the first identifier, performing the step of, based on the computing task start parameter, calling the modified execve system call in the kernel to load the dynamic link library relied on by the target computing task to the first NUMA node and execute the target computing task in the current process; and in the case that the shared library identifier is the second identifier, setting the dynamic link library access strategy of the target computing task to access the dynamic link library shared by the multi-processor system and executing the target computing task in the current process.
[0125] In some embodiments, the multi-processor system determines the shared library identifier of the target computing task, comprising:
[0126] adopting a preset evaluation strategy to evaluate the target computing task to obtain an evaluation result; and determining the shared library identifier to be the first identifier or the second identifier based on the evaluation result.
[0127] In some embodiments, the evaluation result includes a first evaluation result that the target condition is met and a second evaluation result that the target condition is not met, and the target condition includes that a frequency of accessing the dynamic dependency library within a target time duration during execution of the target computing task exceeds a frequency threshold.
[0128] The multi-processor system determines the shared library identifier as the first identifier or the second identifier based on the evaluation result, including:
[0129] In a case where the evaluation result is the first evaluation result, the shared library identifier is determined as the first identifier; and in a case where the evaluation result is the second evaluation result, the shared library identifier is determined as the second identifier.
[0130] In some embodiments, the affinity scheduling information further includes the shared library identifier.
[0131] In some embodiments, the multi-processor system loads the dynamic link library on which the target computing task depends into the first NUMA node, including:
[0132] The multi-processor system loads the dynamic link library shared by the computing tasks in the multi-processor system into the first NUMA node.
[0133] In some embodiments, before obtaining the affinity scheduling information of the target computing task when the target computing task is started in the multi-processor system, the multi-processor system further includes:
[0134] The multi-processor system loads the dynamic link library shared by the computing tasks in the multi-processor system into the second NUMA node, wherein the second NUMA node is any one of the plurality of NUMA nodes except the first NUMA node.
[0135] The affinity scheduling device provided by the embodiments of the present application belongs to the same inventive concept as the affinity scheduling method provided by the above-mentioned embodiments of the present application. Technical details not described in detail in the present embodiment can be referred to the specific processing content of the affinity scheduling method provided by the above-mentioned embodiments of the present application, which will not be described here.
[0136] Exemplary computing device
[0137] Another embodiment of the present application further provides a computing device including the multi-processor system described in the above-mentioned embodiments of the present application. The computing device can be a computer, a server, a workstation, a smart terminal, a handheld terminal, a wearable device, etc.
[0138] Exemplary computer program product and storage medium
[0139] In addition to the above method and device, the affinity scheduling method provided by the embodiments of the present application can also be a computer program product, which includes computer program instructions, and when the computer program instructions are run by a processor, the processor executes the steps in the affinity scheduling method according to various embodiments of the present application described in the above "Exemplary Method" section.
[0140] The computer program product can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, etc., and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server.
[0141] In addition, the embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to perform the steps in the affinity scheduling method according to various embodiments of the present application described in the above "Exemplary Method" section.
[0142] Those skilled in the art can understand that all or part of the processes in the above embodiments can be completed by a computer program instructing related hardware, and the computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the computer program can include the processes of the above embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0143] Any combination of the technical features in the above embodiments can be made, and for the sake of brevity, not all possible combinations are described above, however, as long as the combination of the technical features does not exist in contradiction, it shall be considered within the scope of the present application.
[0144] The above embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the solutions provided by the embodiments of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of protection of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. An affinity scheduling method, characterized by, The application is applied to a multi-processor system of NUMA architecture, the multi-processor system comprises a plurality of NUMA nodes, and the method comprises: When a target computing task is started in the multi-processor system, affinity scheduling information of the target computing task is acquired, wherein the affinity scheduling information comprises a NUMA node parameter and a computing task starting parameter; Based on the NUMA node parameter, the target computing task is bound to a first NUMA node, wherein the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter; Based on the computing task starting parameter, a modified execve system call in the kernel is called to load a dynamic link library relied on by the target computing task to the first NUMA node, and the target computing task is executed in the current process.
2. The method of claim 1, wherein, Based on the computing task starting parameter, a modified execve system call in the kernel is called to load a dynamic link library relied on by the target computing task to the first NUMA node, comprising: Based on the computing task starting parameter, a modified execve system call in the kernel is called to parse an executable file of the target computing task; The dynamic link library relied on by the target computing task is determined through the executable file; The dynamic link library relied on by the target computing task is mapped to the address space of the current process.
3. The method of claim 1, wherein, Based on the computing task starting parameter, a modified execve system call in the kernel is called to load a dynamic link library relied on by the target computing task to the first NUMA node, and the target computing task is executed in the current process, and the method further comprises: Determining a shared library identifier of the target computing task, wherein the shared library identifier comprises a first identifier indicating separate loading and a second identifier indicating sharing; In the case that the shared library identifier is the first identifier, the step of calling the modified execve system call in the kernel based on the computing task starting parameter to load the dynamic link library relied on by the target computing task to the first NUMA node and execute the target computing task in the current process is executed; In the case that the shared library identifier is the second identifier, the dynamic link library access strategy of the target computing task is set to access the dynamic link library shared by the multi-processor system, and the target computing task is executed in the current process.
4. The method of claim 3, wherein, Determining the shared library identifier of the target computing task comprises: Evaluating the target computing task by using a preset evaluation strategy to obtain an evaluation result; Based on the evaluation result, the shared library identifier is determined to be the first identifier or the second identifier.
5. The method of claim 4, wherein, The evaluation result comprises a first evaluation result satisfying a target condition and a second evaluation result not satisfying the target condition, and the target condition comprises that the frequency of accessing a dynamic dependent library within a target time period during execution of the target computing task exceeds a frequency threshold; Based on the evaluation result, the shared library identifier is determined to be the first identifier or the second identifier, comprising: In a case where the evaluation result is the first evaluation result, the shared library identifier is determined as a first identifier. In a case where the evaluation result is the second evaluation result, the shared library identifier is determined as a second identifier.
6. The method of claim 3, wherein, The affinity scheduling information further includes the shared library identifier.
7. The method of claim 1, wherein, Loading the dynamic link library relied by the target computing task to the first NUMA node includes: Searching for the dynamic link library shared by the computing tasks in the multiprocessor system; Loading the dynamic link library shared by the computing tasks to the first NUMA node.
8. The method of claim 1, wherein, Before obtaining the affinity scheduling information of the target computing task when starting the target computing task in the multiprocessor system, the method further includes: Loading the dynamic link library shared by the computing tasks in the multiprocessor system to a second NUMA node, wherein the second NUMA node is any one of the plurality of NUMA nodes except the first NUMA node.
9. A multiprocessor system, characterized by The multiprocessor system adopts a NUMA architecture, and the multiprocessor system includes a plurality of NUMA nodes: The multiprocessor system is configured to, when starting a target computing task, obtain affinity scheduling information of the target computing task, wherein the affinity scheduling information includes a NUMA node parameter and a computing task starting parameter. The multiprocessor system is further configured to, based on the NUMA node parameter, bind the target computing task to a first NUMA node, wherein the first NUMA node is one of the plurality of NUMA nodes indicated by the NUMA node parameter. The multiprocessor system is further configured to, based on the computing task starting parameter, call a modified execve system call in a kernel, load a dynamic link library relied by the target computing task to the first NUMA node, and execute the target computing task in a current process.
10. A computer program product, characterised in that, The computer program product has a computer program stored thereon, and the computer program, when executed by a processor, implements the affinity scheduling method according to any one of claims 1 to 8. The computer program product has a computer program stored thereon, and the computer program, when executed by a processor, implements the affinity scheduling method according to any one of claims 1 to 8.