Re: HZ, preferably as small as possible

Albert D. Cahalan
2002-07-15T18:41:11Z

Russell King writes:
> On Mon, Jul 15, 2002 at 12:07:18PM -0400, Albert D. Cahalan wrote:

>> You have 64, 128, and 1000. See for yourself.
>>
>> arch-cl7500/param.h #define HZ 100
>> arch-epxa10db/param.h #define HZ 100
>> arch-integrator/param.h #define HZ 100
>> arch-l7200/param.h #define HZ 128
>> arch-shark/param.h #define HZ 64
>> arch-tbox/param.h #define HZ 1000
>>
>> I need to support all of that with one binary.
>> So I'm stuck with:
>
> Lets look more closely:
>
> #ifndef HZ
> #define HZ 100
> #endif
> #if defined(__KERNEL__) && (HZ == 100)
> #define hz_to_std(a) (a)
> #endif
>
> And:
>
> $ grep hz_to_std arch-*/param.h
> arch-l7200/param.h:#define hz_to_std(a) ((a * HZ)/100)
> arch-shark/param.h:#define hz_to_std(a) ((a * HZ)/100)

Won't that overflow in 3 or 4 days?

> As I said, tbox is broken, so ignore that.

OK.

> And hz_to_std gets used (fs/proc/array.c):
>
> hz_to_std(task->times.tms_utime),
> hz_to_std(task->times.tms_stime),
> hz_to_std(task->times.tms_cutime),
> hz_to_std(task->times.tms_cstime),

Now look in the 2.4.xx kernel source.

> So merely grepping for HZ doesn't actually tell you anything.
>
> All /proc values are in 100Hz units on ARM.

Since kernel 2.5.25 it looks like. I must support
the 2.4.xx kernels at least, and 2.2.xx is still
pretty popular.