Lines Matching +full:cost +full:- +full:effective

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>
84 * This path almost never happens for VM activity - pages are normally freed
85 * in batches. But it gets used by networking - and for compound pages.
112 free_unref_page(&folio->page, folio_order(folio)); in __folio_put()
117 * put_pages_list() - release a list of pages
118 * @pages: list of pages threaded on page->lru
174 * folio->mlock_count = !!folio_test_mlocked(folio)? in lru_add()
180 folio->mlock_count = 0; in lru_add()
196 struct folio *folio = fbatch->folios[i]; in folio_batch_move_lru()
274 unsigned long cost; in lru_note_cost() local
277 * Reflect the relative cost of incurring IO and spending CPU in lru_note_cost()
283 cost = nr_io * SWAP_CLUSTER_MAX + nr_rotated; in lru_note_cost()
289 * Hold lruvec->lru_lock is safe here, since in lru_note_cost()
291 * 2) From a pre-LRU page during refault (which also holds the in lru_note_cost()
295 spin_lock_irq(&lruvec->lru_lock); in lru_note_cost()
296 /* Record cost event */ in lru_note_cost()
298 lruvec->file_cost += cost; in lru_note_cost()
300 lruvec->anon_cost += cost; in lru_note_cost()
315 if (lruvec->file_cost + lruvec->anon_cost > lrusize / 4) { in lru_note_cost()
316 lruvec->file_cost /= 2; in lru_note_cost()
317 lruvec->anon_cost /= 2; in lru_note_cost()
319 spin_unlock_irq(&lruvec->lru_lock); in lru_note_cost()
400 for (i = folio_batch_count(fbatch) - 1; i >= 0; i--) { in __lru_cache_activate_folio()
401 struct folio *batch_folio = fbatch->folios[i]; in __lru_cache_activate_folio()
415 unsigned long new_flags, old_flags = READ_ONCE(folio->flags); in folio_inc_refs()
438 } while (!try_cmpxchg(&folio->flags, &old_flags, new_flags)); in folio_inc_refs()
447 * folio_mark_accessed - Mark a folio as having seen activity.
452 * * inactive,unreferenced -> inactive,referenced
453 * * inactive,referenced -> active,unreferenced
454 * * active,unreferenced -> active,referenced
456 * When a newly allocated folio is not yet visible, so safe for non-atomic ops,
494 * folio_add_lru - Add a folio to an LRU list.
510 lru_gen_in_fault() && !(current->flags & PF_MEMALLOC)) in folio_add_lru()
518 * folio_add_lru_vma() - Add a folio to the appropate LRU list for this VMA.
529 if (unlikely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED)) in folio_add_lru_vma()
540 * effective than the single-page writeout from reclaim.
545 * 1. active, mapped folio -> none
546 * 2. active, dirty/writeback folio -> inactive, head, reclaim
547 * 3. inactive, mapped folio -> none
548 * 4. inactive, dirty/writeback folio -> inactive, head, reclaim
549 * 5. inactive, clean -> inactive, tail
550 * 6. Others -> none
554 * than the single-page writeout from reclaim.
639 * disabled; or "cpu" is being hot-unplugged, and is already dead.
644 struct folio_batch *fbatch = &fbatches->lru_add; in lru_add_drain_cpu()
649 fbatch = &fbatches->lru_move_tail; in lru_add_drain_cpu()
660 fbatch = &fbatches->lru_deactivate_file; in lru_add_drain_cpu()
664 fbatch = &fbatches->lru_deactivate; in lru_add_drain_cpu()
668 fbatch = &fbatches->lru_lazyfree; in lru_add_drain_cpu()
676 * deactivate_file_folio() - Deactivate a file folio.
695 * folio_deactivate - deactivate a folio
711 * folio_mark_lazyfree - make an anon folio lazyfree
735 * It's called from per-cpu workqueue context in SMP case so
772 return folio_batch_count(&fbatches->lru_add) || in cpu_needs_drain()
773 folio_batch_count(&fbatches->lru_move_tail) || in cpu_needs_drain()
774 folio_batch_count(&fbatches->lru_deactivate_file) || in cpu_needs_drain()
775 folio_batch_count(&fbatches->lru_deactivate) || in cpu_needs_drain()
776 folio_batch_count(&fbatches->lru_lazyfree) || in cpu_needs_drain()
777 folio_batch_count(&fbatches->lru_activate) || in cpu_needs_drain()
783 * Doesn't need any cpu hotplug locking because we do rely on per-cpu
792 * lru_drain_gen - Global pages generation number in __lru_add_drain_all()
797 * This is an optimization for the highly-contended use case where a in __lru_add_drain_all()
851 * below and has already reached CPU #y's per-cpu data. CPU #x comes in __lru_add_drain_all()
852 * along, adds some pages to its per-cpu vectors, then calls in __lru_add_drain_all()
926 * folios_put_refs - Reduce the reference count on a batch of folios.
946 for (i = 0, j = 0; i < folios->nr; i++) { in folios_put_refs()
947 struct folio *folio = folios->folios[i]; in folios_put_refs()
981 folios->folios[j] = folio; in folios_put_refs()
991 folios->nr = j; in folios_put_refs()
998 * release_pages - batched put_page()
1021 /* Is our next entry actually "nr_pages" -> "nr_refs" ? */ in release_pages()
1038 * The folios which we're about to release may be in the deferred lru-addition
1040 * OK from a correctness point of view but is inefficient - those folios may be
1041 * cache-warm and we want to give them back to the page allocator ASAP.
1049 if (!fbatch->percpu_pvec_drained) { in __folio_batch_release()
1051 fbatch->percpu_pvec_drained = true; in __folio_batch_release()
1058 * folio_batch_remove_exceptionals() - Prune non-folios from a batch.
1062 * entries. This function prunes all the non-folio entries from @fbatch
1063 * without leaving holes, so that it can be passed on to folio-only batch
1071 struct folio *folio = fbatch->folios[i]; in folio_batch_remove_exceptionals()
1073 fbatch->folios[j++] = folio; in folio_batch_remove_exceptionals()
1075 fbatch->nr = j; in folio_batch_remove_exceptionals()
1083 unsigned long megs = totalram_pages() >> (20 - PAGE_SHIFT); in swap_setup()
1085 /* Use a smaller cluster for small-memory machines */ in swap_setup()