drivers: pinctrl: add BCM2712D0 EMMC pins
[platform/kernel/linux-rpi.git] / mm / vmscan.c
index cd15648..0dfb9a7 100644 (file)
@@ -4656,6 +4656,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
        int young = 0;
        pte_t *pte = pvmw->pte;
        unsigned long addr = pvmw->address;
+       struct vm_area_struct *vma = pvmw->vma;
        struct folio *folio = pfn_folio(pvmw->pfn);
        bool can_swap = !folio_is_file_lru(folio);
        struct mem_cgroup *memcg = folio_memcg(folio);
@@ -4670,11 +4671,15 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
        if (spin_is_contended(pvmw->ptl))
                return;
 
+       /* exclude special VMAs containing anon pages from COW */
+       if (vma->vm_flags & VM_SPECIAL)
+               return;
+
        /* avoid taking the LRU lock under the PTL when possible */
        walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
 
-       start = max(addr & PMD_MASK, pvmw->vma->vm_start);
-       end = min(addr | ~PMD_MASK, pvmw->vma->vm_end - 1) + 1;
+       start = max(addr & PMD_MASK, vma->vm_start);
+       end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
 
        if (end - start > MIN_LRU_BATCH * PAGE_SIZE) {
                if (addr - start < MIN_LRU_BATCH * PAGE_SIZE / 2)
@@ -4699,7 +4704,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
                unsigned long pfn;
                pte_t ptent = ptep_get(pte + i);
 
-               pfn = get_pte_pfn(ptent, pvmw->vma, addr);
+               pfn = get_pte_pfn(ptent, vma, addr);
                if (pfn == -1)
                        continue;
 
@@ -4710,7 +4715,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
                if (!folio)
                        continue;
 
-               if (!ptep_test_and_clear_young(pvmw->vma, addr, pte + i))
+               if (!ptep_test_and_clear_young(vma, addr, pte + i))
                        VM_WARN_ON_ONCE(true);
 
                young++;
@@ -5291,7 +5296,12 @@ static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq,
        }
 
        /* try to scrape all its memory if this memcg was deleted */
-       *nr_to_scan = mem_cgroup_online(memcg) ? (total >> sc->priority) : total;
+       if (!mem_cgroup_online(memcg)) {
+               *nr_to_scan = total;
+               return false;
+       }
+
+       *nr_to_scan = total >> sc->priority;
 
        /*
         * The aging tries to be lazy to reduce the overhead, while the eviction
@@ -5412,14 +5422,9 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)
        bool success;
        unsigned long scanned = sc->nr_scanned;
        unsigned long reclaimed = sc->nr_reclaimed;
-       int seg = lru_gen_memcg_seg(lruvec);
        struct mem_cgroup *memcg = lruvec_memcg(lruvec);
        struct pglist_data *pgdat = lruvec_pgdat(lruvec);
 
-       /* see the comment on MEMCG_NR_GENS */
-       if (!lruvec_is_sizable(lruvec, sc))
-               return seg != MEMCG_LRU_TAIL ? MEMCG_LRU_TAIL : MEMCG_LRU_YOUNG;
-
        mem_cgroup_calculate_protection(NULL, memcg);
 
        if (mem_cgroup_below_min(NULL, memcg))
@@ -5427,7 +5432,7 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)
 
        if (mem_cgroup_below_low(NULL, memcg)) {
                /* see the comment on MEMCG_NR_GENS */
-               if (seg != MEMCG_LRU_TAIL)
+               if (lru_gen_memcg_seg(lruvec) != MEMCG_LRU_TAIL)
                        return MEMCG_LRU_TAIL;
 
                memcg_memory_event(memcg, MEMCG_LOW);
@@ -5443,7 +5448,15 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)
 
        flush_reclaim_state(sc);
 
-       return success ? MEMCG_LRU_YOUNG : 0;
+       if (success && mem_cgroup_online(memcg))
+               return MEMCG_LRU_YOUNG;
+
+       if (!success && lruvec_is_sizable(lruvec, sc))
+               return 0;
+
+       /* one retry if offlined or too small */
+       return lru_gen_memcg_seg(lruvec) != MEMCG_LRU_TAIL ?
+              MEMCG_LRU_TAIL : MEMCG_LRU_YOUNG;
 }
 
 #ifdef CONFIG_MEMCG