[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211008095123.73b4bubwrpdj6tuz@box.shutemov.name>
Date: Fri, 8 Oct 2021 12:51:23 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Hao Peng <flyingpenghao@...il.com>
Cc: David Hildenbrand <david@...hat.com>, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v2] mm/huge_memory.c: disable THP with large THP size on
small present memory
On Fri, Oct 08, 2021 at 09:22:00AM +0800, Hao Peng wrote:
> From: Peng Hao <flyingpeng@...cent.com>
>
> After setting the page size to 64k on ARM64, the supported huge page
> size is 512M and 1TB. Therefore, if the thp is enabled, the size
> of the thp is 512M. But if THP is enabled, min_free_kbytes will
> be recalculated. At this time, min_free_kbytes is calculated based
> on the size of THP.
>
> On an arm64 server with 64G memory, the page size is 64k, with thp
> enabled.
> cat /proc/sys/vm/min_free_kbytes
> 3335104
>
> Therefore, when judging whether to enable THP by default, consider
> the size of thp.
>
> V2: title suggested by David Hildenbrand
>
> Signed-off-by: Peng Hao <flyingpeng@...cent.com>
> ---
> mm/huge_memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 5e9ef0fc261e..03c7f571b3ae 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -437,7 +437,7 @@ static int __init hugepage_init(void)
> * where the extra memory used could hurt more than TLB overhead
> * is likely to save. The admin can still enable it through /sys.
> */
> - if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) {
> + if (totalram_pages() < (512 << (HPAGE_PMD_SHIFT - PAGE_SHIFT))) {
On x86-64 HPAGE_PMD_SHIFT is 21, so you double the amount of memory
required to enabled THP by default. It doesn't seem to be the intent of
the patch.
What about something like
if (totalram_pages() < 256 * HPAGE_PMD_NR)
?
> transparent_hugepage_flags = 0;
> return 0;
> }
> --
> 2.27.0
>
--
Kirill A. Shutemov
Powered by blists - more mailing lists