CN102855171A - Consumer price index (CPI) real-time monitoring method based on linux system - Google Patents

Consumer price index (CPI) real-time monitoring method based on linux system Download PDF

Info

Publication number
CN102855171A
CN102855171A CN2012102819600A CN201210281960A CN102855171A CN 102855171 A CN102855171 A CN 102855171A CN 2012102819600 A CN2012102819600 A CN 2012102819600A CN 201210281960 A CN201210281960 A CN 201210281960A CN 102855171 A CN102855171 A CN 102855171A
Authority
CN
China
Prior art keywords
event
perf
cpu
pperf
cpuid
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2012102819600A
Other languages
Chinese (zh)
Inventor
刘斐然
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN2012102819600A priority Critical patent/CN102855171A/en
Publication of CN102855171A publication Critical patent/CN102855171A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a consumer price index (CPI) real-time monitoring method based on a linux system. The method comprises the following steps of: calling a sys-perf-event-open system provided by utilizing linux, reading the performance management unit (PMU) contents of a central processing unit (CPU), acquiring the real-time CPU period and execution instruction number, and calculating the real-time CPI of the system. According to the method, the defects of the previous system performance monitoring system in micro-architecture monitoring aspects are overcome, each CPU in the system can be accurately monitored in real time, and the CPI data is calculated. The method can be used for timely and accurately judging the real performance exerted by the system and can reflect the advantages of an application program from the side in the field of high-performance servers.

Description

A kind of method of the CPI Real-Time Monitoring based on the linux system
Technical field
The present invention relates to the CPU framework, C language, and the technical field such as linux programming, specifically a kind of method of the CPI Real-Time Monitoring based on the linux system.
Background technology
Along with the development that high-performance server is used, increasing people begin to note that the performance of micro-architecture aspect is on using the impact of performance.Wherein CPI is an important indicator of micro-architecture aspect, but nearly all monitoring tool all can't this content of Real-Time Monitoring at present.
Summary of the invention
The sys_perf_event_open system call that the objective of the invention is to utilize the linux kernel to provide realizes the CPI method of real-time based on the linux system.
The objective of the invention is to realize in the following manner, based on the linux platform, cpu cycle by PMU among every CPU in the reading system and carry out the related content such as instruction number, real-time calculate entire system CPI value and export, performing step is as follows:
1) packing sys_perf_event_open system call:
static?int?perf_event_open(struct?perf_event_attr?*hw_event_uptr,
pid_t?pid,?int?cpu,?int?group_fd,?unsigned?long?flags)?{
return?syscall(__NR_perf_event_open,?hw_event_uptr,?pid,?cpu,?group_fd,flags);
}
2) statistical system CPU number:
int?cpu_num?=?sysconf(_SC_NPROCESSORS_ONLN);
3) generate the perf_event array:
static?int?event_num=2;
static?int?event[2]={\
PERF_COUNT_HW_CPU_CYCLES,
PERF_COUNT_HW_INSTRUCTIONS\
};
4) generate a group for each CPU:
for(i=0;i<cpu_num;i++){
_perf_event_open(i);
ioctl(pperf_fd[i][0],?PERF_EVENT_IOC_ENABLE,?0);
}
Wherein _ and the perf_event_open function of perf_event_open function for packing, be specially:
static?void?_perf_event_open(int?cpuid)?{
int?i;
struct?perf_event_attr?pe;
memset(&pe,0,sizeof(struct?perf_event_attr));
pe.type?=?PERF_TYPE_HARDWARE;
pe.size?=?sizeof(struct?perf_event_attr);
pe.config?=?event[0];
pe.exclude_kernel=1;
pe.exclude_hv=1;
pe.read_format=PERF_FORMAT_GROUP|PERF_FORMAT_ID;
pe.disabled?=?1;
pperf_fd[cpuid][0]?=?perf_event_open(&pe,?-1,?cpuid,?-1,?0);
if?(pperf_fd[cpuid][0]?>=?0)
for(i=1;i<event_num;i++)
{
pe.config?=?event[i];
pe.disabled?=?0;
pperf_fd[cpuid][i]=?perf_event_open(&pe,?-1,?cpuid,pperf_fd[cpuid][0],?0);
}
return;
}
5) read PMU numerical value and export whole CPI:
for(i=0;i<sys_info.cpu_num;i++){
read(pperf_fd[i][0],?&rf,?sizeof(rf));
pperf_clean(i);
t_c+=?rf.cr[0].value;
t_i+=?rf.cr[1].value;
printf("%f?",(float)rf.cr[0].value/(float)rf.cr[1].value);
}
printf("%f\n",t_c/t_i);
Wherein pperf_clean is the PMU counter that empties corresponding CPU.Specific as follows:
static?inline?void?pperf_clean(cpuid)
{
int?i;
for?(i=0;i<event_num;i++)
{
ioctl(pperf_fd[cpuid][i],?PERF_EVENT_IOC_RESET,?0);
}
}
6) empty the value of t_c and t_i, wait for one second, and continue to read its value.
Major part to this native system is finished substantially.
The invention has the beneficial effects as follows: the content that traditional system performance monitoring system can not monitoring system micro-architecture aspect, but along with the adding that has comprised sys_perf_event_open function in PMU and the linux kernel in the CPU makes it become possibility.The present invention has overcome the in the past deficiency of system performance monitoring system aspect the micro-architecture monitoring, can accomplish in real time accurately each CPU in the supervisory system, and calculate its CPI data.In the high-performance server field, this method can be used for the actual performance of judgement system performance promptly and accurately and the quality that can reflect from the side a application program.
Description of drawings
Fig. 1 is system flowchart.
Embodiment
Explain below with reference to Figure of description method of the present invention being done.
Based on the linux platform, cpu cycle by PMU among every CPU in the reading system and carry out the related content such as instruction number, real-time calculate entire system CPI value and export, performing step is as follows:
1) packing sys_perf_event_open system call:
static?int?perf_event_open(struct?perf_event_attr?*hw_event_uptr,
pid_t?pid,?int?cpu,?int?group_fd,?unsigned?long?flags)?{
return?syscall(__NR_perf_event_open,?hw_event_uptr,?pid,?cpu,?group_fd,flags);
}
2) statistical system CPU number:
int?cpu_num?=?sysconf(_SC_NPROCESSORS_ONLN);
3) generate the perf_event array:
static?int?event_num=2;
static?int?event[2]={\
PERF_COUNT_HW_CPU_CYCLES,
PERF_COUNT_HW_INSTRUCTIONS\
};
4) generate a group for each CPU:
for(i=0;i<cpu_num;i++){
_perf_event_open(i);
ioctl(pperf_fd[i][0],?PERF_EVENT_IOC_ENABLE,?0);
}
Wherein _ and the perf_event_open function of perf_event_open function for packing, be specially:
static?void?_perf_event_open(int?cpuid)?{
int?i;
struct?perf_event_attr?pe;
memset(&pe,0,sizeof(struct?perf_event_attr));
pe.type?=?PERF_TYPE_HARDWARE;
pe.size?=?sizeof(struct?perf_event_attr);
pe.config?=?event[0];
pe.exclude_kernel=1;
pe.exclude_hv=1;
pe.read_format=PERF_FORMAT_GROUP|PERF_FORMAT_ID;
pe.disabled?=?1;
pperf_fd[cpuid][0]?=?perf_event_open(&pe,?-1,?cpuid,?-1,?0);
if?(pperf_fd[cpuid][0]?>=?0)
for(i=1;i<event_num;i++)
{
pe.config?=?event[i];
pe.disabled?=?0;
pperf_fd[cpuid][i]=?perf_event_open(&pe,?-1,?cpuid,pperf_fd[cpuid][0],?0);
}
return;
}
5) read PMU numerical value and export whole CPI:
for(i=0;i<sys_info.cpu_num;i++){
read(pperf_fd[i][0],?&rf,?sizeof(rf));
pperf_clean(i);
t_c+=?rf.cr[0].value;
t_i+=?rf.cr[1].value;
printf("%f?",(float)rf.cr[0].value/(float)rf.cr[1].value);
}
printf("%f\n",t_c/t_i);
Wherein pperf_clean is the PMU counter that empties corresponding CPU.Specific as follows:
static?inline?void?pperf_clean(cpuid)
{
int?i;
for?(i=0;i<event_num;i++)
{
ioctl(pperf_fd[cpuid][i],?PERF_EVENT_IOC_RESET,?0);
}
}
6) empty the value of t_c and t_i, wait for one second, and continue to read its value.
Except the described technical characterictic of instructions, be the known technology of those skilled in the art.

Claims (1)

1. method based on the CPI Real-Time Monitoring of linux system is characterized in that the cpu cycle by PMU among every CPU in the reading system and carries out the related content such as instruction number, real-time calculate entire system CPI value and exports, and the specific implementation step is as follows:
Packing sys_perf_event_open system call:
static?int?perf_event_open(struct?perf_event_attr?*hw_event_uptr,
pid_t?pid,?int?cpu,?int?group_fd,?unsigned?long?flags)?{
return?syscall(__NR_perf_event_open,?hw_event_uptr,?pid,?cpu,?group_fd,flags);
}
Statistical system CPU number:
int?cpu_num?=?sysconf(_SC_NPROCESSORS_ONLN);
Generate the perf_event array:
static?int?event_num=2;
static?int?event[2]={\
PERF_COUNT_HW_CPU_CYCLES,
PERF_COUNT_HW_INSTRUCTIONS\
};
4) generate a group for each CPU:
for(i=0;i<cpu_num;i++){
_perf_event_open(i);
ioctl(pperf_fd[i][0],?PERF_EVENT_IOC_ENABLE,?0);
}
Wherein _ and the perf_event_open function of perf_event_open function for packing, be specially:
static?void?_perf_event_open(int?cpuid)?{
int?i;
struct?perf_event_attr?pe;
memset(&pe,0,sizeof(struct?perf_event_attr));
pe.type?=?PERF_TYPE_HARDWARE;
pe.size?=?sizeof(struct?perf_event_attr);
pe.config?=?event[0];
pe.exclude_kernel=1;
pe.exclude_hv=1;
pe.read_format=PERF_FORMAT_GROUP|PERF_FORMAT_ID;
pe.disabled?=?1;
pperf_fd[cpuid][0]?=?perf_event_open(&pe,?-1,?cpuid,?-1,?0);
if?(pperf_fd[cpuid][0]?>=?0)
for(i=1;i<event_num;i++)
{
pe.config?=?event[i];
pe.disabled?=?0;
pperf_fd[cpuid][i]=?perf_event_open(&pe,?-1,?cpuid,pperf_fd[cpuid][0],?0);
}
return;
}
Read PMU numerical value and export whole CPI:
for(i=0;i<sys_info.cpu_num;i++){
read(pperf_fd[i][0],?&rf,?sizeof(rf));
pperf_clean(i);
t_c+=?rf.cr[0].value;
t_i+=?rf.cr[1].value;
printf("%f?",(float)rf.cr[0].value/(float)rf.cr[1].value);
}
printf("%f\n",t_c/t_i);
Wherein pperf_clean is the PMU counter that empties corresponding CPU;
Specific as follows:
static?inline?void?pperf_clean(cpuid)
{
int?i;
for?(i=0;i<event_num;i++)
{
ioctl(pperf_fd[cpuid][i],?PERF_EVENT_IOC_RESET,?0);
}
}
6) empty the value of t_c and t_i, wait for one second, and continue to read its value;
Major part to this native system is finished substantially.
CN2012102819600A 2012-08-09 2012-08-09 Consumer price index (CPI) real-time monitoring method based on linux system Pending CN102855171A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012102819600A CN102855171A (en) 2012-08-09 2012-08-09 Consumer price index (CPI) real-time monitoring method based on linux system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012102819600A CN102855171A (en) 2012-08-09 2012-08-09 Consumer price index (CPI) real-time monitoring method based on linux system

Publications (1)

Publication Number Publication Date
CN102855171A true CN102855171A (en) 2013-01-02

Family

ID=47401775

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012102819600A Pending CN102855171A (en) 2012-08-09 2012-08-09 Consumer price index (CPI) real-time monitoring method based on linux system

Country Status (1)

Country Link
CN (1) CN102855171A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI552002B (en) * 2014-04-22 2016-10-01 財團法人工業技術研究院 Method and system for dynamic instance deployment of public cloud
CN106155865A (en) * 2016-08-01 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of CPI acquisition methods, system and process performance judgement system in real time

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005135333A (en) * 2003-10-31 2005-05-26 Canon Inc Program monitoring device, program monitoring method, program, storage medium, and information acquisition system
CN1684043A (en) * 2004-04-15 2005-10-19 深圳创维-Rgb电子有限公司 Real time monitoring system and method for computer files

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005135333A (en) * 2003-10-31 2005-05-26 Canon Inc Program monitoring device, program monitoring method, program, storage medium, and information acquisition system
CN1684043A (en) * 2004-04-15 2005-10-19 深圳创维-Rgb电子有限公司 Real time monitoring system and method for computer files

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐恒阳等: "Perf在龙芯2F上的设计与实现", 《计算机工程》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI552002B (en) * 2014-04-22 2016-10-01 財團法人工業技術研究院 Method and system for dynamic instance deployment of public cloud
CN106155865A (en) * 2016-08-01 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of CPI acquisition methods, system and process performance judgement system in real time

Similar Documents

Publication Publication Date Title
Colmant et al. Process-level power estimation in vm-based systems
Capra et al. Is software “green”? Application development environments and energy efficiency in open source applications
Bohra et al. VMeter: Power modelling for virtualized clouds
Podzimek et al. Analyzing the impact of cpu pinning and partial cpu loads on performance and energy efficiency
CN112088365A (en) Quantifying the use of different computing resources into a single measurement unit
CN102073535B (en) Hardware counter virtualization-based performance analysis method for multiple virtual machines
Souza et al. Ecovisor: A virtual energy system for carbon-efficient applications
CN101986280A (en) Automatic testing platform for virtual computing system
Benedict Energy-aware performance analysis methodologies for HPC architectures—An exploratory study
CN102722434A (en) Performance test method and tool aiming at Linux process scheduling
CN102629207A (en) Method for running instance time-sharing update under multi-tenant condition
US10158725B2 (en) Differentiated service identification in a networked computing environment
US20110138389A1 (en) Obtaining application performance data for different performance events via a unified channel
CN103955398A (en) Virtual machine coexisting scheduling method based on processor performance monitoring
Khan et al. Metric based testability model for object oriented design (MTMOOD)
Quesnel et al. Estimating the power consumption of an idle virtual machine
Tanaka et al. Improvement of software process by process description and benefit estimation
CN102855171A (en) Consumer price index (CPI) real-time monitoring method based on linux system
Masek et al. Systematic evaluation of sandboxed software deployment for real-time software on the example of a self-driving heavy vehicle
Wen et al. System power model and virtual machine power metering for cloud computing pricing
CN110322153A (en) Monitor event processing method and system
US9195524B1 (en) Hardware support for performance analysis
Peng et al. A low-cost power measuring technique for virtual machine in cloud environments
Larysch Fine-grained estimation of memory bandwidth utilization
Snee et al. Soroban: attributing latency in virtualized environments

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20130102