From: Nimrod Oren <noren@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH] mm/khugepaged: cap min_free_kbytes recommendation at 1 GiB
Date: Tue, 4 Aug 2026 10:19:44 +0300 [thread overview]
Message-ID: <1f01747a-83b6-469a-928a-8017a47e4c0c@nvidia.com> (raw)
In-Reply-To: <20260728171710.a968591ceea5782270dffcee@linux-foundation.org>
On 29/07/2026 3:17, Andrew Morton wrote:
> On Tue, 28 Jul 2026 23:20:14 +0300 Nimrod Oren <noren@nvidia.com> wrote:
>> Add an absolute 1 GiB cap to the recommendation, in addition to the
>> existing percentage cap. This bounds the automatic recommendation to a
>> sane value on systems with large pageblocks while preserving existing
>> behavior for typical systems with 2 MiB pageblocks.
>
> Another hard-coded number isn't pretty :(
The 1 GiB value follows the RFC discussion.
Would a dedicated constant (e.g. THP_MIN_FREE_MAX_PAGES) make it better?
Would using a new sysctl be preferable?
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index 27e8f3077e80..d9caf10e05b5 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -23,6 +23,7 @@
>> #include <linux/ksm.h>
>> #include <linux/pgalloc.h>
>> #include <linux/backing-dev.h>
>> +#include <linux/sizes.h>
>
> Why this?
For SZ_1G. It's already included transitively, so I'll drop it in the
next revision.
>> #include <asm/tlb.h>
>> #include "internal.h"
>> @@ -3096,9 +3097,13 @@ void set_recommended_min_free_kbytes(void)
>> recommended_min += pageblock_nr_pages * nr_zones *
>> MIGRATE_PCPTYPES * MIGRATE_PCPTYPES;
>>
>> - /* don't ever allow to reserve more than 5% of the lowmem */
>> + /*
>> + * Don't ever allow to reserve more than 5% of lowmem or 1 GiB,
>> + * whichever is smaller.
>> + */
>> recommended_min = min(recommended_min,
>> (unsigned long) nr_free_buffer_pages() / 20);
>> + recommended_min = min(recommended_min, SZ_1G / PAGE_SIZE);
>> recommended_min <<= (PAGE_SHIFT-10);
>>
>> if (recommended_min > min_free_kbytes) {
>
> Is a min_free_kbytes documentation update needed?
> Documentation/admin-guide/sysctl/vm.rst.
I can document THP's automatic recommendation there in the next
revision, along with whichever capping mechanism we decide on.
Thanks for the review!
next prev parent reply other threads:[~2026-08-04 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 20:20 Nimrod Oren
2026-07-29 0:17 ` Andrew Morton
2026-08-04 7:19 ` Nimrod Oren [this message]
2026-08-07 16:03 ` Lorenzo Stoakes (ARM)
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=1f01747a-83b6-469a-928a-8017a47e4c0c@nvidia.com \
--to=noren@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@suse.cz \
--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
all inboxes | Powered by JetHome®