Online Linear Regression Module


Online linear regression module is a custom sampling module based on the pfmon tool. It works inside the pfmon, capturing the variation of the sample values with a series of straight lines as shown in Fig.1. The method behind the lines generation is called the online linear regression which is described in the paper "Online Linear Regression of Sampling Data from Performance Event Counters" and its presentation.

Fig.1 Example of Online Linear Regression of Sampling Data from Performance Event Counters
(Sampling 436.cactusADM from SPEC CPU 2006 benchmark suite at 1M clock cycles)


  1. At first, perfmon 2.81 kernel patch for linux kernel 2.6.26 should be installed which can be found at perfmon project page.

  2. Then, pfmlib 3.52 library should be installed as well, which is available at perfmon project page.

  3. After that, pfmon 3.5 tool should be installed which is also available at perfmon project page.

  4. The source code of online linear regression module can be downloaded here with a GPL license file.

    • Copy the online linear regression module source code to "$(pfmon_source_dir)/pfmon/smpl_mod".

    • Add "linear_regression_smpl.o" to "$(OBJS)" in the "$(pfmon_source_dir)/pfmon/smpl_mod/Makefile" at the same directory.

    • Add "extern pfmon_smpl_module_t linear_regression_smpl_module;" in the "$(pfmon_source_dir)/pfmon/pfmon_smpl.h".

    • Add "&linear_regression_smpl_module," into the initialization list of "static pfmon_smpl_module_t *smpl_modules[]" in "$(pfmon_source_dir)/pfmon/pfmon_smpl.c".

  5. Follow the compilation and installation instructions of pfmon to compile and install pfmon with online linear regression sampling module.

    Typically, it is just "make" and "make install".


Online linear regression module works as other sampling modules delivered with "pfmon".

"pfmon" command line option "--smpl-module=linear-regression" selects the online linear regression sampling module.

Additional module-specific options for online linear regression sampling module include:


Set the alpha to "value" (default is 0.01)


Print the records sampled (default no)


Record and show the time consumed by the sampling module itself (default no)


Event index after the sampling event to do linear regression (default 0, the one just after sampling event). If the given event index is too large, the modular against number of events excluding the sampling event will be used.

The following example commands "pfmon" to select online linear regression module to sample with an "alpha"=0.007, "print-records", "record-self-time" and "event-index"=1 (the third event, "LAST_LEVEL_CACHE_MISSES", in comma separated event list after the "-e" option).

"$(pfmon_install_dir)/pfmon --smpl-module=linear-regression --linear-regression-alpha=0.007 --linear-regression-printrecords --linear-regression-recordselftime --linear-regression-eventindex=1 --long-smpl-period=1048576 -eUNHALTED_CORE_CYCLES,INSTRUCTIONS_RETIRED,LAST_LEVEL_CACHE_MISSES,... --smpl-outfile=./999.specrand_smpl-linear-regression.pfmonlog -- ../run_base_ref_linux64-intel64-gcc41.0000/specrand_base.linux64-intel64-gcc41 1255432124 234923 > rand.234923.out 2>> rand.234923.err"

Faculty of Engineering: Department of Computing
Computer Architecture