linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: jj@chaosbits.net
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	riel@redhat.com, minchan.kim@gmail.com, mgorman@suse.de,
	akpm@linux-foundation.org, kanoj@sgi.com, sct@redhat.com
Subject: Re: [PATCH] vmscan: Remove if statement that will never trigger
Date: Fri, 29 Jul 2011 15:27:46 +0900	[thread overview]
Message-ID: <4E3252E2.1030101@jp.fujitsu.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1107282302580.20477@swampdragon.chaosbits.net>

(2011/07/29 6:05), Jesper Juhl wrote:
> We have this code in mm/vmscan.c:shrink_slab() :
> ...
> 		if (total_scan < 0) {
> 			printk(KERN_ERR "shrink_slab: %pF negative objects to "
> 			       "delete nr=%ld\n",
> 			       shrinker->shrink, total_scan);
> 			total_scan = max_pass;
> 		}
> ...
> but since 'total_scan' is of type 'unsigned long' it will never be
> less than zero, so there is no way we'll ever enter the true branch of
> this if statement - so let's just remove it.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  mm/vmscan.c |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)
> 
> 	Compile tested only.
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7ef6912..c07d9b1 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -271,12 +271,6 @@ unsigned long shrink_slab(struct shrink_control *shrink,
>  		delta *= max_pass;
>  		do_div(delta, lru_pages + 1);
>  		total_scan += delta;
> -		if (total_scan < 0) {
> -			printk(KERN_ERR "shrink_slab: %pF negative objects to "
> -			       "delete nr=%ld\n",
> -			       shrinker->shrink, total_scan);
> -			total_scan = max_pass;
> -		}
>  
>  		/*
>  		 * We need to avoid excessive windup on filesystem shrinkers

Good catch.

However this seems intended to catch a overflow. So, I'd suggest to make proper
overflow check instead.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-07-29  6:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 21:05 Jesper Juhl
2011-07-29  6:27 ` KOSAKI Motohiro [this message]
2011-07-29  9:16   ` Jesper Juhl

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=4E3252E2.1030101@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=jj@chaosbits.net \
    --cc=kanoj@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan.kim@gmail.com \
    --cc=riel@redhat.com \
    --cc=sct@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox