Commit 70af7c5c6492ef6ad137dbff6c4568c73edbcaf0
Committed by
Linus Torvalds
1 parent
9637a5efd4
Exists in
master
and in
20 other branches
[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>
Showing 1 changed file with 1 additions and 3 deletions Side-by-side Diff
mm/swapfile.c
... | ... | @@ -772,10 +772,8 @@ |
772 | 772 | while (*swap_map > 1 && !retval && |
773 | 773 | (p = p->next) != &start_mm->mmlist) { |
774 | 774 | mm = list_entry(p, struct mm_struct, mmlist); |
775 | - if (atomic_inc_return(&mm->mm_users) == 1) { | |
776 | - atomic_dec(&mm->mm_users); | |
775 | + if (!atomic_inc_not_zero(&mm->mm_users)) | |
777 | 776 | continue; |
778 | - } | |
779 | 777 | spin_unlock(&mmlist_lock); |
780 | 778 | mmput(prev_mm); |
781 | 779 | prev_mm = mm; |