All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rongwei Wang <rongwei.wang@linux.alibaba.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Cc: akpm@linux-foundation.org, willy@infradead.org,
	viro@zeniv.linux.org.uk, song@kernel.org,
	william.kucharski@oracle.com, hughd@google.com,
	shy828301@gmail.com, linmiaohe@huawei.com, peterx@redhat.com
Subject: [PATCH 3/3] mm, thp: make mapping address of PIC binaries THP align
Date: Sat,  9 Oct 2021 17:26:58 +0800	[thread overview]
Message-ID: <20211009092658.59665-4-rongwei.wang@linux.alibaba.com> (raw)
In-Reply-To: <20211009092658.59665-1-rongwei.wang@linux.alibaba.com>

For binaries that are compiled with '--pie -fPIC' and with LOAD
alignment smaller than 2M (typically 4K, 64K), the load address
is least likely to be 2M aligned.

This changes the maximum_alignment of such binaries to 2M to
facilitate file THP for .text section as far as possible.

Signed-off-by: Gang Deng <gavin.dg@linux.alibaba.com>
Signed-off-by: Xu Yu <xuyu@linux.alibaba.com>
Signed-off-by: Rongwei Wang <rongwei.wang@linux.alibaba.com>
---
 fs/binfmt_elf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index a813b70f594e..78795572d877 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1136,6 +1136,11 @@ static int load_elf_binary(struct linux_binprm *bprm)
 				retval = -EINVAL;
 				goto out_free_dentry;
 			}
+#ifdef CONFIG_HUGETEXT
+			if (hugetext_enabled() && interpreter &&
+					total_size >= HPAGE_PMD_SIZE)
+				load_bias &= HPAGE_PMD_MASK;
+#endif
 		}
 
 		error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
-- 
2.27.0


  parent reply	other threads:[~2021-10-09  9:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  9:26 [PATCH 0/3] mm, thp: introduce a new sysfs interface to facilitate file THP for .text Rongwei Wang
2021-10-09  9:26 ` [PATCH 1/3] mm, thp: support binaries transparent use of file THP Rongwei Wang
2021-10-09  9:26 ` [PATCH 2/3] mm, thp: make mapping address of libraries THP align Rongwei Wang
2021-10-09  9:26 ` Rongwei Wang [this message]
2021-10-11  8:06 ` [PATCH 0/3] mm, thp: introduce a new sysfs interface to facilitate file THP for .text Christoph Hellwig
2021-10-12  1:50   ` Matthew Wilcox
2021-10-12  7:04     ` Rongwei Wang

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=20211009092658.59665-4-rongwei.wang@linux.alibaba.com \
    --to=rongwei.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=shy828301@gmail.com \
    --cc=song@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=william.kucharski@oracle.com \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.