spmi: hisi-spmi-controller: Use devm_spmi_controller_add()
[linux-2.6-microblaze.git] / mm / madvise.c
index cf4d694..6214a1a 100644 (file)
@@ -335,6 +335,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
        struct folio *folio = NULL;
        LIST_HEAD(folio_list);
        bool pageout_anon_only_filter;
+       unsigned int batch_count = 0;
 
        if (fatal_signal_pending(current))
                return -EINTR;
@@ -416,6 +417,7 @@ huge_unlock:
 regular_folio:
 #endif
        tlb_change_page_size(tlb, PAGE_SIZE);
+restart:
        start_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
        if (!start_pte)
                return 0;
@@ -424,6 +426,15 @@ regular_folio:
        for (; addr < end; pte++, addr += PAGE_SIZE) {
                ptent = ptep_get(pte);
 
+               if (++batch_count == SWAP_CLUSTER_MAX) {
+                       batch_count = 0;
+                       if (need_resched()) {
+                               pte_unmap_unlock(start_pte, ptl);
+                               cond_resched();
+                               goto restart;
+                       }
+               }
+
                if (pte_none(ptent))
                        continue;