Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20343
b: refs/heads/master
c: 06fed33
h: refs/heads/master
i:
  20341: 1286857
  20339: e7c0930
  20335: 4b17c9d
v: v3
  • Loading branch information
Paul Jackson authored and Linus Torvalds committed Feb 15, 2006
1 parent c9138c4 commit ca16d49
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 651c29a17f7ea0204dacbc2a5042d57b1c9e2e37
refs/heads/master: 06fed33849c13af637c4d09e9ba27828fac9edd5
35 changes: 34 additions & 1 deletion trunk/kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,14 +1977,47 @@ void cpuset_fork(struct task_struct *child)
* We don't need to task_lock() this reference to tsk->cpuset,
* because tsk is already marked PF_EXITING, so attach_task() won't
* mess with it, or task is a failed fork, never visible to attach_task.
*
* Hack:
*
* Set the exiting tasks cpuset to the root cpuset (top_cpuset).
*
* Don't leave a task unable to allocate memory, as that is an
* accident waiting to happen should someone add a callout in
* do_exit() after the cpuset_exit() call that might allocate.
* If a task tries to allocate memory with an invalid cpuset,
* it will oops in cpuset_update_task_memory_state().
*
* We call cpuset_exit() while the task is still competent to
* handle notify_on_release(), then leave the task attached to
* the root cpuset (top_cpuset) for the remainder of its exit.
*
* To do this properly, we would increment the reference count on
* top_cpuset, and near the very end of the kernel/exit.c do_exit()
* code we would add a second cpuset function call, to drop that
* reference. This would just create an unnecessary hot spot on
* the top_cpuset reference count, to no avail.
*
* Normally, holding a reference to a cpuset without bumping its
* count is unsafe. The cpuset could go away, or someone could
* attach us to a different cpuset, decrementing the count on
* the first cpuset that we never incremented. But in this case,
* top_cpuset isn't going away, and either task has PF_EXITING set,
* which wards off any attach_task() attempts, or task is a failed
* fork, never visible to attach_task.
*
* Another way to do this would be to set the cpuset pointer
* to NULL here, and check in cpuset_update_task_memory_state()
* for a NULL pointer. This hack avoids that NULL check, for no
* cost (other than this way too long comment ;).
**/

void cpuset_exit(struct task_struct *tsk)
{
struct cpuset *cs;

cs = tsk->cpuset;
tsk->cpuset = NULL;
tsk->cpuset = &top_cpuset; /* Hack - see comment above */

if (notify_on_release(cs)) {
char *pathbuf = NULL;
Expand Down

0 comments on commit ca16d49

Please sign in to comment.