Skip to contentSkip to conversation

asm/timex.h

DISCUSSION Vojtech Pavlik 2 participants 3 messages May 24, 2002

lore
Share & tools
lore
#0 lore raw

Hi!

I have several questions about asm/timex.h

1) Who uses it? The kernel certainly doesn't. Perhaps NTP?

2) CLOCK_TICK_RATE is defined on i386 and similar archs to be 1193180. This is wrong, because the real frequency of the i8253 PIT timer is 14.31818 MHz / 12 = 1.11931816 MHz, so CLOCK_TICK_RATE should be 1193182. Should it be fixed?

3) What if an architecture doesn't have a compile-time known CLOCK_TICK_RATE? I suppose I cannot just #define it to a variable, because the kernel doesn't use it, and that probably means userland does ...

Anyone knows the answers?

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#1 lore raw
Quoted 5 lines · Vojtech Pavlik

Hi!

I have several questions about asm/timex.h

1) Who uses it? The kernel certainly doesn't. Perhaps NTP?

The kernel does. Thanks to the sched.h mess it's even implictly included in almost any file..

Quoted 4 lines

3) What if an architecture doesn't have a compile-time known CLOCK_TICK_RATE? I suppose I cannot just #define it to a variable, because the kernel doesn't use it, and that probably means userland does ...

The kernel DOES use it. grep(1) is your friend.

#2 lore raw
In reply to Vojtech Pavlik
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Vojtech Pavlik

Hi!

I have several questions about asm/timex.h

1) Who uses it? The kernel certainly doesn't. Perhaps NTP?

The kernel does. Thanks to the sched.h mess it's even implictly included in almost any file..

Quoted 6 lines
Quoted 4 lines

3) What if an architecture doesn't have a compile-time known CLOCK_TICK_RATE? I suppose I cannot just #define it to a variable, because the kernel doesn't use it, and that probably means userland does ...

The kernel DOES use it. grep(1) is your friend.

# grep -rw FINETUNE * | grep -v timex.h
# grep -rw CLOCK_TICK_FACTOR * | grep -v timex.h
# grep -rw CLOCK_TICK_RATE * | grep -v timex.h
drivers/char/ftape/lowlevel/ftape-calibr.c:     return (10000 * count) / ((CLOCK_TICK_RATE + 50) / 100);

The only interesting place where is CLOCK_TICK_RATE used is in linux/timex.h to define LATCH. Which subsequently is only used in arch specific code and ftape again.

Ftape's use of it is buggy, because it lacks the needed locking.

So, it seems like CLOCK_TICK_RATE isn't needed by non-arch-specific code.

And FINETUNE isn't used at all.

But ... the fact that kernel uses it ... probably doesn't mean that userland doesn't.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs