Thread (3 messages) 3 messages, 2 authors, 2011-07-29

Re: [PATCH] vmscan: Remove if statement that will never trigger

From: KOSAKI Motohiro <hidden>
Date: 2011-07-29 06:28:09
Also in: lkml

(2011/07/29 6:05), Jesper Juhl wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help