Re: [PATCH 4/7] sched: implement force_cpus_allowed()

From: Peter Zijlstra
Date: Fri Dec 04 2009 - 05:41:42 EST


On Wed, 2009-12-02 at 12:56 +0900, Tejun Heo wrote:
> set_cpus_allowed_ptr() modifies the allowed cpu mask of a task. The
> function performs the following checks before applying new mask.
>
> * Check whether PF_THREAD_BOUND is set. This is set for bound
> kthreads so that they can't be moved around.
>
> * Check whether the target cpu is still marked active - cpu_active().
> Active state is cleared early while downing a cpu.
>
> This patch adds force_cpus_allowed() which bypasses the above two
> checks. The caller is responsible for guaranteeing that the
> destination cpu doesn't go down until force_cpus_allowed() finishes.
>
> The first check is bypassed by factoring out actual migration part
> into __set_cpus_allowed() from set_cpus_allowed_ptr() and calling the
> inner function from force_cpus_allowed().
>
> The second check is buried deep down in __migrate_task() which is
> executed by migration threads. @force parameter is added to
> __migrate_task(). As the only way to pass parameters from
> __set_cpus_allowed() is through migration_req, migration_req->force is
> added and the @force parameter is passed down to __migrate_task().
>
> Please note the naming discrepancy between set_cpus_allowed_ptr() and
> the new functions. The _ptr suffix is from the days when cpumask api
> wasn't mature and future changes should drop it from
> set_cpus_allowed_ptr() too.
>
> force_cpus_allowed() will be used for concurrency-managed workqueue.

Would still like to know why all this is needed.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/