mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: keventd_create_kthread
Date: Thu, 19 Feb 2004 20:46:58 +1100	[thread overview]
Message-ID: <20040219095358.EA9812C301@lists.samba.org> (raw)
In-Reply-To: Your message of "Thu, 19 Feb 2004 02:46:08 CDT." <Pine.LNX.4.58.0402190205040.16515@devserv.devel.redhat.com>

In message <Pine.LNX.4.58.0402190205040.16515@devserv.devel.redhat.com> you write:
> The current wait_task_inactive() code seems to be OK on x86.
> Context-switching cannot be preempted. The goal of wait_task_inactive() is
> to wait for the task to unschedule on a CPU. If that's due to preempt then
> it's due to preempt.

No, because it can come back at any time 8(

> that in any modern interface. Why does keventd_create_kthread() need
> wait_task_inactive()?

Um, the code was taken from sched.c to kthread:

2.6.3 migration_thread():
	set_current_state(TASK_UNINTERRUPTIBLE);
	schedule();

2.6.3 migration_call():
		kernel_thread(migration_thread, &startup, CLONE_KERNEL);
		wait_for_completion(&startup.startup_done);
		wait_task_inactive(startup.task);

		startup.task->thread_info->cpu = cpu;
		startup.task->cpus_allowed = cpumask_of_cpu(cpu);


So, if the migration thread has been preempted immediately before
schedule(), wait_task_inactive returns, but it can come back from
preempt while we're messing with startup.task->thread_info->cpu.

Now, the latter part is wrapped in kthread_bind(), which should really
be doing the wait_task_inactive itself (doing it in kthread_create is
overzealous).  But the race is still there.

Hope that clarifies,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

      parent reply	other threads:[~2004-02-19  9:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040218004648.7471bb37.akpm@osdl.org>
2004-02-18 23:12 ` keventd_create_kthread Rusty Russell
2004-02-19  7:46   ` keventd_create_kthread Ingo Molnar
2004-02-19  8:10     ` keventd_create_kthread Andrew Morton
2004-02-19  8:16       ` keventd_create_kthread Ingo Molnar
2004-02-19 10:05       ` keventd_create_kthread Srivatsa Vaddagiri
2004-02-19 10:10         ` keventd_create_kthread Andrew Morton
2004-02-19  9:46     ` Rusty Russell [this message]

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=20040219095358.EA9812C301@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.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

all inboxes | Powered by JetHome®