On Thu, Oct 29, 2020 at 06:45:02PM +0800, Alex Shi wrote: > Hugh Dickins' found a memcg change bug on original version: > If we want to change the pgdat->lru_lock to memcg's lruvec lock, we have > to serialize mem_cgroup_move_account during pagevec_lru_move_fn. The > possible bad scenario would like: > > cpu 0 cpu 1 > lruvec = mem_cgroup_page_lruvec() > if (!isolate_lru_page()) > mem_cgroup_move_account > > spin_lock_irqsave(&lruvec->lru_lock <== wrong lock. > > So we need TestClearPageLRU to block isolate_lru_page(), that serializes > the memcg change. and then removing the PageLRU check in move_fn callee > as the consequence. > > __pagevec_lru_add_fn() is different from the others, because the pages > it deals with are, by definition, not yet on the lru. TestClearPageLRU > is not needed and would not work, so __pagevec_lru_add() goes its own > way. > > Reported-by: Hugh Dickins <hughd@xxxxxxxxxx> > Signed-off-by: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx> > Acked-by: Hugh Dickins <hughd@xxxxxxxxxx> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: linux-mm@xxxxxxxxx > Cc: linux-kernel@xxxxxxxxxxxxxxx Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>