Lines Matching +full:inactive +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
10 * Linux VM subsystem. Fine-tuning documentation can be found in
11 * Documentation/admin-guide/sysctl/vm.rst.
32 #include <linux/backing-dev.h>
78 * This path almost never happens for VM activity - pages are normally freed
79 * in batches. But it gets used by networking - and for compound pages.
97 zone_stat_mod_folio(folio, NR_MLOCK, -nr_pages); in __page_cache_release()
106 free_unref_page(&folio->page, 0); in __folio_put_small()
125 free_zone_device_page(&folio->page); in __folio_put()
134 * put_pages_list() - release a list of pages
135 * @pages: list of pages threaded on page->lru
145 list_del(&folio->lru); in put_pages_list()
149 list_del(&folio->lru); in put_pages_list()
188 * folio->mlock_count = !!folio_test_mlocked(folio)? in lru_add_fn()
194 folio->mlock_count = 0; in lru_add_fn()
210 struct folio *folio = fbatch->folios[i]; in folio_batch_move_lru()
224 folios_put(fbatch->folios, folio_batch_count(fbatch)); in folio_batch_move_lru()
250 * to the tail of the inactive list.
287 * Hold lruvec->lru_lock is safe here, since in lru_note_cost()
289 * 2) From a pre-LRU page during refault (which also holds the in lru_note_cost()
293 spin_lock_irq(&lruvec->lru_lock); in lru_note_cost()
296 lruvec->file_cost += cost; in lru_note_cost()
298 lruvec->anon_cost += cost; in lru_note_cost()
313 if (lruvec->file_cost + lruvec->anon_cost > lrusize / 4) { in lru_note_cost()
314 lruvec->file_cost /= 2; in lru_note_cost()
315 lruvec->anon_cost /= 2; in lru_note_cost()
317 spin_unlock_irq(&lruvec->lru_lock); in lru_note_cost()
399 * a folio is marked active just after it is added to the inactive in __lru_cache_activate_folio()
402 for (i = folio_batch_count(fbatch) - 1; i >= 0; i--) { in __lru_cache_activate_folio()
403 struct folio *batch_folio = fbatch->folios[i]; in __lru_cache_activate_folio()
417 unsigned long new_flags, old_flags = READ_ONCE(folio->flags); in folio_inc_refs()
440 } while (!try_cmpxchg(&folio->flags, &old_flags, new_flags)); in folio_inc_refs()
451 * inactive,unreferenced -> inactive,referenced
452 * inactive,referenced -> active,unreferenced
453 * active,unreferenced -> active,referenced
455 * When a newly allocated page is not yet visible, so safe for non-atomic ops,
493 * folio_add_lru - Add a folio to an LRU list.
511 lru_gen_in_fault() && !(current->flags & PF_MEMALLOC)) in folio_add_lru()
523 * folio_add_lru_vma() - Add a folio to the appropate LRU list for this VMA.
534 if (unlikely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED)) in folio_add_lru_vma()
542 * inactive list to speed up its reclaim. It is moved to the
545 * effective than the single-page writeout from reclaim.
550 * 1. active, mapped folio -> none
551 * 2. active, dirty/writeback folio -> inactive, head, reclaim
552 * 3. inactive, mapped folio -> none
553 * 4. inactive, dirty/writeback folio -> inactive, head, reclaim
554 * 5. inactive, clean -> inactive, tail
555 * 6. Others -> none
557 * In 4, it moves to the head of the inactive list so the folio is
559 * than the single-page writeout from reclaim.
589 * We move that folio to the tail of the inactive list. in lru_deactivate_file_fn()
644 * disabled; or "cpu" is being hot-unplugged, and is already dead.
649 struct folio_batch *fbatch = &fbatches->lru_add; in lru_add_drain_cpu()
665 fbatch = &fbatches->lru_deactivate_file; in lru_add_drain_cpu()
669 fbatch = &fbatches->lru_deactivate; in lru_add_drain_cpu()
673 fbatch = &fbatches->lru_lazyfree; in lru_add_drain_cpu()
681 * deactivate_file_folio() - Deactivate a file folio.
706 * folio_deactivate - deactivate a folio
709 * folio_deactivate() moves @folio to the inactive list if @folio was on the
728 * folio_mark_lazyfree - make an anon folio lazyfree
731 * folio_mark_lazyfree() moves @folio to the inactive file list.
758 * It's called from per-cpu workqueue context in SMP case so
795 return folio_batch_count(&fbatches->lru_add) || in cpu_needs_drain()
797 folio_batch_count(&fbatches->lru_deactivate_file) || in cpu_needs_drain()
798 folio_batch_count(&fbatches->lru_deactivate) || in cpu_needs_drain()
799 folio_batch_count(&fbatches->lru_lazyfree) || in cpu_needs_drain()
800 folio_batch_count(&fbatches->activate) || in cpu_needs_drain()
806 * Doesn't need any cpu hotplug locking because we do rely on per-cpu
815 * lru_drain_gen - Global pages generation number in __lru_add_drain_all()
820 * This is an optimization for the highly-contended use case where a in __lru_add_drain_all()
874 * below and has already reached CPU #y's per-cpu data. CPU #x comes in __lru_add_drain_all()
875 * along, adds some pages to its per-cpu vectors, then calls in __lru_add_drain_all()
949 * release_pages - batched put_page()
976 * Make sure the IRQ-safe lock-holding time does not get in release_pages()
985 if (is_huge_zero_page(&folio->page)) in release_pages()
993 if (put_devmap_managed_page(&folio->page)) in release_pages()
996 free_zone_device_page(&folio->page); in release_pages()
1036 list_add(&folio->lru, &pages_to_free); in release_pages()
1047 * The folios which we're about to release may be in the deferred lru-addition
1049 * OK from a correctness point of view but is inefficient - those folios may be
1050 * cache-warm and we want to give them back to the page allocator ASAP.
1058 if (!fbatch->percpu_pvec_drained) { in __folio_batch_release()
1060 fbatch->percpu_pvec_drained = true; in __folio_batch_release()
1062 release_pages(fbatch->folios, folio_batch_count(fbatch)); in __folio_batch_release()
1068 * folio_batch_remove_exceptionals() - Prune non-folios from a batch.
1072 * entries. This function prunes all the non-folio entries from @fbatch
1073 * without leaving holes, so that it can be passed on to folio-only batch
1081 struct folio *folio = fbatch->folios[i]; in folio_batch_remove_exceptionals()
1083 fbatch->folios[j++] = folio; in folio_batch_remove_exceptionals()
1085 fbatch->nr = j; in folio_batch_remove_exceptionals()
1093 unsigned long megs = totalram_pages() >> (20 - PAGE_SHIFT); in swap_setup()
1095 /* Use a smaller cluster for small-memory machines */ in swap_setup()