From: Yuly Finkelberg <liquidicecube@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Problem while stopping many threads within a module
Date: Fri, 6 May 2005 19:15:47 -0400 [thread overview]
Message-ID: <92df317505050616152d07f7f@mail.gmail.com> (raw)
In-Reply-To: <d5e597$jok$1@news.cistron.nl>
Hello -
I'm having a strange thread scheduling issue in a project that I'm
working on. We have a module, with an interface that can be called by
many (currently 50) threads simulatenously. Threads that have entered
the kernel, sleep on a wait queue until everyone else has entered. At
this point, a "master" process wakes up the first thread, which does
some work, then wakes up the second, etc. After waking up its
successor, each thread changes its state to STOPPED and sends itself a
SIGSTOP. Note that the threads are created with
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND but NOT CLONE_THREAD so
there is no group stop.
Basically, the structure is the following:
kernel_entry_point() {
wait until its your turn
...... do some work .... (serialized)
wake up the next thread
send SIGSTOP to yourself
}
At the same time, a monitoring process polls until all the threads
have stopped themselves:
monitor() {
repeat:
for each thread
if (thread->state < TASK_STOPPED)
yield()
goto repeat
}
Now, here's the problem. On 2.6.9 UP (Preempt), it is often the case
that one thread gets "stuck" in between the wake up of the next thread
and stopping itself -- this causes the monitor to poll for extended
periods of time, since the thread remains RUNNING. Strangely enough,
it generally gets unstuck by itself, sometimes within 10 seconds,
sometimes after as long as 10 minutes. When peeking at the kernel
stack of the offending process via the monitor, I only see that it is
in schedule and the stack looks like this:
c55e7ad0 00000086 c55e6000 c55e7a94 00000046 c55e6000 c55e7ad0 c0109c2d
00000000 c03ddae0 00000001 fd0b6c12 0013bc9f c6502130 001770fe fd478e5c
0013bc9f c55d546c c05d3960 00002710 c05d3960 c55e6000 c0106f25 c05d3960
Call Trace:
[<c0106f25>] need_resched+0x27/0x32
It also continues to be charged ticks, indicating that its being
scheduled but is making no progress? However, I can't find anything
that this thread could be spinning on. Also, I don't understand why
there is no further context on the stack -- the thread does eventually
finish and never leaves the kernel, so the stack shouldn't be
corrupted... How can it finish if it has nowhere to return?
I realize that this is a long shot, but if anyone has any ideas, I'd
appreciate hearing them. Please let me know if I can provide any
further information.
Thanks,
-Yuly
next prev parent reply other threads:[~2005-05-06 23:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-04 17:37 Scheduler: SIGSTOP on multi threaded processes Olivier Croquette
2005-05-04 18:16 ` Richard B. Johnson
2005-05-04 19:16 ` Daniel Jacobowitz
2005-05-04 21:06 ` Alex Riesen
2005-05-05 0:42 ` Richard B. Johnson
2005-05-05 0:33 ` Richard B. Johnson
2005-05-05 0:45 ` Richard B. Johnson
2005-05-05 12:24 ` Richard B. Johnson
2005-05-05 13:14 ` Denis Vlasenko
2005-05-05 13:30 ` Andreas Schwab
2005-05-05 22:04 ` Miquel van Smoorenburg
2005-05-06 23:15 ` Yuly Finkelberg [this message]
2006-04-20 8:43 ` Problem while stopping many threads within a module shikha
2005-05-10 20:59 ` Scheduler: SIGSTOP on multi threaded processes Olivier Croquette
2005-05-10 21:12 ` Roland McGrath
2005-05-11 18:58 ` Olivier Croquette
2005-05-10 23:05 ` Alex Riesen
2005-05-05 1:04 ` Andy Isaacson
2005-05-04 19:10 ` Alexander Nyberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92df317505050616152d07f7f@mail.gmail.com \
--to=liquidicecube@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox