From: Rik van Riel <riel@surriel.com>
To: Hillf Danton <hdanton@sina.com>
Cc: hughd@google.com, xuyu@linux.alibaba.com,
akpm@linux-foundation.org, mgorman@suse.de, aarcange@redhat.com,
willy@infradead.org, linux-kernel@vger.kernel.org,
kernel-team@fb.com, linux-mm@kvack.org, vbabka@suse.cz,
mhocko@suse.com
Subject: Re: [PATCH 2/2] mm,thp,shm: limit gfp mask to no more than specified
Date: Fri, 06 Nov 2020 12:53:33 -0500 [thread overview]
Message-ID: <0f50046d0195d857bf7dc5a61db0a59795c3e06b.camel@surriel.com> (raw)
In-Reply-To: <20201106030511.396-1-hdanton@sina.com>
[-- Attachment #1: Type: text/plain, Size: 2066 bytes --]
On Fri, 2020-11-06 at 11:05 +0800, Hillf Danton wrote:
> On Thu, 5 Nov 2020 14:15:08 -0500
> > Matthew Wilcox pointed out that the i915 driver opportunistically
> > allocates tmpfs memory, but will happily reclaim some of its
> > pool if no memory is available.
> >
> > Make sure the gfp mask used to opportunistically allocate a THP
> > is always at least as restrictive as the original gfp mask.
> >
> > Signed-off-by: Rik van Riel <riel@surriel.com>
> > Suggested-by: Matthew Wilcox <willy@infradead.org>
> > ---
> > mm/shmem.c | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 6c3cb192a88d..ee3cea10c2a4 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -1531,6 +1531,26 @@ static struct page *shmem_swapin(swp_entry_t
> > swap, gfp_t gfp,
> > return page;
> > }
> >
> > +/*
> > + * Make sure huge_gfp is always more limited than limit_gfp.
> > + * Some of the flags set permissions, while others set
> > limitations.
> > + */
> > +static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp)
> > +{
> > + gfp_t allowflags = __GFP_IO | __GFP_FS | __GFP_RECLAIM;
> > + gfp_t denyflags = __GFP_NOWARN | __GFP_NORETRY;
> > + gfp_t result = huge_gfp & ~allowflags;
> > +
> > + /*
> > + * Minimize the result gfp by taking the union with the deny
> > flags,
> > + * and the intersection of the allow flags.
> > + */
> > + result |= (limit_gfp & denyflags);
>
> Currently NORETRY is always set regardless of i915 and if it's
> determined in 1/2 then the i915 thing can be done like
>
> return huge_gfp | (limit_gfp & __GFP_RECLAIM);
No, if __GFP_KSWAPD_RECLAIM or __GFP_DIRECT_RECLAIM are
not set in either huge_gfp or limit_gfp, we want to ensure
the resulting gfp does not have it set, either.
Your suggested change
would result in __GFP_KSWAPD_RECLAIM
or __GFP_DIRECT_RECLAIM getting set if it was set in either
of the input gfp variables, which is probably not the desired
behavior.
--
All Rights Reversed.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-11-06 17:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 19:15 [PATCH 0/2] mm,thp,shm: limit shmem THP alloc gfp_mask Rik van Riel
2020-11-05 19:15 ` [PATCH 1/2] mm,thp,shmem: " Rik van Riel
2020-11-12 10:52 ` Michal Hocko
2020-11-14 3:44 ` Rik van Riel
2020-11-19 9:37 ` Michal Hocko
2020-11-05 19:15 ` [PATCH 2/2] mm,thp,shm: limit gfp mask to no more than specified Rik van Riel
2020-11-06 3:05 ` Hillf Danton
2020-11-06 17:53 ` Rik van Riel [this message]
2020-11-07 1:58 ` Hillf Danton
2020-11-12 11:22 ` Michal Hocko
2020-11-14 3:40 ` Rik van Riel
2020-11-19 9:38 ` Michal Hocko
2020-11-23 19:39 ` Rik van Riel
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=0f50046d0195d857bf7dc5a61db0a59795c3e06b.camel@surriel.com \
--to=riel@surriel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hdanton@sina.com \
--cc=hughd@google.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=xuyu@linux.alibaba.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).