From: Usama Arif <usamaarif642@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
david@redhat.com, linux-mm@kvack.org
Cc: hannes@cmpxchg.org, shakeel.butt@linux.dev, riel@surriel.com,
ziy@nvidia.com, baolin.wang@linux.alibaba.com,
lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
hughd@google.com, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, kernel-team@meta.com,
Breno Leitao <leitao@debian.org>
Subject: Re: [RFC] mm: khugepaged: use largest enabled hugepage order for min_free_kbytes
Date: Fri, 6 Jun 2025 16:01:28 +0100 [thread overview]
Message-ID: <a179fd65-dc3f-4769-9916-3033497188ba@gmail.com> (raw)
In-Reply-To: <20250606143700.3256414-1-usamaarif642@gmail.com>
On 06/06/2025 15:37, Usama Arif wrote:
> On arm64 machines with 64K PAGE_SIZE, the min_free_kbytes and hence the
> watermarks are evaluated to extremely high values, for e.g. a server with
> 480G of memory, only 2M mTHP hugepage size set to madvise, with the rest
> of the sizes set to never, the min, low and high watermarks evaluate to
> 11.2G, 14G and 16.8G respectively.
> In contrast for 4K PAGE_SIZE of the same machine, with only 2M THP hugepage
> size set to madvise, the min, low and high watermarks evaluate to 86M, 566M
> and 1G respectively.
> This is because set_recommended_min_free_kbytes is designed for PMD
> hugepages (pageblock_order = min(HPAGE_PMD_ORDER, PAGE_BLOCK_ORDER)).
> Such high watermark values can cause performance and latency issues in
> memory bound applications on arm servers that use 64K PAGE_SIZE, eventhough
> most of them would never actually use a 512M PMD THP.
>
> Instead of using HPAGE_PMD_ORDER for pageblock_order use the highest large
> folio order enabled in set_recommended_min_free_kbytes.
> With this patch, when only 2M THP hugepage size is set to madvise for the
> same machine with 64K page size, with the rest of the sizes set to never,
> the min, low and high watermarks evaluate to 2.08G, 2.6G and 3.1G
I forgot to change the other pageblock_nr_pages instance, the patch
will need the below fixlet as well. The watermark numbers will then be
the same as when 4K PAGE_SIZE is used.
commit 0c6bb4e5b3aa078949d712ab9c35e7b2a33cd8a4 (HEAD)
Author: Usama Arif <usamaarif642@gmail.com>
Date: Fri Jun 6 15:43:25 2025 +0100
[fixlet] mm: khugepaged: replace all instances of pageblock_nr_pages
This will change the 64K page size, 2M THP hugepage madvise min, low
and high watermarks to 87M, 575M and 1G.
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index e64cba74eb2a..1c643f13135e 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2650,7 +2650,7 @@ static void set_recommended_min_free_kbytes(void)
}
/* Ensure 2 pageblocks are free to assist fragmentation avoidance */
- recommended_min = pageblock_nr_pages * nr_zones * 2;
+ recommended_min = min_thp_pageblock_nr_pages() * nr_zones * 2;
/*
* Make sure that on average at least two pageblocks are almost free
next prev parent reply other threads:[~2025-06-06 15:01 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 14:37 Usama Arif
2025-06-06 15:01 ` Usama Arif [this message]
2025-06-06 15:18 ` Zi Yan
2025-06-06 15:38 ` Usama Arif
2025-06-06 16:10 ` Zi Yan
2025-06-07 8:35 ` Lorenzo Stoakes
2025-06-08 0:04 ` Zi Yan
2025-06-09 11:13 ` Usama Arif
2025-06-09 13:19 ` Zi Yan
2025-06-09 14:11 ` Usama Arif
2025-06-09 14:16 ` Lorenzo Stoakes
2025-06-09 14:37 ` Zi Yan
2025-06-09 14:50 ` Lorenzo Stoakes
2025-06-09 15:20 ` Zi Yan
2025-06-09 19:40 ` Lorenzo Stoakes
2025-06-09 19:49 ` Zi Yan
2025-06-09 20:03 ` Usama Arif
2025-06-09 20:24 ` Zi Yan
2025-06-10 10:41 ` Usama Arif
2025-06-10 14:03 ` Lorenzo Stoakes
2025-06-10 14:20 ` Zi Yan
2025-06-10 15:16 ` Usama Arif
2025-06-09 15:32 ` Zi Yan
2025-06-06 17:37 ` David Hildenbrand
2025-06-09 11:34 ` Usama Arif
2025-06-09 13:28 ` Zi Yan
2025-06-07 8:18 ` Lorenzo Stoakes
2025-06-07 8:44 ` Lorenzo Stoakes
2025-06-09 12:07 ` Usama Arif
2025-06-09 12:12 ` Usama Arif
2025-06-09 14:58 ` Lorenzo Stoakes
2025-06-09 14:57 ` 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=a179fd65-dc3f-4769-9916-3033497188ba@gmail.com \
--to=usamaarif642@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=riel@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=ziy@nvidia.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