diff options
author | Mika Kukkonen <mikukkon@miku.homelinux.net> | 2007-05-11 01:22:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:32 -0400 |
commit | 7faaa5f0bf4db6ac4908038e2139adc46c165ff4 (patch) | |
tree | e6efe930b1749b4f133945468dad807c43fe1732 /mm/thrash.c | |
parent | 069f11f9d66bc582fb40a37a7b92363f5d321969 (diff) |
Bug in mm/thrash.c function grab_swap_token()
Following bug was uncovered by compiling with '-W' flag:
CC mm/thrash.o
mm/thrash.c: In function âgrab_swap_tokenâ:
mm/thrash.c:52: warning: comparison of unsigned expression < 0 is always false
Variable token_priority is unsigned, so decrementing first and then
checking the result does not work; fixed by reversing the test, patch
attached (compile tested only).
I am not sure if likely() makes much sense in this new situation, but
I'll let somebody else to make a decision on that.
Signed-off-by: Mika Kukkonen <mikukkon@iki.fi>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/thrash.c')
-rw-r--r-- | mm/thrash.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/mm/thrash.c b/mm/thrash.c index 9ef9071f99bc..c4c5205a9c35 100644 --- a/mm/thrash.c +++ b/mm/thrash.c | |||
@@ -48,9 +48,8 @@ void grab_swap_token(void) | |||
48 | if (current_interval < current->mm->last_interval) | 48 | if (current_interval < current->mm->last_interval) |
49 | current->mm->token_priority++; | 49 | current->mm->token_priority++; |
50 | else { | 50 | else { |
51 | current->mm->token_priority--; | 51 | if (likely(current->mm->token_priority > 0)) |
52 | if (unlikely(current->mm->token_priority < 0)) | 52 | current->mm->token_priority--; |
53 | current->mm->token_priority = 0; | ||
54 | } | 53 | } |
55 | /* Check if we deserve the token */ | 54 | /* Check if we deserve the token */ |
56 | if (current->mm->token_priority > | 55 | if (current->mm->token_priority > |