From: David Hildenbrand <david@redhat.com>
To: Zhang Qilong <zhangqilong3@huawei.com>,
arnd@arndb.de, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
lorenzo.stoakes@oracle.com, wangkefeng.wang@huawei.com,
sunnanyong@huawei.com
Subject: Re: [PATCH resend v2] /dev/zero: try to align PMD_SIZE for private mapping
Date: Wed, 30 Jul 2025 11:33:52 +0200 [thread overview]
Message-ID: <eeac8523-801a-4b9a-81f4-6539ce1955c2@redhat.com> (raw)
In-Reply-To: <20250730091905.383353-1-zhangqilong3@huawei.com>
On 30.07.25 11:19, Zhang Qilong wrote:
> Attempt to map aligned to huge page size for private mapping which
> could achieve performance gains, the mprot_tw4m in libMicro average
> execution time on arm64:
> - Test case: mprot_tw4m
> - Before the patch: 22 us
> - After the patch: 17 us
>
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
> v2:
> - Add comments on code suggested by Lorenzo
> - Use IS_ENABLED to check THP config
>
> drivers/char/mem.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> index 48839958b0b1..c27cc89bd02d 100644
> --- a/drivers/char/mem.c
> +++ b/drivers/char/mem.c
> @@ -525,11 +525,18 @@ static unsigned long get_unmapped_area_zero(struct file *file,
> * so as not to confuse shmem with our handle on "/dev/zero".
> */
> return shmem_get_unmapped_area(NULL, addr, len, pgoff, flags);
> }
>
> - /* Otherwise flags & MAP_PRIVATE: with no shmem object beneath it */
> + /*
> + * Otherwise flags & MAP_PRIVATE: with no shmem object beneath it,
> + * attempt to map aligned to huge page size if possible, otherwise we
> + * fall back to system page size mappings.
> + */
> + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
> + return thp_get_unmapped_area(file, addr, len, pgoff, flags);
> +
> return mm_get_unmapped_area(current->mm, file, addr, len, pgoff, flags);
> #else
> return -ENOSYS;
> #endif
> }
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-07-30 9:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 9:19 Zhang Qilong
2025-07-30 9:33 ` David Hildenbrand [this message]
2025-07-30 12:49 ` Matthew Wilcox
2025-07-30 12:59 ` Lorenzo Stoakes
2025-07-30 13:04 ` Lorenzo Stoakes
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=eeac8523-801a-4b9a-81f4-6539ce1955c2@redhat.com \
--to=david@redhat.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=sunnanyong@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=zhangqilong3@huawei.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