From: Hugh Dickins Date: Fri, 23 Jun 2006 09:03:44 +0000 (-0700) Subject: [PATCH] swapoff: use atomic_inc_not_zero() on mm_users X-Git-Tag: v2.6.18-rc1~1081^2~168 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=70af7c5c6492ef6ad137dbff6c4568c73edbcaf0;p=~shefty%2Frdma-dev.git [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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/swapfile.c b/mm/swapfile.c index fbceed67a07..f2824c3c31b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -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;