mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: Con Kolivas <kernel@kolivas.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH -mm] scheduler: fix the return of the first time_slice
Date: Mon, 16 Apr 2007 14:45:59 +0400	[thread overview]
Message-ID: <20070416104559.GA84@tv-sign.ru> (raw)
In-Reply-To: <87wt0dq6jn.wl%takeuchi_satoru@jp.fujitsu.com>

On 04/16, Satoru Takeuchi wrote:
>
> --- linux-2.6.21-rc6-mm1.tsfix.orig/kernel/exit.c	2007-04-15 16:56:12.000000000 +0900
> +++ linux-2.6.21-rc6-mm1.tsfix/kernel/exit.c	2007-04-15 16:56:17.000000000 +0900
> @@ -680,10 +680,14 @@
>  			reaper = child_reaper(father);
>  			break;
>  		}
> +		if (reaper->time_slice_reaper == father)
> +			reaper->time_slice_reaper = NULL;
>  	} while (reaper->exit_state);
>  
>  	list_for_each_safe(_p, _n, &father->children) {
>  		p = list_entry(_p, struct task_struct, sibling);
> +		if (p->time_slice_reaper == father)
> +			p->time_slice_reaper = NULL;
>  		choose_new_parent(p, reaper);
>  		reparent_thread(p, father);
>  	}
> Index: linux-2.6.21-rc6-mm1.tsfix/kernel/sched.c
> ===================================================================
> --- linux-2.6.21-rc6-mm1.tsfix.orig/kernel/sched.c	2007-04-15 16:56:12.000000000 +0900
> +++ linux-2.6.21-rc6-mm1.tsfix/kernel/sched.c	2007-04-15 16:56:17.000000000 +0900
> @@ -1693,7 +1693,7 @@
>  	 * The remainder of the first timeslice might be recovered by
>  	 * the parent if the child exits early enough.
>  	 */
> -	p->first_time_slice = 1;
> +	p->time_slice_reaper = current;
>  	p->timestamp = sched_clock();
>  	local_irq_enable();

I am afraid this doesn't work for CLONE_THREAD. Suppose that some sub-thread (not
main thread) T1 creates another sub-thread, T2.

	T2->time_slice_reaper = T1.

then T1 exits, but forget_original_parent(T1) doesn't change T2->time_slice_reaper,
because T2 is not on T1->children list. Now T2->time_slice_reaper points to an
already freed task_struct.

Oleg.


  reply	other threads:[~2007-04-16 10:46 UTC|newest]

Thread overview: 12+ 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
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 [this message]
2007-04-16 11:47           ` Oleg Nesterov
2007-04-16 11:54             ` Ingo Molnar
2007-04-16 11:58           ` 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=20070416104559.GA84@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=efault@gmx.de \
    --cc=kernel@kolivas.org \
    --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

Powered by JetHome