函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:mm\vmscan.c Create Date:2022-07-27 15:42:38
首页 Copyright©Brick

2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
/*
 * The inactive anon list should be small enough that the VM never has
 * to do too much work.
 *
 * The inactive file list should be small enough to leave most memory
 * to the established workingset on the scan-resistant active list,
 * but large enough to avoid thrashing the aggregate readahead window.
 *
 * Both inactive lists should also be large enough that each inactive
 * page has a chance to be referenced again before it is reclaimed.
 *
 * If that fails and refaulting is observed, the inactive list grows.
 *
 * The inactive_ratio is the target ratio of ACTIVE to INACTIVE pages
 * on this LRU, maintained by the pageout code. An inactive_ratio
 * of 3 means 3:1 or 25% of the pages are kept on 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 inactive_is_low(struct lruvec *lruvec, enum lru_list inactive_lru)
{
    enum lru_list active_lru = inactive_lru + LRU_ACTIVE;
    unsigned long inactive, active;
    unsigned long inactive_ratio;
    unsigned long gb;
 
    inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru);
    active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru);
 
    gb = (inactive + active) >> (30 - PAGE_SHIFT);
    if (gb)
        inactive_ratio = int_sqrt(10 * gb);
    else
        inactive_ratio = 1;
 
    return inactive * inactive_ratio < active;
}