As I understand it, the USER_HZ constant was added in Linux 2.6 to solve the problems associated with waiting for the HZ value in user space: in previous versions of Linux, changing the HZ value can cause the value in user space applications to be unintentionally scaled.
I am confused by how the constant USER_HZ solves this scaling problem. For example, let's say a user space application converts jiffies into seconds:
long MY_HZ = sysconf(_SC_CLK_TCK); long num_jiffies = 1000; long num_seconds = num_jiffies / MY_HZ;
Since the user space application determines the HZ value by calling sysconf , will this not prevent the scaling problem?
If, on the other hand, applications with user space had an HZ value hardcoded in their source, as if the constant USER_HZ prevented the scaling problem - user space applications would use their hardcoded constants, not the USER_HZ system, and there is no guarantee that hardcoded USER_HZ constants match USER_HZ ?
Also, are all the clock values available for user space (e.g. /proc ) already scaled to USER_HZ ? How does a user-space program know if a value in jiffies scales to HZ or USER_HZ ?
linux linux-kernel
Vilhelm Gray
source share