Re: [patches] kernel timer races

From: Andrew Morton (andrewm@uow.edu.au)
Date: Thu May 25 2000 - 09:07:42 EST


Alan Cox wrote:
>
> There is a really dumb fix perhaps ?
>
> wait_on_timers();
>
> That would map to a bh wait on 2.2 and the saner timer wait on 2.3.x

Not quite sure what you mean here. Your emails are shorter than mine :)

Are you suggesting a wait_on_bh() within 2.2's del_timer()? If so we'd
have to take a peek at which CPU currently owns the BH to avoid deadlock
if a BH or ISR called del_timer().

hmm... wait_on_bh() isn't exported, and synchronize_bh() doesn't work
from BH's or IRQ's. This means that each arch would have to export
something new. I'll confess that the current BH locking makes my head
spin. I suspect this would all end up with similar complexity to the
current patch, it it's indeed what you meant.

More hmm... synchronize_bh() doesn't do anything to stop a new BH from
starting as soon as it has returned. So it's safe within __global_cli()
and it can be used after del_timer() to give del_timer_sync() semantics,
but apart from that, what use is it??

This patch, BTW, very much assumes that only one CPU can run a timer
handler at a time. It will BUG() if this isn't true. It's pretty easy
(although a bit expensive) to generalise it when handlers can run
simultaneously. (That's what version 4 did...)

I don't know how often these nasties can happen - you can do sums
assuming that a handler takes 100nS and del_timer() is called every
100mS and everything's stochastic: once every 300 hours. I've observed
it about once every ~5 hours, but this is just with a simple
IDE/NIC/nothing else box. It's guesswork, which is why I put in the
please-send-me-mail printk() when it happens.

I wish Alexey were around to comment, but we've seen neither hideski nor
hairski for a couple of weeks.

BTW2: is there any technical reason why the timer_struct clients haven't
been migrated over to use timer_list yet?

-- 
-akpm-

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



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:14 EST