All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ashok Raj <ashok.raj@intel.com>
To: Shaohua Li <shaohua.li@intel.com>
Cc: lkml <linux-kernel@vger.kernel.org>, akpm <akpm@osdl.org>,
	nickpiggin@yahoo.com.au
Subject: Re: [PATCH]CPU hotplug breaks wake_up_new_task
Date: Tue, 31 May 2005 01:00:31 -0700	[thread overview]
Message-ID: <20050531010030.A5239@unix-os.sc.intel.com> (raw)
In-Reply-To: <1117524909.3820.11.camel@linux-hp.sh.intel.com>; from shaohua.li@intel.com on Tue, May 31, 2005 at 12:35:09AM -0700

On Tue, May 31, 2005 at 12:35:09AM -0700, Shaohua Li wrote:
> 
>    Hi,
>    There is a race condition at wake_up_new_task at CPU hotplug case.
>    Say do_fork
>             copy_process  (which  sets  new  forked  task's  current cpu,
>    cpu_allowed)
>                    <-------- the new forked task's current cpu is offline
>            wake_up_new_task
>    wake_up_new_task will put the forked task into a dead cpu.
> 
>    Thanks,
>    Shaohua
> 
>    Signed-off-by: Shaohua Li<shaohua.li@intel.com>
>    ---
> 
>     linux-2.6.11-rc5-mm1-root/kernel/sched.c            |              25
.... Deleted....
>     /*
>       *  wake_up_new_task  -  wake  up a newly created task for the first
>    time.
>      *
>    @@ -1426,9 +1430,20 @@ void fastcall wake_up_new_task(task_t *
>            runqueue_t *rq, *this_rq;
> 
>            rq = task_rq_lock(p, &flags);
>    -       BUG_ON(p->state != TASK_RUNNING);
>            this_cpu = smp_processor_id();
>            cpu = task_cpu(p);
>    +#ifdef CONFIG_HOTPLUG_CPU
>    +       while (!cpu_online(cpu)) {
>    +               cpu = task_select_online_cpu(cpu, p);
>    +               set_task_cpu(p, cpu);
>    +               task_rq_unlock(rq, &flags);
>    +               /* CPU hotplug might occur here */
>    +               rq = task_rq_lock(p, &flags);
>    +               this_cpu = smp_processor_id();
>    +               cpu = task_cpu(p);
>    +       }
>    +#endif

The while() loop doesnt look pretty here.. could you try to 
disable preempt, and see the problem goes away? or use 
get_cpu()/put_cpu() combo when you get this_cpu?

Just wondering if the code would be a little more simpler in this
case.

Nick should have something to say ...

Cheers,
ashok

  reply	other threads:[~2005-05-31  8:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-31  7:35 [PATCH]CPU hotplug breaks wake_up_new_task Shaohua Li
2005-05-31  8:00 ` Ashok Raj [this message]
2005-05-31  8:35   ` Shaohua Li
2005-05-31  8:50     ` Nick Piggin
2005-05-31  9:11       ` Shaohua Li
2005-05-31  9:08         ` Nick Piggin
2005-05-31  9:40 ` Srivatsa Vaddagiri
2005-05-31  9:46   ` Nick Piggin
2005-05-31 10:40     ` Srivatsa Vaddagiri
2005-05-31 10:49       ` Nick Piggin
  -- strict thread matches above, loose matches on Subject: below --
2005-05-31 11:41 Li, Shaohua

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=20050531010030.A5239@unix-os.sc.intel.com \
    --to=ashok.raj@intel.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=shaohua.li@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.