[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871rchw4x2.fsf@linux.intel.com>
Date: Sun, 14 Mar 2021 19:02:01 -0700
From: Andi Kleen <ak@...ux.intel.com>
To: Yu Zhao <yuzhao@...gle.com>
Cc: linux-mm@...ck.org, Alex Shi <alex.shi@...ux.alibaba.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Hillf Danton <hdanton@...a.com>,
Johannes Weiner <hannes@...xchg.org>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Matthew Wilcox <willy@...radead.org>,
Mel Gorman <mgorman@...e.de>, Michal Hocko <mhocko@...e.com>,
Roman Gushchin <guro@...com>, Vlastimil Babka <vbabka@...e.cz>,
Wei Yang <richard.weiyang@...ux.alibaba.com>,
Yang Shi <shy828301@...il.com>,
Ying Huang <ying.huang@...el.com>,
linux-kernel@...r.kernel.org, page-reclaim@...gle.com
Subject: Re: [PATCH v1 10/14] mm: multigenerational lru: core
Yu Zhao <yuzhao@...gle.com> writes:
> +
> +#ifdef CONFIG_MEMCG
> + if (memcg && atomic_read(&memcg->moving_account))
> + goto contended;
> +#endif
> + if (!mmap_read_trylock(mm))
> + goto contended;
These are essentially spinloops. Surely you need a cpu_relax() somewhere?
In general for all of spinloop like constructs it would be useful to
consider how to teach lockdep about them.
> + do {
> + old_flags = READ_ONCE(page->flags);
> + new_gen = ((old_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1;
> + VM_BUG_ON_PAGE(new_gen < 0, page);
> + if (new_gen >= 0 && new_gen != old_gen)
> + goto sort;
> +
> + new_gen = (old_gen + 1) % MAX_NR_GENS;
> + new_flags = (old_flags & ~LRU_GEN_MASK) | ((new_gen + 1UL) << LRU_GEN_PGOFF);
> + /* mark page for reclaim if pending writeback */
> + if (front)
> + new_flags |= BIT(PG_reclaim);
> + } while (cmpxchg(&page->flags, old_flags, new_flags) !=
> old_flags);
I see this cmpxchg flags pattern a lot. Could there be some common code
factoring?
-Andi
Powered by blists - more mailing lists