Linux HZ checker

22 01 2008

HZ defined how many ticks the internal timer interrupt in 1sec, which means the number of jiffies count in 1 sec.

Different architecture/machine may have different HZ value, you can check using this script from the timer interrupt:

#!/bin/sh
while [ 1 ]; do
A=`cat /proc/interrupts | grep timer | cut -d ‘:’ -f 2 |sed -e ‘s/[^0-9]//g’`
sleep 1
B=`cat /proc/interrupts | grep timer | cut -d ‘:’ -f 2 |sed -e ‘s/[^0-9]//g’`
C=$(($B-$A));
echo “HZ:$C”
done

it is around 250 in my desktop running 2.6, but 100 in my mips 2.4 embedded board.

Sometimes we may need to know the time in seconds from jiffies in kernel.

time(sec) = jiffies/HZ;

Advertisements

Actions

Information

3 responses

10 03 2009
Lincoln

The script wouldn’t work for me. So I used awk instead of cut. It might be a little simpler also.

#!/bin/sh
while [ 1 ]; do
A=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
sleep 1
B=`cat /proc/interrupts | grep timer | awk ‘{ print $2 }’`
C=$(($B-$A));
echo “HZ:$C”
done

5 06 2010
Jules Simon

Rule #1 of shell scripting: cat is NEVER necessary unless it’s actually used for concatenating. If you’re doing cat xxxxx | zzzz, you’re doint it wrong.

#37: Don’t pipe grep into awk. Awk can do regular expressions.

Try this instead:

i=/proc/interrupts;s=’/l timer/{print $2}’;echo $((-`awk “$s”<$i;sleep 1`+`awk "$s"<$i`))

18 09 2012
How to check HZ in the terminal? - feed99

[…] have seen this https://kaasxxx.wordpress.com/2008/01/22/linux-hz-checker/ But the script seems not to work. Does anyway know an easy way to chech “HZ” in the […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: