Dynamic partitioning methods, systems, devices, and media
By dynamically adjusting the control group to different partition levels, the problems of processor starvation and low task migration efficiency in multiprocessor systems are solved, thereby improving processor performance and task migration efficiency.
Patent Information
- Application Number
- CN202111333509.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-11
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2041-11-11
AI Technical Summary
Existing technologies suffer from processor starvation and low task migration efficiency in multiprocessor systems, especially during NUMA node partitioning and task migration, which leads to reduced processor performance.
By acquiring the partition level and control group's operating parameters, the control group can be dynamically adjusted to different partition levels to alleviate processor hunger contention and improve processor performance.
It effectively alleviates processor hunger competition and improves the overall performance of the processor and the efficiency of task migration.
Smart Images

Figure CN114168319B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, and particularly relates to a dynamic partitioning method, system, device and medium. BACKGROUND
[0002] With the development of embedded operating system technology, the demand for processing capacity of the operating system is gradually increasing. For example, multiple processors (CPUs) are used to improve the processing performance.
[0003] In order to improve the utilization rate of the whole machine processor, the deployment density is increased to fill the processor fragments by sharing the processor through the configuration control group (Cgroup). However, this way of sharing the processor will cause the processor starvation phenomenon when the deployment density reaches a certain degree, such as cache, TLB competition causing additional overhead of the processor. In addition, when the whole machine processor is partitioned according to the NUMA node, and the task migration is performed based on the single node, the efficiency is very low when the task is migrated between partitions due to the high affinity, which will cause the performance of the processor to be reduced. Therefore, a dynamic partitioning scheme is needed to improve the performance of the processor. SUMMARY
[0004] To solve or improve the problems in the prior art, embodiments of the present application provide a dynamic partitioning method, system, device and medium.
[0005] In a first aspect, in one embodiment of the present application, a dynamic partitioning method is provided. The method comprises:
[0006] obtaining a first partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprising layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure;
[0007] determining the working parameters of a plurality of control groups contained in the first partition;
[0008] determining an expected second partition level according to the working parameters of the plurality of control groups;
[0009] when the second partition level does not match the first partition level, adjusting the plurality of control groups to the partition contained in the layer corresponding to the second partition level.
[0010] In a second aspect, in one embodiment of the present application, another dynamic partitioning method is provided. The method comprises:
[0011] obtaining a partition usage rate of a first partition and a partition usage rate of a second partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprising layers corresponding to different partition levels, the first partition and the second partition being at a first layer in the hierarchical structure;
[0012] determining a target usage rate based on the partition usage rate of the first partition and the partition usage rate of the second partition;
[0013] if the partition usage rate of the first partition does not conform to the target usage rate, migrating at least one control group corresponding to the first partition to the second partition.
[0014] In a third aspect, in an embodiment of the present application, a dynamic partition system is provided. The system comprises:
[0015] a scheduler configured to obtain a first partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprising layers corresponding to different partition levels, the first partition being at a first layer in the hierarchical structure; determine working parameters of a plurality of control groups contained in the first partition; determine an expected second partition level according to the working parameters of the plurality of control groups; and adjust the plurality of control groups to a partition contained in a layer corresponding to the second partition level when the second partition level does not match the partition level.
[0016] a kernel configured to provide a partition level required by the scheduler.
[0017] In a fourth aspect, in an embodiment of the present application, an electronic device is provided, comprising a memory and a processor; wherein
[0018] the memory is configured to store a program;
[0019] the processor, coupled to the memory, is configured to execute the program stored in the memory, so as to implement the dynamic partition method of the first aspect or the other dynamic partition method of the second aspect.
[0020] In a fifth aspect, in an embodiment of the present application, a non-transitory machine readable storage medium is provided, the non-transitory machine readable storage medium storing executable code, when the executable code is executed by a processor of an electronic device, the processor executes the dynamic partition method of the first aspect or the other dynamic partition method of the second aspect.
[0021] In a sixth aspect, in one embodiment of the present application, a computer program product is provided, comprising computer programs / instructions, which, when executed by a processor, enable the processor to implement the dynamic partitioning method of the first aspect or the other dynamic partitioning method of the second aspect.
[0022] The technical solution provided by the embodiments of the present application acquires a first partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprises layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure; determines working parameters of a plurality of control groups contained in the first partition; determines an expected second partition level according to the working parameters of the plurality of control groups; and adjusts the plurality of control groups to a partition contained in a layer corresponding to the second partition level when the second partition level does not match the first partition level. After adjusting the control groups to the second partition level, further partition balancing adjustment can be performed with the control groups as the division unit. Through the above technical solution, when partitioning, the partition is divided into a plurality of different partition levels with different affinities according to the hardware topology structure and the partition rule. When dynamic partitioning is needed, the processor pressure of the partition level corresponding to the first partition is adjusted between the layers corresponding to different partition levels in the same partition branch, effectively relieving the processor starvation competition (such as cache competition) problem. In addition, when there is a need for cross-affinity domain adjustment, the migration of the whole between different partitions in the layer where the same partition level is located is performed with the control group as the division unit, relieving the problem of reduced processor performance caused by task migration, thereby effectively improving the overall processor performance. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0024] Figure 1 A flowchart of a dynamic partitioning method provided by an embodiment of the present application;
[0025] Figure 2 A schematic diagram of a partition hierarchical structure provided by an embodiment of the present application;
[0026] Figure 3 A schematic diagram of the structural relationship between a partition and a control group provided by an embodiment of the present application;
[0027] Figure 4A flowchart of a method for determining a second partition level provided by an embodiment of the present application is shown in FIG. 1;
[0028] Figure 5 A flowchart of a method for adjusting a partition level provided by an embodiment of the present application is shown in FIG. 2;
[0029] Figure 6 A flowchart of a method for adjusting a partition level provided by an embodiment of the present application is shown in FIG. 2;
[0030] Figure 7 A flowchart of a method for controlling a group cross-partition migration provided by an embodiment of the present application is shown in FIG. 3;
[0031] Figure 8 A flowchart of a method for controlling a group migration provided by an embodiment of the present application is shown in FIG. 4;
[0032] Figure 9 A flowchart of another dynamic partition provided by an embodiment of the present application is shown in FIG. 5;
[0033] Figure 10 A structural diagram of a dynamic partition device provided by an embodiment of the present application is shown in FIG. 6;
[0034] Figure 11 A structural diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 7;
[0035] Figure 12 A structural diagram of another dynamic partition device provided by an embodiment of the present application is shown in FIG. 8;
[0036] Figure 13 A structural diagram of another electronic device provided by an embodiment of the present application is shown in FIG. 9. DETAILED DESCRIPTION
[0037] In an embedded operating system with multiple processors, in order to improve the overall working performance of the system, a shared processor is used to complete the specified task. Although in the processor share solution, the performance of the overall processor is obviously improved, but in some cases (such as the whole machine load level breaks through the safety warning line), it will cause the performance of the processor to decline (such as cache TLB competition causes additional processor overhead). Although in the prior art NUMABalancer, NUMA Affine and other solutions, partitioning is performed according to the NUMA node, and all control groups (Cgroup) are bound to these partitions in a dynamic binding or static binding manner, thereby improving the NUMA node affinity. However, when there is a need to adjust the task, due to the fact that cross-affinity domain adjustment is not very friendly or does not support cross-affinity domain, a high cost is paid or the migration efficiency is low when migrating the task. In some solutions, the lack of soft binding mechanism makes it difficult to support small affinity migration. In actual application, the demand for processor resources during task execution is dynamically changing, and therefore, a dynamic adjustment of the partition according to the dynamic changing demand of the task is required.
[0038] In order to enable those skilled in the art to better understand the technical scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application.
[0039] In some of the processes described in the specification, claims, and accompanying drawings of the present application, a plurality of operations appear in a specific order. These operations can be executed in the order they appear in this document or in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and the operations can be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this document are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence. Also, "first" and "second" are not of different types.
[0040] The technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0041] As Figure 1 A flowchart of a dynamic partitioning method provided by an embodiment of the present application is shown. The method comprises:
[0042] 101: obtaining a first partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprising layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure.
[0043] 102: determining working parameters of a plurality of control groups contained in the first partition.
[0044] 103: determining a desired second partition level according to the working parameters of the plurality of control groups.
[0045] 104: when the second partition level does not match the first partition level, adjusting the plurality of control groups to a partition contained in a layer corresponding to the second partition level.
[0046] In the technical solution of the present application, the number of processors in the operating system of the plurality of processors is not specifically limited, and the user can select a plurality of processors according to needs. The system processing resource has a hierarchical structure, and when performing hierarchical division, different levels of partitions need to be performed according to actual conditions combined with the specific hardware platform architecture. The specific number of layers and the specific topology of each layer are determined according to the specific hardware platform structure, and a plurality of layers can be added between two layers for further constraint.
[0047] A control group (cgroup) is a mechanism provided by the Linux kernel to limit, record, and isolate the use of system resources (such as CPU, memory, IO interface, etc.) by process groups. In actual applications, related tasks can be bound to the same control group according to task types or task requirements. For example, the control group contains a plurality of tasks that have associated requirements. Figure 2 A schematic diagram of a partition hierarchical structure provided by an embodiment of the present application is shown in FIG. 1. Figure 2 As can be seen from FIG. 1, there are five partition levels in five layers, respectively level0, level1, level2, level3, and level4. For example, in an X86 platform, level4 is a collection of smts, level3 is a collection of MCs, level2 is a collection of CPU DIEs, level1 is a collection of NUMA Nodes, and level0 is a collection of all CPUs. Each partition has its own parent node partition (except for the root node) and child node partition (except for the leaf node). Each partition part contains at least the following information: the CPU range cpus part of the partition, the parent node partition part parent , and the child node partition group list childand a soft binding list of the cgroup cg .
[0048] In the process of multi-processor executing tasks, since a shared processor is used to execute multiple different tasks, the required resources of various tasks are different, resulting in different resource occupation of different tasks. When some tasks are not enough in resources, they will compete for more resources from the shared processor resources. When many tasks have more resource requirements, resource competition will occur. Therefore, in the present scheme, the processor resources are partitioned, and each partition has its corresponding (binding) multiple control groups. Figure 3 The schematic diagram of the structure relationship of the partition and the control group provided by the embodiment of the present application. It can be seen from Figure 3 that part0-1 as a parent node partition and two child node partitions part1-1 and part1-2 corresponding to the parent node partition are included. Cgroup1 and cgroup3 are included in the child node partition part1-1, and cgroup2 and cgroup4 are included in the child node partition part1-2. Specifically, in the cgroup partition, cpus (the hard binding processor range of the current partition), part_parent (the corresponding parent node partition), part_child (the corresponding child node partition) and list_cg_head (the table header of the group link table) are included. In the control group cgroup, group_balancer = 1 (group_balancer function is turned on), cpus_allowed (control group hard binding processor range), soft_cpus_allowed (control group soft binding processor range), list_gb (control group balance link table) and list_cg (group link table, used to realize the binding relationship between the control group and the partition) are included.
[0049] In the present scheme, it is assumed that a first partition is included in the first layer of the hierarchical structure (here, the first layer can be any layer in the partition level, and is not strictly limited in sequence, such as level1 or level2 in the hierarchical structure). The first partition includes multiple control groups. Each control group includes multiple tasks. It should be noted that in the present embodiment, when the control group is adjusted in the second partition level, the control group is adjusted between different layers of the second partition level, rather than between different partitions in the same layer.
[0050] After obtaining the first partition level of the first partition, the second partition level needs to be calculated according to the working parameters of the plurality of control groups in the first partition provided by the kernel and other related parameters (such as the number of context switches of the whole machine processor). The second partition level is compared with the first partition level of the first partition obtained from the kernel. If the second partition level does not match the first partition level of the first partition, it indicates that the partition pressure of the current first partition is too large or too small, and the partition needs to be adjusted by taking the control group as the division unit, that is, the plurality of control groups need to be adjusted from the first partition to the partition contained in the second partition level corresponding layer.
[0051] Here, when the second partition level does not match the first partition level of the first partition, it indicates that the partition pressure of the current first partition is too large or too small. Specifically, for example, assuming that the hard binding processor range of the first partition is 0-9, and there are two control groups in the first partition, the two control groups will share the 10 processors. When the demand of any one control group for processor resources increases, the problem of the two control groups competing for processor resources will occur, which indicates that the pressure of the current first partition is too large, and the first partition needs to be upgraded, that is, the control groups in the first partition are adjusted to a higher partition level. Conversely, when the demand of the control group in the first partition for processor resources decreases, there will be more idle resources, and the first partition needs to be downgraded, that is, the control groups in the first partition are adjusted to a lower partition level. The specific adjustment process and the partition level to which the adjustment is needed will be specifically illustrated in the following embodiments.
[0052] As shown in Figure 4 The flowchart of a method for determining a second partition level provided by the embodiments of the present application is shown in FIG. 4. From Figure 4 It can be seen from the above that the second partition level is determined according to the working parameters of the plurality of control groups, and specifically includes the following steps: 401: determining the second partition level according to the number of context switches of the plurality of control groups in the layer where the partition level is located and the number of context switches of each partition in the layer. 402: obtaining the hard binding processor range of the first parent node partition or the first child node partition corresponding to the second partition level.
[0053] The first partition contains the working parameters of the plurality of control groups. Here, the working parameters may be, for example, the partition level level current The level corresponding to all valid partition levels (excluding level 0) and the layer where it is located. Further, the idle rate usage% of the whole machine processor, the number of context switches nr contex_switch and the number of context switches nr cgroupflip of the control group cgroup are counted. Further, the cgroup switching rate Further, a current second partition level is calculated, If level current == level expected , it indicates that the second partition level matches the first partition level, otherwise, it indicates that the second partition level does not match the first partition level.
[0054] Here, the first partition is any partition except the root node. As in the above embodiment, it is assumed that the hard-bound processor range of the first partition is 0-9, i.e., 10 processors, and the hard-bound processor ranges of the two child node partitions can be 0-4 and 5-9, i.e., two partition ranges, and there is no intersection between the two child node partitions. If the first partition further has a parent node partition, the hard-bound processor range of the parent node partition can be 0-19.
[0055] In one or more embodiments of the present application, the adjusting the plurality of control groups to the partitions included in the layer corresponding to the second partition level when the second partition level does not match the first partition level comprises: adjusting the plurality of control groups from the first partition to the first parent node partition or the first child node partition included in the layer corresponding to the second partition level when the second partition level does not match the first partition level. The soft-bound processor range of the plurality of control groups is adjusted according to the hard-bound processor range of the first parent node partition or the first child node partition.
[0056] It should be noted that, in order to better adjust the processor range of the control group, so as to better solve the problem of processor starvation competition, a corresponding soft-bound processor range can be set for each control group participating in the adjustment. The soft-bound processor range is used to guarantee the running range of the tasks in the cgroup as much as possible with minimal overhead, but it is not mandatory. On the basis of the hard-bound processor range, the scheduler will filter the candidate processors that do not meet the soft-bound processor range when selecting a running processor for the task, and the soft-bound processor range can be dynamically adjusted without changing the hard-bound processor range.
[0057] Through Figure 4 As can be seen in the corresponding embodiments, there is no intersection between the hard-bound processor ranges of the partitions, but there is intersection between the plurality of control groups in the same partition. When the control groups in the partition are upgraded or downgraded, the range can be re-divided by soft binding within the hard-bound processor range, so that the control groups have clear available processor ranges. Thus, the problem of processor starvation competition of different control groups when executing tasks can be well alleviated.
[0058] The following will illustrate the scheme of adjusting the partition level of the first partition and the scheme of adjusting the partition level of the first partition through specific embodiments. It should be noted that the level of the child node partition is higher than the level of the parent node partition. Therefore, when the level of the first partition is adjusted, it can be understood as adjusting to the child node partition or the grandchild node partition, or adjusting to the direction close to the leaf node in the binary tree hierarchical structure where the first partition is located; when the level of the first partition is adjusted, it can be understood as adjusting to the parent node partition or the parent node partition of the next level, or adjusting to the direction close to the root node in the binary tree hierarchical structure where the first partition is located.
[0059] As Figure 5 A flowchart of a method for adjusting the partition level provided by the embodiments of the present application is shown. From Figure 5 It can be seen from the above that if the second partition level is greater than the first partition level corresponding to the first partition, the adjusting of the plurality of control groups from the first partition to the first parent node partition or the first child node partition corresponding to the second partition level comprises:
[0060] 501: Determine the child node partition set corresponding to the first partition at a high partition level.
[0061] 502: Determine the processor requirement quantity of the plurality of control groups bound in the first partition.
[0062] 503: If the processor binding range corresponding to the first child node partition is greater than the processor requirement quantity, adjust the plurality of control groups to the first child node partition at the second partition level.
[0063] When the partition level is adjusted, it further comprises: 504: Obtain the hard binding processor range corresponding to the first child node partition. 505: Obtain the hard binding processor range of the plurality of control groups. 506: Determine the second intersection range of the hard binding processor range corresponding to the first child node partition and the hard binding processor range of the plurality of control groups. 507: Set the soft binding processor range of the plurality of control groups to the first intersection range or the second intersection range.
[0064] It's important to note that adjustments can be made across different levels. That is, the calculated second partition level can be a parent or child partition adjacent to the first partition, or any parent partition or child partition located multiple levels away from the first partition. When the processor resource cache contention for the first partition (located in the first level) is high, it indicates significant resource pressure on the first partition. In this case, the partition level needs to be increased to effectively alleviate processor resource starvation (e.g., cache contention). Conversely, when processor resource contention is low and processor resources are idle, the partition level can be decreased to effectively improve processor resource utilization.
[0065] Before adjusting the first partition, first obtain the number of processors required (nr) for the multiple controls contained in the first partition. cg And, determine the set of child partitions at the second partition level, which corresponds to the first partition. Create a temporary linked list (list) of all partitions in the level corresponding to the second partition level. tmp Add all child or grandchild partitions of the second partition level to this temporary linked list. tmp In the middle, create a linked list of groups corresponding to multiple control groups within the first partition. cg In other words, in this group of linked lists cg It contains linked list information for all control groups in the first partition.
[0066] Then, obtain the linked list. cg The first cgroup element in the dataset is selected, and the hard-bound processor range of that cgroup is determined. cg Get the temporary linked list of partitions. tmp The first partition element (part) determines the hard-bound processor range (cpus) corresponding to that first partition element (part). part And the linked lists of subgroups corresponding to multiple control groups cgroup in the first partition element part.
[0067] Hard-bound processor scope based on the first group element cgroup (cpus) cg The hard-bound processor range cpus corresponding to the first partition element part part Calculate the second intersection range cpus and Furthermore, the second intersection range is cpus and processor demand number nr cg A comparison will be made. Specifically:
[0068] If the second intersection range cpus and is less than the processor demand number nr cg , it means that the first partition element part cannot meet the processor demand number, and the next partition element part will be obtained from the temporary linked list list tmp of the partition, and the second intersection range cpus and will be re-set and compared with the processor demand number nr cg until the last partition element part in the temporary linked list list tmp , and no partition adjustment will be made for the first group element cgroup.
[0069] If the second intersection range cpus and is greater than the processor demand number nr cg , it means that the first partition element part cannot meet the processor demand number, and the first group element cgroup will be deleted from the group linked list list cg of the original first partition, and the first group element cgroup will be placed in the sub-group linked list corresponding to the first partition element part. The soft binding processor range of the first group element cgroup will be set according to the second intersection range cpus and , that is, the soft binding processor range of the first group element cgroup will be set as cpus and . When the adjustment is made, the first partition will be bound to the last position in the partition temporary linked list list tmp , which can effectively prevent the situation that a large number of cgroups are simultaneously opened for group balance adjustment group_balancer and are concentrated on the same partition.
[0070] If the first group element cgroup is the last element in the group linked list list cg , the partition temporary linked list list tmp will be destroyed and ended, and if it is not the last element, the next group element cgroup in the group linked list list cg will be obtained, and the corresponding hard binding range cpus will be obtained.
[0071] For example, assume that the hard-bound processor range of the first partition is 0~95, and there are two child node partitions adjacent to the first partition, with ranges of child node partition A: 0~47 and child node partition B: 48~95, respectively. Assume that the processor requirement number of the first group element cgroup is 45, and the corresponding hard-bound processor range is 2~46. After calculation, the second intersection range with child node partition A is 2~46, with a processor number of 45, and the second intersection range with child node partition B is empty, with a processor number of 0. Further, the first group element cgroup can be placed into the first parent node partition corresponding to the second partition level. and the soft-bound processor range is set to 2~46.
[0072] For another example, assume that the hard-bound processor range of the first partition is 0~100, and there are multiple child node partitions adjacent to the first partition, two of which are child node partition A: 0~47 and child node partition B: 48~66, respectively. Assume that the processor requirement number of the first group element cgroup is 51, and the corresponding hard-bound processor range is 0~50. After calculation, the second intersection range with child node partition A is 0~47, with a processor number of 48, and the second intersection range with child node partition B is 48~50, with a processor number of 3. Since the processor requirement number of the first group element cgroup is 51, neither of the above two second intersection ranges can meet the requirement, and thus the next child node partition will be judged from the temporary linked list. If none of the child node partitions meets the requirement, the adjustment of the first group element cgroup will be terminated. In the above manner, all partition elements in the partition temporary linked list list tmp and all group elements in the group linked list list cg are compared, so as to complete the partition level adjustment of each control group in the first partition.
[0073] As Figure 6 shown in a flowchart of a method for adjusting a low partition level provided by an embodiment of the present application. As Figure 6 can be seen, if the second partition level is smaller than the first partition level corresponding to the first partition, the adjustment of the multiple control groups from the first partition to the first parent node partition or the first child node partition corresponding to the second partition level comprises:
[0074] 601: determining the first parent node partition at a low partition level corresponding to the first partition.
[0075] 602: adjusting the multiple control groups to the first parent node partition corresponding to the second partition level.
[0076] When the partition level is lowered, the following steps are further included: 603: obtaining the hard binding processor range corresponding to the first parent node partition; 604: obtaining the hard binding processor range of the plurality of control groups; 605: determining the first intersection range of the hard binding processor range corresponding to the first parent node partition and the hard binding processor range of the plurality of control groups; and 606: setting the soft binding processor range of the plurality of control groups as the first intersection range.
[0077] It should be noted that, as described above, the hard binding processor range of the parent node partition is the union set of the hard binding ranges of the corresponding plurality of child node partitions. Therefore, when the first partition is adjusted in the lowering of the partition level, the range of the parent node partition is certainly not smaller than the range of the child node partition and the range corresponding to the processor requirement number, so it is no longer necessary to obtain the intersection range.
[0078] determining the first parent node partition part at the second partition level of the first partition at the low partition level parent The first parent node partition mentioned herein can be understood as any partition close to the root node at any level lower than the first partition. For example, it can be a parent node partition or a grandparent node partition. The hard binding processor range cpus parent of the first parent node partition and the group linked list composed of the control groups cgroup in the partition are obtained The group linked list list corresponding to the plurality of control groups in the first partition is established cg Then, the first group element cgroup in the group linked list list cg and the hard binding processor range cpus cg corresponding to the first group element cgroup are obtained.
[0079] The first intersection range cpus cg is calculated based on the hard binding processor range cpus parent of the first group element cgroup and the hard binding processor range cpus and corresponding to the first partition element part. The first group element cgroup is deleted from the original group linked list list cg of the first partition, and the first group element cgroup is placed into the subgroup linked list corresponding to the first partition element part. The soft binding processor range of the first group element cgroup is set according to the second intersection range cpus and , in other words, the soft binding processor range of the first group element cgroup is set as cpus and When the adjustment is performed, the first partition needs to be bound to the partition temporary linked list list tmpThe last position in the cgroup can effectively prevent the simultaneous binding of a large number of cgroup open group balancing adjustment group_balancer to the same partition. After being degraded to the parent node partition, multiple control groups share the processors in the hard binding range. In order to prevent the competition problem caused by the fluctuation of processor resource demand of different control groups, the adjusted control group is limited to the soft binding processor range.
[0080] In practical applications, in order to improve the overall processor utilization or overall processor performance, it is still necessary to adjust the partition across the affinity domain. After the Figures 1 to 4 The various embodiments determine the appropriate partition level for each partition, and then adjust the level based on the control group. Next, the cross-affinity domain adjustment can be performed based on the partition hierarchy. The specific process is as follows:
[0081] As Figure 7 A flowchart of a control group cross-partition migration method provided by the embodiments of the present application. From Figure 7 It can be seen that the specific steps include the following steps:
[0082] 701: Obtain the partition usage of at least one second partition included in the first partition level and the partition usage of the first partition.
[0083] 702: Determine the target usage based on the partition usage of at least one second partition in the corresponding layer of the first partition level and the partition usage of the first partition.
[0084] 703: If the partition usage of the first partition does not meet the target usage, migrate the multiple control groups corresponding to the first partition to a second partition at the same partition level as the first partition.
[0085] When the second partition level matches the first partition level, or after adjusting the multiple control groups to the partitions included in the second partition level corresponding layer, the control groups in the first partition can be migrated as needed.
[0086] Specifically, the processor usage of each partition in the layer of the partition level is obtained from the kernel, including the partition usage of at least one second partition and the partition usage of the first partition. And determine the highest usage usage max , the lowest usage usage min and the average usage usage avg . Further, according to the usage of each partition, the partition chain table list partIf the partition usage rate of the partition level corresponding layer is consistent with the target usage rate, it indicates that the system is in a balanced state, and no cross-affinity domain partition balancing is needed for the control group. On the contrary, if the partition usage rate of the partition level corresponding layer is not consistent with the target usage rate, it is necessary to perform cross-affinity domain migration for the control group.
[0087] As described above, with the increase of the partition level, the affinity between the partitions in the corresponding layer is weakened, and the migration operation between the partitions in the same layer can be easily realized by taking the control group as the division unit. That is, the control group in the partition with high processor usage rate is migrated to the partition with low processor usage rate, so that the usage rates of the partitions are balanced, thereby improving the overall processor usage rate and overall performance.
[0088] As shown in step 702, the method for determining the target usage rate based on the partition usage rate of at least one second partition in the first partition level corresponding layer and the partition usage rate of the first partition includes the following steps:
[0089] 7021: Determine the first partition with the maximum usage rate and the second partition with the minimum usage rate.
[0090] 7022: Determine the target usage rate of the first partition level according to the partition usage rate of the second partition and the partition usage rate of the first partition.
[0091] 7024: If the first usage rate of the plurality of control groups in the first partition is less than the target usage rate, it is determined that the partition usage rate of the first partition does not conform to the target usage rate.
[0092] Specifically, after obtaining the maximum usage rate usage max of the first partition in the layer where the first partition level is located, the minimum usage rate usage min of the second partition, and the average usage rate usage avg of the plurality of partitions in the current layer calculated, the usage rate difference |δ abs | and the usage rate difference relative value δ rlt are calculated according to the maximum usage rate usage max and the minimum usage rate usage min . Further, based on the maximum usage rate usage max , further judgment is made. If usage avg > usage abs + |δ max | and usage avg > usage rlt *(1+δ max ), further judgment is made for each control group in the first partition with the maximum usage rate.
[0093] based on the maximum usage usage max The target usage is calculated based on the difference between the minimum usage usage min , and the calculation formula is: usage target =(usage max -usage min ) / 2. Further, the processor usage usagecg of each control group in the group linked list list max of the first partition part cg with the maximum usage is counted within a preset clock cycle. The first usage usage cg corresponding to the first group element cgroup in the group linked list list cg is obtained. If the first usage usage cg corresponding to the first group element cgroup is less than the target usage, the first group element cgroup can be considered to be adjusted into the second partition with the minimum usage.
[0094] As shown in the flowchart of the control group migration method provided by the embodiments of the present application. As can be seen from Figure 8 , the migration of the plurality of control groups corresponding to the first partition to the second partition at the same partition level as the first partition includes the following steps: Figure 8
[0095] 801: Obtain the hard-bound processor range and the processor demand range of the plurality of control groups.
[0096] 802: Obtain the hard-bound processor range of the second partition.
[0097] 803: Determine the third intersection range of the hard-bound processor range of the plurality of control groups and the hard-bound processor range of the second partition.
[0098] 804: If the processor demand range of the plurality of control groups is less than the third intersection range, set the soft-bound processor range of the plurality of control groups to the third intersection range.
[0099] 805: Delete the plurality of control groups from the first partition, and migrate the plurality of control groups to the second partition at the same partition level as the first partition.
[0100] When adjusting the first group element cgroup, it is also necessary to determine whether the adjustment is really allowed. Specifically, the hard-bound processor range cups part , calculate the hard binding processor range cpus corresponding to the first group element cgroup cg and the third intersection range cpus part between cpus and If the processor requirement number nrcg of the first group element cgroup is less than or equal to the third intersection range cpus and , it indicates that the first group element cgroup can be migrated to the second partition across the affinity domain. If the processor requirement number nr cg of the first group element cgroup is greater than the third intersection range cpus and , the next group element cgroup is selected from the group linked list, the relationship between the processor usage and the target usage corresponding to the group element cgroup is obtained, and it is judged whether the group element cgroup can be migrated to the second partition. Through the above steps, the migration judgment of all elements in the group linked list list cg is completed, and in the process of migrating the control group in the first partition to the second partition, it is judged whether the target usage is zero. If the target usage is zero, it indicates that the difference between the maximum usage and the minimum usage becomes zero, and then the migration operation of the control group is terminated, and the usage balance of the first partition and the second partition is realized. The partition in the higher partition level has smaller affinity, and in the migration operation, the control group is taken as the division unit for overall migration, instead of taking the task as the unit for migration, and the memory does not need to be migrated, so that the migration efficiency can be effectively improved, and the overall performance of the processor is improved.
[0101] Based on the same idea, the embodiment of the application also provides another dynamic partitioning method. As Figure 9 shown in another flowchart of the dynamic partitioning method provided by the embodiment of the application. As Figure 9 can be seen, the method specifically includes the following steps:
[0102] 901: Obtain the partition usage of the first partition and the partition usage of the second partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure includes layers corresponding to different partition levels, and the first partition and the second partition are in the first layer in the hierarchical structure.
[0103] 902: Determine a target usage based on the partition usage of the first partition and the partition usage of the second partition.
[0104] 903: If the partition usage of the first partition does not conform to the target usage, migrate at least one control group corresponding to the first partition to the second partition.
[0105] In the solution, it is assumed that the first partition and the second partition are included in the first level of the hierarchy. The first partition includes a plurality of control groups. Each control group includes a plurality of tasks. When the second partition level matches the first partition level, or after the plurality of control groups are adjusted to the partitions included in the level corresponding to the second partition level (the adjustment method will be described in the embodiments below), the control groups in the first partition can be migrated as needed.
[0106] Specifically, the processor usage of each partition in the level where the partition level is located, the partition usage of at least one second partition, and the partition usage of the first partition are obtained from the kernel. The highest usage usage max , the lowest usage usage min , and the average usage usage avg are determined from the obtained usage. Then, the partitions are sorted in the partition list list part according to the usage of each partition to determine the balance state corresponding to the partition level. If the partition usage of the level corresponding to the first partition level matches the target usage, it indicates that the balance state is balanced, and the control groups do not need to be migrated across the affinity domain. On the contrary, if the partition usage of the level corresponding to the first partition level does not match the target usage, the control groups need to be migrated across the affinity domain. The specific process of migrating the control groups across the affinity domain can refer to Figures 7 to 8 the corresponding embodiments, which will not be repeated here.
[0107] As described above, with the increase of the partition level, the affinity between the partitions in the corresponding level decreases, and the migration operation between the partitions in the same level with the control group as the division unit can be easily realized. That is, the control groups in the partition with high processor usage are migrated to the partition with low processor usage, so that the usage of each partition is balanced, thereby improving the overall processor usage and overall performance.
[0108] It should be noted that before migrating the control groups between the partitions, it is also necessary to determine whether the partition level matches the second partition level. Assuming that the partition level of the first partition does not match the second partition level, before determining the target usage based on the partition usage of the first partition and the partition usage of the second partition, it further includes: obtaining the first partition level of the first partition; determining the working parameters of the plurality of control groups included in the first partition; determining the expected second partition level according to the working parameters of the plurality of control groups; and adjusting the plurality of control groups to the partitions included in the level corresponding to the second partition level when the second partition level does not match the first partition level.
[0109] It should be noted that in the present embodiment, when adjusting the second partition level of the control group, the control group is adjusted between different levels of the partition level, rather than being adjusted between different partitions in the same level. Specifically,
[0110] After obtaining the partition level of the first partition, the second partition level is calculated according to the working parameters of the plurality of control groups in the first partition provided by the kernel and other related parameters (such as the number of processor context switches of the whole machine). The second partition level is compared with the first partition level obtained from the kernel. If the second partition level does not match the first partition level, it indicates that the partition pressure of the current first partition is too large or too small, and the partition needs to be adjusted accordingly by taking the control group as the division unit, that is, the plurality of control groups need to be adjusted from the first partition to the partition included in the level corresponding to the second partition level. Since the technical solution of the present application obtains relevant information based on the kernel state, compared with obtaining information in the user state, it has good timeliness and high accuracy, and can effectively reduce resource consumption without batch calling of kernel interfaces.
[0111] Here, when the second partition level does not match the first partition level, it indicates that the partition pressure of the current first partition is too large or too small. Specifically, when the demand of any control group for processor resources increases, the problem of two control groups competing for processor resources will occur, which indicates that the pressure of the current first partition is too large, and the first partition needs to be upgraded, that is, the control groups in the first partition are adjusted to a higher partition level. Conversely, when the demand of the control groups in the first partition for processor resources decreases, there will be more idle resources, and the first partition needs to be downgraded, that is, the control groups in the first partition are adjusted to a lower partition level. The specific adjustment process and the partition level to which the control groups need to be adjusted can be referred to in Figures 1 to 6 The corresponding embodiments will not be repeated here.
[0112] It should be noted that when the hard-bound processor range of the control group cgroup changes, the present solution will also check whether the current partition is still suitable for the control group cgroup according to the hard-bound processor range of the partition. If not, a suitable partition will be selected for it again.
[0113] In order to facilitate understanding, the following will illustrate the related technologies of partition adjustment and partition balancing by way of example.
[0114] 1. First, initialization is performed, and the specific process is as follows:
[0115] 1.1, create the group linked list listgb of the control group balance adjustment and the corresponding mutexgb.
[0116] 1.2, read the configuration file and generate the partition with hierarchical structure according to the configuration file and partition rules.
[0117] 1.3, create the partition linked list head of the layer for each partition level level, and hang all the partitions of the layer to the listpart.
[0118] 1.4, the initial partition level is set to level1.
[0119] 1.5, create the work queue queueworker and the delay task worker, put the delay task worker into the queueworker, and set the delay period to δ t1 .
[0120] 2. The group_balancer process for cgroup is as follows:
[0121] 2.1, get the lock mutexgb created in the previous link.
[0122] 2.2, add each control group cgroup participating in group balancing to the linked list listgb.
[0123] 2.3, get the hard-bound processor range cpuscg of each partition cgroup and the processor demand number nrcg of the partition cgroup.
[0124] 2.4, get the current partition level level and the partition linked list listpart.
[0125] 2.5, get the first partition element part in the partition linked list listpart and the hard-bound processor range cpuspart of the partition.
[0126] 2.6, calculate the intersection cpusand of cpuscg and cpuspart, if the number of processors in cpusand is less than the processor demand number nrcg, jump to step 2.7; otherwise, jump to step 2.8.
[0127] 2.7, if the partition is the last one in the linked list listpart, hang the cgroup to the cgroup linked list listcglevel0 of level0, and record the current partition level levelcg, and end; otherwise, take the next partition part, the cpu range of part is cpuspart, and jump to step 2.6.
[0128] 2.8, set the soft-bound processor range of the control group cgroup to cpusand calculated in step 2.6.
[0129] 2.9, put the control group cgroup on the listcg corresponding to the partition part.
[0130] 2.10, put the partition part at the end of the listpart (to prevent the situation of binding a large number of cgroups on a partition at the same time when group_balancer is started).
[0131] 2.11, release the lock mutexgb.
[0132] 3 After completing the group_balancer adjustment, the cgroup closes the group_balancer process as follows:
[0133] When the control group cgroup is destroyed, the group_balancer is set to 0 first, and this process is triggered.
[0134] 3.1, get the lock mutexgb.
[0135] 3.2, get the hard-bound processor range cpuscg of the control group cgroup.
[0136] 3.3, set the soft-bound processor range of the control group cgroup to cpuscg.
[0137] 3.4, remove the control group cgroup from the listcg of the partition part.
[0138] 3.5, remove the control group cgroup from the listgb.
[0139] 3.6, release the lock mutexgb.
[0140] 4 Start the delay task worker workflow, as follows:
[0141] 4.1, get the current partition level levelcurrent and all valid partition levels (excluding level0) L.
[0142] 4.2, count the idle rate of the whole machine usage%, the number of context switches nr contex_switch and the number of cgroup switches
[0143] 4.3, calculate the control group cgroup switching rate
[0144] 4.4, calculate the current expected partition level
[0145] 4.5, if levecurrent == leveexpected, then go to 4.6; otherwise go to 4.7.
[0146] 4.6, adjust partition according to 5.
[0147] 4.7, balance partition according to 8.
[0148] 4.8, traverse each cgroup on level 0's cgroup list , if level cg > level current , then try to add cgroup to partition according to 2, otherwise end.
[0149] 5 adjust partition mainly includes two parts, which are increasing partition level (such as part 6) and decreasing partition level (such as part 7).
[0150] 5.1, get mutex gb .
[0151] 5.2, if level current < level expcted , then go to 5.3; otherwise go to 5.4.
[0152] 5.3, traverse level current 's list part , for each part on list part , increase partition level according to part 6, go to 5.5.
[0153] 5.4, traverse level current 's list part , for each part on list part , decrease partition level according to part 7.
[0154] 5.5, let level current = level expcted .
[0155] 5.6, release mutex gb .
[0156] 6 increasing partition level flow is as follows:
[0157] 6.1, create cgroup list in created partition as list cg , create temporary list as list tmp , and put him in level expectedAll children or grandchildren are in list tmp .
[0158] 6.2, get the first group element cgroup of list cg , get its hard bound processor range cpus cg .
[0159] 6.3, get the first element part of list tmp , the hard bound processor range cpus part of this partition, and the cgroup linked list
[0160] 6.4, calculate the intersection cups cg of cpus part and cups and , if the number of processors in cups and is less than nr cg , jump to 6.5; otherwise jump to 6.6.
[0161] 6.5, if part is the last element of list tmp , do not adjust the cgroup partition, jump to 6.10; otherwise take the next element part, the hard bound processor range of part is cpus part , jump to 6.4.
[0162] 6.6, set the soft bound processor range of cgroup to cpus and .
[0163] 6.7, remove cgroup from list cg .
[0164] 6.8, put cgroup to partition part .
[0165] 6.9, put part to the end of list tmp , in order to prevent the situation of concentrating binding on one partition when a large number of cgroups are opened group_balancer at the same time.
[0166] 6.10, if cgroup is the last element of list cg , destroy list tmp and end; otherwise take the next element cgroup, get its hard bound processor range cpus, jump to 6.3.
[0167] 7 The process of lowering the partition level is as follows:
[0168] 7.1 Find the part in the level expected The parent node or grandparent node part parent Get its CPU range (cpus) parent and cgroup linked lists
[0169] 7.2. Obtain the first element (cgroup) of the cgroup linked list (listcg) of the part, and obtain its hard-bound processor scope (cpus). cg .
[0170] 7.3 Calculate cpus cg and cpus parent The intersection of cpus and .
[0171] 7.4 Set the cgroup's soft-bound processor scope to cpus and .
[0172] 7.5. Removing cgroups from a list cg Delete it.
[0173] 7.6. Add cgroup to the top
[0174] 7.7 If cgroup is a list cg If the last element is found, the process ends; otherwise, the next element (cgroup) is retrieved, and its hard-bound processor range (cpus) is obtained. cg Jump to 7.3.
[0175] The 8-partition balancing process is as follows:
[0176] 8.1. Calculate the CPU (processor) usage of each partition at the current partition level, and identify the partition with the highest CPU usage. max Usage rate max The partition with the lowest CPU usage min Usage rate min Average usage rate avg .
[0177] 8.2. Arrange each partition in a list according to its CPU usage. part Sort them in ascending order.
[0178] 8.3 If usgae max >usage avg +δ abs And usgae max >usageavg *(1+δ rlt ), jump to 8.4; otherwise jump to 8.16.
[0179] 8.4, usage target = (usage max - usage min ) / 2.
[0180] 8.5, get mutex gb .
[0181] 8.6, count the cpu usage usage max of all cgroups in the list cg of part t2 within δ cg .
[0182] 8.7, get the first element cgroup in the list max of part cg , whose cpu usage is usage cg .
[0183] 8.8, if usage cg ≤ usage target , jump to 8.10; otherwise jump to 8.9.
[0184] 8.9, if cgroup is the last element in the list cg , jump to 8.15; otherwise get the next element cgroup, whose cpu usage is usage cg , jump to 8.8.
[0185] 8.10, get the cpus min of part part , calculate the intersection cpus cg of cpus part and cpus and , if the number of cpus in cpus and is less than nr cg , jump to 8.9.
[0186] 8.11, remove cgroup from the list max of part cg .
[0187] 8.12, set the soft binding range of cgroup to cpus and .
[0188] 8.13, put cgroup to part minlist cg up.
[0189] 8.14、usage target = usage target -usage cg if usage target == 0, jump to 15; otherwise jump to 8.9.
[0190] 8.15、release mutex gb .
[0191] 8.16、put worker into queue worker , delay period is set as δ t1 .
[0192] Based on the same idea, the embodiment of the present application further provides a dynamic partition system. The system comprises:
[0193] a scheduler, configured to acquire a partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprises layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure; determine work parameters of a plurality of control groups contained in the first partition; determine an expected second partition level according to the work parameters of the plurality of control groups; when the second partition level does not match the first partition level, adjust the plurality of control groups to a partition contained in a layer corresponding to the second partition level.
[0194] a kernel, configured to provide a partition level required by the scheduler.
[0195] In addition, the scheduler can also be configured to acquire a partition usage rate of the first partition and a partition usage rate of a second partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprises layers corresponding to different partition levels, and the first partition and the second partition are at a first layer in the hierarchical structure. If the partition usage rate does not meet a target usage rate, at least one control group corresponding to the first partition is migrated to the second partition.
[0196] Based on the same idea, the embodiment of the present application further provides a dynamic partition device. As Figure 10 a structural schematic diagram of a dynamic partition device provided by the embodiment of the present application. The dynamic partition device comprises:
[0197] an acquisition module 1001, configured to acquire a first partition level of a first partition; wherein the system processing resource has a hierarchical structure, the hierarchical structure comprises layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure.
[0198] The determining module 1002 is configured to determine work parameters of the plurality of control groups contained in the first partition.
[0199] The determining module 1002 is further configured to determine the expected second partition level according to the work parameters of the plurality of control groups.
[0200] The adjusting module 1003 is configured to adjust the plurality of control groups to a partition contained in a layer corresponding to the second partition level when the second partition level does not match the first partition level.
[0201] Optionally, the balancing module 1004 is further configured to obtain a partition usage rate of at least one second partition included in the first partition level and a partition usage rate of the first partition; determine a target usage rate based on the partition usage rate of at least one second partition in a layer corresponding to the first partition level and the partition usage rate of the first partition; and migrate the plurality of control groups corresponding to the first partition to a second partition at the same partition level as the first partition if the partition usage rate of the first partition does not conform to the target usage rate.
[0202] Optionally, the determining module 1002 is further configured to determine the second partition level according to a switching number of the plurality of control groups in a layer where the partition level is located and a context switching number of each partition in the layer; and obtain a hard binding processor range of a first parent node partition or a first child node partition corresponding to the second partition level.
[0203] Optionally, the determining module 1002 is further configured to adjust the plurality of control groups from the first partition to a first parent node partition or a first child node partition contained in a layer corresponding to the second partition level when the second partition level does not match the first partition level; and adjust a soft binding processor range of the plurality of control groups according to the hard binding processor range of the first parent node partition or the first child node partition.
[0204] Optionally, the adjusting module 1003 is further configured to, if the second partition level is greater than a first partition level corresponding to the first partition, adjust the plurality of control groups from the first partition to a first parent node partition or a first child node partition corresponding to the second partition level, including: determining a child node partition set of the second partition level corresponding to the first partition; determining a processor demand number of the plurality of control groups contained in the first partition; and adjusting the plurality of control groups to the first child node partition at the second partition level if a processor binding range corresponding to the first child node partition is greater than the processor demand number.
[0205] Optionally, the adjusting module 1003 is further configured to: if the second partition level is smaller than the first partition level corresponding to the first partition, the adjusting the plurality of control groups from the first partition to a first parent node partition or a first child node partition corresponding to the second partition level comprises: determining a first parent node partition corresponding to the first partition and at a lower partition level; and adjusting the plurality of control groups to the first parent node partition corresponding to the second partition level.
[0206] Optionally, the adjusting module 1003 is further configured to: acquire a hard binding processor range corresponding to the first parent node partition, or acquire a hard binding processor range corresponding to the first child node partition; acquire a hard binding processor range of the plurality of control groups; determine a first intersection range of the hard binding processor range corresponding to the first parent node partition and the hard binding processor range of the plurality of control groups, or determine a second intersection range of the hard binding processor range corresponding to the first child node partition and the hard binding processor range of the plurality of control groups; and set a soft binding processor range of the plurality of control groups as the first intersection range or the second intersection range.
[0207] Optionally, the determining module 1002 is further configured to: determine a second partition level corresponding to the first partition within a preset clock cycle of a delay task; and if the second partition level is equal to the partition level corresponding to the first partition, determine that the partition level of the first partition matches an expected pressure.
[0208] Optionally, the determining module 1002 is further configured to: determine a first partition with a maximum usage rate and a second partition with a minimum usage rate.
[0209] determine a target usage rate of the first partition level according to a partition usage rate of the second partition and a partition usage rate of the first partition;
[0210] if a first usage rate of the plurality of control groups in the first partition is smaller than the target usage rate, determine that the partition usage rate of the first partition does not meet the target usage rate.
[0211] Optionally, the balancing module 1004 is configured to: the migrating the plurality of control groups corresponding to the first partition to a second partition at a same partition level as the first partition comprises:
[0212] acquire a hard binding processor range and a processor demand range of the plurality of control groups;
[0213] acquire a hard binding processor range of the second partition;
[0214] determine a third intersection range of the hard binding processor range of the plurality of control groups and the hard binding processor range of the second partition;
[0215] If the processor requirement range of the plurality of control groups is less than the third intersection range, set the soft binding processor range of the plurality of control groups as the third intersection range.
[0216] An embodiment of the present application further provides an electronic device. The electronic device is a master node electronic device in a computing unit. As shown in Figure 11 An embodiment of the present application provides a structural schematic diagram of an electronic device. The electronic device comprises a memory 1101, a processor 1102 and a communication component 1103; wherein,
[0217] The memory 1101 is configured to store a program.
[0218] The processor 1102 is coupled with the memory and is configured to execute the program stored in the memory, so as to:
[0219] obtain a first partition level of a first partition; wherein a system processing resource has a hierarchical structure, the hierarchical structure comprises layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure;
[0220] determine working parameters of a plurality of control groups contained in the first partition;
[0221] determine an expected second partition level according to the working parameters of the plurality of control groups;
[0222] when the second partition level does not match the first partition level, adjust the plurality of control groups to a partition contained in a layer corresponding to the second partition level.
[0223] The memory 1101 can be configured to store other various data to support operations on the electronic device. Examples of the data include instructions of any application program or method for operating on the electronic device. The memory can be realized by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0224] Further, the processor 1102 in the embodiment can be specifically a programmable switching processing chip, wherein a data replication engine is configured in the programmable switching processing chip, and the data replication engine can replicate received data.
[0225] When the processor 1102 executes the program in the memory, in addition to the above functions, the processor 1102 can also realize other functions, which can be referred to the descriptions of the foregoing embodiments. Further, as shown inFigure 11 As shown, the electronic device further includes a power supply component 1104 and other components.
[0226] Based on the same idea, the embodiment of the present application further provides another dynamic partition device. As shown in Figure 12 The structural schematic diagram of another dynamic partition device provided by the embodiment of the present application. The another dynamic partition device includes:
[0227] The acquisition module 1201 is configured to acquire a partition usage rate of a first partition and a partition usage rate of a second partition; wherein, the system processing resource has a hierarchical structure, the hierarchical structure includes layers corresponding to different partition levels, and the first partition and the second partition are at a first layer in the hierarchical structure.
[0228] The determination module 1202 is configured to determine a target usage rate based on the partition usage rate of the first partition and the partition usage rate of the second partition.
[0229] The migration module 1203 is configured to migrate at least one control group corresponding to the first partition to the second partition if the partition usage rate of the first partition does not meet the target usage rate.
[0230] Optionally, further comprising an adjustment module 1204 configured to acquire a first partition level of a first partition; determine working parameters of a plurality of control groups contained in the first partition; determine an expected second partition level according to the working parameters of the plurality of control groups; and adjust the plurality of control groups to a partition contained in a layer corresponding to the second partition level when the second partition level does not match the first partition level.
[0231] The embodiment of the present application further provides an electronic device. The electronic device is a backup node electronic device in a computing unit. As shown in Figure 13 The structural schematic diagram of another electronic device provided by the embodiment of the present application. The electronic device includes a memory 1301, a processor 1302 and a communication component 1303; wherein,
[0232] The memory 1301 is configured to store a program;
[0233] The processor 1302 is coupled with the memory and is configured to execute the program stored in the memory, so as to:
[0234] Acquire a partition usage rate of a first partition and a partition usage rate of a second partition; wherein, the system processing resource has a hierarchical structure, the hierarchical structure includes layers corresponding to different partition levels, and the first partition and the second partition are at a first layer in the hierarchical structure.
[0235] determining a target usage based on the partition usage of the first partition and the partition usage of the second partition;
[0236] migrating at least one control group corresponding to the first partition to the second partition if the partition usage of the first partition does not conform to the target usage.
[0237] The memory 1301 can be configured to store other various data to support operations on the electronic device. Examples of these data include instructions for any application or method operating on the electronic device. The memory can be realized by any type of volatile or nonvolatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0238] Further, the processor 1302 in the embodiment can be specifically: a programmable switching processing chip, wherein a data replication engine is configured in the programmable switching processing chip, and the received data can be replicated.
[0239] In addition to the above functions, the processor 1302 can also implement other functions when executing programs in the memory, which can be specifically understood from the description of the foregoing embodiments. Further, as shown in Figure 13 The electronic device further includes a power supply component 1304 and other components.
[0240] Based on the above embodiments, a first partition level of the first partition is obtained; the system processing resource has a hierarchical structure, the hierarchical structure includes layers corresponding to different partition levels, and the first partition is at a first layer in the hierarchical structure; working parameters of a plurality of control groups contained in the first partition are determined; a desired second partition level is determined according to the working parameters of the plurality of control groups; and when the second partition level does not match the first partition level, the plurality of control groups are adjusted to a partition contained in a layer corresponding to the second partition level. After adjusting the control groups to the second partition level, further partition balancing adjustment can be performed in the control group division unit. Through the above technical solution, when the partition is divided, the partition is divided into a plurality of different partition levels with different affinities according to the hardware topology structure and the partition rule. When dynamic partitioning is required, the processor pressure of the first partition corresponding to the partition level is adjusted between the layers corresponding to the different partition levels of the same partition branch, effectively alleviating the processor starvation competition (such as cache competition) problem. In addition, when there is a need for cross-affinity domain adjustment, the migration of the whole between different partitions in the layer where the same partition level is located is performed in the control group division unit, which alleviates the problem of reduced processor performance caused by task migration, thereby effectively improving the overall processor performance.
[0241] It should be noted that the dynamic partitioning device provided by the above embodiments can implement the technical solutions described in the above method embodiments, and the principles of the implementation of the above modules or units can be referred to the corresponding content in the above method embodiments, which will not be described here.
[0242] The device embodiments described above are only schematic, and the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e. they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the present embodiment scheme according to actual needs. Those skilled in the art can understand and implement it without creative labor.
[0243] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software and necessary general hardware platform, and of course it can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of software product, which can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including a plurality of instructions to make a computer device (which can be a personal computer, server, or network device, etc.) execute the method described in each embodiment or some parts of the embodiment.
[0244] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can still be modified, or some technical features therein can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A dynamic partition method applied to a system processing resource having a hierarchical structure, the hierarchical structure comprising layers corresponding to different partition levels, a partition in the hierarchical structure having a corresponding hard-bound processor range, a control group (Cgroup) in a partition corresponding to a task bound to be executed by a processor, and a scenario in which control groups in a same partition share the hard-bound processor range corresponding to the same partition, the method comprising: obtaining a first partition level of a first partition, the first partition being in a first layer in the hierarchical structure; determining work parameters of a plurality of control groups contained in the first partition; determining a desired second partition level according to the work parameters of the plurality of control groups; and adjusting the control groups contained in the first partition to a partition contained in a layer corresponding to the second partition level when the second partition level does not match the first partition level, so as to adjust the control groups from sharing the hard-bound processor range corresponding to the first partition to sharing the hard-bound processor range corresponding to the partition contained in the layer corresponding to the second partition level. 2.The method of claim 1, further comprising: obtaining a partition usage rate of at least one second partition included in the first partition level and a partition usage rate of the first partition; determining a target usage rate based on the partition usage rate of at least one second partition in the layer corresponding to the first partition level and the partition usage rate of the first partition; and migrating the plurality of control groups corresponding to the first partition to a second partition at the same partition level as the first partition if the partition usage rate of the first partition does not conform to the target usage rate. 3.The method of claim 1, wherein the determining the desired second partition level according to the work parameters of the plurality of control groups comprises: determining the desired second partition level according to a number of switches of the plurality of control groups in the layer in which the partition level is located and a number of context switches of each partition in the layer; and obtaining a hard-bound processor range of a first parent partition or a first child partition corresponding to the second partition level. 4.The method of claim 3, wherein the adjusting the control groups contained in the first partition to a partition contained in the layer corresponding to the second partition level when the second partition level does not match the first partition level comprises: adjusting the control groups contained in the first partition from the first partition to a first parent partition or a first child partition contained in the layer corresponding to the second partition level when the second partition level does not match the first partition level; and adjusting a soft-bound processor range of the control groups contained in the first partition according to the hard-bound processor range of the first parent partition or the first child partition. 5.The method of claim 4, wherein if the second partition level is greater than a first partition level corresponding to the first partition, the adjusting the control groups contained in the first partition from the first partition to the first parent partition or the first child partition contained in the layer corresponding to the second partition level comprises: determining a set of child partitions of the second partition level corresponding to the first partition; and adjusting the control groups contained in the first partition to the first parent partition or the first child partition corresponding to the second partition level according to the set of child partitions of the second partition level corresponding to the first partition. determining a number of processor requirements of a plurality of control groups contained in the first partition; if the processor binding range corresponding to the first sub-node partition is greater than the number of processor requirements of the control groups contained in the first partition, adjusting the control groups to the first sub-node partition at the second partition level.
6. The method of claim 4, if the second partition level is less than the first partition level corresponding to the first partition; the adjusting the control groups contained in the first partition from the first partition to the first parent partition or the first sub-node partition contained in the corresponding layer of the second partition level comprises: determining a first parent partition at a low partition level corresponding to the first partition; adjusting the control groups contained in the first partition to the first parent partition corresponding to the second partition level.
7. The method of claim 4, the adjusting the soft binding processor range of the control groups contained in the first partition according to the hard binding processor range of the first parent partition or the first sub-node partition comprises: obtaining the hard binding processor range corresponding to the first parent partition, or obtaining the hard binding processor range corresponding to the first sub-node partition; obtaining the hard binding processor range of the control groups contained in the first partition; determining a first intersection range of the hard binding processor range corresponding to the first parent partition and the hard binding processor range of the control groups contained in the first partition, or determining a second intersection range of the hard binding processor range corresponding to the first sub-node partition and the hard binding processor range of the control groups contained in the first partition; setting the soft binding processor range of the control groups contained in the first partition as the first intersection range or the second intersection range.
8. The method of claim 2, the determining a target usage rate based on the partition usage rate of at least one second partition in the corresponding layer of the first partition level and the partition usage rate of the first partition comprises: determining the first partition with the maximum usage rate and the second partition with the minimum usage rate; determining the target usage rate of the first partition level according to the partition usage rate of the second partition and the partition usage rate of the first partition; if the first usage rate of the plurality of control groups in the first partition is less than the target usage rate, determining that the partition usage rate of the first partition does not conform to the target usage rate.
9. The method of claim 8, the migrating the plurality of control groups corresponding to the first partition to a second partition at the same partition level as the first partition comprises: obtaining the hard binding processor range and the processor requirement range of the plurality of control groups; obtaining the hard binding processor range of the second partition; determining a third intersection range of the hard binding processor range of the plurality of control groups and the hard binding processor range of the second partition; if the processor requirement range of the plurality of control groups is less than the third intersection range, setting the soft binding processor range of the plurality of control groups as the third intersection range. 10.A dynamic partition method, applied to a system having a hierarchical structure of processing resources, the hierarchical structure comprising layers corresponding to different partition levels, and a partition in the hierarchical structure having a corresponding hard-bound processor range, and a control group (Cgroup) corresponding to the partition having tasks bound to be executed by a processor, and a scenario in which control groups corresponding to a same partition share the hard-bound processor range corresponding to the same partition, the method comprising: obtaining a partition usage rate of a first partition and a partition usage rate of a second partition, the first partition and the second partition being in a first layer in the hierarchical structure; determining a target usage rate based on the partition usage rate of the first partition and the partition usage rate of the second partition; and if the partition usage rate of the first partition does not conform to the target usage rate, migrating at least one control group corresponding to the first partition to the second partition to adjust the control group from sharing the hard-bound processor range corresponding to the first partition to sharing the hard-bound processor range corresponding to the second partition. 11.The method of claim 10, before determining a target usage rate based on the partition usage rate of the first partition and the partition usage rate of the second partition, further comprising: obtaining a first partition level of a first partition; determining working parameters of a plurality of control groups contained in the first partition; determining an expected second partition level according to the working parameters of the plurality of control groups; and when the second partition level does not match the first partition level, adjusting the control groups contained in the first partition to partitions contained in a layer corresponding to the second partition level to adjust the control groups from sharing the hard-bound processor range corresponding to the first partition to sharing the hard-bound processor range corresponding to the partitions contained in the layer corresponding to the second partition level. 12.A dynamic partition system, applied to a system having a hierarchical structure of processing resources, the hierarchical structure comprising layers corresponding to different partition levels, and a partition in the hierarchical structure having a corresponding hard-bound processor range, and a control group (Cgroup) corresponding to the partition having tasks bound to be executed by a processor, and a scenario in which control groups corresponding to a same partition share the hard-bound processor range corresponding to the same partition, comprising: a scheduler configured to obtain a first partition level of a first partition, the first partition being in a first layer in the hierarchical structure; determine working parameters of a plurality of control groups contained in the first partition; determine an expected second partition level according to the working parameters of the plurality of control groups; and when the second partition level does not match the first partition level, adjust the control groups contained in the first partition to partitions contained in a layer corresponding to the second partition level to adjust the control groups from sharing the hard-bound processor range corresponding to the first partition to sharing the hard-bound processor range corresponding to the partitions contained in the layer corresponding to the second partition level; and a kernel configured to provide partition levels required by the scheduler. 13.An electronic device, comprising a memory and a processor; wherein the memory is configured to store a program; and the processor is configured to execute the program. The processor, coupled with the memory, is configured to execute the program stored in the memory, so as to implement the method in any one of claims 1-9, or implement the method in any one of claims 10-11.
14. A non-transitory machine-readable storage medium having stored thereon executable code to cause a processor of an electronic device to execute a method as described in any one of claims 1-9, or implement the method in any one of claims 10-11.
Citation Information
Patent Citations
Allocating resources among tiered partitions of different types
US7941804B1