[lkml]   [2004]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[Patch 2/4] cpusets simplify cpus_allowed setting in attach
    When reattaching a task to a different cpuset, I had
    code that attempted to preserve the cpuset relative
    placement of the task (such as might have been done
    using sched_setaffinity, mbind or set_mempolicy) by
    rebinding the task to the intersection of its old
    and new placement, if not empty.

    This resulted in strange and puzzling behaviour, such
    as having a tasks cpus_allowed not change if the task
    was reattached to the root cpuset.

    Simplify the code - when attaching a task to a cpuset,
    simply set its cpus_allowed to that of the cpuset.
    This is much less surprising in practice.

    Signed-off-by: Paul Jackson <>

    Index: 2.6.9-rc1-mm4/kernel/cpuset.c
    --- 2.6.9-rc1-mm4.orig/kernel/cpuset.c 2004-09-08 15:22:59.000000000 -0700
    +++ 2.6.9-rc1-mm4/kernel/cpuset.c 2004-09-08 18:44:33.000000000 -0700
    @@ -605,7 +605,6 @@ static int attach_task(struct cpuset *cs
    pid_t pid;
    struct task_struct *tsk;
    struct cpuset *oldcs;
    - cpumask_t cpus;

    if (sscanf(buf, "%d", &pid) != 1)
    return -EIO;
    @@ -645,16 +644,7 @@ static int attach_task(struct cpuset *cs
    tsk->cpuset = cs;

    - /*
    - * If the tasks current CPU placement overlaps with its new cpuset,
    - * then let it run in that overlap. Otherwise fallback to simply
    - * letting it have the run of the CPUs in the new cpuset.
    - */
    - if (cpus_intersects(tsk->cpus_allowed, cs->cpus_allowed))
    - cpus_and(cpus, tsk->cpus_allowed, cs->cpus_allowed);
    - else
    - cpus = cs->cpus_allowed;
    - set_cpus_allowed(tsk, cpus);
    + set_cpus_allowed(tsk, cs->cpus_allowed);

    if (atomic_dec_and_test(&oldcs->count))
    I won't rest till it's the best ...
    Programmer, Linux Scalability
    Paul Jackson <> 1.650.933.1373
    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:06    [W:0.021 / U:2.788 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site