Time bug on 2.2.* kernels
Henry Cejtin
henry@sourcelight.com
Sat, 14 Jul 2001 00:57:55 -0500
The bug I mentioned before, about the race when the counter wraps, is easy to
produce on 2.4.2 kernels with SMP machines. I tried to see if I could
produce the problem with 2.2 kernels. I assumed that I could not, since they
had much much less multi-threading, but I seem to recall that we have seen
this problem on such machines.
I ran the C grinder on a 2.2.14 machine with 2 CPUs, and although it took
much longer, I got the bug there, but slightly differently. On that machine,
when the wrap happens you get back a tv_usec field which contains 10^6. This
is actually better, since you could work around it, but I don't see at all
how this is happening since the kernel code, after expanding the macros, is
res.ru_stime.tv_sec = <utime-counter> / 100;
res.ru_stime.tv_use = (<utime-counter> % 100) * 10000;
so it should have the same bug, and should never ever return a tv_usec larger
than 990,000.