* Re: PROBLEM: Bug in __pollwait() can cause select() and poll() to hang in
@ 2003-06-19 16:13 Manfred Spraul
2003-06-19 18:09 ` PROBLEM: Bug in __pollwait() can cause select() and poll() tohang in Ray Bryant
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2003-06-19 16:13 UTC (permalink / raw)
To: Ray Bryant, linux-kernel
Hi Ray,
your bug description seems to be correct, but the fix is wrong:
If the allocation is for the 2nd page of wait queue heads, then
"current->state = TASK_INTERRUPTIBLE" can lead to lost wakeups, if an fd
that is stored in the first page gets ready during the allocation.
Setting the state to interruptible is only permitted if a full scan of
all file descriptors happens before calling schedule(). This is
expensive and should be avoided.
The correct fix is current->state = TASK_RUNNING just before calling
yield() in the rebalance code.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PROBLEM: Bug in __pollwait() can cause select() and poll() tohang in
2003-06-19 16:13 PROBLEM: Bug in __pollwait() can cause select() and poll() to hang in Manfred Spraul
@ 2003-06-19 18:09 ` Ray Bryant
2003-06-19 18:21 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Ray Bryant @ 2003-06-19 18:09 UTC (permalink / raw)
To: Manfred Spraul; +Cc: linux-kernel
Manfred Spraul wrote:
>
> Hi Ray,
>
> your bug description seems to be correct, but the fix is wrong:
> If the allocation is for the 2nd page of wait queue heads, then
> "current->state = TASK_INTERRUPTIBLE" can lead to lost wakeups, if an fd
> that is stored in the first page gets ready during the allocation.
Hi Manfred,
Grumble. :-) Yes, I believe you are correct.
> Setting the state to interruptible is only permitted if a full scan of
> all file descriptors happens before calling schedule(). This is
> expensive and should be avoided.
>
> The correct fix is current->state = TASK_RUNNING just before calling
> yield() in the rebalance code.
But doesn't this have the same kind of problem? e. g., just before
calling yield() in the rebalance code we save current->state, set it to
TASK_RUNNING, then restore current->state on return from yield(). If a
fd becomes ready after the call to yield(), and we entered
__alloc_pages() with state TASK_INTERRUPTIBLE, aren't we in exactly the
same situation as described above?
Let me think about this some more.
Thanks,
--
Best Regards,
Ray
-----------------------------------------------
Ray Bryant
512-453-9679 (work) 512-507-7807 (cell)
raybry@sgi.com raybry@austin.rr.com
The box said: "Requires Windows 98 or better",
so I installed Linux.
-----------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PROBLEM: Bug in __pollwait() can cause select() and poll() tohang in
2003-06-19 18:09 ` PROBLEM: Bug in __pollwait() can cause select() and poll() tohang in Ray Bryant
@ 2003-06-19 18:21 ` Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2003-06-19 18:21 UTC (permalink / raw)
To: Ray Bryant; +Cc: manfred, linux-kernel
Ray Bryant <raybry@sgi.com> wrote:
>
> > The correct fix is current->state = TASK_RUNNING just before calling
> > yield() in the rebalance code.
>
> But doesn't this have the same kind of problem? e. g., just before
> calling yield() in the rebalance code we save current->state, set it to
> TASK_RUNNING, then restore current->state on return from yield(). If a
> fd becomes ready after the call to yield(), and we entered
> __alloc_pages() with state TASK_INTERRUPTIBLE, aren't we in exactly the
> same situation as described above?
No, you cannot restore the task state after having set it to TASK_RUNNING.
Just leave the state at TASK_RUNNING. The (silly) code which called the
page allocator in state TASK_[IN]TERRUPTIBLE will just go around its wait
loop an extra time and go back to sleep. This almost always works.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-06-19 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-19 16:13 PROBLEM: Bug in __pollwait() can cause select() and poll() to hang in Manfred Spraul
2003-06-19 18:09 ` PROBLEM: Bug in __pollwait() can cause select() and poll() tohang in Ray Bryant
2003-06-19 18:21 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox