mm/mglru: fix underprotected page cache
[platform/kernel/linux-starfive.git] / mm / workingset.c
index da58a26..2559a1f 100644 (file)
@@ -313,10 +313,10 @@ static void lru_gen_refault(struct folio *folio, void *shadow)
         * 1. For pages accessed through page tables, hotter pages pushed out
         *    hot pages which refaulted immediately.
         * 2. For pages accessed multiple times through file descriptors,
-        *    numbers of accesses might have been out of the range.
+        *    they would have been protected by sort_folio().
         */
-       if (lru_gen_in_fault() || refs == BIT(LRU_REFS_WIDTH)) {
-               folio_set_workingset(folio);
+       if (lru_gen_in_fault() || refs >= BIT(LRU_REFS_WIDTH) - 1) {
+               set_mask_bits(&folio->flags, 0, LRU_REFS_MASK | BIT(PG_workingset));
                mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + type, delta);
        }
 unlock: