How can I know HZ value of Android kernel through ADB shell? (without any coding)
I checked How to check HZ in the terminal?, but this is not work with Android ADB shell.
Any suggestion?
How can I know HZ value of Android kernel through ADB shell? (without any coding)
I checked How to check HZ in the terminal?, but this is not work with Android ADB shell.
Any suggestion?
Provided you have
busybox
installed:Theory
You can derive the kernel space HZ value by taking an elapsed time in jiffies and dividing it by the elapsed time in seconds.
You can get both the system uptime in jiffies and in nanoseconds from the /proc/timer_list file.
now at <nanoseconds> nsecs
line<nanoseconds>
will be the uptime in nanosecondsjiffies: <jiffies>
line (any processor will do)<jiffies>
will be the uptime in jiffiesINITIAL_JIFFIES
in the kernel -- so it may not start counting at0
. Nevertheless, this shouldn't affect the outcome of our calculation since we're concerned with the elapsed time rather than obsolute uptime.By taking these two values over an elapsed period of time, you can calculate the HZ value using the following equation:
Example
If you happen to have
awk
(perhaps via BusyBox), you can automate this calculation:Due to rounding errors, the HZ value may be slightly off; you might want to perform this calculation several times and average it. Most modern kernels have kernel space
HZ
set to250
.Breakdown
Here's the same command spread over several lines to clarify how it works:
/^now at/ { nsec=$3; }
nsec
/^jiffies/ { jiffies=$2; }
jiffies
END {
print nsec, jiffies;
system("sleep 1");
' /proc/timer_list | awk '
awk
NR==1 { nsec1=$1; jiffies1=$2; }
nsec
andjiffies
values from the previousawk
tonsec1
andjiffies1
respectively/^now at/ NR>1 { nsec2=$3; }
nsec2
/^jiffies/ NR>1 { jiffies2=$2; }
jiffies2
END {
dsec=(nsec2-nsec1)/1e9;
djiff=(jiffies2-jiffies1);
print int(djiff/dsec);
' - /proc/timer_list