From: Mika Kukkonen <mikukkon@miku.homelinux.net>
To: akpm@google.com, ashwin.chaugule@celunite.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix bug in mm/thrash.c function grab_swap_token()
Date: Thu, 10 May 2007 15:58:32 +0300 [thread overview]
Message-ID: <20070510125832.GA16461@srv1-m700-lanp.koti> (raw)
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
Field token_priority is unsigned, so decrementing first and the checking
is not a good plan. Attached patch (compile tested) reverses the order.
Btw, I'm not sure if likely() makes any sense in this new situation.
Signed-off-by: Mika Kukkonen <mikukkon@iki.fi>
diff --git a/mm/thrash.c b/mm/thrash.c
index 9ef9071..c4c5205 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -48,9 +48,8 @@ void grab_swap_token(void)
if (current_interval < current->mm->last_interval)
current->mm->token_priority++;
else {
- current->mm->token_priority--;
- if (unlikely(current->mm->token_priority < 0))
- current->mm->token_priority = 0;
+ if (likely(current->mm->token_priority > 0))
+ current->mm->token_priority--;
}
/* Check if we deserve the token */
if (current->mm->token_priority >
next reply other threads:[~2007-05-10 12:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-10 12:58 Mika Kukkonen [this message]
2007-05-10 15:26 ` Satyam Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070510125832.GA16461@srv1-m700-lanp.koti \
--to=mikukkon@miku.homelinux.net \
--cc=akpm@google.com \
--cc=ashwin.chaugule@celunite.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mikukkon@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®