From: Michal Hocko <mhocko@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: "Huang, Ying" <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>,
Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz>,
Zi Yan <ziy@nvidia.com>, Peter Zijlstra <peterz@infradead.org>,
Minchan Kim <minchan@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH -V3] mm: Add PageLayzyFree() helper functions for MADV_FREE
Date: Mon, 9 Mar 2020 13:13:00 +0100 [thread overview]
Message-ID: <20200309121300.GL8447@dhcp22.suse.cz> (raw)
In-Reply-To: <68360241-eb18-b3d8-bf6f-4dbbed258ee6@redhat.com>
On Mon 09-03-20 09:55:38, David Hildenbrand wrote:
> On 09.03.20 03:17, Huang, Ying wrote:
[...]
> > @@ -1235,7 +1234,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> > * Try to allocate it some swap space here.
> > * Lazyfree page could be freed directly
> > */
> > - if (PageAnon(page) && PageSwapBacked(page)) {
> > + if (PageAnon(page) && !__PageLazyFree(page)) {
> > if (!PageSwapCache(page)) {
> > if (!(sc->gfp_mask & __GFP_IO))
> > goto keep_locked;
> > @@ -1411,7 +1410,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> > }
> > }
> >
> > - if (PageAnon(page) && !PageSwapBacked(page)) {
> > + if (PageLazyFree(page)) {
> > /* follow __remove_mapping for reference */
> > if (!page_ref_freeze(page, 1))
> > goto keep_locked;
> >
>
> I still prefer something like
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index fd6d4670ccc3..7538501230bd 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -63,6 +63,10 @@
> * page_waitqueue(page) is a wait queue of all tasks waiting for the page
> * to become unlocked.
> *
> + * PG_swapbacked used with anonymous pages (PageAnon()) indicates that a
> + * page is backed by swap. Anonymous pages without PG_swapbacked are
> + * pages that can be lazily freed (e.g., MADV_FREE) on demand.
> + *
> * PG_uptodate tells whether the page's contents is valid. When a read
> * completes, the page becomes uptodate, unless a disk I/O error happened.
> *
>
> and really don't like the use of !__PageLazyFree() instead of PageSwapBacked().
I have to say that I do not have a strong opinion about helper
functions. In general I tend to be against adding them unless there is a
very good reason for them. This particular patch is in a gray zone a bit.
There are few places which are easier to follow but others sound like,
we have a hammer let's use it. E.g. shrink_page_list path above. There
is a clear comment explaining PageAnon && PageSwapBacked check being
LazyFree related but do I have to know that this is LazyFree path? I
believe that seeing PageSwapBacked has a more meaning to me because it
tells me that anonymous pages without a backing store doesn't really
need swap entry. This happens to be Lazy free related today but with a
heavy overloading of our flags this might differ in the future. You have
effectively made a more generic description more specific without a very
good reason.
On the other hand having PG_swapbacked description in page-flags.h above
gives a very useful information which was previously hidden at the
definition so this is a clear improvement.
That being said I think that the patch is not helpful enough. I would
much rather see a simply documentation update.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-03-09 12:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 2:17 [PATCH -V3] mm: Add PageLayzyFree() helper functions for MADV_FREE Huang, Ying
2020-03-09 8:55 ` David Hildenbrand
2020-03-09 9:15 ` Huang, Ying
2020-03-09 9:21 ` David Hildenbrand
2020-03-10 0:45 ` David Rientjes
2020-03-09 12:13 ` Michal Hocko [this message]
2020-03-10 2:28 ` Huang, Ying
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200309121300.GL8447@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=peterz@infradead.org \
--cc=vbabka@suse.cz \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).