Skip to content

Commit 4bc6a46

Browse files
committed
PMCTrack v2.0
1 parent 179be0e commit 4bc6a46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6015
-612
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
PMCTrack is an open-source OS-oriented performance monitoring tool for GNU/Linux. This performance tool has been specifically designed to aid kernel developers in implementing scheduling algorithms in Linux that leverage data from performance monitoring counters (PMCs) to perform optimizations at run time. Unlike other monitoring tools, PMCTrack features and in-kernel API enabling the OS scheduler to access per-thread PMC data in an architecture-independent fashion.
1+
PMCTrack is an open-source OS-oriented performance monitoring tool for GNU/Linux. This performance tool has been specifically designed to aid kernel developers in implementing scheduling algorithms or resource-management strategies on Linux that leverage data from performance monitoring counters (PMCs) to perform optimizations at run time. Unlike other monitoring tools, PMCTrack features and in-kernel API enabling the OS to access per-thread PMC data in an architecture-independent fashion.
22

3-
Despite being an OS-oriented tool, PMCTrack still allows gathering PMC values from user space, enabling kernel developers to carry out the necessary offline analysis and debugging to assist them during the scheduler design process. In addition, the tool provides both the scheduler and the userspace PMCTrack components with other insightful metrics available in modern processors that are not directly exposed as PMCs, such as cache occupancy or energy consumption.
3+
Despite being an OS-oriented tool, PMCTrack still allows the gathering of PMC values from user space, enabling kernel developers to carry out the necessary offline analysis and debugging to assist them during the OS-level design process. In addition, the tool provides both the OS and the userspace PMCTrack components with other insightful metrics available in modern processors that are not directly exposed as PMCs, such as cache occupancy or energy consumption.
44

55
[![Analytics](https://ga-beacon.appspot.com/UA-76163836-1/github-pmctrack/readme)](http://pmctrack.dacya.ucm.es)
66

77
## Project Contributors
88

99
* Juan Carlos Saez Alcaide (<jcsaezal@ucm.es>) - Creator of PMCTrack and main maintainer
1010
* Adrián García García (aka [@Mizadri](https://github.com/mizadri))
11+
* Lazaro Clemen Palafox (aka <lazarocl@ucm.es>)
1112
* Jaime Sáez de Buruaga Brouns (aka [@jaimesaez97](https://github.com/jaimesaez97))
1213

1314
## Past Contributors
@@ -28,10 +29,16 @@ Despite being an OS-oriented tool, PMCTrack still allows gathering PMC values fr
2829

2930
## System requirements
3031

31-
To support PMCTrack, a patched Linux kernel must be installed on the machine. A number of kernel patches for various Linux versions can be found in the `src/kernel-patches` directory. The name of each patch file encodes the Linux kernel version where the patch must be applied to as well as the processor architecture supported. The format is as follows:
32+
Starting from version v2.0, PMCTrack works with vanilla Linux kernels, and, in this case, Linux kernel v5.9.x and above are highly recommended to enjoy the full functionality of the tool. For earlier versions of PMCTrack, a patched Linux kernel must be installed on the machine. A number of kernel patches for various Linux versions can be found in the `src/kernel-patches` directory. The name of each patch file encodes the Linux kernel version where the patch must be applied to as well as the processor architecture supported. The format is as follows:
3233

3334
pmctrack_linux-<kernel_version>_<architecture>.patch
3435

36+
To apply the patch run the following command from the root directory of the kernel sources:
37+
38+
```
39+
patch -p1 < <path_to_patch_file>
40+
```
41+
3542
To build the kernel for PMCTrack, the following option must be enabled when configuring the kernel:
3643

3744
CONFIG_PMCTRACK=y
@@ -48,9 +55,9 @@ We also created PMCTrack-GUI, a Python front-end for the `pmctrack` command-line
4855
* sshpass (command)
4956
* WxPython v3.0
5057

51-
On Debian or Ubuntu the necessary software can be installed as follows:
58+
On Debian or Ubuntu the necessary software to run PMCTrack-GUI can be installed as follows:
5259

53-
$ sudo apt-get install python2.7 python-matplotlib python-wxgtk3.0 sshpass
60+
$ sudo apt install python2.7 python-matplotlib python-wxgtk3.0 sshpass
5461

5562
On Mac OS X, PMCTrack-GUI has been succesfully tested after installing the above software dependencies using MacPorts as follows:
5663

@@ -68,7 +75,7 @@ On Mac OS X, PMCTrack-GUI has been succesfully tested after installing the above
6875

6976
## Building PMCTrack from source for ARM and x86 processors
7077

71-
The `PMCTRACK_ROOT` environment variable must be defined for a successful execution of the various PMCTrack command-line tools. The `shrc` script found in the repository's root directory can be used to set the `PMCTRACK_ROOT` variable appropriately as well as to add command-line tools' directories to the PATH. To make this possible, run the following command in the root directory of the repository:
78+
Before building PMCTrack make sure a compatible kernel is running (it must be a patched one for PMCTrack versions earlier than 2.0!), and the associated kernel header files are installed on the system. The `PMCTRACK_ROOT` environment variable must be defined for a successful execution of the various PMCTrack command-line tools. The `shrc` script found in the repository's root directory can be used to set the `PMCTRACK_ROOT` variable appropriately as well as to add command-line tools' directories to the PATH. To make this possible, run the following command in the root directory of the repository:
7279

7380
$ . shrc
7481

@@ -187,7 +194,7 @@ The following table summarizes the properties of the various flavors of the kern
187194
| arm64 | `src/modules/pmcs/arm64/mchw_arm64.ko` | This module has been successfully tested on ARM systems featuring 64-bit big.LITTLE processors, which combine ARM Cortex A57 cores with and ARM Cortex A53 cores. Specifically, tests were performed on the ARM Juno Development Board. |
188195
| xeon-phi | `src/modules/pmcs/xeon-phi/mchw_phi.ko` | Intel Xeon Phi Coprocessor |
189196
| core2 | `src/modules/pmcs/phi/mchw_core2.ko` | This module has been specifically designed for the Intel QuickIA prototype system. The Intel QuickIA is a dual-socket asymmetric multicore system that features a quad-core Intel Xeon E5450 processor and a dual-core Intel Atom N330. The module also works with Intel Atom processors as well as "old" Intel multicore processors, such as the Intel Core 2 Duo. Nevertheless, given the numerous existing hacks for the QuickIA in this module, users are advised to use the more general "intel-core" flavor. |
190-
| perf | `src/modules/pmcs/perf/mchw_perf.ko` | Experimental backend that uses Perf Events's kernel API to access performance monitoring counters |
197+
| perf | `src/modules/pmcs/perf/mchw_perf.ko` | Backend that uses Perf Events's kernel API to access performance monitoring counters. It currently works for Intel, AMD, ARMv7 and ARMv8 processors, only. |
191198

192199

193200
Once the most suitable kernel model for the system has been identified, the module can be loaded in the running PMCTrack-enabled kernel as follows:

bin/pmctrack-manager

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,31 @@ function figure_out_kernel_HZ_setting(){
106106
function update_compatible_modules(){
107107
local vendor_str=$1
108108
local bitw=$2
109-
if [ "$vendor_str" == "Intel" ]; then
109+
110+
grep 'CONFIG_PMCTRACK=y' /boot/config-$(uname -r)
111+
patched_kernel=$?
112+
113+
if [ "$FORCE_LEGACY" != "yes" ] && [ ${patched_kernel} -ne 0 ]; then
114+
compatible_modules=(perf)
115+
module_names=(mchw_perf)
116+
elif [ "$vendor_str" == "Intel" ]; then
110117
compatible_modules=(intel-core core2 perf)
111118
module_names=(mchw_intel_core mchw_core2 mchw_perf)
112119
elif [ "$vendor_str" == "AMD" ]; then
113-
compatible_modules=(amd)
114-
module_names=(mchw_amd.ko)
120+
compatible_modules=(amd perf)
121+
module_names=(mchw_amd.ko mchw_perf)
115122
else # ARM
116123
if [ $bitw -eq 32 ]; then
117124
if [ "$ODROID" == "yes" ]; then
118-
compatible_modules=(odroid-xu)
119-
module_names=(mchw_odroid_xu)
125+
compatible_modules=(odroid-xu perf)
126+
module_names=(mchw_odroid_xu mchw_perf)
120127
else
121-
compatible_modules=(arm odroid-xu)
122-
module_names=(mchw_arm mchw_odroid_xu)
128+
compatible_modules=(arm odroid-xu perf)
129+
module_names=(mchw_arm mchw_odroid_xu mchw_perf)
123130
fi
124131
else
125-
compatible_modules=(arm64)
126-
module_names=(mchw_arm64)
132+
compatible_modules=(arm64 perf)
133+
module_names=(mchw_arm64 mchw_perf)
127134
fi
128135
fi
129136
}
@@ -300,8 +307,8 @@ function do_clean(){
300307
i=0
301308
for module in ${compatible_modules[*]}
302309
do
303-
modname=${module_names[$i]}
304-
dir_module="${PMCTRACK_ROOT}/src/modules/pmcs/${module}"
310+
modname="${module_names[$i]}.ko"
311+
dir_module="${PMCTRACK_ROOT}/src/modules/pmcs/${module}"
305312

306313
if [ ! -d ${dir_module} ]; then
307314
echo "Module directory not found in the source tree: ${dir_module}"

etc/events/armv7.cortex_a7.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ bus_accesses,-,0x19,-,-
2222
data_mem_access,-,0x13,-,-
2323
instr_cache_access,-,0x14,-,-
2424
data_cache_eviction,-,0x15,-,-
25+
a7_cycles,-,0x11,-,pmu=6
26+
a7_instr,-,0x8,-,pmu=6
27+
a7_instr_arch_executed,-,0x8,-,pmu=6
28+
a7_l2_cache_accesses,-,0x16,-,pmu=6
29+
a7_l2_cache_refills,-,0x17,-,pmu=6
30+
a7_l2_cache_writebacks,-,0x18,-,pmu=6
31+
a7_l1_data_refills,-,0x03,-,pmu=6
32+
a7_l1_data_accesses,-,0x04,-,pmu=6
33+
a7_llc_accesses,-,0x16,-,pmu=6
34+
a7_llc_misses,-,0x17,-,pmu=6
35+

etc/events/x86_amd.epyc.csv

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
event_name,subevent_name,event_code,description,flags
2+
instr_retired,-,0xc0,-,-
3+
uops_retired,-,0xc1,-,-
4+
unhalted_core_cycles,-,0x76,-,-
5+
instr,-,0xc0,-,-
6+
cycles,-,0x76,-,-
7+
instr_retired,-,0xc0,-,-
8+
branch_instr_retired,-,0xc2,-,-
9+
branch_misses_retired,-,0xc3,-,-
10+
cache_misses,-,0x64,-,-,umask=0x09
11+
cache_accesses,-,0x60,-,umask=0xff
12+
stalled_cycles_frontend,-,0x87,-,umask=0x02
13+
stalled_cycles_backend,-,0x87,-,umask=0x01
14+
l2_cache_accesses,dc_misses,0x60,-,umask=0xc8
15+
l2_cache_misses,dc_misses,0x64,-,umask=0xc8
16+
l2_pf_miss_l2_hit_l3,-,0x71,-,umask=0xff
17+
l2_pf_miss_l2_l3,-,0x72,-,umask=0xff
18+
l3_misses_core0,-,0x030f000000000106,-,pmu=9;systemwide
19+
l3_misses_core1,-,0x0c0f000000000106,-,pmu=9;systemwide
20+
l3_misses_core2,-,0x300f000000000106,-,pmu=9;systemwide
21+
l3_misses_core3,-,0xc00f000000000106,-,pmu=9;systemwide=1
22+
l3_accesses_core0,-,0x030f000000008001,-,pmu=9;systemwide
23+
l3_accesses_core1,-,0x0c0f000000008001,-,pmu=9;systemwide
24+
l3_accesses_core2,-,0x300f000000008001,-,pmu=9;systemwide
25+
l3_accesses_core3,-,0xc00f000000008001,-,pmu=9;systemwide

etc/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5
1+
2.0

src/cmdtools/pmctrack/pmctrack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,9 @@ void sigchld_handler(int signo)
10951095

10961096
void sigint_handler(int signo)
10971097
{
1098-
if (kill(pid,SIGTERM))
1099-
fprintf(stderr,"Could not send signal %d to PID %d\n",signo,pid);
1098+
if (pid>0)
1099+
if (kill(pid,SIGTERM))
1100+
fprintf(stderr,"Could not send signal %d to PID %d\n",signo,pid);
11001101

11011102
/* Finish immediately */
11021103
stop_profiling=1;

src/lib/libpmctrack/include/pmctrack_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ int pmct_syswide_start_counting( void );
293293

294294
#define MAX_CORE_TYPES 2
295295
#define NAME_HW_EVENT_SIZE 50
296-
#define CODE_HW_EVENT_SIZE 10
296+
#define CODE_HW_EVENT_SIZE 22
297297
#define NAME_KEY_PMC_PROPERTY_SIZE 30
298298
#define VALUE_PMC_PROPERTY_SIZE 50
299299
#define MAX_NR_PROPERTIES 10

src/lib/libpmctrack/src/pmu_info.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ static int parse_csv_file(pmu_info_t *pmu_info)
175175
strcpy(hw_subevt->name, subevt_name);
176176
hw_subevt->nr_properties = 0;
177177

178+
/* Remove linebreak */
179+
if (flags && flags[strlen(flags)-1]=='\n')
180+
flags[strlen(flags)-1]='\0';
181+
178182
while((flag = strsep(&flags, ";")) != NULL) {
179183
key = strsep(&flag, "=");
180184
value = strsep(&flag, "=");

src/modules/pmcs/amd/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MODULE_NAME=mchw_amd
22
obj-m += $(MODULE_NAME).o
3-
$(MODULE_NAME)-objs += mchw_core.o mc_experiments.o pmu_config_x86.o cbuffer.o monitoring_mod.o syswide.o ipc_sampling_sf_mm.o
3+
$(MODULE_NAME)-objs += mchw_core.o mc_experiments.o pmu_config_x86.o cbuffer.o monitoring_mod.o syswide.o \
4+
ipc_sampling_sf_mm.o pmctrack_stub.o
45
SYMLINKS=$(patsubst %.o,%.c,$($(MODULE_NAME)-objs))
56
SOURCES=$(patsubst %.o,../%.c,$($(MODULE_NAME)-objs))
67

src/modules/pmcs/arm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MODULE_NAME=mchw_arm
22
obj-m += $(MODULE_NAME).o
33
$(MODULE_NAME)-objs += mchw_core.o mc_experiments.o pmu_config_arm.o cbuffer.o monitoring_mod.o syswide.o ipc_sampling_sf_mm.o \
4-
vexpress_sensors_core.o vexpress_sensors_mm.o
4+
vexpress_sensors_core.o vexpress_sensors_mm.o edp_core.o pmctrack_stub.o
55
SYMLINKS=$(patsubst %.o,%.c,$($(MODULE_NAME)-objs))
66
SOURCES=$(patsubst %.o,../%.c,$($(MODULE_NAME)-objs))
77

0 commit comments

Comments
 (0)