From: Con Kolivas <kernel@kolivas.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>,
Ingo Molnar <mingo@elte.hu>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Mike Galbraith <efault@gmx.de>
Subject: Re: [BUG] scheduler: first timeslice of the exiting thread
Date: Sat, 14 Apr 2007 01:31:12 +1000 [thread overview]
Message-ID: <200704140131.12500.kernel@kolivas.org> (raw)
In-Reply-To: <20070408230927.9a49c504.akpm@linux-foundation.org>
On Monday 09 April 2007 16:09, Andrew Morton wrote:
> On Sat, 07 Apr 2007 16:31:39 +0900 Satoru Takeuchi
<takeuchi_satoru@jp.fujitsu.com> wrote:
> > When I was examining the following program ...
> >
> > 1. There are a large amount of small jobs takes several msecs,
> > and the number of job increases constantly.
> > 2. The process creates a thread or a process per job (I examined both
> > the thread model and the process model).
> > 3. Each child process/thread does the assigned job and exit
> > immediately.
> >
> > ... I found that the thread model's latency is longer than proess
> > model's one against my expectation. It's because of the current
> > sched_fork()/sched_exit() implementation as follows:
> >
> > a) On sched_fork, the creator share its timeslice with new process.
> > b) On sched_exit, if the exiting process didn't exhaust its first
> > timeslice yet, it gives its timeslice to the parent.
> >
> > It has no problem on the process model since the creator is the parent.
> > However, on the thread model, the creator is not the parent, it is same
> > as the creator's parent. Hence, on this kind of program, the creator
> > can't retrieve shared timeslice and exausts its timeslice at a rate of
> > knots. In addition, somehow, the parent (typically shell?) gets extra
> > timeslice.
> >
> > I believe it's a bug and the exiting process should give its timeslice
> > to the creator. Now I have some patch plan to fix this problem as follow:
> >
> > a) Add the field for the creator to task_struct. It needs extra memory.
> > b) Doesn't add extra field and have thread's parent the creater, which
> > is same as process creation. However it has many side effects, for
> > example, we also need to change sys_getppid() implementation.
> >
> > What do you think? Any comments are welcome.
>
> This comes at an awkward time, because we might well merge the
> staircase/deadline work into 2.6.22, and I think it rewrites the part of
> the scheduler which is causing the problems you're observing.
>
> Has anyone verified that SD fixes this problem and the one at
> http://lkml.org/lkml/2007/4/7/21 ?
No, SD does nothing different in this regard. There is no notion of who made
the thread and who the remaining timeslice should go to. As you say, some
decision on sched_exit should probably be used to decide where to send it. In
the absence of yet more fields in task_struct, the easiest thing to do would
be to check if the the thread id is equal to the pid and if not, send it to
the pid (or any parent of that if it no longer exists). Whether it's worth
adding yet another field to task_struct to track this or not I do not have
enough information to make an informed choice in this regard. Either way I'm
low on patch-creation cycles so please feel free to provide your solution.
--
-ck
next prev parent reply other threads:[~2007-04-13 15:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-07 7:31 [BUG] scheduler: first timeslice of the exiting thread Satoru Takeuchi
2007-04-07 7:45 ` Satoru Takeuchi
2007-04-09 6:09 ` Andrew Morton
2007-04-09 6:50 ` Mike Galbraith
2007-04-10 7:18 ` Satoru Takeuchi
2007-04-13 15:31 ` Con Kolivas [this message]
2007-04-16 2:16 ` [PATCH] scheduler: fix the return of the first time_slice Satoru Takeuchi
2007-04-16 4:36 ` [PATCH -mm] " Satoru Takeuchi
2007-04-16 10:45 ` Oleg Nesterov
2007-04-16 11:47 ` Oleg Nesterov
2007-04-16 11:54 ` Ingo Molnar
2007-04-16 11:58 ` Satoru Takeuchi
-- strict thread matches above, loose matches on Subject: below --
2007-04-09 10:29 [BUG] scheduler: first timeslice of the exiting thread Oleg Nesterov
2007-04-09 11:03 ` Oleg Nesterov
2007-04-10 1:19 ` Satoru Takeuchi
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=200704140131.12500.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=akpm@linux-foundation.org \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=takeuchi_satoru@jp.fujitsu.com \
/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