diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/exit.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 20a406471525..f2b321bae440 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -561,29 +561,28 @@ void exit_files(struct task_struct *tsk) | |||
| 561 | 561 | ||
| 562 | #ifdef CONFIG_MM_OWNER | 562 | #ifdef CONFIG_MM_OWNER |
| 563 | /* | 563 | /* |
| 564 | * Task p is exiting and it owned mm, lets find a new owner for it | 564 | * A task is exiting. If it owned this mm, find a new owner for the mm. |
| 565 | */ | 565 | */ |
| 566 | static inline int | ||
| 567 | mm_need_new_owner(struct mm_struct *mm, struct task_struct *p) | ||
| 568 | { | ||
| 569 | /* | ||
| 570 | * If there are other users of the mm and the owner (us) is exiting | ||
| 571 | * we need to find a new owner to take on the responsibility. | ||
| 572 | */ | ||
| 573 | if (atomic_read(&mm->mm_users) <= 1) | ||
| 574 | return 0; | ||
| 575 | if (mm->owner != p) | ||
| 576 | return 0; | ||
| 577 | return 1; | ||
| 578 | } | ||
| 579 | |||
| 580 | void mm_update_next_owner(struct mm_struct *mm) | 566 | void mm_update_next_owner(struct mm_struct *mm) |
| 581 | { | 567 | { |
| 582 | struct task_struct *c, *g, *p = current; | 568 | struct task_struct *c, *g, *p = current; |
| 583 | 569 | ||
| 584 | retry: | 570 | retry: |
| 585 | if (!mm_need_new_owner(mm, p)) | 571 | /* |
| 572 | * If the exiting or execing task is not the owner, it's | ||
| 573 | * someone else's problem. | ||
| 574 | */ | ||
| 575 | if (mm->owner != p) | ||
| 586 | return; | 576 | return; |
| 577 | /* | ||
| 578 | * The current owner is exiting/execing and there are no other | ||
| 579 | * candidates. Do not leave the mm pointing to a possibly | ||
| 580 | * freed task structure. | ||
| 581 | */ | ||
| 582 | if (atomic_read(&mm->mm_users) <= 1) { | ||
| 583 | mm->owner = NULL; | ||
| 584 | return; | ||
| 585 | } | ||
| 587 | 586 | ||
| 588 | read_lock(&tasklist_lock); | 587 | read_lock(&tasklist_lock); |
| 589 | /* | 588 | /* |
