OpenBSD 5.2 was released nearly two months ago and I had forgotten to upgrade my Soekris net6501, apart from my driver now being part of the kernel, this release also added support to the SpeedStep frequency scaling driver for the Atom CPU.
The simple benchmark to keep in mind is using the md5(1)
command, using its built-in time trial test. Under the previous OpenBSD 5.1 release:
# md5 -ttt MD5 time trial. Processing 1000000 10000-byte blocks... Digest = f0843f04c524250749d014a8152920ec Time = 124.227876 seconds Speed = 80497230.750367 bytes/second |
You can see I’m getting roughly 80 MB/s. Now upgrade to OpenBSD 5.2 and repeat the test, you’ll get pretty much the same speeds, however now we have the CPU frequency scaling to play with. The scaling is very coarse, the only two speeds supported are 600 MHz and whatever maximum the CPU supports, so in my case with a net6501-70, it’s 1.6 GHz. To change the scaling simply manipulate the hw.setperf
sysctl(8)
variable.
By default the CPU is running at 100%, confirmed by:
# sysctl hw.setperf hw.setperf=100 |
Now set the CPU frequency to the slowest speed:
# sysctl hw.setperf=0 hw.setperf: 100 -> 0 |
Now running the test again I get the following results:
# md5 -ttt MD5 time trial. Processing 1000000 10000-byte blocks... Digest = f0843f04c524250749d014a8152920ec Time = 123.948587 seconds Speed = 80678612.334645 bytes/second |
Almost exactly the same speed, which doesn’t make sense given I’ve knocked 1 GHz off the clock speed! So put the CPU back to 100% and try again:
# sysctl hw.setperf=100 hw.setperf: 0 -> 100 # md5 -ttt MD5 time trial. Processing 1000000 10000-byte blocks... Digest = f0843f04c524250749d014a8152920ec Time = 46.424699 seconds Speed = 215402581.285449 bytes/second |
Ah-ha, about 210 MB/s this time! It transpires there’s a bug in the Soekris BIOS, despite advertising the CPU as 1.6 GHz it wasn’t programmed correctly and was only being clocked at 600 MHz, so all this time I’ve effectively had the base net6501-30 model albeit with the extra RAM. You can work around this by setting hw.setperf
to 100 on each boot.
A new BIOS 1.41c has been released which fixes this issue and programs the CPU to run at its advertised maximum speed. However to upgrade to this involves my eternal battle with serial terminal software and uploading over XMODEM which is notoriously fickle, although I think I have it cracked…
I usually use a Mac OS X host with a KeySpan USB/Serial adapter to connect to the net6501 so I already have tools like cu(1)
and screen(1)
. You’ll also need the lrzsz tools installed which if using MacPorts is as easy as:
# sudo port install lrzsz |
Using cu(1)
, connect to the Soekris:
# sudo cu -l /dev/tty.KeySerial1 -s 19200 |
Power the board on, use Ctrl+P to break into the BIOS monitor and type download
to start the Soekris waiting to receive over XMODEM. Now you need to type ~+sz -X /path/to/b6501_141c.bin
, possibly as quickly as you can after the previous command. If that works, type flashupdate
afterwards to reprogram the BIOS. You’ll get something like the following transcript:
> download Start sending file using XMODEM/CRC protocol. ~+sz -X /path/to/b6501_141c.bin Sending /path/to/b6501_141c.bin, 1982 blocks: Give your local XMODEM receive command now. Bytes Sent: 253696 BPS:1746 Transfer complete File downloaded succesfully, size 253696 Bytes. > flashupdate Updating BIOS Flash ,,,,,,,,,,,,, Done. > reboot |
Reboot and boot back into OpenBSD. Now the time trial should return a result of roughly 210 MB/s every time. Because I obviously don’t need 1.6 GHz of CPU all time, I’ve enabled the apmd(8)
daemon which manipulates the hw.setperf
variable based on the CPU idle time. Add the following to /etc/rc.conf.local
:
apmd_flags="-C -f /dev/null" |
The -f
is only necessary when running i386 otherwise apmd(8)
complains. Start with:
# /etc/rc.d/apmd start apmd(ok) |
Normally hw.setperf
will be 0 however when you do something CPU-intensive (such as the MD5 time trial) apmd(8)
will automatically adjust hw.setperf
back to 100 so you still get the 210 MB/s result, but most of the time you’ll have lower power draw and less heat.