[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o8tc3ogc.fsf@yhuang-dev.intel.com>
Date: Wed, 04 Mar 2020 09:20:51 +0800
From: "Huang\, Ying" <ying.huang@...el.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: <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
Hi, Andrew,
Andrew Morton <akpm@...ux-foundation.org> writes:
> 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.
>
> And they aren't free!
>
> before:
>
> q:/usr/src/25> size -t mm/rmap.o mm/swap.o mm/vmscan.o
> text data bss dec hex filename
> 41580 4211 192 45983 b39f mm/rmap.o
> 50684 9259 1184 61127 eec7 mm/swap.o
> 117728 46775 128 164631 28317 mm/vmscan.o
> 209992 60245 1504 271741 4257d (TOTALS)
>
> after:
>
> text data bss dec hex filename
> 42035 4299 192 46526 b5be mm/rmap.o
> 51091 9347 1184 61622 f0b6 mm/swap.o
> 118132 46775 128 165035 284ab mm/vmscan.o
> 211258 60421 1504 273183 42b1f (TOTALS)
>
> ALso, if they actually trigger, Linus goes berserk.
>
> If you have some special reason to add these assertions, please do it
> as a (changelogged!) followup patch and I'll keep it as a linux-next only thing.
Sorry, originally I thought that VM_BUG_ON_PAGE() will not be used in
the production kernel, so it's cheap. But it seems that people do care
about its usage. I will send v2 to fix this.
Best Regards,
Huang, Ying
Powered by blists - more mailing lists