linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: alexlzhu@fb.com
Cc: kernel-team@fb.com, linux-mm@kvack.org, clm@fb.com,
	josef@toxicpanda.com, dsterba@suse.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] btrfs: fix alginment of VMA for memory mapped files on THP
Date: Wed, 3 Aug 2022 15:40:33 +0200	[thread overview]
Message-ID: <20220803134033.GG13489@twin.jikos.cz> (raw)
In-Reply-To: <20220802203246.434560-1-alexlzhu@fb.com>

On Tue, Aug 02, 2022 at 01:32:46PM -0700, alexlzhu@fb.com wrote:
> From: Alexander Zhu <alexlzhu@fb.com>
> 
> With CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for
> read-only mmapped files, such as shared libraries. However, the kernel
> makes no attempt to actually align those mappings on 2MB boundaries,
> which makes it impossible to use those THPs most of the time. This issue
> applies to general file mapping THP as well as existing setups using
> CONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by using
> thp_get_unmapped_area for the unmapped_area function in btrfs, which
> is what ext2, ext4, fuse, and xfs all use.
> 
> Initially btrfs had been left out in Commit 8c07fc452ac0 ("btrfs: fix
> alginment of VMA for memory mapped files on THP") as btrfs does not support
> DAX. However, Commit 1854bc6e2420 ("mm/readahead: Align file mappings
> for non-DAX") removed the DAX requirement. We should now be able to call
> thp_get_unmapped_area() for btrfs.
> 
> The problem can be seen in /proc/PID/smaps where THPeligible is set to 0
> on mappings to eligible shared object files as shown below.
> 
> Before this patch:
> 
> 7fc6a7e18000-7fc6a80cc000 r-xp 00000000 00:1e 199856
> /usr/lib64/libcrypto.so.1.1.1k
> Size:               2768 kB
> THPeligible:    0
> VmFlags: rd ex mr mw me
> 
> With this patch the library is mapped at a 2MB aligned address:
> 
> fbdfe200000-7fbdfe4b4000 r-xp 00000000 00:1e 199856
> /usr/lib64/libcrypto.so.1.1.1k
> Size:               2768 kB
> THPeligible:    1
> VmFlags: rd ex mr mw me
> 
> This fixes the alignment of VMAs for any mmap of a file that has the
> rd and ex permissions and size >= 2MB. The VMA alignment and
> THPeligible field for anonymous memory is handled separately and
> is thus not effected by this change.
> 
> Signed-off-by: Alexander Zhu <alexlzhu@fb.com>

Added to misc-next, thanks.


      reply	other threads:[~2022-08-03 13:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 20:32 alexlzhu
2022-08-03 13:40 ` David Sterba [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=20220803134033.GG13489@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=alexlzhu@fb.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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