[lkml]   [2004]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: keventd_create_kthread
    In message <> 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():

    2.6.3 migration_call():
    kernel_thread(migration_thread, &startup, CLONE_KERNEL);

    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,
    Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:01    [W:0.025 / U:8.224 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site