How to check HZ in the terminal? How to check HZ in the terminal? linux linux

How to check HZ in the terminal?


There's no uniform answer to this questions, as in some cases your kernel may be compiled "tickless" and not use a regular timer interrupt at all. But if you're on a traditional kernel and a traditional distro, you can find the current kernel's .config file under /boot with something like grep 'CONFIG_HZ=' /boot/config-$(uname -r).


The value of HZ can be determined like so:

$ getconf CLK_TCK100

Any of the compile time options of the running kernel can be gleamed using getconf. Keep in mind that HZ is configurable:

$ man 7 time

The value of HZ varies across kernel versions and hardware platforms. On i386 the situation is as follows: on kernels up to and including 2.4.x, HZ was 100 giving a jiffy value of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since kernel 2.6.13, the HZ value is a kernel configuration parameter and can be 100, 250 (the default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. Since kernel 2.6.20, a further frequency is available: 300, a number that divides evenly for the common video frame rates (PAL, 25 HZ; NTSC, 30 HZ).

The times(2) system call is a special case. It reports times with a granularity defined by the kernel constant USER_HZ. User-space applications can determine thecvalue of this constant using sysconf(_SC_CLK_TCK).

As is typically the case you may need to trim the _SC_ bit off of the variable name shown in the man pages when inquiring about it using getconf.


There are many different approaches to get a hint on what your settings are.On some single-core systems this trick is handy:

/ # cat /proc/interrupts | grep -i time; sleep 10; cat /proc/interrupts | grep time 16:   10404858      INTC  68 Level     gp_timer 16:   10514798      INTC  68 Level     gp_timer

It shows you the amount of ticks there were during the 10 sec. sleep.Here about 100'000. Divide by 10 gives about 10'000 HZ.

This might get confusing on multicore systems, as it will be a per core list.

Another option will be to check if you can get a hand on the original kernel config. It would be stored in

/proc/config.gz

Unpack it and open the file. Search for parts that look similar to

CONFIG_HZ_FIXED=0# CONFIG_HZ_100 is not set# CONFIG_HZ_200 is not set# CONFIG_HZ_250 is not set# CONFIG_HZ_300 is not set# CONFIG_HZ_500 is not set# CONFIG_HZ_1000 is not setCONFIG_HZ_10000=yCONFIG_HZ=10000CONFIG_SCHED_HRTICK=y

Just to warn you; 10'000 is way off normal settings. Experimental setup.