October 15th, 2005

Got bored with Descartes and Spinoza, wrote a patch to powernowd

Saturday, October 15th, 2005

While I was studying, I noticed that I wasn’t exactly happy with the cooling/cpu frequency scaling on my laptop. I use a nice program called powernowd which scales my CPU speed up and down depending on various factors related to system load. But I didn’t like how my setup was kind of “all or nothing.” When I am plugged into AC, I switch to “performance” mode which just runs me at 100% CPU frequency all the time (making my laptop hot, my fan noisy, but my machine fast), whereas when I’m unplugged I switch to “userspace” mode, which lets powernowd kick in, and he jumps about from 400mhz to the full 1.6Ghz based on load, keeping the machine cool but also making it feel a bit sluggish since if I’m overloading my CPU at 400mhz it’s already “too late” to pump it up, it will have already felt slow for at least an instant.

So I have this conflict: hot and responsive, or cool and sluggish. I thought, well, I must be able to come to a compromise.

I decided to take a look at powernowd’s code, and it turns out it’s written quite straightforwardly. Within 30 minutes of tinkering, I had a patch that did what I wanted. With another 30 minutes, I polished it and made it quite commitable.

Basically, I added a new mode called “COOLING” to powernowd, which runs your CPU a few notches below your full frequency (which I call your “cool_spot”), based on the following approach:

  • if you have two frequencies available, you normally run with the lowest.
  • if you have three frequencies available, you normally run with the second from highest.
  • if you have four frequencies available, you normally run with the third from highest.
  • if you have five or more frequencies available, you normally run with the fourth from highest.
  • if your load goes above your specified trigger (”highwater” in the code), you jump to highest frequency. When it lowers (”lowwater”), you go down to your cool_spot, but not below it.

On my machine, I have 5 frequencies (1.6Ghz, 1.5Ghz, 1.4Ghz, 1.2Ghz, and 400Mhz), and so I normally am running at 1.2Ghz. This new COOLING mode runs while I’m plugged in, and keeps my machine nice and cool but still lets it immediately respond when I want to do something, like a workspace switch.

I then hacked the init.d script to have a BATTERY and AC mode, and switch between AGGRESSIVE and COOLING modes accordingly. Now, when I’m unplugged, I get the best battery life and pretty good performance, and when I’m plugged in I get a cool notebook with good performance.

I’ll probably post the patch after my midterms…

Police officers are disgusting

Saturday, October 15th, 2005

still cap from beating videoFor some of the most disturbing footage you’ve seen in awhile, you can download this clip of New Orleans police officers brutally attacking a 64-year-old black man (the race is important) in New Orleans.

Here is a little piece of a Miami Herald article that describes the clip.

For those who missed it, here’s the scene: It is Saturday night in the fabled French Quarter. Police are arresting one Robert Davis, a 64-year-old former schoolteacher.

As an Associated Press camera records the episode, an officer on horseback moves into the frame, apparently to block the camera’s view. But the camera operator, shooting over the horse’s flank, captures officers pinning the old man to a brick wall and one apparently delivering vicious blows to the head. Davis is then wrestled to the ground, several officers on top of him. Another tape, this one shot by CNN, shows him writhing handcuffed in a pool of blood. When he tries to roll over, an officer’s foot shoves him back.

Police say he was arrested for public drunkenness, battery and public intimidation. Davis later told reporters he had simply asked an officer on horseback about the curfew time when another officer barged into the conversation. Davis called that officer unprofessional and walked away, at which point, he says, the cop hit him from behind.

I, for one, believe Davis. Watch that clip one more time. See how brutally they attack him in the face, even though he is already subdued? See how they kick him while he is down? This was not self-defense.