Re: [PATCH v9 07/16] mm/mglru: balance anon and file scan budget by refault rate
From: KunWu Chan
Date: Fri Nov 20 2026 - 11:13:51 EST
[...]
> @@ -5769,8 +5822,8 @@ static int run_aging(struct lruvec *lruvec, unsigned long seq,
> static int run_eviction(struct lruvec *lruvec, unsigned long seq, struct scan_control *sc,
> int swappiness, unsigned long nr_to_reclaim)
> {
> - int nr_batch;
> DEFINE_MAX_SEQ(lruvec);
> + unsigned long nr_to_scan[ANON_AND_FILE];
>
> if (seq + MIN_NR_GENS > max_seq)
> return -EINVAL;
> @@ -5786,8 +5839,11 @@ static int run_eviction(struct lruvec *lruvec, unsigned long seq, struct scan_co
> if (sc->nr_reclaimed >= nr_to_reclaim)
> return 0;
>
> - nr_batch = min(nr_to_reclaim - sc->nr_reclaimed, MAX_LRU_BATCH);
> - if (!evict_folios(nr_batch, lruvec, sc, swappiness))
> + lruvec_evictable_size(lruvec, swappiness, nr_to_scan);
> + lru_gen_balance_scan(lruvec, swappiness,
> + nr_to_reclaim - sc->nr_reclaimed, nr_to_scan);
> +
When nr_to_reclaim is omitted, the first split here uses ULONG_MAX.
At swappiness=200, the excess anon budget goes to file, so we can
scan file in the first round even with plenty of cold anon left.
Is that what we want for the unlimited case?
Thanks,
Kunwu
> + if (!evict_folio_lists(nr_to_scan, lruvec, sc, swappiness, MAX_LRU_BATCH))
> return 0;
>
> cond_resched();
> @@ -5850,6 +5906,7 @@ static ssize_t lru_gen_seq_write(struct file *file, const char __user *src,
> .may_writepage = true,
> .may_unmap = true,
> .may_swap = true,
> + .priority = DEF_PRIORITY,
> .reclaim_idx = MAX_NR_ZONES - 1,
> .gfp_mask = GFP_KERNEL,
> .proactive = true,
> --
> 2.39.3 (Apple Git-146)
>