Re: [PATCH 07/25] mm/fbatch: LRU_NEXT_ACTIVATE bit to optimize folio_activate()

From: Kiryl Shutsemau

Date: Thu Aug 27 2026 - 08:02:47 EST


On Mon, Aug 24, 2026 at 07:09:34AM -0700, Hugh Dickins wrote:
> @@ -355,6 +356,8 @@ bool lru_add_del_folio(struct folio *folio)
> /* BUG_ON(folio_test_lru(folio)); */
> if (!(folio->lru_next & BIT(LRU_NEXT_BATCHED)))
> return false;
> + if (folio->lru_next & BIT(LRU_NEXT_ACTIVATE))
> + folio_set_active(folio);
> folio->lru.next = LIST_POISON1;
> /* BUG_ON(folio->lru_next & BIT(LRU_NEXT_BATCHED)); */
> return true;

folio_activate()'s try_cmpxchg() can land in between two lru_next reads.
Logically, it is safe but I suspect KCSAN would not be happy about it.

Maybe READ_ONCE() here?

Other note, page_pool (pp_magic) seems to be using bit 2, but I don't
think there's a real conflict.

--
Kiryl Shutsemau / Kirill A. Shutemov