Re: [PATCH v9 07/20] mm/lru: introduce TestClearPageLRU

From: Andrew Morton
Date: Mon Mar 02 2020 - 17:11:47 EST


On Mon, 2 Mar 2020 19:00:17 +0800 Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx> wrote:

> Combined PageLRU check and ClearPageLRU into one function by new
> introduced func TestClearPageLRU. This function will be used as page
> isolation precondition.
>
> No functional change yet.
>
> ...
>
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2588,9 +2588,8 @@ static void commit_charge(struct page *page, struct mem_cgroup *memcg,
> pgdat = page_pgdat(page);
> spin_lock_irq(&pgdat->lru_lock);
>
> - if (PageLRU(page)) {
> + if (TestClearPageLRU(page)) {
> lruvec = mem_cgroup_page_lruvec(page, pgdat);
> - ClearPageLRU(page);
> del_page_from_lru_list(page, lruvec, page_lru(page));
> } else

The code will now get exclusive access of the page->flags cacheline and
will dirty that cacheline, even for !PageLRU() pages. What is the
performance impact of this?