aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2006-06-23 05:03:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:42:51 -0400
commit70af7c5c6492ef6ad137dbff6c4568c73edbcaf0 (patch)
tree4e8646ba72b14f2bdd94802d42684c00c1a7507c /mm/swapfile.c
parent9637a5efd4fbe36164c5ce7f6a0ee68b2bf22b7f (diff)
[PATCH] swapoff: use atomic_inc_not_zero() on mm_users
Now that we have atomic_inc_not_zero, it's more elegant for try_to_unuse to use that on mm_users: doesn't actually matter at present, but safer to be sure that once mm_users has gone to 0, nothing raises it for an instant. Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index fbceed67a075..f2824c3c31b4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -772,10 +772,8 @@ static int try_to_unuse(unsigned int type)
772 while (*swap_map > 1 && !retval && 772 while (*swap_map > 1 && !retval &&
773 (p = p->next) != &start_mm->mmlist) { 773 (p = p->next) != &start_mm->mmlist) {
774 mm = list_entry(p, struct mm_struct, mmlist); 774 mm = list_entry(p, struct mm_struct, mmlist);
775 if (atomic_inc_return(&mm->mm_users) == 1) { 775 if (!atomic_inc_not_zero(&mm->mm_users))
776 atomic_dec(&mm->mm_users);
777 continue; 776 continue;
778 }
779 spin_unlock(&mmlist_lock); 777 spin_unlock(&mmlist_lock);
780 mmput(prev_mm); 778 mmput(prev_mm);
781 prev_mm = mm; 779 prev_mm = mm;