All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mikukkon@iki.fi
Cc: Mika Kukkonen <mikukkon@miku.homelinux.net>,
	ashwin.chaugule@celunite.com, linux-mm@kvack.org,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH] Bug in mm/thrash.c function grab_swap_token()
Date: Thu, 10 May 2007 15:29:57 -0700	[thread overview]
Message-ID: <20070510152957.edb26df3.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070510122359.GA16433@srv1-m700-lanp.koti>

On Thu, 10 May 2007 15:24:00 +0300
Mika Kukkonen <mikukkon@miku.homelinux.net> wrote:

> Following bug was uncovered by compiling with '-W' flag:
> 
>   CC      mm/thrash.o
> mm/thrash.c: In function a??grab_swap_tokena??:
> 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>
> 
> 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 >

argh.

This has potential to cause large changes in system performance.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

       reply	other threads:[~2007-05-10 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070510122359.GA16433@srv1-m700-lanp.koti>
2007-05-10 22:29 ` Andrew Morton [this message]
2007-05-11  6:49   ` [PATCH] Bug in mm/thrash.c function grab_swap_token() Ashwin Chaugule
2007-05-11  6:58     ` ashwin chaugule
2007-05-13 20:15     ` Rik van Riel
2007-05-14  7:38       ` ashwin chaugule

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=20070510152957.edb26df3.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ashwin.chaugule@celunite.com \
    --cc=linux-mm@kvack.org \
    --cc=mikukkon@iki.fi \
    --cc=mikukkon@miku.homelinux.net \
    --cc=riel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.