Skip to contentSkip to conversation

vmscan: shrinker->nr updates race and go wrong

DISCUSSION Dan Carpenter 2 participants 2 messages Jul 19, 2011 – Jul 20, 2011 Memory management

lore
Share & tools
lore
#0 lore raw

Hi Dave,

There is a sign error in e5b94d7463e0 "vmscan: shrinker->nr updates race and go wrong"

mm/vmscan.c +274 shrink_slab(41)
warn: unsigned 'total_scan' is never less than zero.

   268                  total_scan = nr;
   269                  max_pass = do_shrinker_shrink(shrinker, shrink, 0);
   270                  delta = (4 * nr_pages_scanned) / shrinker->seeks;
   271                  delta *= max_pass;
   272                  do_div(delta, lru_pages + 1);
   273                  total_scan += delta;
   274                  if (total_scan < 0) {
                            ^^^^^^^^^^^^^^

total_scan is unsigned so it's never less than zero here.

   275                          printk(KERN_ERR "shrink_slab: %pF negative objects to "
   276                                 "delete nr=%ld\n",
   277                                 shrinker->shrink, total_scan);
   278                          total_scan = max_pass;
   279                  }

regards,
dan carpenter

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 16 lines · Dan Carpenter

Hi Dave,

There is a sign error in e5b94d7463e0 "vmscan: shrinker->nr updates race and go wrong"

mm/vmscan.c +274 shrink_slab(41)
warn: unsigned 'total_scan' is never less than zero.

   268                  total_scan = nr;
   269                  max_pass = do_shrinker_shrink(shrinker, shrink, 0);
   270                  delta = (4 * nr_pages_scanned) / shrinker->seeks;
   271                  delta *= max_pass;
   272                  do_div(delta, lru_pages + 1);
   273                  total_scan += delta;
   274                  if (total_scan < 0) {
                            ^^^^^^^^^^^^^^
Quoted 1 line

total_scan is unsigned so it's never less than zero here.

Obviously. You'd think a kernel build would warn about that given that it's almost always a bug, wouldn't you?

I'll send a patch to fix it up....

Cheers,

Dave.

Signature · 9 lines
Dave Chinner
[email protected]

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  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:"[email protected]"> [email protected] </a>