Method and device for binding processor for process and electronic equipment

By obtaining the parameters of the process and its associated processes, determining and setting the target processor, the problem of low reliability of process binding processors in the prior art is solved, and more efficient process resource allocation and system performance improvement is achieved.

CN119065823APending Publication Date: 2024-12-03ZHONGKE FANGDE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310647114.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-02
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the prior art, the reliability of binding a processor for processes is low, and it is impossible to effectively bind processes that have not been run before, resulting in some processes being unable to be bound to the processor.

Method used

By obtaining the parameters of the process and its associated processes, determining the target processor, and setting the running parameters of the process according to these parameters, the process can run on the target processor.

Benefits of technology

Improve the reliability of process-bound processors, avoid the situation where unrunning processes cannot bind processors, ensure that processes can run on the appropriate processors, and improve the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065823A_ABST
    Figure CN119065823A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for binding a processor for a process and electronic equipment, and the method comprises the steps that multiple target parameters are obtained for a first process, the target parameters at least comprise process parameters corresponding to the first process and process parameters corresponding to a second process, and the second process is associated with the first process; determining a target processor corresponding to the first process according to the target parameter; according to the target processor, operation parameters of the first process are set, and the operation parameters are used for indicating that the first process runs on the target processor.
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 method, device and electronic device for binding a processor to a process. Background Art

[0002] Servers are usually equipped with two or more processors, such as a central processing unit (CPU) or a graphics processing unit (GPU), and each processor can have multiple processing cores. The processing cores in different processors may differ in computing performance, input and output (IO) access, memory access, etc. Therefore, in actual applications, processes in the server are usually bound to specific processors as needed, which is called processor affinity setting.

[0003] Currently, when binding a processor to a process, a specific processor is usually bound to a process with a specific pid based on the process identifier pid (ProcessIdentifier) ​​of the process.

[0004] However, in this solution, only the processor can be bound to the process with known pid, and the processor cannot be bound to the process that has not been run before, that is, the process whose pid is not recorded. Therefore, there will be a situation where at least some processes cannot be bound to the processor, which leads to low reliability of binding the processor to the process. Summary of the invention

[0005] In view of this, the present application provides a method, device and electronic device for binding a processor to a process, which are used to solve the technical problem of low reliability of binding a processor to a process in the prior art, as follows:

[0006] A method for binding a processor to a process, the method comprising:

[0007] For a first process, obtaining a plurality of target parameters, the target parameters at least including a process parameter corresponding to the first process and a process parameter corresponding to a second process, the second process being associated with the first process;

[0008] Determining a target processor corresponding to the first process according to the target parameter;

[0009] According to the target processor, an operating parameter of the first process is set, where the operating parameter is used to indicate that the first process runs on the target processor.

[0010] The above method, preferably, determines the target processor corresponding to the first process according to the target parameter, including:

[0011] In a policy set, searching for a target policy that matches the target parameter; the policy set includes a plurality of binding policies, and the binding policy represents a binding relationship between at least one process matching information and processor information;

[0012] A target processor corresponding to the first process is determined according to the processor information in the target policy.

[0013] In the above method, preferably, the process matching information includes at least one of a process identifier of the current process, a file name of an executable program file of the current process, a file name keyword of the current process, a file content hash value of the current process, a user identifier corresponding to the current process, a process identifier of an associated process corresponding to the current process, and a file name of an executable program file of the associated process;

[0014] The processor information at least includes: a processor identifier, where the processor identifier is used to identify a processor or a processor group to which the processor identifier belongs, and the processor group includes multiple processors.

[0015] In the above method, preferably, the target strategy matches the target parameter, including:

[0016] Among the target parameters, there is a process parameter that matches at least one item of process matching information in the target policy.

[0017] The above method, preferably, further comprises:

[0018] A matching identifier corresponding to the target policy and the target parameter is saved, wherein the matching identifier represents a process type to which the process matching information in the target policy that matches the target parameter belongs, and the process type corresponds to the current process, or the process type corresponds to the associated process.

[0019] The above method, preferably, determines the target processor corresponding to the first process according to the target parameter, including:

[0020] Inputting the target parameter into a binding recognition model to obtain target information output by the binding recognition model, wherein the target information corresponds to a target processor;

[0021] Among them, the binding identification model is trained through training samples, and the training samples include input samples and output samples; the input samples include: process parameters of the sample process and process parameters of the associated process corresponding to the sample process; the output samples include: processor information of the processor used by the sample process.

[0022] In the above method, preferably, before obtaining a plurality of target parameters for the first process, the method further comprises:

[0023] Searching in a record set whether there is target record information matching the first process, the record set including at least one historical record information, the historical record information being matching record information of a historical process and a historical processor;

[0024] If target record information matching the first process is found in the record set, the operating parameters of the first process are set according to the historical processor in the target record information.

[0025] The above method, preferably, further comprises:

[0026] Monitor whether a process is started;

[0027] In the case where it is monitored that the first process is started, the following steps are performed: obtaining a plurality of target parameters for the first process.

[0028] A device for binding a processor to a process, the device comprising:

[0029] A parameter obtaining unit, configured to obtain a plurality of target parameters for a first process, wherein the target parameters include at least a process parameter corresponding to the first process and a process parameter corresponding to a second process, wherein the second process is associated with the first process;

[0030] a processor determining unit, configured to determine a target processor corresponding to the first process according to the target parameter;

[0031] A parameter setting unit is used to set the operating parameters of the first process according to the target processor, and the operating parameters are used to indicate that the first process runs on the target processor.

[0032] An electronic device, comprising:

[0033] A plurality of processors, the processors being used to run processes;

[0034] A controller is used to obtain multiple target parameters for a first process, wherein the target parameters include at least process parameters corresponding to the first process and process parameters corresponding to a second process, wherein the second process is associated with the first process; determine a target processor corresponding to the first process according to the target parameters; and set operating parameters of the first process according to the target processor, wherein the operating parameters are used to indicate that the first process runs on the target processor.

[0035] It can be seen from the above technical solutions that in the method, device and electronic device for binding a process to a processor disclosed in the present application, for a first process, by obtaining its corresponding process parameters and the process parameters of the associated second process, and then determining the target processor according to these process parameters, the running parameters of the first process are set accordingly, so that the first process can run on the target processor. It can be seen that in the present application, even if the process parameters of the process itself are unknown, the processor can be bound to the process according to the process parameters of other processes associated with it, thereby avoiding the situation where the process that has not been run cannot be bound to the processor, and thus improving the reliability of binding the processor to the process. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0037] Figure 1 A flowchart of a method for binding a processor to a process provided in Embodiment 1 of the present application;

[0038] Figure 2 A partial flow chart of a method for binding a processor to a process provided in Embodiment 1 of the present application;

[0039] Figure 3 , Figure 4 and Figure 5 They are respectively another flow chart of a method for binding a processor to a process provided in the first embodiment of the present application;

[0040] Figure 6 A schematic diagram of the structure of a device for binding a processor to a process provided in Embodiment 2 of the present application;

[0041] Figure 7 A schematic diagram of the structure of a device for binding a processor to a process provided in Embodiment 2 of the present application;

[0042] Figure 8 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present application;

[0043] Fig. 9 This is a system architecture diagram for a computer using the Linux operating system that is applicable to this application;

[0044] Fig.10 A flowchart for binding a CPU to a process in a computer using the Linux operating system for this application;

[0045] Fig.11Flowchart of strategy design in a computer using the Linux operating system for this application. DETAILED DESCRIPTION

[0046] 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.

[0047] refer to Figure 1 As shown, it is a flowchart of a method for binding a processor to a process provided in the first embodiment of the present application, and the method can be applied to an electronic device having a processor and capable of running a process, such as a computer or a server, etc. The technical solution in this embodiment is mainly used to improve the reliability of binding a processor to a process.

[0048] Specifically, the method in this embodiment may include the following steps:

[0049] Step 101: For a first process, a plurality of target parameters are obtained, where the target parameters at least include process parameters corresponding to the first process and process parameters corresponding to the second process.

[0050] The second process is associated with the first process. For example, the second process is the parent process of the first process. Therefore, when it is necessary to bind a processor to the first process, the process parameters corresponding to the first process and its parent process can be obtained.

[0051] Specifically, the process parameters corresponding to the first process may include: a process identifier of the first process, a file name of an executable program file of the first process, a file name keyword of the first process, a file content hash value of the first process, and at least one of a user identifier corresponding to the first process.

[0052] The process parameter corresponding to the second process may include: at least one of a process identifier of the second process and a file name of an executable program file of the second process.

[0053] For example, taking process a as an example, the target parameters may include: the file name file of a's executable program file, the file name keyword of a's executable program file such as the file name wildcard key, the header hash value of the file content of a's executable program file, a's user identifier such as the security identifier sid (Security Identifier) ​​usid, the file name pfile of the executable program file of the parent process of a process, and the pid value of the parent process of a process, namely ppid, any one or more of the following.

[0054] Step 102: Determine a target processor corresponding to the first process according to the target parameter.

[0055] Specifically, in this embodiment, a target processor can be screened out from a plurality of processors in the electronic device according to the target parameters, and the target processor matches the target parameters.

[0056] The processor in the electronic device may be a processor having one or more processing cores, such as a multi-core CPU, etc. The processing parameters of each processor are the same or different, and accordingly, the processors in the electronic device have the same or different processing performance. Based on this, in this embodiment, a target processor whose processing performance matches the target parameter can be screened out from these processors according to the target parameter, so that the target processor can support the operation of the first process.

[0057] Step 103: According to the target processor, the operating parameters of the first process are set, where the operating parameters are used to indicate that the first process runs on the target processor.

[0058] Furthermore, the running parameter is used to indicate the memory resources used when the first process runs on the target processor.

[0059] For example, after determining processor A that matches the target parameters of process a in the computer, the running parameters of process a are set to indicate that process a runs on processor A. Furthermore, process a is also indicated to run on processor A and use memory address B.

[0060] It can be seen from the above technical solution that in a method for binding a processor to a process provided in the first embodiment of the present application, for a first process, by obtaining its corresponding process parameters and the process parameters of the associated second process, and then determining the target processor according to these process parameters, the running parameters of the first process are set accordingly, so that the first process can run on the target processor. It can be seen that in this embodiment, even if the process parameters of the process itself are unknown, the processor can be bound to the process according to the process parameters of other processes associated with it, thereby avoiding the situation where the process that has not been run cannot be bound to the processor, and thus improving the reliability of binding the processor to the process.

[0061] In one implementation, when determining the target processor corresponding to the first process according to the target parameter in step 102, it can be implemented in the following manner: Figure 2 As shown in:

[0062] Step 201: Search the policy set for a target policy that matches the target parameters.

[0063] The policy set includes multiple binding policies, each of which represents a binding relationship between at least one process matching information and processor information, thereby indicating that a process that can match the process matching information in the binding policy can run on the processor corresponding to the processor information in the binding policy.

[0064] Based on this, in this embodiment, according to the target parameters, the target policy that matches the target parameters is searched in the policy set. Specifically, in this embodiment, the policy set is searched to see whether the process matching information in the binding policy matches the target parameters. If so, the binding policy whose process matching information matches the target parameters is the target policy.

[0065] Step 202: Determine the target processor corresponding to the first process according to the processor information in the target policy.

[0066] Specifically, the process matching information in the binding policy may include: the process identifier of the current process, the file name of the executable program file of the current process, the file name keyword of the current process, the file content hash value of the current process, the user identifier corresponding to the current process, the process identifier of the associated process corresponding to the current process, and at least one of the file name of the executable program file of the associated process.

[0067] The current process refers to the process targeted by the binding policy, that is, the process that needs to be bound to the processor in the binding policy. The associated process here can be the parent process of the current process.

[0068] Correspondingly, the processor information at least includes: a processor identifier, where the processor identifier is used to identify a processor or a processor group to which it belongs, and a processor group includes multiple processors.

[0069] The target policy matches the target parameters, which may include: in the target parameters, there is a process parameter that matches at least one process matching information in the target policy.

[0070] For example, the target policy and the target parameter match at least one of the following: the process identifier in the target parameter is consistent with the process identifier in the target policy; the file name of the executable program file in the target parameter matches the file name wildcard in the target policy; for example, the file name of the executable program file in the target parameter matches the file name keyword in the target policy; for example, the file content hash value of the executable program file in the target parameter is consistent with the file content hash value in the target policy; for example, the user identifier in the target parameter is consistent with the user identifier in the target policy; for example, the process identifier of the parent process in the target parameter is consistent with the process identifier of the associated process in the target policy; for example, the file name of the executable program file of the parent process in the target parameter matches the file name of the executable program file of the associated process in the target policy, etc. Based on this, according to the processor information in the target policy, the target processor corresponding to the first process is determined.

[0071] For example, the process matching information may include: the file name file of the executable program file, the keyword of the file name of the executable program file (such as the file name wildcard key), the header hash value of the file content of the executable program file, the user identifier such as usid, the file name pfile of the executable program file of the parent process, and the pid value of the parent process, i.e., ppid. Correspondingly, the processor information may be a processor mask or a processor code, which represents a processor or a processor group including multiple processors.

[0072] It should be noted that the processor information in the binding policy may also include an automatic setting flag, which indicates that a process matching the binding policy can determine the corresponding processor according to the current idle state of the processor in the electronic device.

[0073] For example, when the processor information in the target policy includes a processor mask of a processor, the processor corresponding to the processor mask is determined as the target processor; for another example, when the processor information in the target policy includes an automatic setting flag, one or more processors are determined as the target processor based on the current idle state of each processor in the electronic device.

[0074] It should be noted that the binding policy in the policy set can be obtained by processing the process parameters of the historical processes that have been run on the electronic device.

[0075] In one implementation, in this embodiment, a binding policy corresponding to the historical process can be constructed based on the process parameters of the historical process, the process parameters of the associated process corresponding to the historical process, such as the parent process, and the historical processor on which the historical process runs.

[0076] In another implementation, in this embodiment, the process parameters of the historical process and the process parameters of the associated process can be expanded or predicted to obtain the process parameters of all processes that may be created on the electronic device. The processes to which these process parameters belong have not been created but may be created in the future. Based on this, binding policies corresponding to these processes are constructed according to these process parameters and the historical processors corresponding to the historical processes; for example, in this embodiment, a machine learning model can be constructed, and the process parameters of the historical process and the process parameters of the associated process can be learned and predicted through the machine learning model to obtain new process parameters, thereby constructing a binding policy corresponding to the new process.

[0077] In another implementation, in this embodiment, the server may receive the policy setting operation input by the user, then extract the process parameters and processor information in the policy setting operation, and then construct a corresponding binding policy.

[0078] Furthermore, in this embodiment, a modification instruction for the binding policy can also be received, and in response to the modification instruction, the process parameters and / or processor in the binding policy are modified. The modification instruction can be generated by the server receiving a modification operation input by the user, or the modification instruction can be generated based on the processor binding record information in the electronic device within a certain period of time, thereby realizing the modification of the binding policy.

[0079] Based on the above implementation scheme, in this embodiment, a matching identifier corresponding to the target policy and the target parameter can also be saved, and the matching identifier represents the process type to which the process matching information that matches the target parameter in the target policy belongs, where the process type corresponds to the current process, or the process type corresponds to the associated process. It can be understood that the saved matching identifier can represent whether the process matching information that matches the target policy and the target parameter belongs to the current process or to the associated process. For example, if the process matching information that matches the target policy and the target parameter is the process identifier of the current process, the file name of the executable program file, the user identifier, and other information, then the matching identifier represents the process type as the current process; if the process matching information that matches the target policy and the target parameter is the process identifier of the associated process or the file name of the executable program file, and other information, then the matching identifier represents the process type as the associated process.

[0080] In one implementation, the method in this embodiment may further include the following steps: Figure 3 As shown in:

[0081] Step 104: Save matching record information corresponding to the first process and the target processor.

[0082] The matching record information indicates that the first process has been bound to the target processor.

[0083] Specifically, the matching record information can be added to a preset record set, so that at least one historical record information is saved in the record set, and the historical record information is the matching record information of the historical process and the historical processor, and the historical record information indicates that the corresponding historical process has been bound to the corresponding historical processor. In this embodiment, each historical record information is saved through a record set, so as to facilitate other analysis or processing of the operation of the process or processor in the future, so that it can be checked.

[0084] In one implementation, the method in this embodiment may further include the following steps before step 101: Figure 4 As shown in:

[0085] Step 105: Search the record set for target record information that matches the first process; if target record information that matches the first process is found in the record set, execute step 106; if target record information that matches the first process is not found in the record set, execute step 101.

[0086] Specifically, in this embodiment, it is possible to search in the record set whether the historical process corresponding to the historical record information is consistent with the first process. If so, the historical record information corresponding to the historical process consistent with the first process is the target record information.

[0087] Step 106: according to the historical processor in the target record information, set the running parameters of the first process so that the first process is bound to the historical processor in the target record information, thereby the first process can run on the historical processor in the target record information.

[0088] That is to say, in this embodiment, the matching record information recorded in the historical matching is saved through the record set. Therefore, when a first process needs to bind a processor, it is possible to first search in the record set whether the first process has been bound to a processor. If not, then execute steps 101 to 103, that is, bind the target processor to the first process through the process parameters of the first process and the process parameters of the second process associated with it. Further, after step 103, step 104 can be executed to save the matching record information corresponding to the first process and the target processor; if it is found in the record set that the first process has been bound to a processor, then the operating parameters of the first process are set according to the processor that has been bound, and there is no need to obtain the target parameters or determine the target processor according to the target parameters, so that the processor can be bound to the process faster, and the efficiency of binding the processor to the process is improved by reducing the processing complexity.

[0089] In one implementation, the method in this embodiment may further include the following steps: Figure 5 As shown in:

[0090] Step 107: monitor whether a process is started, and if it is detected that the first process is started, execute step 101.

[0091] For example, in this embodiment, a call to the method in this embodiment may be added to an execve-related function in the kernel system call interface layer of the electronic device, thereby monitoring whether a process is started.

[0092] The process being started may include: the process being created or the process being called, so that the process is started and needs to be run on a certain processor.

[0093] It can be seen that in this embodiment, the process can be monitored and the method in this embodiment can be executed when the process is started, thereby binding the processor to the process, and then the processor binding can be completed as soon as the process runs, so that the process can achieve optimal running performance.

[0094] In one implementation, step 102 may be implemented as follows: inputting a target parameter into a binding recognition model to obtain target information output by the binding recognition model, where the target information corresponds to a target processor.

[0095] The binding identification model is trained by training samples, and the training samples include input samples and output samples; the input samples include: process parameters of the sample process and process parameters of the associated process corresponding to the sample process; the output samples include: processor information of the processor used by the sample process.

[0096] Specifically, the sample process may be a historical process that has been run in the electronic device, and the processor used by the sample process is the historical processor occupied when the process was run in the electronic device.

[0097] For example, the binding recognition model can be a machine learning model constructed by a machine learning algorithm, and the binding recognition model is trained using the process parameters of the historical process on the electronic device and the process parameters of the associated process associated with the historical process as input samples, and the processor information of the historical processor used by the historical process as output samples. Thus, the binding recognition model can process the input target parameters to obtain the processor information of the target processor corresponding to the target parameters, based on which, in step 103, the operating parameters can be set for the first process according to the target processor.

[0098] refer to Figure 6, is a schematic diagram of a structure of a device for binding a processor to a process provided in Embodiment 2 of the present application, and the device can be configured in an electronic device having a processor and capable of running a process, such as a computer or a server. The technical solution in this embodiment is mainly used to improve the reliability of binding a processor to a process.

[0099] Specifically, the device in this embodiment may include the following units:

[0100] A parameter obtaining unit 601 is used to obtain a plurality of target parameters for a first process, where the target parameters at least include a process parameter corresponding to the first process and a process parameter corresponding to a second process, where the second process is associated with the first process;

[0101] A processor determining unit 602 is used to determine a target processor corresponding to the first process according to the target parameter;

[0102] The parameter setting unit 603 is used to set the operating parameters of the first process according to the target processor, and the operating parameters are used to indicate that the first process runs on the target processor.

[0103] It can be seen from the above technical solution that in the device for binding a process to a processor provided in the second embodiment of the present application, for a first process, by obtaining its corresponding process parameters and the process parameters of the associated second process, and then determining the target processor according to these process parameters, the running parameters of the first process are set accordingly, so that the first process can run on the target processor. It can be seen that in this embodiment, even if the process parameters of the process itself are unknown, the processor can be bound to the process according to the process parameters of other processes associated with it, thereby avoiding the situation where the process that has not been run cannot be bound to the processor, and thus improving the reliability of binding the processor to the process.

[0104] In one implementation, the processor determination unit 602 is specifically used to: search for a target policy that matches the target parameters in a policy set; the policy set includes multiple binding policies, and the binding policies represent a binding relationship between at least one process matching information and processor information; and determine the target processor corresponding to the first process based on the processor information in the target policy.

[0105] Specifically, the process matching information includes at least one of the process identifier of the current process, the file name of the executable program file of the current process, the file name keyword of the current process, the file content hash value of the current process, the user identifier corresponding to the current process, the process identifier of the associated process corresponding to the current process, and the file name of the executable program file of the associated process; the processor information includes at least: a processor identifier, which is used to represent a processor or a processor group to which it belongs, and the processor group includes multiple processors.

[0106] The target policy matches the target parameter, which includes: in the target parameter, there is a process parameter that matches at least one process matching information in the target policy.

[0107] Optionally, the processor determination unit 602 is also used to: save a matching identifier corresponding to the target policy and the target parameter, the matching identifier represents the process type to which the process matching information in the target policy that matches the target parameter belongs, the process type corresponds to the current process, or the process type corresponds to the associated process.

[0108] In one implementation, the processor determination unit 602 is further configured to: save matching record information corresponding to the first process and the target processor.

[0109] In one implementation, the device in this embodiment may further include the following units: Figure 7 As shown in:

[0110] The record search unit 604 is used to search whether there is target record information matching the first process in the record set before the parameter acquisition unit 601 obtains multiple target parameters for the first process. The record set contains at least one historical record information, and the historical record information is matching record information of the historical process and the historical processor; if the target record information matching the first process is found in the record set, the operating parameters of the first process are set according to the historical processor in the target record information; if not found, the parameter acquisition unit 601 is triggered.

[0111] In one implementation, the parameter obtaining unit 601 is further used to: monitor whether a process is started; and when it is monitored that a first process is started, execute the following: obtain multiple target parameters for the first process.

[0112] It should be noted that the specific implementation method of each unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.

[0113] refer to Figure 8, is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present application, and the electronic device may include the following structure:

[0114] A plurality of processors 801, wherein the processors 801 are used to run a process;

[0115] The controller 802 is used to obtain multiple target parameters for a first process, where the target parameters include at least process parameters corresponding to the first process and process parameters corresponding to a second process, where the second process is associated with the first process; determine a target processor corresponding to the first process based on the target parameters; and set operating parameters of the first process based on the target processor, where the operating parameters are used to indicate that the first process runs on the target processor.

[0116] It can be seen from the above technical solution that in an electronic device provided in the third embodiment of the present application, for a first process, by obtaining its corresponding process parameters and the process parameters of the associated second process, and then determining the target processor according to these process parameters, the running parameters of the first process are set accordingly, so that the first process can run on the target processor. It can be seen that in this embodiment, even if the process parameters of the process itself are unknown, the processor can be bound to the process according to the process parameters of other processes associated with it, thereby avoiding the situation where the process that has not been run cannot be bound to the processor, and thus improving the reliability of binding the processor to the process.

[0117] Taking a computer configured with the Linux operating system as an example, in order to allow a process to complete its task more efficiently, it is often necessary to set the CPU affinity for the process, that is, to specify that the process runs on one or more CPUs. The usual method is to use the cpuset mechanism in the cgroup resource isolation function provided by the underlying operating system to set it. This method requires knowing the PID of the process in advance, or the SID of the user running the program. Users can set the CPU affinity for the cgroup group according to the process pid or user sid, or directly use the cpuset command to set the CPU affinity of the process according to the process pid.

[0118] In actual use, it is often necessary to make automatic settings for programs that have not yet been started, or to set different CPU bindings for multiple programs run by a user. In this case, the user needs to write a setting script, periodically detect the processes in the system, add specific processes to the cgroup group or make cpuset settings, which is inefficient and inflexible.

[0119] Specifically, the CPU affinity setting methods currently used are: one method requires the process to be running before setting it for the pid, and the other method sets it for all processes of a specific user. Both have obvious defects. For example, in the first method, although setting the pid is more flexible, it means that only the already running process can be set, which has great limitations. In the second method, setting it for the user means that all the user's processes will run on the specified CPU, which lacks flexibility.

[0120] In the real environment, different processes of the same user and the same software have different CPU and memory usage requirements, and different CPU affinities often need to be set for different processes. The existing system management method cannot flexibly adapt to the needs of actual applications.

[0121] To solve the problem of flexible settings, you can currently write periodic scripts to detect processes in the system, add specific processes to cgroup groups or set cpusets. However, if the interval of periodic detection is long, it will not be possible to set it quickly, which may cause the environment initialized when the program is running to be inconsistent with the subsequent execution environment settings; if the interval is too short, it will bring additional burden to the system.

[0122] In view of this, in order to solve the defects of the above existing technologies, this application provides a technical solution for automatically binding a process to one or more specified CPU cores. The solution automatically checks when the process starts and automatically sets the CPU and memory affinity for the process that matches the binding policy. There is no need to use monitoring scripts for periodic detection, and the binding can be completed as soon as the process runs, so that the process can achieve optimal running performance.

[0123] The solutions provided in this application are as follows:

[0124] First, the new CPU binding mechanism provided by this application identifies process parameters such as process name and hash characteristic attributes when the process is about to start, and automatically sets the CPU and memory affinity attributes for the newly started process according to the binding policy configured by the user.

[0125] Secondly, in this application, a process monitoring component, a policy parsing component, and a user interface component are added to the computer's operating system kernel, such as Fig. 9As shown in the figure, it is the system architecture in the computer, which includes the user space and the Linux kernel. The user space includes user applications and command line tools. In addition to the process monitoring component, policy parsing component and user interface component, the Linux kernel also includes the system call interface, VirtualFilesystem interface and other components of the Linux kernel. In addition, the task_struct structure is added to the Linux kernel. The specific working principle is as follows:

[0126] 1. Add a process monitoring component, a policy parsing component, and a user interface component to the operating system kernel.

[0127] The process monitoring component is used to monitor the process creation process, specifically by adding a call to the process monitoring component in the execve related function of the kernel system call interface layer. The process monitoring component will cooperate with the policy parsing component to perform policy matching and execution affinity setting.

[0128] The user interface component registers a virtual character device through the Linux virtualfilesystem and provides an interface for the user-mode process to call. The user process can submit the policy to be set to the kernel component in the form of a string through the virtual character device.

[0129] The policy parsing component is used to load user policies and match the process binding policy configured by the user during the monitoring process. The policy parsing component receives the policy setting data received by the user interface component and parses the policy content, including the target matching conditions (which can be one or more of the file name, file hash, user SID, and parent process ID). When matching policies and processes, the policy parsing component receives the detection conditions input by the process monitoring component and returns the CPU information that needs to be bound.

[0130] For example, the content of the binding policy includes two parts: the policy conditions and the CPU settings, namely the process parameters and processor information mentioned above.

[0131] The policy conditions can consist of one or more of the following:

[0132] file: executable program file name (e.g. testcpuset);

[0133] key: file name keyword;

[0134] hash: hash value of the file header;

[0135] usid: user SID value;

[0136] ppid: pid value of the parent process;

[0137] pfile: the executable program file name of the parent process;

[0138] The cpu is set in the following format:

[0139] cpu: 0xFFFF (the value is the CPU mask in hexadecimal);

[0140] cpu:auto;

[0141] node:auto;

[0142] In fact, a binding policy consists of the above items in one line of text, and each item is separated by ";". For example: "file:testcpu;ppid:12345;cpu:0xFFFF".

[0143] 2. Add two variables related to strategy matching to the original task_struct structure of the system kernel: process matching status variable and hit strategy variable, which are used to record the current process matching status and hit strategy respectively.

[0144] The process matching state variable may record a state including a combination of the following contents: whether the current process matches, and whether it matches its own policy (the process type of the current process) or the associated policy (the process type of the associated process).

[0145] The hit strategy variable is used to record which strategy is hit, which facilitates subsequent matching queries.

[0146] 3. When there is an operation to create a new process, the process monitoring component will be triggered.

[0147] The process monitoring component obtains the necessary process information (i.e., target parameters) according to the policy content of the policy parsing component, submits it to the policy parsing component for matching, sets the CPU affinity information according to the returned result, and records the policy matching information in the above two variables.

[0148] 4. The policy parsing component can support weak feature matching and associated feature matching of matching targets, as an extension of the above target matching conditions, including:

[0149] The target matching condition in the policy can be a file name wildcard. For example, if you configure "copyfile*", you can match the corresponding processes such as "copyfile01" and "copyfile02".

[0150] The target matching condition in the policy can be a file name or a keyword in the command line. For example, if "file" is configured, multiple processes containing the word "file" will be matched.

[0151] The target matching condition in the policy can specify the matching of the associated parent process. For example, you can specify to match all child processes whose parent process is transdata, but not the parent process transdata itself.

[0152] 5. The policy parsing component can support automatic setting of affinity.

[0153] When specifying CPU affinity information in a policy, you can specify a specific CPU mask, or you can specify automatic settings for CPU or node. When specifying automatic settings for CPU, the policy parser will automatically bind a CPU based on the current system configuration. When specifying automatic settings for Node, the policy parser will automatically bind a group of adjacent CPUs based on the current system configuration.

[0154] For example, the technical solution of the present application, when combined with automatic affinity setting and keyword or associated parent process matching strategy, can realize automatic grouping and setting of CPU affinity for multiple running instances of specified software, and achieve the effect of automatically allocating software 1, software 2, software 3, and software 4 to CPU group 1, group 2, group 3, and group 4 on the same server.

[0155] It should be noted that the process monitoring component can only detect the file name of the program to be executed. At this time, the policy parsing component is only a logical concept, which can be simplified to extract and simply judge the file name in the actual program. Similarly, it can be simplified to only process the file hash, user SID, parent process ID, etc.

[0156] Specifically, the specific workflow of this application is as follows Fig.10 As shown in:

[0157] 1. The user program initiates the operation of creating a new process (such as execve) through the application layer interface API (application).

[0158] 2. After the application layer API function library completes the necessary processing (such as checking the file name and path of the program to be executed), it calls the kernel interface function through the system syscall.

[0159] 3. The operating system kernel enters the __do_execve_file function through the system call interface.

[0160] 4. First, complete some pre-checks in the kernel function, such as the number of processes, permissions, etc. The following is the new process for this application:

[0161] 5. At this time, the process monitoring component interface is called.

[0162] 6. The process monitoring component first obtains the information type that needs to be checked from the policy parsing component. This information type can be an integer variable bitwise ANDed, or an array object.

[0163] 7. The process monitoring component extracts the file name, file header hash, current user SID, parent process ID and other information of the program to be executed based on the tag of the returned information type.

[0164] 8. The process monitoring component passes the information to the policy parsing component for matching.

[0165] 9. The policy parsing component matches the policy against features such as file name, file hash, user SID, parent process, etc. If the policy is matched, the CPU affinity information that needs to be set is returned.

[0166] 10. The process monitoring component sets the CPU affinity information based on the returned results and fills the modified task_struct structure.

[0167] 11. Continue to execute the system's original creation process operation.

[0168] When the process is running, the data that needs to be checked is obtained through the process monitoring component. For processes that meet the policy conditions, their CPU and memory affinity settings can be updated so that the system can dynamically adjust the resources for task operation according to the configuration.

[0169] In addition, the policy setting process is as follows Fig.11 As shown in:

[0170] 1. The user program passes the policy setting information to the virtual character device.

[0171] 2. The user interface component receives the policy setting information.

[0172] 3. The user interface component parses the information and saves it internally.

[0173] In summary, this application can provide a more flexible and automated CPU and memory affinity setting mechanism, and make different settings for different programs by flexibly combining matching conditions. In the case of fierce competition for system resources, application performance can be significantly improved.

[0174] At the same time, since it is integrated in the process startup process, the environment settings can be completed while the process is created, preventing the problem of inconsistency between the program initialization state and the execution state.

[0175] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0176] 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.

[0177] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module 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.

[0178] 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 binding a processor to a process, characterized in that: The method comprises: For a first process, obtaining a plurality of target parameters, the target parameters at least including a process parameter corresponding to the first process and a process parameter corresponding to a second process, the second process being associated with the first process; Determining a target processor corresponding to the first process according to the target parameter; According to the target processor, an operating parameter of the first process is set, where the operating parameter is used to indicate that the first process runs on the target processor.

2. The method according to claim 1, characterized in that Determining a target processor corresponding to the first process according to the target parameter includes: In a policy set, searching for a target policy that matches the target parameter; the policy set includes a plurality of binding policies, and the binding policy represents a binding relationship between at least one process matching information and processor information; A target processor corresponding to the first process is determined according to the processor information in the target policy.

3. The method according to claim 2, characterized in that The process matching information includes at least one of a process identifier of the current process, a file name of an executable program file of the current process, a file name keyword of the current process, a file content hash value of the current process, a user identifier corresponding to the current process, a process identifier of an associated process corresponding to the current process, and a file name of an executable program file of the associated process; The processor information at least includes: a processor identifier, where the processor identifier is used to identify a processor or a processor group to which the processor identifier belongs, and the processor group includes multiple processors.

4. The method according to claim 3, characterized in that The target strategy matches the target parameter, including: Among the target parameters, there is a process parameter that matches at least one item of process matching information in the target policy.

5. The method according to claim 3, characterized in that: The method further comprises: A matching identifier corresponding to the target policy and the target parameter is saved, wherein the matching identifier represents a process type to which the process matching information in the target policy that matches the target parameter belongs, and the process type corresponds to the current process, or the process type corresponds to the associated process.

6. The method according to claim 1 or 2, characterized in that: Determining a target processor corresponding to the first process according to the target parameter includes: Inputting the target parameter into a binding recognition model to obtain target information output by the binding recognition model, wherein the target information corresponds to a target processor; Among them, the binding identification model is trained through training samples, and the training samples include input samples and output samples; the input samples include: process parameters of the sample process and process parameters of the associated process corresponding to the sample process; the output samples include: processor information of the processor used by the sample process.

7. The method according to claim 1 or 2, characterized in that: Before obtaining a plurality of target parameters for the first process, the method further includes: Searching in a record set whether there is target record information matching the first process, the record set including at least one historical record information, the historical record information being matching record information of a historical process and a historical processor; If target record information matching the first process is found in the record set, the operating parameters of the first process are set according to the historical processor in the target record information.

8. The method according to claim 1 or 2, further comprising: Monitor whether a process is started; In the case where it is monitored that the first process is started, the following steps are performed: obtaining a plurality of target parameters for the first process.

9. A device for binding a processor to a process, characterized in that: The device comprises: A parameter obtaining unit, configured to obtain a plurality of target parameters for a first process, wherein the target parameters include at least a process parameter corresponding to the first process and a process parameter corresponding to a second process, wherein the second process is associated with the first process; a processor determining unit, configured to determine a target processor corresponding to the first process according to the target parameter; A parameter setting unit is used to set the operating parameters of the first process according to the target processor, and the operating parameters are used to indicate that the first process runs on the target processor.

10. An electronic device, characterized in that: include: A plurality of processors, the processors being used to run processes; A controller is used to obtain multiple target parameters for a first process, wherein the target parameters include at least process parameters corresponding to the first process and process parameters corresponding to a second process, wherein the second process is associated with the first process; determine a target processor corresponding to the first process according to the target parameters; and set operating parameters of the first process according to the target processor, wherein the operating parameters are used to indicate that the first process runs on the target processor.