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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Rientjes
Date: Saturday, October 6, 2007 - 10:54 am

On Sat, 6 Oct 2007, Paul Jackson wrote:


It would probably be better to just save references to the tasks.

	struct cgroup_iter it;
	struct task_struct *p, **tasks;
	int i = 0;

	cgroup_iter_start(cs->css.cgroup, &it);
	while ((p = cgroup_iter_next(cs->css.cgroup, &it))) {
		get_task_struct(p);
		tasks[i++] = p;
	}
	cgroup_iter_end(cs->css.cgroup, &it);

	while (--i >= 0) {
		set_cpus_allowed(tasks[i], cs->cpus_allowed);
		put_task_struct(tasks[i]);
	}

The getting and putting of the tasks will prevent them from exiting or 
being deallocated prematurely.  But this is also a critical section that 
will need to be protected by some mutex so it doesn't race with other 
set_cpus_allowed().

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

Messages in current thread:
Re: [PATCH] task containersv11 add tasks file interface fi ..., David Rientjes, (Sat Oct 6, 10:54 am)
Re: [PATCH] task containersv11 add tasks file interface fi ..., Eric W. Biederman, (Thu Oct 11, 4:20 pm)