From: Matthew Wilcox <willy@infradead.org>
To: Fangrui Song <maskray@google.com>
Cc: Yang Shi <shy828301@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, Song Liu <songliubraving@fb.com>,
Miaohe Lin <linmiaohe@huawei.com>,
linux-kernel@vger.kernel.org, Zhouyi Zhou <zhouzhouyi@gmail.com>
Subject: Re: [PATCH] mm: remove VM_EXEC requirement for THP eligibility
Date: Thu, 21 Dec 2023 19:50:55 +0000 [thread overview]
Message-ID: <ZYSXH58aQpI1SLr2@casper.infradead.org> (raw)
In-Reply-To: <CAFP8O3+5fKcGS8xEY5=DHqsN0YdybEY178nM+cXRY1bbQXV4WQ@mail.gmail.com>
On Wed, Dec 20, 2023 at 08:53:38PM -0800, Fangrui Song wrote:
> Thanks for the comment. Frankly, I am not familiar with huge pages...
> I noticed this VM_EXEC condition when I was writing this
> hugepage-related section in
> https://maskray.me/blog/2023-12-17-exploring-the-section-layout-in-linker-output#transparent-huge-pages-for-mapped-files
> (Thanks to Alexander Monakov's comment about
> CONFIG_READ_ONLY_THP_FOR_FS in
> https://mazzo.li/posts/check-huge-page.html).
CONFIG_READ_ONLY_THP_FOR_FS is a preliminary hack which solves some
problems. The real solution is using large folios, which at the moment
means that you should test on XFS or AFS; filesystem authors have not
been enthusiastic about adding support to their filesystems so far.
In your blog, you write:
: In -z noseparate-code layouts, the file content starts somewhere at
: the first page, potentially wasting half a huge page on unrelated
: content. Switching to -z separate-code allows reclaiming the benefits
: of the half huge page but increases the file size. Balancing
: these aspects poses a challenge. One potential solution is using
: fallocate(FALLOC_FL_PUNCH_HOLE), which introduces complexity into the
: linker. However, this approach feels like a workaround to address a
: kernel limitation. It would be preferable if a file-backed huge page
: didn't necessitate a file offset aligned to a huge page boundary.
You should distinguish between file size (ie st_size in stat(3)) and
amount of space occupied on storage (st_blocks). The linker should be
fine with creating a sparse file. If it doesn't, cp --sparse will do
the trick.
Yes, it's a kernel limitation that folios have to be aligned within the
file as well as in both virtual and physical address space. It's a huge
complexity win to do that; I don't think we'd be able to tile the page
cache effectively if we allowed folios to be placed at arbitrary offsets
(I think it turns into a knapsack problem at that point).
> As dTLB for read-only data is also an important optimization of
> file-backed THP, it seems straightforward that we should drop the
> VM_EXEC condition :)
I'm not particularly enthusiastic about making CONFIG_READ_ONLY_THP_FOR_FS
better. Large folios are the future. Indeed, I'd like to see
CONFIG_READ_ONLY_THP_FOR_FS go away in the next year or two once
btrfs and ext4 have support for large folios.
prev parent reply other threads:[~2023-12-21 19:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 5:41 Fangrui Song
2023-12-20 23:42 ` Yang Shi
2023-12-21 4:53 ` Fangrui Song
2023-12-21 19:31 ` Yang Shi
2023-12-21 19:45 ` Yang Shi
2023-12-21 19:50 ` 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:
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=ZYSXH58aQpI1SLr2@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maskray@google.com \
--cc=shy828301@gmail.com \
--cc=songliubraving@fb.com \
--cc=zhouzhouyi@gmail.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