[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.2003031726300.77561@chino.kir.corp.google.com>
Date: Tue, 3 Mar 2020 17:27:05 -0800 (PST)
From: David Rientjes <rientjes@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
cc: "Huang, Ying" <ying.huang@...el.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>,
David Hildenbrand <david@...hat.com>,
Mel Gorman <mgorman@...e.de>, Vlastimil Babka <vbabka@...e.cz>,
Zi Yan <ziy@...dia.com>, Michal Hocko <mhocko@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Minchan Kim <minchan@...nel.org>,
Johannes Weiner <hannes@...xchg.org>,
Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH] mm: Add PageLayzyFree() helper functions for MADV_FREE
On Tue, 3 Mar 2020, Andrew Morton wrote:
> On Tue, 3 Mar 2020 11:37:38 +0800 "Huang, Ying" <ying.huang@...el.com> wrote:
>
> > From: Huang Ying <ying.huang@...el.com>
> >
> > Now PageSwapBacked() is used as the helper function to check whether
> > pages have been freed lazily via MADV_FREE. This isn't very obvious.
> > So Dave suggested to add PageLazyFree() family helper functions to
> > improve the code readability.
> >
> > --- a/include/linux/page-flags.h
> > +++ b/include/linux/page-flags.h
> > @@ -498,6 +498,31 @@ static __always_inline int PageKsm(struct page *page)
> > TESTPAGEFLAG_FALSE(Ksm)
> > #endif
> >
> > +/*
> > + * For pages freed lazily via MADV_FREE. lazyfree pages are clean
> > + * anonymous pages. They have SwapBacked flag cleared to distinguish
> > + * with normal anonymous pages
> > + */
> > +static __always_inline int PageLazyFree(struct page *page)
> > +{
> > + page = compound_head(page);
> > + return PageAnon(page) && !PageSwapBacked(page);
> > +}
> > +
> > +static __always_inline void SetPageLazyFree(struct page *page)
> > +{
> > + VM_BUG_ON_PAGE(PageTail(page), page);
> > + VM_BUG_ON_PAGE(!PageAnon(page), page);
> > + ClearPageSwapBacked(page);
> > +}
> > +
> > +static __always_inline void ClearPageLazyFree(struct page *page)
> > +{
> > + VM_BUG_ON_PAGE(PageTail(page), page);
> > + VM_BUG_ON_PAGE(!PageAnon(page), page);
> > + SetPageSwapBacked(page);
> > +}
>
> These BUG_ONs aren't present in the current code and are
> unchangelogged.
>
Yeah, as well as the implicit conversion to check compound_head().
Powered by blists - more mailing lists