Skip to content

Commit

Permalink
[PATCH] swapoff: use atomic_inc_not_zero() on mm_users
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Jun 23, 2006
1 parent 9637a5e commit 70af7c5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,8 @@ static int try_to_unuse(unsigned int type)
while (*swap_map > 1 && !retval &&
(p = p->next) != &start_mm->mmlist) {
mm = list_entry(p, struct mm_struct, mmlist);
if (atomic_inc_return(&mm->mm_users) == 1) {
atomic_dec(&mm->mm_users);
if (!atomic_inc_not_zero(&mm->mm_users))
continue;
}
spin_unlock(&mmlist_lock);
mmput(prev_mm);
prev_mm = mm;
Expand Down

0 comments on commit 70af7c5

Please sign in to comment.