Re: [PATCH] i386 Time: Avoid PIT SMP lockups

From: Andrew Morton
Date: Wed Oct 11 2006 - 19:04:01 EST


On Wed, 11 Oct 2006 15:48:31 -0700
john stultz <johnstul@xxxxxxxxxx> wrote:

> > Wouldn't it be better to fix the livelock? What's causing it?
>
> I spent a few days trying to narrow this down, and I haven't been able
> to do so to my satisfaction.
>
> At this point, my suspicion is that because the PIT io-read is very slow
> (~18us), and done while holding a lock. It would be possible that one
> cpu calling gettimeofday would do the following:
>
> grab xtime sequence read lock
> grab i8253 spin lock
> do port io (very slow)
> release i8253 spin lock
> realize xtime has been grabed and repeat
>
> While another cpu does the following after in a timer interrupt:
> Grabs xtime sequence write lock
> spins trying to grab i8253 spin lock
>
> Assuming the first thread can reacquire the i8253 lock before the
> second, you could have both threads potentially spinning forever.

Is there any actual need to hold xtime_lock while doing the port IO? I'd
have thought it would suffice to do

temp = port_io
write_seqlock(xtime_lock);
xtime = muck_with(temp);
write_sequnlock(xtime_lock);

?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/