diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2008-07-25 04:47:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:39 -0400 |
commit | 246bb0b1deb29726990620d8b5e55ca29f331362 (patch) | |
tree | 5173b9e0c1d18934a8b2693c690a7162acb1bca8 /fs/aio.c | |
parent | 7b34e4283c685f5cc6ba6d30e939906eee0d4bcf (diff) |
kill PF_BORROWED_MM in favour of PF_KTHREAD
Kill PF_BORROWED_MM. Change use_mm/unuse_mm to not play with ->flags, and
do s/PF_BORROWED_MM/PF_KTHREAD/ for a couple of other users.
No functional changes yet. But this allows us to do further
fixes/cleanups.
oom_kill/ptrace/etc often check "p->mm != NULL" to filter out the
kthreads, this is wrong because of use_mm(). The problem with
PF_BORROWED_MM is that we need task_lock() to avoid races. With this
patch we can check PF_KTHREAD directly, or use a simple lockless helper:
/* The result must not be dereferenced !!! */
struct mm_struct *__get_task_mm(struct task_struct *tsk)
{
if (tsk->flags & PF_KTHREAD)
return NULL;
return tsk->mm;
}
Note also ecard_task(). It runs with ->mm != NULL, but it's the kernel
thread without PF_BORROWED_MM.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 2 |
1 files changed, 0 insertions, 2 deletions
@@ -586,7 +586,6 @@ static void use_mm(struct mm_struct *mm) | |||
586 | struct task_struct *tsk = current; | 586 | struct task_struct *tsk = current; |
587 | 587 | ||
588 | task_lock(tsk); | 588 | task_lock(tsk); |
589 | tsk->flags |= PF_BORROWED_MM; | ||
590 | active_mm = tsk->active_mm; | 589 | active_mm = tsk->active_mm; |
591 | atomic_inc(&mm->mm_count); | 590 | atomic_inc(&mm->mm_count); |
592 | tsk->mm = mm; | 591 | tsk->mm = mm; |
@@ -610,7 +609,6 @@ static void unuse_mm(struct mm_struct *mm) | |||
610 | struct task_struct *tsk = current; | 609 | struct task_struct *tsk = current; |
611 | 610 | ||
612 | task_lock(tsk); | 611 | task_lock(tsk); |
613 | tsk->flags &= ~PF_BORROWED_MM; | ||
614 | tsk->mm = NULL; | 612 | tsk->mm = NULL; |
615 | /* active_mm is still 'mm' */ | 613 | /* active_mm is still 'mm' */ |
616 | enter_lazy_tlb(mm, tsk); | 614 | enter_lazy_tlb(mm, tsk); |