All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vmscan: Remove if statement that will never trigger
@ 2011-07-28 21:05 ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-07-28 21:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, Rik van Riel, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	Andrew Morton, kanoj, sct

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
-- 
1.7.6


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] vmscan: Remove if statement that will never trigger
@ 2011-07-28 21:05 ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-07-28 21:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, Rik van Riel, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	Andrew Morton, kanoj, sct

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
-- 
1.7.6


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
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>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmscan: Remove if statement that will never trigger
  2011-07-28 21:05 ` Jesper Juhl
@ 2011-07-29  6:27   ` KOSAKI Motohiro
  -1 siblings, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2011-07-29  6:27 UTC (permalink / raw)
  To: jj; +Cc: linux-kernel, linux-mm, riel, minchan.kim, mgorman, akpm, kanoj, sct

(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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmscan: Remove if statement that will never trigger
@ 2011-07-29  6:27   ` KOSAKI Motohiro
  0 siblings, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2011-07-29  6:27 UTC (permalink / raw)
  To: jj; +Cc: linux-kernel, linux-mm, riel, minchan.kim, mgorman, akpm, kanoj, sct

(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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmscan: Remove if statement that will never trigger
  2011-07-29  6:27   ` KOSAKI Motohiro
@ 2011-07-29  9:16     ` Jesper Juhl
  -1 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-07-29  9:16 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: linux-kernel, linux-mm, riel, minchan.kim, mgorman, akpm, kanoj, sct

On Fri, 29 Jul 2011, KOSAKI Motohiro wrote:

> (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.
> 
Right. We probably shouldn't just remove it.

I'll cook a new version of the patch tonight that properly checks for 
overflow.


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vmscan: Remove if statement that will never trigger
@ 2011-07-29  9:16     ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-07-29  9:16 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: linux-kernel, linux-mm, riel, minchan.kim, mgorman, akpm, kanoj, sct

On Fri, 29 Jul 2011, KOSAKI Motohiro wrote:

> (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.
> 
Right. We probably shouldn't just remove it.

I'll cook a new version of the patch tonight that properly checks for 
overflow.


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-29  9:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 21:05 [PATCH] vmscan: Remove if statement that will never trigger Jesper Juhl
2011-07-28 21:05 ` Jesper Juhl
2011-07-29  6:27 ` KOSAKI Motohiro
2011-07-29  6:27   ` KOSAKI Motohiro
2011-07-29  9:16   ` Jesper Juhl
2011-07-29  9:16     ` Jesper Juhl

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.