Procedure:Perfctr

From OACISS Systems Wiki
Jump to navigation Jump to search

1. First, get the source RPM, create an rpm build tree, and install the source rpm.

2. Modify kernel-2.6.spec

*** kernel-2.6.spec-original    2009-06-29 11:47:25.000000000 -0700
--- kernel-2.6.spec     2009-06-29 12:01:15.000000000 -0700
***************
*** 67,73 ****
  # by setting the define to ".local" or ".bz123456"
  #
  #% define buildid
! #
  %define sublevel 18
  %define kversion 2.6.%{sublevel}
  %define rpmversion 2.6.%{sublevel}
--- 67,75 ----
  # by setting the define to ".local" or ".bz123456"
  #
  #% define buildid
!
! %define buildid .perfctr
! %define perfctr 2.6.39
  %define sublevel 18
  %define kversion 2.6.%{sublevel}
  %define rpmversion 2.6.%{sublevel}
***************
*** 395,400 ****
--- 397,403 ----
  Source80: config-rhel-generic
  Source82: config-rhel-ppc64-generic
  Source83: config-olpc-generic
+ Source84: config-perfctr

  Source100: kabi_whitelist_i686
  Source101: kabi_whitelist_i686PAE
***************
*** 6577,6582 ****
--- 6580,6590 ----
  %patch99999 -p1
  %endif

+ # Run perfctr patch script
+ %ifarch i386 i586 i686 x86_64
+   %{_builddir}/perfctr-%{perfctr}/update-kernel --patch="2.6.18-128.el5-redhat"
+ %endif
+
  # END OF PATCH APPLICATIONS

  cp %{SOURCE10} Documentation/
***************
*** 6634,6639 ****
--- 6642,6657 ----
  rm -f kernel-%{kversion}-*-debug.config
  %endif

+
+ # Merge in perfctr configs. Should have an arch
+ %ifarch i386 i586 i686 x86_64
+ for i in %{all_arch_configs} ; do
+   mv $i $i.tmp
+   $RPM_SOURCE_DIR/merge.pl $RPM_SOURCE_DIR/config-perfctr $i.tmp > $i
+   rm $i.tmp
+ done
+ %endif
+
  # now run oldconfig over all the config files
  for i in *.config
  do

3. Create the file "config-perfctr" in the SOURCES directory:

cat > SOURCES/config-perfctr << EOF
#
# Performance-monitoring counters support
#
CONFIG_PERFCTR=y
CONFIG_KPERFCTR=y
# CONFIG_PERFCTR_DEBUG is not set
CONFIG_PERFCTR_INIT_TESTS=y
CONFIG_PERFCTR_VIRTUAL=y
CONFIG_PERFCTR_GLOBAL=y
CONFIG_PERFCTR_INTERRUPT_SUPPORT=y
CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK=y
EOF

4. Get perfctr and grab the spec file:

cd SOURCES
wget http://user.it.uu.se/~mikpe/linux/perfctr/current/perfctr-2.6.39.tar.gz
tar -xzvf perfctr-2.6.39.tar.gz
cp perfctr-2.6.39/perfctr.spec ../SPECS

5. Fix broken perfctr.spec file, remove changelog (it contains syntax errors)

6. Build perfctr rpm

rpmbuild -ba --target x86_64 SPECS/perfctr.spec

7. Build the kernel rpm

rpmbuild --with baseonly --without debuginfo --without kabichk -ba SPECS/kernel-2.6.spec



NOTES from ivan

If your goal is to build RPMs, you need the following from my home directory:

kernel-2.6.30.8-64.fc11.SPEC.patch
kernel-2.6.30.8-64.fc11.src.rpm
linux-2.6.30.i686.perfctr.patch
Makefile
rpmbuild.CLEAN
.ccache
You would just type "make" in your home directory. Please DO NOT do any of this as root, but create a new user and copy everything from my home directory to your home directory. After running "make" the RPMs would be produced in "rpmbuild/RPMS" and "rpmbuild/SRPMS"

If your goal is to just path the kernel source with your changes, do this:

rm -rf rpmbuild
rpmdev-setuptree
rpm -Uvh kernel-2.6.30.8-64.fc11.src.rpm
cd rpmbuild/BUILD
rsync -a kernel-2.6.30/linux-2.6.30.i586/ linux-2.6.30.i586.old/
rsync -a kernel-2.6.30/linux-2.6.30.i586/ linux-2.6.30.i586.new/
Patch the code in kernel-2.6.30/linux-2.6.30.i586/ linux-2.6.30.i586.new/
Then do "make bzImage"
Then do "sudo make install"
When you are all done, you can diff the old and new directory to make a new patch with your work.

If you want to install the new RPM so you can run the PAPI kernel on the machine, just use the following RPMs:

/home/ivan/rpmbuild.BUILT/SRPMS/kernel-2.6.30.8-64.nic.fc11.src.rpm
/home/ivan/rpmbuild.BUILT/RPMS/i586/kernel-firmware-2.6.30.8-64.nic.fc11.i586.rpm
/home/ivan/rpmbuild.BUILT/RPMS/i586/kernel-devel-2.6.30.8-64.nic.fc11.i586.rpm
/home/ivan/rpmbuild.BUILT/RPMS/i586/kernel-headers-2.6.30.8-64.nic.fc11.i586.rpm
/home/ivan/rpmbuild.BUILT/RPMS/i586/kernel-2.6.30.8-64.nic.fc11.i586.rpm