Re: [PATCH] task containersv11 add tasks file interface fix for cpusets

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Paul Menage
Date: Saturday, October 6, 2007 - 2:09 pm

On 10/6/07, Paul Jackson <pj@sgi.com> wrote:

But if userspace has to do it, the effect will be far more expensive.


In general, the loop inside cgroup_task_count() will only have a
single iteration. (It's iterating across the shared css_set objects,
not across member tasks.

What's wrong with:

  allocate a page of task_struct pointers
again:
  need_repeat = false;
  cgroup_iter_start();
  while (cgroup_iter_next()) {
    if (p->cpus_allowed != new_cpumask) {
      store p;
      if (page is full) {
        need_repeat = true;
        break;
      }
    }
  }
  for each saved task p {
    set_cpus_allowed(p, new_cpumask);
    release p;
  }
  if (need_repeat)
    goto again;

Advantages:

- no vmalloc needed
- just one iteration in the case where a cgroup has fewer than 512 members
- additional iterations only need to deal with tasks that don't have
the right cpu mask
- automatically handles fork races


Another option would be to have a cpuset fork callback that forces
p->cpus_allowed to its cpuset's cpus_allowed if another thread is in
the middle of update_cpumask(). Then you don't need to worry about
fork races at all, since all new threads will get the right cpumask.


I'd much rather not perpetuate that broken API requirement. The fact
that cpusets wants this odd behaviour is based on a nasty hack.

Paul
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] task containersv11 add tasks file interface fi ..., Paul Menage, (Sat Oct 6, 2:09 pm)
Re: [PATCH] task containersv11 add tasks file interface fi ..., Eric W. Biederman, (Thu Oct 11, 4:20 pm)