/*
* The inactive anon list should be smallenough that the VM never has
* to do too much work.
*
* The inactive file list should be smallenough to leave most memory
* to the established workingset on thescan-resistant active list,
* but large enough to avoid thrashing theaggregate readahead window.
*
* Both inactive lists should also be largeenough that each inactive
* page has a chance to be referenced againbefore it is reclaimed.
*
* The inactive_ratio is the target ratio ofACTIVE to INACTIVE pages
* on this LRU, maintained by the pageout code.A zone->inactive_ratio
* of 3 means 3:1 or 25% of the pages are kepton the inactive list.
*
* total target max
* memory ratio inactive
* -------------------------------------
* 10MB 1 5MB
* 100MB 1 50MB
* 1GB 3 250MB
* 10GB 10 0.9GB
* 100GB 31 3GB
* 1TB 101 10GB
* 10TB 320 32GB
*/
static bool c(struct lruvec *lruvec, bool file)
{
unsigned long inactive_ratio;
unsigned long inactive;
unsigned long active;
unsigned long gb;
/*
*If we don't have swap space, anonymous page deactivation
*is pointless.
*/
if (!file && !total_swap_pages)
return false;
inactive = lruvec_lru_size(lruvec, file * LRU_FILE);
active =lruvec_lru_size(lruvec, file * LRU_FILE + LRU_ACTIVE);
gb = (inactive + active) >> (30 -PAGE_SHIFT);
if (gb)
inactive_ratio = int_sqrt(10 *gb);
else
inactive_ratio = 1;
return inactive * inactive_ratio < active;
}