函数源码 |
Source File:mm\swapfile.c |
Create Date:2022-07-27 16:48:56 |
首页 | Copyright©Brick |
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 | /* * Scan swap_map (or frontswap_map if frontswap parameter is true) * from current position to next entry still in use. Return 0 * if there are no inuse entries after prev till end of the map. */ static unsigned int find_next_to_unuse( struct swap_info_struct *si, unsigned int prev, bool frontswap) { unsigned int i; unsigned char count; /* * No need for swap_lock here: we're just looking * for whether an entry is in use, not modifying it; false * hits are okay, and sys_swapoff() has already prevented new * allocations from this area (while holding swap_lock). */ for (i = prev + 1; i < si->max; i++) { count = READ_ONCE(si->swap_map[i]); if (count && swap_count(count) != SWAP_MAP_BAD) if (!frontswap || frontswap_test(si, i)) break ; if ((i % LATENCY_LIMIT) == 0) cond_resched(); } if (i == si->max) i = 0; return i; } |