lkml.org 
[lkml]   [2010]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 06/11] Export fragmentation index via /proc/extfrag_index
Date
> > > +	/*
> > > + * Index is between 0 and 1 so return within 3 decimal places
> > > + *
> > > + * 0 => allocation would fail due to lack of memory
> > > + * 1 => allocation would fail due to fragmentation
> > > + */
> > > + return 1000 - ( (1000+(info->free_pages * 1000 / requested)) / info->free_blocks_total);
> > > +}
> >
> > Dumb question.
> > your paper (http://portal.acm.org/citation.cfm?id=1375634.1375641) says
> > fragmentation_index = 1 - (TotalFree/SizeRequested)/BlocksFree
> > but your code have extra '1000+'. Why?
>
> To get an approximation to three decimal places.

Do you mean this is poor man's round up logic?
Why don't you use DIV_ROUND_UP? likes following,

return 1000 - (DIV_ROUND_UP(info->free_pages * 1000 / requested) / info->free_blocks_total);




\
 
 \ /
  Last update: 2010-03-23 01:25    [W:0.112 / U:6.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site