Skip to contentSkip to conversation

alpha bug in signal handling

Linux-ia64 David S. Miller 4 participants 6 messages Dec 5, 2001 – Dec 6, 2001

lore
Share & tools
lore
#0 lore raw

From: Richard Henderson <[email protected]>
Date: Tue, 4 Dec 2001 19:00:48 -0800

Quoted 11 lines · David Mosberger

Oh, sorry, I was referring to teh *other* problem... ;-)

What I meant is that the check for re-scheduling (current->need_resched) and signal deliverify (current->sigpending) needs to be done with interrupts turned off, and the interrupts need to be left off until user space is reached. Otherwise, you could get an interrupt which would wake up a higher priority task or post a signal between the check and the return to user space.

I didn't see this interrupt disabling in the Alpha version of entry.S, but I have to admit my Alpha assembly is getting quite rusty.

Oh, yes, I see. This should fix it.

I don't understand why this is even necessary.

What if the interrupt comes in on another processor. How does this return from trap behavior avoid that interrupt modifying the signal and/or scheduling state wrt. the current cpu's task?

I think the change is bogus, we don't do this on sparc64 and things have been perfectly fine.

And if the change isn't necessary, it's bad to disable interrupts for a longer period of time than necessary.

#1 lore raw
Quoted 5 lines · David S. Miller

I don't understand why this is even necessary.

What if the interrupt comes in on another processor. How does this return from trap behavior avoid that interrupt modifying the signal and/or scheduling state wrt. the current cpu's task?

It doesn't. But it also prevents the IPI from being recognized until we are back in userland. Apparently DMT had a test case that failed without disabling interrupts; I didn't see it myself.

r~

#2 lore raw
In reply to David S. Miller

From: Richard Henderson <[email protected]>
Date: Wed, 5 Dec 2001 08:58:08 -0800

It doesn't. But it also prevents the IPI from being recognized until we are back in userland. Apparently DMT had a test case that failed without disabling interrupts; I didn't see it myself.

I would like to see this test case :-)

#3 lore raw
In reply to David S. Miller
Quoted 13 lines · David S. Miller

From: Richard Henderson <[email protected]>
Date: Tue, 4 Dec 2001 19:00:48 -0800

Quoted 9 lines · David Mosberger

Oh, sorry, I was referring to teh *other* problem... ;-)

What I meant is that the check for re-scheduling (current->need_resched) and signal deliverify (current->sigpending) needs to be done with interrupts turned off, and the interrupts need to be left off until user space is reached. Otherwise, you could get an interrupt which would wake up a higher priority task or post a signal between the check and the return to user space.

Quoted 6 lines
Quoted 2 lines

I didn't see this interrupt disabling in the Alpha version of entry.S, but I have to admit my Alpha assembly is getting quite rusty.

Oh, yes, I see. This should fix it.

I don't understand why this is even necessary.

I think David (Mosberger, not Miller :) is right here, and in fact this is also wrong on PPC at the moment. However, the worst case is that the reschedule or signal delivery will get delayed until the next interrupt on that cpu (max 1/HZ seconds). Since it is a pretty narrow window for the race I think it would be hard to observe the effect of the bug.

Quoted 3 lines

What if the interrupt comes in on another processor. How does this return from trap behavior avoid that interrupt modifying the signal and/or scheduling state wrt. the current cpu's task?

If the interrupt comes in on another processor, then we call schedule() on that processor and it does an IPI if it thinks that this processor should reschedule.

The logic requires that we do the signal/schedule checks on exit to userland. The scenario where they can get missed is where we are returning to userland, and we get an interrupt just after we have done the checks. Suppose the interrupt routine raises a signal or wakes up a task. On the return from the interrupt routine it won't do the signal/schedule checks because we are returning to the kernel mainline. When we get back there it just completes the return to userspace without doing the checks (since we have already done them).

Paul.

#4 lore raw
In reply to David S. Miller
Quoted 7 lines

I think David (Mosberger, not Miller :) is right here, and in fact this is also wrong on PPC at the moment. However, the worst case is that the reschedule or signal delivery will get delayed until the next interrupt on that cpu (max 1/HZ seconds). Since it is a pretty narrow window for the race I think it would be hard to observe the effect of the bug.

Yup, I found that some time ago. I though I even fixed it while hacking on the return from exception path. The fix has probably been lost along with some of that experimental stuff I was doing at that time though, I remember you saying the problem wasn't that big.

Ben.

#5 lore raw
In reply to David S. Miller

From: Paul Mackerras <[email protected]>
Date: Thu, 6 Dec 2001 07:55:26 +1100 (EST)

I think David (Mosberger, not Miller :) is right here, and in fact this is also wrong on PPC at the moment. However, the worst case is that the reschedule or signal delivery will get delayed until the next interrupt on that cpu (max 1/HZ seconds). Since it is a pretty narrow window for the race I think it would be hard to observe the effect of the bug.

I understand now, thanks. I've fixed up sparc64.

So it's a latency problem, not a correctness problem.