[PATCH] swapoff atomic_inc_not_zero on mm_users

From: Hugh Dickins
Date: Fri May 26 2006 - 15:41:08 EST


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@xxxxxxxxxxx>
---
mm/swapfile.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

--- 2.6.17-rc5/mm/swapfile.c 2006-05-25 03:43:37.000000000 +0100
+++ linux/mm/swapfile.c 2006-05-26 17:55:29.000000000 +0100
@@ -785,10 +785,8 @@ again:
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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/