Build a patched Debian Linux Kernel

Here we patch with the perfctr patch. This is a (cleaned) up transcript of the actual actions used. Replace versions and patches as appropriate.
cd /usr/src
tar xvfz perfctr-2.6.33.tar.gz 
apt-get install linux-source-2.6.25 
tar xvfj linux-source-2.6.25.tar.bz2 
cd linux-source-2.6.25
../perfctr-2.6.33/update-kernel --test
#now get the Debian default config file (from a binary package):
apt-get --download-only install -t unstable  linux-image-2.6-amd64
dpkg -c /var/cache/apt/archives/linux-image-2.6.25-2-amd64_2.6.25-3_amd64.deb|
 grep config
dpkg --fsys-tarfile /var/cache/apt/archives/linux-image-2.6.25-2-amd64_2.6.25-3_amd64.deb |
 tar xvf - ./boot/config-2.6.25-2-amd64
cp -p boot/config-2.6.25-2-amd64 .config
make oldconfig
CONCURRENCY_LEVEL=8 make-kpkg --initrd --append-to-version=-perfctr kernel_image
cd ..
mount /boot
dpkg -i linux-image-2.6.25-perfctr_2.6.25-perfctr-10.00.Custom_amd64.deb
See also: How to backport a Debian package yourself.
Anton Ertl