archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <>
To: Rik van Riel <>
Cc: Hugh Dickins <>, Yu Xu <>,
	Andrew Morton <>,
	Mel Gorman <>,
	Andrea Arcangeli <>,
	Michal Hocko <>, Vlastimil Babka <>,
	"Kirill A. Shutemov" <>,,,
Subject: Re: [PATCH v2] mm,thp,shmem: limit shmem THP alloc gfp_mask
Date: Fri, 23 Oct 2020 13:55:16 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, Oct 22, 2020 at 11:40:53PM -0400, Rik van Riel wrote:
> On Thu, 2020-10-22 at 19:54 -0700, Hugh Dickins wrote:
> > Michal is right to remember pushback before, because tmpfs is a
> > filesystem, and "huge=" is a mount option: in using a huge=always
> > filesystem, the user has already declared a preference for huge
> > pages.
> > Whereas the original anon THP had to deduce that preference from sys
> > tunables and vma madvice.
> ...
> > But it's likely that they have accumulated some defrag wisdom, which
> > tmpfs can take on board - but please accept that in using a huge
> > mount,
> > the preference for huge has already been expressed, so I don't expect
> > anon THP alloc_hugepage_direct_gfpmask() choices will map one to one.
> In my mind, the huge= mount options for tmpfs corresponded
> to the "enabled" anon THP options, denoting a desired end
> state, not necessarily how much we will stall allocations
> to get there immediately.
> The underlying allocation behavior has been changed repeatedly,
> with changes to the direct reclaim code and the compaction
> deferral code.
> The shmem THP gfp_mask never tried really hard anyway,
> with __GFP_NORETRY being the default, which matches what
> is used for non-VM_HUGEPAGE anon VMAs.
> Likewise, the direct reclaim done from the opportunistic
> THP allocations done by the shmem code limited itself to
> reclaiming 32 4kB pages per THP allocation.
> In other words, mounting
> with huge=always has never behaved
> the same as the more aggressive allocations done for
> This patch would leave shmem THP allocations for non-MADV_HUGEPAGE
> mapped files opportunistic like today, and make shmem THP
> allocations for files mapped with MADV_HUGEPAGE more aggressive
> than today.
> However, I would like to know what people think the shmem
> huge= mount options should do, and how things should behave
> when memory gets low, before pushing in a patch just because
> it makes the system run smoother "without changing current
> behavior too much".
> What do people want tmpfs THP allocations to do?

I'm also interested for non-tmpfs THP allocations.  In my patchset, THPs
are no longer limited to being PMD sized, and allocating smaller pages
isn't such a tax on the VM.  So currently I'm doing:

        gfp_t gfp = readahead_gfp_mask(mapping);
        struct page *page = __page_cache_alloc_order(gfp, order);

which translates to:

        mapping_gfp_mask(mapping) | __GFP_NORETRY | __GFP_NOWARN;
        gfp |= GFP_TRANSHUGE_LIGHT;
        gfp &= ~__GFP_DIRECT_RECLAIM;

Everything's very willing to fall back to order-0 pages, but I can see
that, eg, for a VM_HUGEPAGE vma, we should perhaps be less willing to
fall back to small pages.  I would prefer not to add a mount option to
every filesystem.  People will only get it wrong.

      parent reply	other threads:[~2020-10-23 12:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 16:45 [PATCH v2] mm,thp,shmem: limit shmem THP alloc gfp_mask Rik van Riel
2020-10-22 16:52 ` Vlastimil Babka
2020-10-23  2:54 ` Hugh Dickins
2020-10-23  3:40   ` Rik van Riel
2020-10-23  8:49     ` Michal Hocko
2020-10-23 12:55     ` Matthew Wilcox [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* 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).