Some random thoughts about some folio_test_lru() users:
mm/khugepaged.c: skips pages if !folio_test_lru(), but would fail skip
it either way if there is the unexpected reference from the LRU batch!
mm/compaction.c: skips pages if !folio_test_lru(), but would fail skip
it either way if there is the unexpected reference from the LRU batch!
mm/memory.c: would love to identify this case and to a lru_add_drain()
to free up that reference.
mm/huge_memory.c: splitting with the additional reference will fail
already. Maybe we'd want to drain the LRU batch.
Agree.
mm/madvise.c: skips pages if !folio_test_lru(). I wonder what happens if
we have the same page twice in an LRU batch with different target goals ...
IIUC, LRU batch can ignore this folio since it's LRU flag is cleared by
folio_isolate_lru(), then will call folios_put() to frop the reference.
Some other users (there are not that many that don't use it for sanity
checks though) might likely be a bit different.
mm/page_isolation.c: fail to set pageblock migratetype to isolate if
!folio_test_lru(), then alloc_contig_range_noprof() can be failed. But
the original code could set pageblock migratetype to isolate, then
calling drain_all_pages() in alloc_contig_range_noprof() to drop
reference of the LRU batch.
mm/vmscan.c: will call lru_add_drain() before calling
isolate_lru_folios(), so seems no impact.
BTW, we also need to look at the usage of folio_isolate_lru().
It doesn’t seem to have major obstacles, but there are many details to
analyze :)