Wednesday, April 29, 2009

Magic SysRq enhancement (2)

I've rewrote this module using workqueue instead of timers and it works perfectly now on blackbird (to be tested on lappy soon).

An additional feature is that I now flip the leds twice so the original state is restored and also the blink is not missed if all leds were originally on.

Code is here

Monday, April 27, 2009

BTrace Rocks!

At work we're using a maven based build process. On the build machine it takes a while to finish the complete build (about 2 hours).

One of the final parts of the build is to generate the mvn:site. This stage takes, in my opinion, longer than it would seem necessary. Looking at #top, the machine is almost idle and there are 14 processes listed in #ps, where the last one keeps changing (I guess it finishes a directory and a new is spawned for the next one).

Due to bad design, there's no logging whatsoever in this stage and the machine seems stuck. I wanted to debug this on the build machine but didn't want to distrupt the running build (so can't start in debug mode).

To the rescue comes BTrace. A DTrace clone for java, allowing you to write small java scripts that can monitor and profile running java code. BTrace allows you to attach to an existing JVM process, without requiring any special switches to be added a priori to its command line (although it does support an -agent scenario).

That was so cool! Just downloaded one of the examples on the BTrace site, found the process pid using #jps so I can attach to it, and voila. I get printouts of all file accesses done by maven.
The BTrace examples page is full of actuall useful scripts. For example there's a script to print stacktraces for all threads (similar to #jstack).

Sunday, April 26, 2009

Magic SysRq enhancement

I really love the Magic SysRq key. It's always nice to know that you can do some emergency actions even when the system is 99% locked up. What's my favorite sequence? Probably 'subo'. I'm still figuring it out.

One of my beefs with MSRK is that sometimes I can't be sure if it is responding (am I pressing the right sequence?). This usually happens when I get a crash while in X, not seeing the console.
I wrote a small kernel module to add a new action to the Magic SysRq key. The new action's, "Visualize", only purpose is to give back a cue that it's listening.

I copied from some kernel hacking example code for blinking the keyboard leds (should be possible if the kernel still reads commands from the keyboard) and for beeping (although I haven't got that working yet).

First try is using timers ('add_timer'). This seems to be working nicely on lappy but inconsistently on blackbird (sometimes the leds don't light up and sometime they light up but don't go off). I'm pretty sure that the timer function gets called because I can see the printk's. I guess this means that the IOCTL is failing. I'll try replacing the timer with work queue, see if that helps.

P.S.: Another difference between lappy and blackbird: On blackbird the 'v' from the Alt-SysRq-V sequence gets swallowed, whily on lappy it gets printed. Strange.

Wednesday, April 22, 2009

Googling myself again...

My name comes up a few times in the internet, in various bug reports and forum posts. I found out today it also appears in the hibernate-annotations changelog (quite undeservingly since someone else did all the heavy lifting). Nice.

Profiling Java Applications

A new beta of simon 2 is out. Also, btrace (https://btrace.dev.java.net/source/browse/btrace/docs/usersguide.html?rev=1.6) looks like an interesting alternative to JIP. It even has a visualvm plugin.

Tomcat Logging, Another Rant

For integration with another application I need the logs comming out of tomcat to have predictable names. This is not a problem for my webapp log which is created by log4j. Apparently this can be done with java logging as well. However, the tomcat main log uses JULI by default, which always creates log files with the date embedded in the file name.

There doesn't seem to be a way to configure it otherwise (except to change the logging to use a different mechanism).

Friday, April 10, 2009

ALSA, oh, ALSA

A week a two ago a hal update broke alsa on blackbird. After a few reboots I managed to get sound back, I believe it was fixed by downgrading hal-info to 20080508.

Yesterday I upgraded the kernel to 2.6.29-r1, and after the first reboot, again no sound (I also got the messages about /etc/modules.d in the boot messages as I got the last time this was b0rked).
So, I tried upgrading hal-info back to 20081219 (latest stable) and rebooted. Now it works (and no warning messages).

I'm assuming it's hal-info (maybe there is some dependency between the new hal version and new kernel version?) but maybe it has something to do with the reboot itself. We'll see next time.