[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220412070616.GT2731@worktop.programming.kicks-ass.net>
Date: Tue, 12 Apr 2022 09:06:16 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Yu Zhao <yuzhao@...gle.com>, Stephen Rothwell <sfr@...hwell.id.au>,
linux-mm@...ck.org, Andi Kleen <ak@...ux.intel.com>,
Aneesh Kumar <aneesh.kumar@...ux.ibm.com>,
Barry Song <21cnbao@...il.com>,
Catalin Marinas <catalin.marinas@....com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Hillf Danton <hdanton@...a.com>, Jens Axboe <axboe@...nel.dk>,
Jesse Barnes <jsbarnes@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Jonathan Corbet <corbet@....net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>,
Mel Gorman <mgorman@...e.de>,
Michael Larabel <Michael@...haellarabel.com>,
Michal Hocko <mhocko@...nel.org>,
Mike Rapoport <rppt@...nel.org>,
Rik van Riel <riel@...riel.com>,
Vlastimil Babka <vbabka@...e.cz>,
Will Deacon <will@...nel.org>,
Ying Huang <ying.huang@...el.com>,
linux-arm-kernel@...ts.infradead.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, page-reclaim@...gle.com,
x86@...nel.org, Brian Geffon <bgeffon@...gle.com>,
Jan Alexander Steffens <heftig@...hlinux.org>,
Oleksandr Natalenko <oleksandr@...alenko.name>,
Steven Barrett <steven@...uorix.net>,
Suleiman Souhlal <suleiman@...gle.com>,
Daniel Byrne <djbyrne@....edu>,
Donald Carr <d@...os-reins.com>,
Holger Hoffstätte
<holger@...lied-asynchrony.com>,
Konstantin Kharlamov <Hi-Angel@...dex.ru>,
Shuang Zhai <szhai2@...rochester.edu>,
Sofia Trinh <sofia.trinh@....works>,
Vaibhav Jain <vaibhav@...ux.ibm.com>
Subject: Re: [PATCH v10 05/14] mm: multi-gen LRU: groundwork
On Mon, Apr 11, 2022 at 07:16:15PM -0700, Andrew Morton wrote:
> > +{
> > + int gen;
> > + unsigned long old_flags, new_flags;
> > +
> > + do {
> > + new_flags = old_flags = READ_ONCE(folio->flags);
> > + if (!(new_flags & LRU_GEN_MASK))
> > + return false;
> > +
> > + VM_BUG_ON_FOLIO(folio_test_active(folio), folio);
> > + VM_BUG_ON_FOLIO(folio_test_unevictable(folio), folio);
> > +
> > + gen = ((new_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1;
> > +
> > + new_flags &= ~LRU_GEN_MASK;
> > + /* for shrink_page_list() */
> > + if (reclaiming)
> > + new_flags &= ~(BIT(PG_referenced) | BIT(PG_reclaim));
> > + else if (lru_gen_is_active(lruvec, gen))
> > + new_flags |= BIT(PG_active);
> > + } while (cmpxchg(&folio->flags, old_flags, new_flags) != old_flags);
Also; please use the form:
unsigned long new, old = READ_ONCE(folio->flags);
do {
new = /* something */ old;
} while (!try_cmpxchg(&folio->flags, &old, new))
Powered by blists - more mailing lists