Skip to contentSkip to conversation

Remove spurious BUG from posix-cpu-timers

PATCH In review Matthew Wilcox 3 participants 4 messages Mar 19, 2005 – Mar 20, 2005 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove spurious BUG from posix-cpu-timers

PA-RISC does not necessarily have interrupts disabled while timers are running. This doesn't appear to be a requirement, but posix-cpu-timers seems to think it is.

kernel/posix-cpu-timers.c +0 -2
diff -urpNX dontdiff linus-2.6/kernel/posix-cpu-timers.c parisc-2.6/kernel/posix-cpu-timers.c
@@ -1242,8 +1242,6 @@ void run_posix_cpu_timers(struct task_st
 	LIST_HEAD(firing);
 	struct k_itimer *timer, *next;
 
-	BUG_ON(!irqs_disabled());
-
 #define UNEXPIRED(clock) \
 		(tsk->it_##clock##_expires == 0 || \
 		 cputime_lt(clock##_ticks(tsk), tsk->it_##clock##_expires))
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
#1 lore raw
Quoted 6 lines · Matthew Wilcox

PA-RISC does not necessarily have interrupts disabled while timers are running. This doesn't appear to be a requirement, but posix-cpu-timers seems to think it is.

But a bit later on we do

        spin_lock(&tsk->sighand->siglock);

rather than spin_lock_irqsave()?

#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 6 lines · Matthew Wilcox

PA-RISC does not necessarily have interrupts disabled while timers are running. This doesn't appear to be a requirement, but posix-cpu-timers seems to think it is.

Quoted 5 lines

But a bit later on we do

        spin_lock(&tsk->sighand->siglock);

rather than spin_lock_irqsave()?

We're in interrupt context ... we're ok, unless another interrupt handler tries to take the same spinlock. Maybe the posix cpu timer code should be using _irqsave anyway?

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
#3 lore raw

I put those BUG_ON's in places where I was using spin_lock on a lock that requires irqs disabled. Those places are called in contexts that already require irqs disabled for some other reason, so I didn't use irqsave/irqrestore there to skip the unnecessary overhead. (Of course it's the same the BUG_ON's have, but those can be compiled out.) I really don't recall at the moment if there was a deeper reason, i.e. that the code itself in some other way relies on interrupts being disabled for its proper operation. But I don't see any reason to change it.

Thanks,
Roland