When shrinking the active file list we rotate referenced pages only when they're in an executable mapping. The others get deactivated. When it comes to balancing scan pressure, though, we count all referenced pages as rotated, even the deactivated ones. Yet they do not carry the same cost to the system: the deactivated page *might* refault later on, but the deactivation is tangible progress toward freeing pages; rotations on the other hand cost time and effort without getting any closer to freeing memory. Don't treat both events as equal. The following patch will hook up LRU balancing to cache and anon refaults, which are a much more concrete cost signal for reclaiming one list over the other. Thus, remove the maybe-IO cost bias from page references, and only note the CPU cost for actual rotations that prevent the pages from getting reclaimed.
Unified · Split
| @@ -2054,7 +2054,6 @@ static void shrink_active_list(unsigned long nr_to_scan, · 2053 unmodified lines | |||
| 2054 | 2054 | ||
| 2055 | if (page_referenced(page, 0, sc->target_mem_cgroup, | 2055 | if (page_referenced(page, 0, sc->target_mem_cgroup, |
| 2056 | &vm_flags)) { | 2056 | &vm_flags)) { |
| 2057 | nr_rotated += hpage_nr_pages(page); | ||
| 2058 | /* | 2057 | /* |
| 2059 | * Identify referenced, file-backed active pages and | 2058 | * Identify referenced, file-backed active pages and |
| 2060 | * give them one more trip around the active list. So | 2059 | * give them one more trip around the active list. So |
| @@ -2065,6 +2064,7 @@ static void shrink_active_list(unsigned long nr_to_scan, · 4 unmodified lines | |||
| 2065 | * so we ignore them here. | 2064 | * so we ignore them here. |
| 2066 | */ | 2065 | */ |
| 2067 | if ((vm_flags & VM_EXEC) && page_is_file_lru(page)) { | 2066 | if ((vm_flags & VM_EXEC) && page_is_file_lru(page)) { |
| 2067 | nr_rotated += hpage_nr_pages(page); | ||
| 2068 | list_add(&page->lru, &l_active); | 2068 | list_add(&page->lru, &l_active); |
| 2069 | continue; | 2069 | continue; |
| 2070 | } | 2070 | } |
| @@ -2080,10 +2080,8 @@ static void shrink_active_list(unsigned long nr_to_scan, · 9 unmodified lines | |||
| 2080 | */ | 2080 | */ |
| 2081 | spin_lock_irq(&pgdat->lru_lock); | 2081 | spin_lock_irq(&pgdat->lru_lock); |
| 2082 | /* | 2082 | /* |
| 2083 | * Count referenced pages from currently used mappings as rotated, | 2083 | * Rotating pages costs CPU without actually |
| 2084 | * even though only some of them are actually re-activated. This | 2084 | * progressing toward the reclaim goal. |
| 2085 | * helps balance scan pressure between file and anonymous pages in | ||
| 2086 | * get_scan_count. | ||
| 2087 | */ | 2085 | */ |
| 2088 | lru_note_cost(lruvec, file, nr_rotated); | 2086 | lru_note_cost(lruvec, file, nr_rotated); |
| 2089 | 2087 | ||