I’ve noticed for ages that my thinkpad x61 with 4 gigs of ram has been sluggish on the desktop with redraws. Now that I have a bit more time, I looked into this, oh, and because I’ve been shamed into getting all the funky compiz-fusion graphics looking hot on my desktop by Freddie B and Mr. Adams.
After some gentoo forum spelunking into the issue across distros, I found out that at least with Intel 965 (x3100) and kernel 2.6.25-26, there are some major issues with mtrr not being set properly.
I took the plunge at trying to understand the issue and wrote a basic script to fix-up my mtrr settings from the commandline:
#!/bin/bash
#
# fixmtrr
#
# fixes /proc/mtrr
# based upon termites script from gentoo forums
# disable pre-existing ones and order does matter!
echo "disable=0" >| /proc/mtrr
echo "disable=1" >| /proc/mtrr
echo "disable=3" >| /proc/mtrr
echo "disable=4" >| /proc/mtrr
echo "disable=5" >| /proc/mtrr
echo "disable=2" >| /proc/mtrr
# Now create the right ones...
# These are powers of two, they get progressively smaller
# so we can get right up to the system device page below.
echo "base=0x00000000 size=0x80000000 type=write-back" >| /proc/mtrr
echo "base=0x80000000 size=0x40000000 type=write-back" >| /proc/mtrr
echo "base=0xC0000000 size=0x10000000 type=write-back" >| /proc/mtrr
# Video Card:
# 0x10000000 was the value for size trying for
echo "base=0xE0000000 size=0x10000000 type=write-combining" >| /proc/mtrr
# High memory area
echo "base=0x100000000 size=0x40000000 type=write-back" >| /proc/mtrr
This helped to set my mtrr up right so that X can find the dynamic shared memory to do all the fun compiz effects and more. If there is a better fix for the above, I’d love to hear about it! More than just bling bling, my overall computer is much much better. I can’t believe I put up with this!
Then, I started running powertop to test out my system, and noticed that there are many features that can be set after a computer is setup, so I created an init script to set all this at boot:
!/sbin/runscript
#
# This starts the thinkpad post-boot settings
#
TITLE="Thinkpad Specific Options"
LINKPOWER=/sys/class/scsi_host/host0/link_power_management_policy
FIXMTRR=/usr/local/bin/fixmtrr
WRITEBACK=/proc/sys/vm/dirty_writeback_centisecs
checkconfig() {
if [ ! -e $LINKPOWER ] &&
[ ! -e $FIXMTRR ] &&
[ ! -e $WRITEBACK ] ; then
eerror "You cannot set $TITLE. Check settings."
return 1
fi
}
start()
{
checkconfig || return 1
ebegin "Starting $TITLE"
$FIXMTRR
echo min_power > $LINKPOWER
echo 1500 > $WRITEBACK
}
stop()
{
checkconfig || return 1
ebegin "Stopping $TITLE"
echo 500 > $WRITEBACK
}
Make sure to put the fixmtrr script in /usr/local/bin or change the path to fixmtrr in your script. Then, set thinkpad script to run at boot before xdm kicks in:
rc-update add thinkpad boot
These are pretty basic scripts, but I wanted to dump them out for other users of this system. Its beyond just Gentoo-based distros, and will take a while to get into main kernel especially for slow distros like Ubuntu, Fedora, etc
I had to put that one in there for those who try to convert or chide me off Gentoo.