Multi-processor performance index acquisition method, device, electronic equipment and vehicle
By acquiring CPU microarchitecture data in the kernel state and transmitting it in the user state, containers are dynamically scheduled, which solves the problem of interference between containers, realizes low-overhead container scheduling, and enhances the resource utilization efficiency of the system.
Patent Information
- Application Number
- CN202211733202.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In the existing technology, when multiple containers run under the same Linux kernel, it is difficult to effectively obtain their respective CPU microarchitecture data, resulting in unavoidable interference between containers.
By dynamically obtaining the CPU microarchitecture data of the container in the kernel state, using the container orchestration module in the user state to regularly obtain PMU data from the kernel state, and dynamically scheduling the container to the appropriate CPU to avoid interference.
It realizes user mode acquisition of container CPU microarchitecture data, provides scheduling basis, dynamic scheduling reduces interference between containers, low system overhead, and normal operation.
Smart Images

Figure CN116302732B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic equipment and vehicle for acquiring multi-processor performance indicators. Background Art
[0002] In related technologies, in order to make full use of hardware resources, multiple applications are deployed in a mixed manner on one device to maximize the use of hardware performance and save costs. Generally, the Linux operating system is installed on a machine and multiple containers are created, and different applications are run on different containers. Since these containers run on the same Linux kernel at the bottom layer, they may interfere with each other. Based on this, the central processing unit (CPU) micro-architecture data of each container can be dynamically obtained in the kernel state to provide a scheduling basis for the upper-level container orchestration, and different containers can be dynamically scheduled to the appropriate CPU, thereby avoiding interference between containers. The CPU micro-architecture data can be characterized using the performance indicators of the processor.
[0003] Currently, there is an urgent need for a method to obtain CPU microarchitecture data of a container. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a method, device, electronic device and vehicle for obtaining performance indicators of multiple processors.
[0005] According to a first aspect of an embodiment of the present disclosure, a method for obtaining performance indicators of multiple processors is provided, comprising obtaining target information from multiple container records, wherein each of the container records corresponds to a container, the container record is a data structure for recording container information, each container record comprises multiple record information, the multiple record information corresponds one-to-one to the multiple processors, each record information is used to record the performance indicator of the corresponding processor, and the target information comprises at least one record information.
[0006] According to a second aspect of an embodiment of the present disclosure, a multi-processor performance indicator acquisition device is provided, including a first acquisition module, used to acquire target information from multiple container records, wherein each of the container records corresponds to a container, the container record is a data structure for recording container information, each container record includes multiple record information, the multiple record information corresponds one-to-one to the multiple processors, each record information is used to record the performance indicator of the corresponding processor, and the target information includes at least one record information.
[0007] According to a third aspect of an embodiment of the present disclosure, a vehicle is provided, storing a set of instruction sets, wherein the instruction sets are executed by the vehicle to implement the multi-processor performance indicator acquisition method provided by the first aspect of the present disclosure.
[0008] According to the fourth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement the multi-processor performance indicator acquisition method provided by the first aspect of the present disclosure.
[0009] According to a fifth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the multi-processor performance indicator acquisition method provided in the first aspect of the present disclosure are implemented.
[0010] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: the user state can obtain record information from the container record, thereby obtaining the CPU micro-architecture data of the container, providing a scheduling basis for the upper-layer container orchestration, and dynamically scheduling different containers to the appropriate CPU, thereby avoiding interference between containers.
[0011] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0013] Figure 1 is a flow chart of a method for obtaining multi-processor performance indicators according to an exemplary embodiment;
[0014] Figure 2 is a schematic diagram of a structure of a container record according to an exemplary embodiment;
[0015] Figure 3 is a class diagram of a container record according to an exemplary embodiment;
[0016] Figure 4 is a block diagram of a device for acquiring performance indicators of multiple processors according to an exemplary embodiment;
[0017] Figure 5 is a block diagram of a vehicle according to an exemplary embodiment;
[0018] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0019] Exemplary embodiments will be described in detail below with reference to the accompanying drawings.
[0020] It should be pointed out that the relevant embodiments and drawings are only for describing exemplary embodiments provided by the present disclosure, rather than all embodiments of the present disclosure, and it should not be understood that the present disclosure is limited to the relevant exemplary embodiments.
[0021] It should be noted that the terms "first", "second", etc. used in the present disclosure are only used to distinguish different steps, devices or modules, etc. The related terms neither represent any specific technical meanings nor indicate the order or interdependence between them.
[0022] It should be noted that the modifications of the terms "one", "multiple", and "at least one" used in the present disclosure are illustrative rather than restrictive. Unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0023] It should be noted that the term "and / or" used in this disclosure is used to describe the association relationship between associated objects, and generally indicates that there are at least three association relationships. For example, A and / or B can at least indicate the existence of three association relationships: A exists alone, A and B exist at the same time, and B exists alone.
[0024] It should be noted that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. Unless otherwise specified, the scope of the present disclosure is not limited by the order of description of the steps in the relevant embodiments.
[0025] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0026] Technical terminology
[0027] CPU microarchitecture: MicroArchitecture, including cache management, cache design, out-of-order execution, superscalar, superpipeline, memory control, branch prediction and many other extremely complex circuits. The efficiency of these structural circuits directly determines the CPU performance.
[0028] The Performance Monitoring Unit (PMU) is used to count specific hardware events that occur in the system, such as cache misses or branch misprediction. At the same time, multiple events can be combined to calculate some advanced indicators, such as cycles per instruction (CPI), cache hit rate, etc. A specific micro-architecture can provide hundreds of events through the PMU. The data of the CPU micro-architecture can be presented through PMU data. A specific micro-architecture can provide hundreds of events through the PMU. The present disclosure mainly obtains commonly used PMU data, including running instruction counts, cycle counts, branch prediction failures, cache misses, etc. The bottom layer of the Linux system's container is implemented through containers (Cgroup) and Namespaces. The present disclosure uses Cgroup as a unit to count CPU micro-architecture data in kernel state, and the upper layer can be associated with containers through Cgroup.
[0029] Container: A lightweight virtualization method that can run multiple virtual environments simultaneously on a single host. It uses the Namespace and Cgroup features of Linux to isolate and restrict resources.
[0030] Control Groups (Cgroup) is a mechanism provided by the Linux kernel that can limit, record, and isolate the physical resources (such as CPU, memory, disk IO, etc.) used by process groups.
[0031] Exemplary Methods
[0032] Figure 1 is a flowchart of a method for obtaining multi-processor performance indicators according to an exemplary embodiment. Figure 1 As shown, the method for obtaining multi-processor performance indicators can be used in a system including multiple processors, and includes the following steps:
[0033] Step S110, obtaining target information from multiple container records, wherein each container record corresponds to a container, the container record is a data structure for recording container information, each container record includes multiple record information, the multiple record information corresponds to multiple processors one-to-one, each record information is used to record the performance index of the corresponding processor, and the target information includes at least one record information. The target information may include part of the record information of the container record, or may include all the record information in all container records, which is not limited here.
[0034] Specifically, each time a container is created, a container record is created accordingly. There is a one-to-one correspondence between containers and container records. A container record is a data structure that records container information, such as Figure 2 As shown in the figure, chushi_cgroup_record is a container record, which includes multiple record information, each of which is used to record the performance index of a processor, and different record information records the performance index of different processors. Figure 2 As shown, the system includes N processors, and chushi_cgroup_record includes N record information, each record information is used to record the performance index of a processor. The performance index can be CPU microarchitecture data, specifically PMU data value. In the present disclosure, PMU data value can also be referred to as PMU data.
[0035] The container records are stored in the kernel state, and the user state needs to obtain the container records to understand the CPU micro-architecture data of each container, provide a scheduling basis for the upper-level container orchestration, and dynamically schedule different containers to the appropriate CPU to avoid interference between containers. Step S110 can be triggered based on the acquisition request sent by the container orchestration module in the user state. For example, the user state obtains the target information from the kernel state through an ioctl function call.
[0036] For example, in the kernel, a container (i.e., cgroup) corresponds to a container record, such as Figure 2 As shown in the figure, a container record is a chushi_cgroup_record structure, which contains the PMU data part. The chushi_cgroup_record structure is an array, corresponding to the PMU data of this cgroup on each CPU. When the kernel creates a cgroup, a new chushi_cgroup_record is created, and when the kernel destroys the cgroup, the corresponding chushi_cgroup_record is deleted. When the kernel switches processes, the chushi_cgroup_record is updated.
[0037] When the container orchestration module in user mode needs to obtain the CPU microarchitecture data of each container. Through ioctl calls to the kernel, the kernel will schedule the workqueue processing function running on each CPU. In the workqueue processing function, all chushi_cgroup_record structures in the system will be traversed, and the part of the PMU data corresponding to the current CPU (that is, the CPU corresponding to the workqueue processing function) will be processed, and the data will be formatted and copied to the user state. Using parallel programming technology, no locking is required during the process of the kernel updating chushi_cgroup_record and obtaining PMU data from chushi_cgroup_record. The system overhead of the entire solution is extremely low (accounting for 0.1% of a single core), and it can run normally in the system.
[0038] The container orchestration module in user state periodically, for example, calls the kernel state through ioctl every few seconds to obtain the PMU data in the system. In the kernel, the corresponding work queue scheduling operation on each CPU is triggered and the corresponding processing function is executed. The workqueue processing function corresponding to the work queue will traverse all chushi_cgroup_records in the system, process the part of the PMU data corresponding to the processor running the work queue, format the data and copy it to a buffer, which is used to transfer data between the kernel state and the user state, and then clear the sum value.
[0039] The formatted data obtained in the user state includes the container name, CPU number, and PMU data. In the user state, different application containers can be mapped according to the container name. After aggregating and analyzing these data, each container can be scheduled to the appropriate CPU to avoid interference between containers.
[0040] In some embodiments of the present disclosure, step S110 may specifically include step S1101: traversing each container record through each processor, and obtaining record information corresponding to the processor from each container record;
[0041] Specifically, each container record is traversed by a work queue running on each processor, and record information corresponding to the processor is obtained from each container record.
[0042] Step S1102: Determine the target information according to the plurality of record information.
[0043] Specifically, the record information is formatted to obtain formatted information, where the formatted information includes an identifier of a container record to which the record information belongs, an identifier of a processor corresponding to the record information, and a performance indicator recorded in the record information.
[0044] Furthermore, after step S110, the method further includes:
[0045] Step S111, grouping the target information according to the identifier of the container record to obtain at least one group, each group corresponds to a container, that is, the record information corresponding to the same container is in one group.
[0046] Step S112, determining the processor for scheduling the container according to the sum of the performance indicators in the same group. For each group, the sum of the performance indicators of the records in the group is counted, and the processor for scheduling the container is determined according to the sum of the performance indicators.
[0047] In some embodiments of the present disclosure, before the step of acquiring target information from a plurality of container records, the method further includes:
[0048] A memory pool and a tree structure are initialized in the kernel, wherein the memory pool is used to allocate memory required for the container record, the tree structure is used to store the container record, and the key of the tree structure is a pointer to the container.
[0049] Specifically, the tree structure can be specifically called a radix tree, and the memory pool is used to allocate the memory required by chushi_cgroup_record. The radix tree is used to store chushi_cgroup_record, and the key of the radix tree is a pointer to the container in the kernel.
[0050] Furthermore, after the tree structure is constructed, all existing containers are traversed, the container record is created for each container, and the container record is added to the tree structure.
[0051] In some embodiments of the present disclosure, before the step of acquiring target information from a plurality of container records, the method further includes:
[0052] A work queue is created on each of the processors, and the work queue is used to export the PMU data stored on the processor in each container record from the kernel.
[0053] Specifically, a work queue is created on each processor, and the work queue can traverse all container records in the kernel and obtain the PMU data on the processor where the work queue is located from each container record. For example, if work queue 1 is created on processor 1, and work queue 2 is created on processor 2, and the kernel includes container record 1 and container record 2, then work queue 1 traverses container record 1 and container record 2, and work queue 1 obtains the PMU data of processor 1 from container record 1 and container record 2, and work queue 2 traverses container record 1 and container record 2, and work queue 2 obtains the PMU data of processor 2 from both container record 1 and container record 2. Part of the implementation code is as follows:
[0054] for_each_possible_cpu(i){
[0055] dump_work=per_cpu_ptr(&dump_works,i);
[0056]
[0057] A PMU event is created on each of the processors, and the PMU event is used to generate PMU data. Specifically, the underlying layer uses the existing perf_event mechanism of the Linux kernel and calls perf_event_create_kernel_counter() to register the hardware perf event event. Part of the implementation code is as follows:
[0058]
[0059] Traverse all existing containers in the current system, create a container record for each container, and add the container record to the radix tree, so that the containers in the current system are managed.
[0060] In some embodiments of the present disclosure, before the step of acquiring target information from a plurality of container records, the method further includes:
[0061] In the case of creating a container, a corresponding container record is created for the container.
[0062] Specifically, each time a container is created, a container record is created for the container. A first hook function is added to the creation function of the container, the first hook function is used to create a container record corresponding to the container and add the container record to the tree structure.
[0063] For different kernel versions, you can hook the container creation function in the form of tracepoint or kprobe. In the corresponding hook function, a new Figure 2 chushi_cgroup_record shown in the figure and add it to the radix tree.
[0064] In some embodiments of the present disclosure, when a container is created, after the step of creating a corresponding container record for the container, the method further includes:
[0065] When a process is switched in, obtaining a current first performance indicator of a processor into which the process is switched in;
[0066] When the process is switched out, obtaining a current second performance indicator of the processor;
[0067] The difference between the first performance indicator and the second performance indicator is stored in a container record corresponding to the process.
[0068] For example, process 1 runs on processor 1. When process 1 switches into processor 1, the current first performance indicator of processor 1 is obtained. When process 1 completes running and switches out, the current second performance indicator of processor 1 is obtained. The difference between the first performance indicator and the second performance indicator is the performance indicator of processor 1 during the period when process 1 runs on processor 1. The difference is stored in the container record corresponding to process 1, for example, container record 1 corresponding to process 1, and the difference is stored in the record information corresponding to processor 1 in container record 1.
[0069] It should be noted that process entry can be understood as the process starting to run on the processor, and process exit can be understood as the process ending running on the processor.
[0070] In the above, the performance indicator may be PMU data, and obtaining the current first performance indicator of the processor into which the process is switched specifically includes the following steps:
[0071] Obtaining a current first PMU data value of the first processor;
[0072] Determine a container where the process running on the first processor is located, and obtain a first container record of the container;
[0073] The first PMU data value is saved in a first field of a data structure corresponding to the first processor in the first container record.
[0074] In the above, the first processor is the processor that the process cuts in, the container record of the container corresponding to the process is the first container record, and the first processor in the first easy record corresponds to a data structure, which includes a first field, and the first PMU data value is stored in the first field.
[0075] Specifically, the data structure of the container record can be as follows Figure 3As shown, the container record chushi_cgroup_record includes multiple record information chushi_cgroup_stat_percpu, and each chushi_cgroup_stat_percpu includes three fields, namely last, sum, and flags. The specific data structure settings of the container record and the record information can be adjusted according to actual conditions. This is only an example and is not limited.
[0076] Get the PMU data of the first processor, for example, read the count field of each perf_event. Find the container where the corresponding process is located, further find the container record corresponding to the container, and find the corresponding container record from the radix tree. Save the current PMU data value to the last of chushi_cgroup_stat_percpu corresponding to the current CPU.
[0077] When the process is switched out, obtaining the current second performance indicator of the processor specifically includes the following steps:
[0078] Obtaining a current second PMU data value of the first processor;
[0079] Subtract the value in the first field of the data structure corresponding to the first processor in the first container record from the second PMU data value to obtain a difference;
[0080] The difference is accumulated into the value of the second field of the data structure.
[0081] In the above, the first processor is the processor of the process, the container record of the container corresponding to the process is the first container record, and the first processor in the first container record corresponds to a data structure, which includes a second field, and the difference is stored in the second field.
[0082] Get the PMU data of the first processor, for example, read the count field of each perf_event. Find the container where the process is located, and further find the chushi_cgroup_record corresponding to the container. Subtract the last value saved in the current first container record chushi_cgroup_stat_percpu from the current PMU data value, and add the difference to the sum of the first container record. This sum represents the accumulated PMU data value of the process during its operation on the first processor.
[0083] In some embodiments of the present disclosure, before the step of acquiring target information from a plurality of container records, the method further includes:
[0084] When a container is destroyed, each record information in the container record corresponding to the container is exported, and the memory occupied by the container record is released.
[0085] Specifically, when a container is destroyed, the container record corresponding to the container is also destroyed. Specifically, a second hook function can be added to the destruction function of destroying the container. The second hook function is used to force the export of all PMU data in the container record corresponding to the container, remove the container record from the tree structure, and release the memory of the container record.
[0086] For different kernel versions, a hook can be set on the container destruction function in the form of tracepoint or kprobe. In the corresponding hook function, when the container is destroyed, all PMU data in the chushi_cgroup_record corresponding to the container is forced to be exported, for example, put into the corresponding buffer, and then the corresponding chushi_cgroup_record is removed from the radixtree and the corresponding memory is released.
[0087] The multi-processor performance indicators in the disclosed embodiments can be run in the system in a normalized and low-overhead manner without causing interference or jitter to existing services in the system. By creating multiple containers on the host of the Linux operating system, multiple applications can be deployed in a mixed manner to maximize the use of hardware performance to save costs. Different applications run in different containers, and it is necessary to avoid interference between containers. The CPU microarchitecture data of each container can be dynamically obtained to provide a scheduling basis for the upper-level container orchestration, and different containers can be dynamically scheduled to different CPUs, thereby avoiding interference between containers.
[0088] Exemplary Devices
[0089] Figure 4 is a block diagram of a device for acquiring performance indicators of multiple processors according to an exemplary embodiment. Figure 4 , the device 400 comprises:
[0090] The first acquisition module 401 is used to acquire target information from multiple container records, wherein each of the container records corresponds to a container, the container record is a data structure for recording container information, each container record includes multiple record information, the multiple record information corresponds one-to-one to the multiple processors, each record information is used to record the performance indicator of the corresponding processor, and the target information includes at least one of the record information.
[0091] Optionally, the first acquisition module 401 includes:
[0092] A first acquisition submodule, configured to traverse each of the container records through each of the processors, and acquire record information corresponding to the processor from each of the container records;
[0093] The determination submodule is used to determine the target information according to the plurality of record information.
[0094] Optionally, the first acquisition submodule is specifically used to:
[0095] Each of the container records is traversed by a work queue running on each of the processors, and record information corresponding to the processor is obtained from each of the container records.
[0096] Optionally, the determining submodule is specifically used to:
[0097] The record information is formatted to obtain formatted information, where the formatted information includes an identifier of a container record to which the record information belongs, an identifier of a processor corresponding to the record information, and a performance indicator recorded in the record information.
[0098] Optionally, the device further comprises:
[0099] A second acquisition module, configured to group the target information according to the identifier of the container record to obtain at least one group, each group corresponding to a container;
[0100] The first determination module is used to determine the processor for scheduling the container according to the sum of the performance indicators in the same group.
[0101] Optionally, the device further comprises:
[0102] The first creation module is used to create the corresponding container record for the container when creating a container.
[0103] Optionally, the device further comprises:
[0104] A third acquisition module, used for acquiring a current first performance indicator of a processor into which the process is switched when the process is switched;
[0105] A fourth acquisition module, used for acquiring a current second performance indicator of the processor when the process is switched out;
[0106] The first storage module is used to store the difference between the first performance indicator and the second performance indicator in a container record corresponding to the process.
[0107] Optionally, the device further comprises:
[0108] The destroying module is used to export each record information in the container record corresponding to the container and release the memory occupied by the container record when the container is destroyed.
[0109] Optionally, the device further comprises:
[0110] The initialization module is used to initialize a memory pool and a tree structure in the kernel, wherein the memory pool is used to allocate the memory required for the container record, the tree structure is used to store the container record, and the key of the tree structure is a pointer to the container.
[0111] Optionally, the device further comprises:
[0112] The second creation module is used to create a work queue on each of the processors, and the work queue is used to export the performance monitor unit PMU data stored on the processor in each container record from the kernel.
[0113] Optionally, the device further comprises:
[0114] The third creation module is used to create a PMU event on each of the processors, and the PMU event is used to generate PMU data.
[0115] Optionally, the device further comprises:
[0116] A fourth creation module, used for traversing all existing containers and creating the container record for each container;
[0117] The first adding module is used to add the container record into the tree structure.
[0118] Optionally, the device further comprises:
[0119] The second adding module is used to add a first hook function in the creation function of creating the container, wherein the first hook function is used to create a container record corresponding to the container and add the container record to the tree structure.
[0120] Optionally, the device further comprises:
[0121] The third adding module is used to add a second hook function in the destruction function of destroying the container, and the second hook function is used to force the export of all PMU data in the container record corresponding to the container, remove the container record from the tree structure and release the memory of the container record.
[0122] Optionally, the device further comprises:
[0123] A fifth acquisition module, used to acquire a current first PMU data value of the first processor;
[0124] A second determination module is used to determine a container where the process running on the first processor is located, and obtain a first container record of the container;
[0125] The second storage module is used to save the first PMU data value into the first field of the data structure corresponding to the first processor in the first container record.
[0126] Optionally, the device further comprises:
[0127] A sixth acquisition module, used to acquire a current second PMU data value of the first processor;
[0128] a seventh acquisition module, configured to subtract a value in a first field of a data structure corresponding to the first processor in the first container record from the second PMU data value to obtain a difference;
[0129] The third storage module is used to accumulate the difference into the value of the second field of the data structure.
[0130] Example Vehicles
[0131] Figure 5 is a block diagram of a vehicle 800 according to an exemplary embodiment. The vehicle 800 may be a fuel vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle or other types of vehicles.
[0132] Reference Figure 5 The vehicle 800 may include multiple subsystems, for example, a driving system 810, a control system 820, a perception system 830, a communication system 840, an information display system 850, and a computing system 860. The vehicle 800 may also include more or fewer subsystems, and each subsystem may also include multiple components, which are not described one by one here.
[0133] The driving system 810 includes components that provide power movement for the vehicle 800, such as an engine, an energy source, a transmission device, etc.
[0134] The control system 820 includes components that provide control for the vehicle 800, such as vehicle control, cockpit equipment control, and driving assistance control.
[0135] The perception system 830 includes components that provide the vehicle 800 with surrounding environment perception, such as a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, a camera device, and the like.
[0136] The communication system 840 includes components that provide communication connections for the vehicle 800, such as mobile communication networks (such as 3G, 4G, 5G networks, etc.), WiFi, Bluetooth, and Internet of Vehicles.
[0137] The information display system 850 includes components that provide various information displays for the vehicle 800, such as vehicle information display, navigation information display, entertainment information display, etc.
[0138] The computing and processing system 860 includes components that provide data computing and processing capabilities for the vehicle 800. The computing and processing system 860 may include at least one processor 861 and a memory 862. The processor 861 may execute instructions stored in the memory 862.
[0139] The processor 861 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.
[0140] Memory 862 can be implemented 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.
[0141] In the embodiment of the present disclosure, a set of instruction sets is stored in the memory 862, and the processor 861 can execute the instruction set to implement all or part of the steps of the multi-processor performance indicator acquisition method described in any of the above exemplary embodiments.
[0142] Exemplary Electronic Devices
[0143] Figure 6 1 is a block diagram of an electronic device 900 according to an exemplary embodiment. The electronic device 900 may be a vehicle controller, a vehicle terminal, a vehicle computer or other types of electronic devices.
[0144] Reference Figure 6 , the electronic device 900 may include at least one processor 910 and a memory 920. The processor 910 may execute instructions stored in the memory 920. The processor 910 is communicatively connected to the memory 920 via a data bus. In addition to the memory 920, the processor 910 may also be communicatively connected to an input device 930, an output device 940, and a communication device 950 via a data bus.
[0145] The processor 910 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.
[0146] The memory 920 may be implemented by any type of volatile or nonvolatile 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.
[0147] In an embodiment of the present disclosure, executable instructions are stored in the memory 920, and the processor 910 can read the executable instructions from the memory 920 and execute the instructions to implement all or part of the steps of the multi-processor performance indicator acquisition method described in any of the above exemplary embodiments.
[0148] Exemplary computer-readable storage media
[0149] In addition to the above methods and devices, the exemplary embodiments of the present disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in any method in the above exemplary embodiments.
[0150] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., as well as conventional procedural programming languages such as "C" or similar programming languages and scripting languages (e.g., Python). The program code may be executed entirely on the user computing device, partially on the user computing device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0151] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of readable storage media include: a static random access memory (SRAM) with one or more wires electrically connected, an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic storage, a flash memory, a magnetic disk or an optical disk, or any suitable combination of the above.
[0152] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0153] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for obtaining multi-processor performance indicators, characterized in that: include: Acquire target information from a plurality of container records, wherein each of the container records corresponds to a container, the container record is a data structure for recording container information, each container record includes a plurality of record information, the plurality of record information corresponds one-to-one to a plurality of processors, each of the record information is used to record a performance indicator of a corresponding processor, the target information includes at least one of the record information, and the container record is stored in a kernel state; The performance indicator includes PMU data, and the performance indicator acquisition of the processor includes: Creating a PMU event on each of the processors, wherein the PMU event is used to generate PMU data; When a process is switched in, a current first performance indicator of a processor into which the process is switched in is obtained through the PMU; When the process is switched out, obtaining a current second performance indicator of the processor through the PMU; storing a difference between the first performance indicator and the second performance indicator in a container record corresponding to the process; In the kernel state, a work queue processing function is scheduled to run on each processor. The work queue processing function is used to traverse all container records in the system and format the PMU data corresponding to the current processor, and copy the target information in the container record to a buffer. The buffer is used to transfer data between the kernel state and the user state.
2. The method according to claim 1, characterized in that Before the step of acquiring target information from a plurality of container records, the method further comprises: When a container is created, creating a corresponding container record for the container; The obtaining target information from the plurality of container records includes: Traversing each of the container records through each of the processors, and obtaining record information corresponding to the processor from each of the container records; When a container is destroyed, each record information in the container record corresponding to the container is exported, and the memory occupied by the container record is released; The target information is determined based on the plurality of record information.
3. The method according to claim 2, characterized in that When the container is created, creating the corresponding container record for the container includes: Adding a first hook function in a creation function for creating the container, wherein the first hook function is used to create a container record corresponding to the container, thereby realizing creation of the corresponding container record for the container; When the container is destroyed, each record information in the container record corresponding to the container is exported, and the memory occupied by the container record is released, including: Adding a second hook function in the destruction function of the container, wherein the second hook function is used to forcibly export all record information in the container record corresponding to the container, remove the container record and release the memory of the container record; The step of traversing each container record through each processor and obtaining record information corresponding to the processor from each container record includes: Each container record is traversed by a work queue running on each processor, and record information corresponding to the processor is obtained from each container record.
4. The method according to claim 2, characterized in that: The step of determining the target information according to the plurality of recorded information comprises: Formatting the record information to obtain formatted information, where the formatted information includes an identifier of a container record to which the record information belongs, an identifier of a processor corresponding to the record information, and a performance indicator recorded in the record information; The formatted information is copied to a buffer, and then the corresponding record information is cleared.
5. The method according to claim 1, characterized in that After the step of acquiring target information from a plurality of container records, the method further comprises: Grouping the target information according to the identifier of the container record to obtain at least one group, each group corresponding to a container; A processor for scheduling the container is determined according to the sum of the performance indicators in the same group.
6. The method according to claim 1, characterized in that Before the step of acquiring target information from a plurality of container records, the method further comprises: When a container is created, a corresponding container record is created for the container. The container record is deleted when the container is destroyed. The container record is updated when the kernel performs a process switch. By utilizing parallel programming technology, no locking is required during the process of updating the container record and obtaining PMU data from the container record.
7. A device for acquiring multi-processor performance indicators, characterized in that: include: A first acquisition module is used to acquire target information from a plurality of container records, wherein each of the container records corresponds to a container, the container record is a data structure for recording container information, each container record includes a plurality of record information, the plurality of record information corresponds to a plurality of processors one-to-one, each of the record information is used to record a performance indicator of a corresponding processor, the target information includes at least one of the record information, and the container record is stored in a kernel state; The performance indicator includes PMU data, and the performance indicator acquisition of the processor includes: Creating a PMU event on each of the processors, wherein the PMU event is used to generate PMU data; When a process is switched in, a current first performance indicator of a processor into which the process is switched in is obtained through the PMU; When the process is switched out, obtaining a current second performance indicator of the processor through the PMU; storing a difference between the first performance indicator and the second performance indicator in a container record corresponding to the process; In the kernel state, a work queue processing function is scheduled to run on each processor. The work queue processing function is used to traverse all container records in the system and format the PMU data corresponding to the current processor, and copy the target information in the container record to a buffer. The buffer is used to transfer data between the kernel state and the user state.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the multi-processor performance indicator acquisition method described in any one of claims 1-6.
9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method for obtaining multi-processor performance indicators described in any one of claims 1-6 are implemented.
10. A vehicle, characterized in that: A set of instruction sets is stored, and the instruction sets are executed by the vehicle to implement the multi-processor performance indicator acquisition method described in any one of claims 1-6.
